Skip to content

Commit

Permalink
Remove in-place add, sub, and mul
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Moss committed Jul 4, 2024
1 parent d70c2f9 commit 8f76c6a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 84 deletions.
6 changes: 0 additions & 6 deletions src/flint/test/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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({
Expand All @@ -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}) \
Expand Down
39 changes: 0 additions & 39 deletions src/flint/types/fmpq_mpoly.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,6 @@ cdef class fmpq_mpoly(flint_mpoly):
return res
return NotImplemented

def __iadd__(self, other):
if typecheck(other, fmpq_mpoly):
if (<fmpq_mpoly>self).ctx is not (<fmpq_mpoly>other).ctx:
raise IncompatibleContextError(f"{(<fmpq_mpoly>self).ctx} is not {(<fmpq_mpoly>other).ctx}")
fmpq_mpoly_add((<fmpq_mpoly>self).val, (<fmpq_mpoly>self).val, (<fmpq_mpoly>other).val, self.ctx.val)
return self
else:
other = any_as_fmpq(other)
if other is not NotImplemented:
fmpq_mpoly_add_fmpq((<fmpq_mpoly>self).val, (<fmpq_mpoly>self).val, (<fmpq>other).val, self.ctx.val)
return self
return NotImplemented

def __sub__(self, other):
cdef fmpq_mpoly res
if typecheck(other, fmpq_mpoly):
Expand All @@ -386,19 +373,6 @@ cdef class fmpq_mpoly(flint_mpoly):
return -res
return NotImplemented

def __isub__(self, other):
if typecheck(other, fmpq_mpoly):
if (<fmpq_mpoly>self).ctx is not (<fmpq_mpoly>other).ctx:
raise IncompatibleContextError(f"{(<fmpq_mpoly>self).ctx} is not {(<fmpq_mpoly>other).ctx}")
fmpq_mpoly_sub((<fmpq_mpoly>self).val, (<fmpq_mpoly>self).val, (<fmpq_mpoly>other).val, self.ctx.val)
return self
else:
other = any_as_fmpq(other)
if other is not NotImplemented:
fmpq_mpoly_sub_fmpq((<fmpq_mpoly>self).val, (<fmpq_mpoly>self).val, (<fmpq>other).val, self.ctx.val)
return self
return NotImplemented

def __mul__(self, other):
cdef fmpq_mpoly res
if typecheck(other, fmpq_mpoly):
Expand All @@ -424,19 +398,6 @@ cdef class fmpq_mpoly(flint_mpoly):
return res
return NotImplemented

def __imul__(self, other):
if typecheck(other, fmpq_mpoly):
if (<fmpq_mpoly>self).ctx is not (<fmpq_mpoly>other).ctx:
raise IncompatibleContextError(f"{(<fmpq_mpoly>self).ctx} is not {(<fmpq_mpoly>other).ctx}")
fmpq_mpoly_mul((<fmpq_mpoly>self).val, (<fmpq_mpoly>self).val, (<fmpq_mpoly>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, (<fmpq_mpoly>self).val, (<fmpq>other).val, self.ctx.val)
return self
return NotImplemented

def __pow__(self, other, modulus):
cdef fmpq_mpoly res
if modulus is not None:
Expand Down
39 changes: 0 additions & 39 deletions src/flint/types/fmpz_mpoly.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,6 @@ cdef class fmpz_mpoly(flint_mpoly):
return res
return NotImplemented

def __iadd__(self, other):
if typecheck(other, fmpz_mpoly):
if (<fmpz_mpoly>self).ctx is not (<fmpz_mpoly>other).ctx:
raise IncompatibleContextError(f"{(<fmpz_mpoly>self).ctx} is not {(<fmpz_mpoly>other).ctx}")
fmpz_mpoly_add((<fmpz_mpoly>self).val, (<fmpz_mpoly>self).val, (<fmpz_mpoly>other).val, self.ctx.val)
return self
else:
zval = any_as_fmpz(other)
if zval is not NotImplemented:
fmpz_mpoly_add_fmpz((<fmpz_mpoly>self).val, (<fmpz_mpoly>self).val, (<fmpz>zval).val, self.ctx.val)
return self
return NotImplemented

def __sub__(self, other):
cdef fmpz_mpoly res
if typecheck(other, fmpz_mpoly):
Expand All @@ -366,19 +353,6 @@ cdef class fmpz_mpoly(flint_mpoly):
return -res
return NotImplemented

def __isub__(self, other):
if typecheck(other, fmpz_mpoly):
if (<fmpz_mpoly>self).ctx is not (<fmpz_mpoly>other).ctx:
raise IncompatibleContextError(f"{(<fmpz_mpoly>self).ctx} is not {(<fmpz_mpoly>other).ctx}")
fmpz_mpoly_sub((<fmpz_mpoly>self).val, (<fmpz_mpoly>self).val, (<fmpz_mpoly>other).val, self.ctx.val)
return self
else:
other = any_as_fmpz(other)
if other is not NotImplemented:
fmpz_mpoly_sub_fmpz((<fmpz_mpoly>self).val, (<fmpz_mpoly>self).val, (<fmpz>other).val, self.ctx.val)
return self
return NotImplemented

def __mul__(self, other):
cdef fmpz_mpoly res
if typecheck(other, fmpz_mpoly):
Expand All @@ -404,19 +378,6 @@ cdef class fmpz_mpoly(flint_mpoly):
return res
return NotImplemented

def __imul__(self, other):
if typecheck(other, fmpz_mpoly):
if (<fmpz_mpoly>self).ctx is not (<fmpz_mpoly>other).ctx:
raise IncompatibleContextError(f"{(<fmpz_mpoly>self).ctx} is not {(<fmpz_mpoly>other).ctx}")
fmpz_mpoly_mul((<fmpz_mpoly>self).val, (<fmpz_mpoly>self).val, (<fmpz_mpoly>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, (<fmpz_mpoly>self).val, (<fmpz>other).val, self.ctx.val)
return self
return NotImplemented

def __pow__(self, other, modulus):
cdef fmpz_mpoly res
if modulus is not None:
Expand Down

0 comments on commit 8f76c6a

Please sign in to comment.