Skip to content

Commit 135aab3

Browse files
authored
Merge pull request #48 from btalb/pr-equality
Fix __ne__ error, and add opinionated change to __eq__, in `BasePoseMatrix`
2 parents bc2247d + 7297788 commit 135aab3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

spatialmath/baseposematrix.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,8 +1535,8 @@ def __eq__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argu
15351535
========= ========== ==== ================================
15361536
15371537
"""
1538-
assert type(left) == type(right), "operands to == are of different types"
1539-
return left._op2(right, lambda x, y: np.allclose(x, y))
1538+
return (left._op2(right, lambda x, y: np.allclose(x, y))
1539+
if type(left) == type(right) else False)
15401540

15411541
def __ne__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
15421542
"""
@@ -1563,7 +1563,8 @@ def __ne__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argu
15631563
========= ========== ==== ================================
15641564
15651565
"""
1566-
return [not x for x in left == right]
1566+
eq = left == right
1567+
return (not eq if isinstance(eq, bool) else [not x for x in eq])
15671568

15681569
def _op2(
15691570
left, right, op
@@ -1581,8 +1582,8 @@ def _op2(
15811582
:return: list of matrices
15821583
:rtype: list
15831584
1584-
Peform a binary operation on a pair of operands. If either operand
1585-
contains a sequence the results is a sequence accordinging to this
1585+
Perform a binary operation on a pair of operands. If either operand
1586+
contains a sequence the results is a sequence according to this
15861587
truth table.
15871588
15881589
========= ========== ==== ================================

0 commit comments

Comments
 (0)