@@ -5407,7 +5407,7 @@ def test_same_value_cast(self):
54075407 b = a .astype (QuadPrecision , casting = 'same_value' )
54085408 c = b .astype (np .float32 , casting = 'same_value' )
54095409 assert np .all (c == a )
5410- with pytest .raises (ValueError , match = "could not cast 'same_value'" ):
5410+ with pytest .raises (ValueError ):
54115411 (b + 1e22 ).astype (np .float32 , casting = 'same_value' )
54125412
54135413
@@ -5449,4 +5449,99 @@ def test_same_value_cast_quad_to_int(self, dtype, passing, failing):
54495449 for val in failing :
54505450 q = np .array ([val ], dtype = QuadPrecDType ())
54515451 with pytest .raises (ValueError ):
5452- q .astype (dtype , casting = "same_value" )
5452+ q .astype (dtype , casting = "same_value" )
5453+
5454+ # @pytest.mark.parametrize("dtype,passing,failing", [
5455+ # # float16/half: 11-bit significand (10 explicit + 1 implicit)
5456+ # # max: 65504, exact integers up to 2^11 = 2048
5457+ # ("float16",
5458+ # [0.0, -0.0, float('inf'), float('-inf'), float('nan'),
5459+ # 1.0, -1.0, 0.5, 0.25,
5460+ # 2048.0, # 2^11, largest consecutive integer
5461+ # 65504.0, # max representable
5462+ # 2**-14, # min positive normal
5463+ # ],
5464+ # [65536.0, # overflow (> max)
5465+ # # precision loss (first non-representable int > 2048)
5466+ # 2049.0,
5467+ # 1.0 + 2**-11, # precision loss (step from 1.0 is 2^-10)
5468+ # ]),
5469+
5470+ # ("half", # alias, same values
5471+ # [0.0, float('inf'), float('-inf'), float('nan'), 1.0, 2048.0],
5472+ # [65536.0, 2049.0]),
5473+
5474+ # # float32: 24-bit significand (23 explicit + 1 implicit)
5475+ # # max: ~3.4e38, exact integers up to 2^24 = 16777216
5476+ # ("float32",
5477+ # [0.0, -0.0, float('inf'), float('-inf'), float('nan'),
5478+ # 1.0, -1.0, 0.5, 0.25,
5479+ # 16777216.0, # 2^24, largest consecutive integer
5480+ # 3.4028235e38, # max representable (approx)
5481+ # 2**-126, # min positive normal
5482+ # ],
5483+ # [16777217.0, # precision loss (first non-representable int)
5484+ # 1e39, # overflow
5485+ # 1.0 + 2**-24, # precision loss (step from 1.0 is 2^-23)
5486+ # ]),
5487+
5488+ # ("float", # alias
5489+ # [0.0, float('inf'), float('-inf'), float('nan'), 1.0, 16777216.0],
5490+ # [16777217.0, 1e39]),
5491+
5492+ # # float64: 53-bit significand (52 explicit + 1 implicit)
5493+ # # max: ~1.8e308, exact integers up to 2^53
5494+ # ("float64",
5495+ # [0.0, -0.0, float('inf'), float('-inf'), float('nan'),
5496+ # 1.0, -1.0, 0.5, 0.25,
5497+ # 2.0**53, # largest consecutive integer
5498+ # 1.7976931348623157e308, # max representable (approx)
5499+ # 2**-1022, # min positive normal
5500+ # ],
5501+ # [2.0**53 + 1, # precision loss
5502+ # 1e309, # overflow
5503+ # 1.0 + 2**-53, # precision loss (step from 1.0 is 2^-52)
5504+ # ]),
5505+
5506+ # ("double", # alias
5507+ # [0.0, float('inf'), float('-inf'), float('nan'), 1.0, 2.0**53],
5508+ # [2.0**53 + 1, 1e309]),
5509+
5510+ # # longdouble: platform-dependent!
5511+ # # x86 Linux: 80-bit extended, 64-bit significand → integers up to 2^64
5512+ # # Windows/macOS: often same as float64
5513+ # # Consider using np.finfo(np.longdouble).nmant to adjust dynamically
5514+ # # ("longdouble",
5515+ # # [0.0, -0.0, float('inf'), float('-inf'), float('nan'),
5516+ # # 1.0, 2.0**53, 2.0**53 + 1], # 2^53+1 passes if longdouble > float64
5517+ # # # Failing cases depend on platform - maybe skip or parametrize separately
5518+ # # []),
5519+ # ])
5520+ # def test_same_value_cast_floats(self, dtype, passing, failing):
5521+ # for val in passing:
5522+ # q = np.array([val], dtype=QuadPrecDType())
5523+ # result = q.astype(dtype, casting="same_value")
5524+ # # Use appropriate comparison for nan
5525+ # if np.isnan(val):
5526+ # assert np.isnan(result)
5527+ # else:
5528+ # assert result == val
5529+
5530+ # for val in failing:
5531+ # q = np.array([val], dtype=QuadPrecDType())
5532+ # with pytest.raises(ValueError):
5533+ # q.astype(dtype, casting="same_value")
5534+
5535+ # @pytest.mark.parametrize("dtype", [
5536+ # "S50", "U50", "<U50", ">U50", "S100", "U100", "<U100", ">U100", np.dtypes.StringDType()])
5537+ # @pytest.mark.parametrize("values", [
5538+ # ])
5539+ # def test_same_value_cast_strings_enough_width(self, dtype, values):
5540+ # pass
5541+
5542+ # @pytest.mark.parametrize("dtype", [
5543+ # "S20", "U20", "<U20", ">U20"])
5544+ # @pytest.mark.parametrize("values", [
5545+ # ])
5546+ # def test_same_value_cast_strings_small_width(self, dtype, values):
5547+ # pass
0 commit comments