[Repetition] fix ordering
This commit is contained in:
parent
e7f847d4c7
commit
932565d531
2 changed files with 17 additions and 4 deletions
|
|
@ -34,7 +34,7 @@ class Repetition(Copyable, Rotatable, Mirrorable, Scalable, Bounded, metaclass=A
|
|||
pass
|
||||
|
||||
@abstractmethod
|
||||
def __le__(self, other: 'Repetition') -> bool:
|
||||
def __lt__(self, other: 'Repetition') -> bool:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
|
@ -288,7 +288,7 @@ class Grid(Repetition):
|
|||
return False
|
||||
return True
|
||||
|
||||
def __le__(self, other: Repetition) -> bool:
|
||||
def __lt__(self, other: Repetition) -> bool:
|
||||
if type(self) is not type(other):
|
||||
return repr(type(self)) < repr(type(other))
|
||||
other = cast('Grid', other)
|
||||
|
|
@ -347,7 +347,7 @@ class Arbitrary(Repetition):
|
|||
return False
|
||||
return numpy.array_equal(self.displacements, other.displacements)
|
||||
|
||||
def __le__(self, other: Repetition) -> bool:
|
||||
def __lt__(self, other: Repetition) -> bool:
|
||||
if type(self) is not type(other):
|
||||
return repr(type(self)) < repr(type(other))
|
||||
other = cast('Arbitrary', other)
|
||||
|
|
@ -415,4 +415,3 @@ class Arbitrary(Repetition):
|
|||
"""
|
||||
self.displacements = self.displacements * c
|
||||
return self
|
||||
|
||||
|
|
|
|||
|
|
@ -49,3 +49,17 @@ def test_arbitrary_transform() -> None:
|
|||
# self.displacements[:, 1 - axis] *= -1
|
||||
# if axis=0, 1-axis=1, so y *= -1
|
||||
assert_allclose(arb.displacements, [[0, -10]], atol=1e-10)
|
||||
|
||||
|
||||
def test_repetition_less_equal_includes_equality() -> None:
|
||||
grid_a = Grid(a_vector=(10, 0), a_count=2)
|
||||
grid_b = Grid(a_vector=(10, 0), a_count=2)
|
||||
assert grid_a == grid_b
|
||||
assert grid_a <= grid_b
|
||||
assert grid_a >= grid_b
|
||||
|
||||
arb_a = Arbitrary([[0, 0], [1, 0]])
|
||||
arb_b = Arbitrary([[0, 0], [1, 0]])
|
||||
assert arb_a == arb_b
|
||||
assert arb_a <= arb_b
|
||||
assert arb_a >= arb_b
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue