From 65b21beaaf198bdb140c14425d1b2ea278b21da8 Mon Sep 17 00:00:00 2001 From: dasm Date: Wed, 29 Oct 2025 17:21:04 -0700 Subject: [PATCH 1/3] Add test for neg. --- src/flint/test/test_all.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/flint/test/test_all.py b/src/flint/test/test_all.py index e82c8f3a..4c87513b 100644 --- a/src/flint/test/test_all.py +++ b/src/flint/test/test_all.py @@ -1669,6 +1669,8 @@ def test_arb(): assert arb(3) <= arb("inf") assert arb(3) == arb(3) assert arb(3) != arb(2) + assert -arb(3) == arb(-3) + assert arb(3).neg() == arb(-3) assert not (arb("1.1") == arb("1.1")) assert arb(3).repr() == 'arb((0x3, 0x0))' From 997ecfd19b054e87ae011552e61052185c915a27 Mon Sep 17 00:00:00 2001 From: dasm Date: Wed, 29 Oct 2025 17:21:43 -0700 Subject: [PATCH 2/3] Fix arg.neg() --- src/flint/types/arb.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flint/types/arb.pyx b/src/flint/types/arb.pyx index dab29f0e..d552dc7a 100644 --- a/src/flint/types/arb.pyx +++ b/src/flint/types/arb.pyx @@ -567,9 +567,9 @@ cdef class arb(flint_scalar): def neg(self, bint exact=False): res = arb.__new__(arb) if exact: - arb_set((res).val, (self).val) + arb_neg((res).val, (self).val) else: - arb_set_round((res).val, (self).val, getprec()) + arb_neg_round((res).val, (self).val, getprec()) return res def __abs__(self): From 87ebbb29b9bf9444b1f70372f260ce85b74563d5 Mon Sep 17 00:00:00 2001 From: dasm Date: Thu, 30 Oct 2025 12:31:43 -0700 Subject: [PATCH 3/3] Add to changelog --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6f6746be..b5ab58b5 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,7 @@ Contributors (0.9.0): - Rémy Oudompheng (RO) - Agriya Khetarpal (AK) - Oscar Benjamin (OB) +- Daniel Simmons-Marengo (DSM) Changes (0.9.0): @@ -181,6 +182,9 @@ Changes (0.9.0): - [gh-312](https://github.com/flintlib/python-flint/pull/312), Add `discriminant` method to `fmpz_poly`, `fmpq_poly` and `nmod_poly`. (RO) +- [gh-336](https://github.com/flintlib/python-flint/pull/336), + Fixed a bug in `arb.neg()` which caused it to return its input + without negating it. (DSM) 0.8.0 -----