Skip to content

Commit a38a651

Browse files
committed
roundtrip
1 parent 84c4dfd commit a38a651

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

quaddtype/tests/test_quaddtype.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -567,32 +567,27 @@ class TestArrayCastStringBytes:
567567
"-nan",
568568
])
569569
def test_cast_string_to_quad_roundtrip(self, input_val, strtype):
570-
# Test 1: String to Quad conversion
571570
str_array = np.array(input_val, dtype=strtype)
572571
quad_array = str_array.astype(QuadPrecDType())
573572
expected = np.array(input_val, dtype=QuadPrecDType())
574573

575-
# Verify string to quad conversion
576574
if np.isnan(float(expected)):
577575
np.testing.assert_array_equal(np.isnan(quad_array), np.isnan(expected))
578576
else:
579577
np.testing.assert_array_equal(quad_array, expected)
580578

581-
# Test 2: Quad to String conversion
582579
quad_to_string_array = quad_array.astype(strtype)
583580

584-
# Test 3: Round-trip - String -> Quad -> String -> Quad should preserve value
581+
# Round-trip - String -> Quad -> String -> Quad should preserve value
585582
roundtrip_quad_array = quad_to_string_array.astype(QuadPrecDType())
586583

587584
if np.isnan(float(expected)):
588-
# For NaN, just verify both are NaN
589585
np.testing.assert_array_equal(np.isnan(roundtrip_quad_array), np.isnan(quad_array))
590586
else:
591-
# For non-NaN values, the round-trip should preserve the exact value
592587
np.testing.assert_array_equal(roundtrip_quad_array, quad_array,
593588
err_msg=f"Round-trip failed for {input_val}")
594589

595-
# Test 4: Verify the string representation can be parsed back
590+
# Verify the string representation can be parsed back
596591
# (This ensures the quad->string cast produces valid parseable strings)
597592
scalar_str = str(quad_array[()])
598593
scalar_from_str = QuadPrecision(scalar_str)

0 commit comments

Comments
 (0)