Add DType.min and DType.max properties (#10749)

* add properties

* cleaner test

* remove added newline
This commit is contained in:
Sieds Lykles
2025-06-10 17:31:34 +02:00
committed by GitHub
parent 5d9c274924
commit 0daa4c6ed0
2 changed files with 10 additions and 0 deletions

View File

@@ -469,14 +469,20 @@ class TestHelpers(unittest.TestCase):
if dtypes.is_float(dt):
np.testing.assert_equal(dtypes.min(dt), -math.inf)
np.testing.assert_equal(dtypes.max(dt), math.inf)
np.testing.assert_equal(dt.min, -math.inf)
np.testing.assert_equal(dt.max, math.inf)
elif dtypes.is_int(dt):
info = np.iinfo(_to_np_dtype(dt))
np.testing.assert_equal(dtypes.min(dt), info.min)
np.testing.assert_equal(dtypes.max(dt), info.max)
np.testing.assert_equal(dt.min, info.min)
np.testing.assert_equal(dt.max, info.max)
else:
assert dt == dtypes.bool, dt
np.testing.assert_equal(dtypes.min(dt), False)
np.testing.assert_equal(dtypes.max(dt), True)
np.testing.assert_equal(dt.min, False)
np.testing.assert_equal(dt.max, True)
def test_truncate_fp16(self):
self.assertEqual(truncate_fp16(1), 1)