From 8f76c6a212a5f1e293983890ec0db0b29b1edb30 Mon Sep 17 00:00:00 2001 From: Jake-Moss Date: Thu, 4 Jul 2024 19:17:59 +1000 Subject: [PATCH] Remove in-place add, sub, and mul --- src/flint/test/test_all.py | 6 ------ src/flint/types/fmpq_mpoly.pyx | 39 ---------------------------------- src/flint/types/fmpz_mpoly.pyx | 39 ---------------------------------- 3 files changed, 84 deletions(-) diff --git a/src/flint/test/test_all.py b/src/flint/test/test_all.py index 9b31c253..9dbf021c 100644 --- a/src/flint/test/test_all.py +++ b/src/flint/test/test_all.py @@ -2840,8 +2840,6 @@ def quick_poly(): assert raises(lambda: mpoly({(0, 0): 2, (0, 1): 2, (1, 0): 3, (2, 2): 4}) + None, TypeError) assert raises(lambda: None + mpoly({(0, 0): 2, (0, 1): 2, (1, 0): 3, (2, 2): 4}), TypeError) assert raises(lambda: quick_poly() + P(ctx=ctx1), IncompatibleContextError) - assert raises(lambda: quick_poly().__iadd__(P(ctx=ctx1)), IncompatibleContextError) - assert quick_poly().__iadd__(None) is NotImplemented assert quick_poly() - mpoly({(0, 0): 5, (0, 1): 6, (1, 0): 7, (2, 2): 8}) \ == mpoly({(0, 0): -4, (0, 1): -4, (1, 0): -4, (2, 2): -4}) @@ -2855,8 +2853,6 @@ def quick_poly(): assert raises(lambda: quick_poly() - None, TypeError) assert raises(lambda: None - quick_poly(), TypeError) assert raises(lambda: quick_poly() - P(ctx=ctx1), IncompatibleContextError) - assert raises(lambda: quick_poly().__isub__(P(ctx=ctx1)), IncompatibleContextError) - assert quick_poly().__isub__(None) is NotImplemented assert quick_poly() * mpoly({(1, 0): 5, (0, 1): 6}) \ == mpoly({ @@ -2878,8 +2874,6 @@ def quick_poly(): assert raises(lambda: quick_poly() * None, TypeError) assert raises(lambda: None * quick_poly(), TypeError) assert raises(lambda: quick_poly() * P(ctx=ctx1), IncompatibleContextError) - assert raises(lambda: quick_poly().__imul__(P(ctx=ctx1)), IncompatibleContextError) - assert quick_poly().__imul__(None) is NotImplemented assert quick_poly() // mpoly({(1, 1): 1}) == mpoly({(1, 1): 4}) assert quick_poly() % mpoly({(1, 1): 1}) \ diff --git a/src/flint/types/fmpq_mpoly.pyx b/src/flint/types/fmpq_mpoly.pyx index 79efd9d9..185ade76 100644 --- a/src/flint/types/fmpq_mpoly.pyx +++ b/src/flint/types/fmpq_mpoly.pyx @@ -348,19 +348,6 @@ cdef class fmpq_mpoly(flint_mpoly): return res return NotImplemented - def __iadd__(self, other): - if typecheck(other, fmpq_mpoly): - if (self).ctx is not (other).ctx: - raise IncompatibleContextError(f"{(self).ctx} is not {(other).ctx}") - fmpq_mpoly_add((self).val, (self).val, (other).val, self.ctx.val) - return self - else: - other = any_as_fmpq(other) - if other is not NotImplemented: - fmpq_mpoly_add_fmpq((self).val, (self).val, (other).val, self.ctx.val) - return self - return NotImplemented - def __sub__(self, other): cdef fmpq_mpoly res if typecheck(other, fmpq_mpoly): @@ -386,19 +373,6 @@ cdef class fmpq_mpoly(flint_mpoly): return -res return NotImplemented - def __isub__(self, other): - if typecheck(other, fmpq_mpoly): - if (self).ctx is not (other).ctx: - raise IncompatibleContextError(f"{(self).ctx} is not {(other).ctx}") - fmpq_mpoly_sub((self).val, (self).val, (other).val, self.ctx.val) - return self - else: - other = any_as_fmpq(other) - if other is not NotImplemented: - fmpq_mpoly_sub_fmpq((self).val, (self).val, (other).val, self.ctx.val) - return self - return NotImplemented - def __mul__(self, other): cdef fmpq_mpoly res if typecheck(other, fmpq_mpoly): @@ -424,19 +398,6 @@ cdef class fmpq_mpoly(flint_mpoly): return res return NotImplemented - def __imul__(self, other): - if typecheck(other, fmpq_mpoly): - if (self).ctx is not (other).ctx: - raise IncompatibleContextError(f"{(self).ctx} is not {(other).ctx}") - fmpq_mpoly_mul((self).val, (self).val, (other).val, self.ctx.val) - return self - else: - other = any_as_fmpq(other) - if other is not NotImplemented: - fmpq_mpoly_scalar_mul_fmpq(self.val, (self).val, (other).val, self.ctx.val) - return self - return NotImplemented - def __pow__(self, other, modulus): cdef fmpq_mpoly res if modulus is not None: diff --git a/src/flint/types/fmpz_mpoly.pyx b/src/flint/types/fmpz_mpoly.pyx index 4ff0c938..f7446542 100644 --- a/src/flint/types/fmpz_mpoly.pyx +++ b/src/flint/types/fmpz_mpoly.pyx @@ -328,19 +328,6 @@ cdef class fmpz_mpoly(flint_mpoly): return res return NotImplemented - def __iadd__(self, other): - if typecheck(other, fmpz_mpoly): - if (self).ctx is not (other).ctx: - raise IncompatibleContextError(f"{(self).ctx} is not {(other).ctx}") - fmpz_mpoly_add((self).val, (self).val, (other).val, self.ctx.val) - return self - else: - zval = any_as_fmpz(other) - if zval is not NotImplemented: - fmpz_mpoly_add_fmpz((self).val, (self).val, (zval).val, self.ctx.val) - return self - return NotImplemented - def __sub__(self, other): cdef fmpz_mpoly res if typecheck(other, fmpz_mpoly): @@ -366,19 +353,6 @@ cdef class fmpz_mpoly(flint_mpoly): return -res return NotImplemented - def __isub__(self, other): - if typecheck(other, fmpz_mpoly): - if (self).ctx is not (other).ctx: - raise IncompatibleContextError(f"{(self).ctx} is not {(other).ctx}") - fmpz_mpoly_sub((self).val, (self).val, (other).val, self.ctx.val) - return self - else: - other = any_as_fmpz(other) - if other is not NotImplemented: - fmpz_mpoly_sub_fmpz((self).val, (self).val, (other).val, self.ctx.val) - return self - return NotImplemented - def __mul__(self, other): cdef fmpz_mpoly res if typecheck(other, fmpz_mpoly): @@ -404,19 +378,6 @@ cdef class fmpz_mpoly(flint_mpoly): return res return NotImplemented - def __imul__(self, other): - if typecheck(other, fmpz_mpoly): - if (self).ctx is not (other).ctx: - raise IncompatibleContextError(f"{(self).ctx} is not {(other).ctx}") - fmpz_mpoly_mul((self).val, (self).val, (other).val, self.ctx.val) - return self - else: - other = any_as_fmpz(other) - if other is not NotImplemented: - fmpz_mpoly_scalar_mul_fmpz(self.val, (self).val, (other).val, self.ctx.val) - return self - return NotImplemented - def __pow__(self, other, modulus): cdef fmpz_mpoly res if modulus is not None: