summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2022-01-19 16:49:56 -0600
committerSebastian Berg <sebastian@sipsolutions.net>2022-01-19 20:11:14 -0600
commit763a3d4878671d383ba8aa573af90fee125efff4 (patch)
tree0ff428c2bf2c15ad51ce5edaab255e2c01325e1f /numpy/lib
parentdfc898913404533d54bf0000d1d17ff92b6ae0e4 (diff)
downloadnumpy-763a3d4878671d383ba8aa573af90fee125efff4.tar.gz
TST: Use repr in byteswapping tests
The `str` values for those weird values used for longdouble are truncated by PyPy's complex `str` output. Which seems fine probably since PyPy's `repr` does the right thing and will not truncate.
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/tests/test_loadtxt.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/numpy/lib/tests/test_loadtxt.py b/numpy/lib/tests/test_loadtxt.py
index 366210a0f..c5a14ed46 100644
--- a/numpy/lib/tests/test_loadtxt.py
+++ b/numpy/lib/tests/test_loadtxt.py
@@ -658,18 +658,20 @@ def test_warn_on_skipped_data(skiprows):
("float16", 3.07e-05),
("float32", 9.2557e-41), ("complex64", 9.2557e-41+2.8622554e-29j),
("float64", -1.758571353180402e-24),
- ("complex128", 5.406409232372729e-29-1.758571353180402e-24j),
+ # Here and below, the repr side-steps a small loss of precision in
+ # complex `str` in PyPy (which is probably fine, as repr works):
+ ("complex128", repr(5.406409232372729e-29-1.758571353180402e-24j)),
# Use integer values that fit into double. Everything else leads to
# problems due to longdoubles going via double and decimal strings
# causing rounding errors.
("longdouble", 0x01020304050607),
- ("clongdouble", 0x01020304050607 + (0x00121314151617 * 1j)),
+ ("clongdouble", repr(0x01020304050607 + (0x00121314151617 * 1j))),
("U2", "\U00010203\U000a0b0c")])
@pytest.mark.parametrize("swap", [True, False])
def test_byteswapping_and_unaligned(dtype, value, swap):
# Try to create "interesting" values within the valid unicode range:
dtype = np.dtype(dtype)
- data = [f"x,{value}\n"]
+ data = [f"x,{value}\n"] # repr as PyPy `str` truncates some
if swap:
dtype = dtype.newbyteorder()
full_dt = np.dtype([("a", "S1"), ("b", dtype)], align=False)