+1 for the general idea!

It may be nice to have such a function which sits at the top level of the API, 
to fit into 
https://data-apis.org/array-api/draft/API_specification/data_type_functions.html
 nicely. However, ‘min_value’ or ‘min‘ won’t do then - we’d probably need to 
include ‘dtype’ in the name somewhere. But I don’t really like 
`np.min_dtype(dt)`. Maybe `np.min_dtype_value(dt)`?

Cheers,
Lucas

> On 25 Aug 2024, at 20:59, Carlos Martin <cgmar...@andrew.cmu.edu> wrote:
> 
> As discussed 
> [here](https://github.com/numpy/numpy/issues/5032#issuecomment-1830838701), 
> [here](https://github.com/numpy/numpy/issues/5032#issuecomment-2307927804), 
> and 
> [here](https://github.com/google/jax/issues/18661#issuecomment-1829031914), 
> I'm interested in a uniform interface for accessing the minimum or maximum 
> value of a given dtype.
> 
> Currently, this requires branching on the type of dtype (boolean, integer, or 
> floating point) and then (for the latter two) calling either 
> [iinfo](https://numpy.org/doc/stable/reference/generated/numpy.iinfo.html) or 
> [finfo](https://numpy.org/doc/stable/reference/generated/numpy.finfo.html), 
> respectively. It would be more ergonomic to have a single, uniform interface 
> for accessing this information that is dtype-independent.
> 
> Possible interfaces include:
> 
> ```python3
> import numpy as np
> dt = np.dtype('int32')
> 
> dt.min
> np.dtypes.info(dt).min
> np.dtypes.min(dt)
> np.dtypes.min_value(dt)
> ```
> _______________________________________________
> NumPy-Discussion mailing list -- numpy-discussion@python.org
> To unsubscribe send an email to numpy-discussion-le...@python.org
> https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
> Member address: lucas.coll...@gmail.com
_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to