Returns the maximum representable value in this data type. Raises: TypeError: if this is a non-numeric, unordered, or quantized type.
(self)
| 199 | |
| 200 | @property |
| 201 | def max(self): |
| 202 | """Returns the maximum representable value in this data type. |
| 203 | |
| 204 | Raises: |
| 205 | TypeError: if this is a non-numeric, unordered, or quantized type. |
| 206 | |
| 207 | """ |
| 208 | if (self.is_quantized or |
| 209 | self.base_dtype in (bool, string, complex64, complex128)): |
| 210 | raise TypeError("Cannot find maximum value of %s." % self) |
| 211 | |
| 212 | # there is no simple way to get the max value of a dtype, we have to check |
| 213 | # float and int types separately |
| 214 | try: |
| 215 | return np.finfo(self.as_numpy_dtype()).max |
| 216 | except: # bare except as possible raises by finfo not documented |
| 217 | try: |
| 218 | return np.iinfo(self.as_numpy_dtype()).max |
| 219 | except: |
| 220 | if self.base_dtype == bfloat16: |
| 221 | return _np_bfloat16(float.fromhex("0x1.FEp127")) |
| 222 | raise TypeError("Cannot find maximum value of %s." % self) |
| 223 | |
| 224 | @property |
| 225 | def limits(self, clip_negative=True): |