be more consistent about when copies are made

This commit is contained in:
Jan Petykiewicz 2024-07-29 03:13:23 -07:00
commit ef6c5df386
14 changed files with 28 additions and 34 deletions

View file

@ -60,7 +60,7 @@ class Mirrorable(metaclass=ABCMeta):
# def mirrored(self, val: Sequence[bool]) -> None:
# if is_scalar(val):
# raise MasqueError('Mirrored must be a 2-element list of booleans')
# self._mirrored = numpy.array(val, dtype=bool, copy=True)
# self._mirrored = numpy.array(val, dtype=bool)
#
# #
# # Methods

View file

@ -81,12 +81,11 @@ class PositionableImpl(Positionable, metaclass=ABCMeta):
@offset.setter
def offset(self, val: ArrayLike) -> None:
if not isinstance(val, numpy.ndarray) or val.dtype != numpy.float64:
val = numpy.array(val, dtype=float)
val = numpy.array(val, dtype=float)
if val.size != 2:
raise MasqueError('Offset must be convertible to size-2 ndarray')
self._offset = val.flatten() # type: ignore
self._offset = val.flatten()
#
# Methods

View file

@ -112,7 +112,7 @@ class PivotableImpl(Pivotable, metaclass=ABCMeta):
""" `[x_offset, y_offset]` """
def rotate_around(self, pivot: ArrayLike, rotation: float) -> Self:
pivot = numpy.array(pivot, dtype=float)
pivot = numpy.asarray(pivot, dtype=float)
cast(Positionable, self).translate(-pivot)
cast(Rotatable, self).rotate(rotation)
self.offset = numpy.dot(rotation_matrix_2d(rotation), self.offset) # type: ignore # mypy#3004