On Fri, Jul 24, 2015 at 3:46 AM, Robert Kern <robert.k...@gmail.com> wrote:

> On Wed, Jul 22, 2015 at 7:45 PM, <josef.p...@gmail.com> wrote:
> >
> > Is there an explanation somewhere of what different basic dtypes mean,
> across platforms and python versions?
> >
> > >>> np.bool8
> > <type 'numpy.bool_'>
> > >>> np.bool_
> > <type 'numpy.bool_'>
> > >>> bool
> > <type 'bool'>
> >
> >
> > Are there any rules and recommendations or is it all folks lore?
>
> This may help a little:
>
>
> 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,
> etc. still exist:
>
> 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




>
> --
> Robert Kern
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to