Skip to content

Commit 7e2296c

Browse files
Merge pull request flintlib#336 from Maegereg/dasm/fix-neg
Fix arb.neg()
2 parents 18fce6b + 87ebbb2 commit 7e2296c

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Contributors (0.9.0):
167167
- Rémy Oudompheng (RO)
168168
- Agriya Khetarpal (AK)
169169
- Oscar Benjamin (OB)
170+
- Daniel Simmons-Marengo (DSM)
170171

171172
Changes (0.9.0):
172173

@@ -181,6 +182,9 @@ Changes (0.9.0):
181182
- [gh-312](https://github.com/flintlib/python-flint/pull/312),
182183
Add `discriminant` method to `fmpz_poly`, `fmpq_poly` and
183184
`nmod_poly`. (RO)
185+
- [gh-336](https://github.com/flintlib/python-flint/pull/336),
186+
Fixed a bug in `arb.neg()` which caused it to return its input
187+
without negating it. (DSM)
184188

185189
0.8.0
186190
-----

src/flint/test/test_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,8 @@ def test_arb():
16731673
assert arb(3) <= arb("inf")
16741674
assert arb(3) == arb(3)
16751675
assert arb(3) != arb(2)
1676+
assert -arb(3) == arb(-3)
1677+
assert arb(3).neg() == arb(-3)
16761678
assert not (arb("1.1") == arb("1.1"))
16771679

16781680
assert arb(3).repr() == 'arb((0x3, 0x0))'

src/flint/types/arb.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,9 @@ cdef class arb(flint_scalar):
567567
def neg(self, bint exact=False):
568568
res = arb.__new__(arb)
569569
if exact:
570-
arb_set((<arb>res).val, (<arb>self).val)
570+
arb_neg((<arb>res).val, (<arb>self).val)
571571
else:
572-
arb_set_round((<arb>res).val, (<arb>self).val, getprec())
572+
arb_neg_round((<arb>res).val, (<arb>self).val, getprec())
573573
return res
574574

575575
def __abs__(self):

0 commit comments

Comments
 (0)