On Sat, Jun 8, 2013 at 12:40 PM,  <[email protected]> wrote:
> Question about namespace
>
> why is there bool and bool_ ?
>
>>>> np.bool(True) + np.bool(True)
> 2
>>>> np.bool_(True) + np.bool_(True)
> True
>
>>>> type(np.bool(True))
> <type 'bool'>
>>>> type(np.bool_(True))
> <type 'numpy.bool_'>
>
> I didn't pay attention to the trailing underline in Pauli's original example

`np.bool is __builtin__.bool`. It's a backwards-compatibility alias
for an old version of numpy that used the name `np.bool` for the
scalar type now called `np.bool_` (similarly for `np.float`, `np.int`,
and `np.complex`). Since `from numpy import *` caused name collisions,
we moved the scalar types to their current underscored versions.
However, since people had started to use `dtype=np.bool`, we just
aliased the builtin type objects to keep that code working. I would
love to be able to remove those since they are an unending source of
confusion. However, there is no good way to issue deprecation warnings
when you use them, so that means that upgrades would cause sudden,
unwarned breakage, which we like to avoid.

--
Robert Kern
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to