diff --git a/codegen/templates/transform_2d.pyx b/codegen/templates/transform_2d.pyx index fcd7914..47f08d1 100644 --- a/codegen/templates/transform_2d.pyx +++ b/codegen/templates/transform_2d.pyx @@ -114,9 +114,10 @@ cdef class Transform2D: """ if not isinstance(other, Transform2D): return False - return self.xx == ( other).xx and self.xy == ( other).xy and\ - self.yx == ( other).yx and self.yy == ( other).yy and\ - self.ox == ( other).ox and self.oy == ( other).oy + cdef Transform2D trans = other + return self.xx == trans.xx and self.xy == trans.xy and\ + self.yx == trans.yx and self.yy == trans.yy and\ + self.ox == trans.ox and self.oy == trans.oy def __ne__(self, object other) -> bool: """Perform exact comparison. @@ -125,9 +126,10 @@ cdef class Transform2D: """ if not isinstance(other, Transform2D): return True - return self.xx != ( other).xx or self.xy != ( other).xy or \ - self.yx != ( other).yx or self.yy != ( other).yy or \ - self.ox != ( other).ox or self.oy != ( other).oy + cdef Transform2D trans = other + return self.xx != trans.xx or self.xy != trans.xy or \ + self.yx != trans.yx or self.yy != trans.yy or \ + self.ox != trans.ox or self.oy != trans.oy def is_close(self, Transform2D other, /, py_float rel_tol = DEFAULT_RELATIVE_TOLERANCE, py_float abs_tol = DEFAULT_ABSOLUTE_TOLERANCE) -> bool: """Determine if the two transforms are close enough. diff --git a/codegen/templates/transform_3d.pyx b/codegen/templates/transform_3d.pyx index 12c54d2..05950fb 100644 --- a/codegen/templates/transform_3d.pyx +++ b/codegen/templates/transform_3d.pyx @@ -168,10 +168,11 @@ cdef class Transform3D: """ if not isinstance(other, Transform3D): return False - return self.xx == ( other).xx and self.xy == ( other).xy and self.xz == ( other).xz and\ - self.yx == ( other).yx and self.yy == ( other).yy and self.yz == ( other).yz and\ - self.zx == ( other).zx and self.zy == ( other).zy and self.zz == ( other).zz and\ - self.ox == ( other).ox and self.oy == ( other).oy and self.oz == ( other).oz + cdef Transform3D trans = other + return self.xx == trans.xx and self.xy == trans.xy and self.xz == trans.xz and\ + self.yx == trans.yx and self.yy == trans.yy and self.yz == trans.yz and\ + self.zx == trans.zx and self.zy == trans.zy and self.zz == trans.zz and\ + self.ox == trans.ox and self.oy == trans.oy and self.oz == trans.oz def __ne__(self, object other) -> bool: """Perform exact comparison. @@ -180,10 +181,11 @@ cdef class Transform3D: """ if not isinstance(other, Transform3D): return True - return self.xx != ( other).xx or self.xy != ( other).xy or self.xz != ( other).xz or\ - self.yx != ( other).yx or self.yy != ( other).yy or self.yz != ( other).yz or\ - self.zx != ( other).zx or self.zy != ( other).zy or self.zz != ( other).zz or\ - self.ox != ( other).ox or self.oy != ( other).oy or self.oz != ( other).oz + cdef Transform3D trans = other + return self.xx != trans.xx or self.xy != trans.xy or self.xz != trans.xz or\ + self.yx != trans.yx or self.yy != trans.yy or self.yz != trans.yz or\ + self.zx != trans.zx or self.zy != trans.zy or self.zz != trans.zz or\ + self.ox != trans.ox or self.oy != trans.oy or self.oz != trans.oz def is_close(self, Transform3D other, /, py_float rel_tol = DEFAULT_RELATIVE_TOLERANCE, py_float abs_tol = DEFAULT_ABSOLUTE_TOLERANCE) -> bool: """Determine if the two transforms are close enough. diff --git a/codegen/templates/vec_class.pyx b/codegen/templates/vec_class.pyx index 28c7464..2a264a7 100644 --- a/codegen/templates/vec_class.pyx +++ b/codegen/templates/vec_class.pyx @@ -65,7 +65,8 @@ cdef class _VecClassName_: """ if not isinstance(other, _VecClassName_): return False - return #: gen_for_each_dim("self.{dim} == other.{dim}", _Dims_, join=" and ") + cdef _VecClassName_ vec = <_VecClassName_> other + return #: gen_for_each_dim("self.{dim} == vec.{dim}", _Dims_, join=" and ") def __ne__(self, object other) -> bool: """Perform exact comparison. @@ -74,7 +75,8 @@ cdef class _VecClassName_: """ if not isinstance(other, _VecClassName_): return True - return #: gen_for_each_dim("self.{dim} != other.{dim}", _Dims_, join=" or ") + cdef _VecClassName_ vec = <_VecClassName_> other + return #: gen_for_each_dim("self.{dim} != vec.{dim}", _Dims_, join=" or ") def is_close(self, _VecClassName_ other, /, py_float rel_tol = DEFAULT_RELATIVE_TOLERANCE, py_float abs_tol = DEFAULT_ABSOLUTE_TOLERANCE) -> bool: """Determine if the two vectors are close enough.