Skip to content

Commit b2ef947

Browse files
committed
use nstr
1 parent 9ffa7ab commit b2ef947

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

quaddtype/tests/test_quaddtype.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,8 @@ def test_sin_cos_tan(self, op, val):
17711771
quad_result = numpy_op(quad_val)
17721772
mpmath_result = mpmath_op(mpf_val)
17731773
# convert mpmath result to quad for comparison
1774-
mpmath_result = QuadPrecision(str(mpmath_result))
1774+
# Use mp.nstr to get full precision (40 digits for quad precision)
1775+
mpmath_result = QuadPrecision(mp.nstr(mpmath_result, 40))
17751776

17761777
# Handle NaN cases
17771778
if np.isnan(mpmath_result):
@@ -1815,7 +1816,8 @@ def test_inverse_sin_cos(self, op, val):
18151816
quad_result = numpy_op(quad_val)
18161817
mpmath_result = mpmath_op(mpf_val)
18171818
# convert mpmath result to quad for comparison
1818-
mpmath_result = QuadPrecision(str(mpmath_result))
1819+
# Use mp.nstr to get full precision (40 digits for quad precision)
1820+
mpmath_result = QuadPrecision(mp.nstr(mpmath_result, 40))
18191821

18201822
# Handle NaN cases
18211823
if np.isnan(mpmath_result):
@@ -1941,7 +1943,8 @@ def test_atan2(self, y, x):
19411943

19421944
# For all other cases, compare with mpmath
19431945
mpmath_result = mp.atan2(mpf_y, mpf_x)
1944-
mpmath_result = QuadPrecision(str(mpmath_result))
1946+
# Use mp.nstr to get full precision (40 digits for quad precision)
1947+
mpmath_result = QuadPrecision(mp.nstr(mpmath_result, 40))
19451948

19461949
if np.isnan(mpmath_result):
19471950
assert np.isnan(quad_result), f"Expected NaN for atan2({y}, {x}), got {quad_result}"

0 commit comments

Comments
 (0)