Post by j***@gmail.comPost by j***@gmail.comIs there an explanation somewhere of what different basic dtypes mean,
across platforms and python versions?
Post by j***@gmail.comnp.bool8
<type 'numpy.bool_'>
np.bool_
<type 'numpy.bool_'>
bool
<type 'bool'>
Are there any rules and recommendations or is it all folks lore?
http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#arrays-dtypes-constructing
Basically, we accept the builtin Python type objects as a dtype argument
and do something sensible with them. float -> np.float64 because Python
floats are C doubles. int -> np.int32 or np.int64 depending on whatever a C
long is (i.e. depending on the 64bitness of your CPU and how your OS
chooses to deal with that). We encode those precision choices as aliases to
the corresponding specific numpy scalar types (underscored as necessary to
avoid shadowing builtins of the same name): np.float_ is np.float64, for
example.
See here for why the aliases to Python builtin types, np.int, np.float,
https://github.com/numpy/numpy/pull/6103#issuecomment-123652497
If you just need to pass a dtype= argument and want the precision that
matches the "native" integer and float for your platform, then I prefer to
use the Python builtin types instead of the underscored aliases; they just
look cleaner. If you need a true numpy scalar type (e.g. to construct a
numpy scalar object), of course, you must use one of the numpy scalar
types, and the underscored aliases are convenient for that. Never use the
aliases to the Python builtin types.
(I don't have time to follow up on this for at least two weeks)
my thinking was that, if there is no actual difference between bool,
np.bool and np.bool_, the np.bool could become an alias and a replacement
for np.bool_, so we can get rid of a "ugly" trailing underscore.
If np.float is always float64 it could be mapped to that directly.
As the previous discussion on python int versus numpy int on python 3.x,
int is at least confusing.
Also I'm thinking that maybe adjusting the code to the (mis)interpretation,
instead of adjusting killing np.float completely might be nicer, (but
changing np.int would be riskier?)
Josef
Post by j***@gmail.com--
Robert Kern
_______________________________________________
NumPy-Discussion mailing list
http://mail.scipy.org/mailman/listinfo/numpy-discussion