simpler dtypes.max for int [pr] (#8058)

This commit is contained in:
chenyu
2024-12-05 10:31:41 -05:00
committed by GitHub
parent 66b8242375
commit 87594a8153

View File

@@ -99,7 +99,7 @@ class dtypes:
@staticmethod
@functools.lru_cache(None)
def max(dtype:DType):
if dtypes.is_int(dtype): return (2**(dtype.itemsize*8-(0 if dtypes.is_unsigned(dtype) else 1)))-1
if dtypes.is_int(dtype): return 2**(dtype.itemsize*8)-1+dtypes.min(dtype)
return float("inf") if dtypes.is_float(dtype) else True
@staticmethod
def finfo(dtype:DType) -> Tuple[int, int]: