[NumPy-Tickets] [NumPy] #1701: NumPy dtype arithmetic is the opposite of Python type arithmetic!
NumPy Trac
numpy-tickets@scipy....
Sat Dec 25 16:59:56 CST 2010
#1701: NumPy dtype arithmetic is the opposite of Python type arithmetic!
------------------------+---------------------------------------------------
Reporter: pv00 | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 2.0.0
Component: numpy.core | Version: 1.5.0
Keywords: dtype |
------------------------+---------------------------------------------------
NumPy dtype arithmetic is the opposite of Python type arithmetic!
The operators "and" and "or" switch roles:
<type 'int'> or <type 'float'> = <type 'int'>
<type 'int'> and <type 'float'> = <type 'float'>
int64 or float64 = float64
int64 and float64 = int64
This will be very confusing to users at large.
Can we make the conventions agree in NumPy 2.0?
More details: I was happy to find that NumPy exposed the numerical
datatype promotion rules such as
int + float = float
by means of the logical operator or :
dtype('int64'), ' or ', dtype('float64'), ' = ', dtype('float64')
But then I was shocked to find that Python had the
_exact_opposite_convention_!
I propose that there be a negotiation between the NumPy developers and the
Python developers, and that a consistent convention be set. Right now I
think it's undocumented (or not very publically documented) behavior, and
it would be better to make a change earlier, and fix a relatively small
base of code, rather than carry it along forever, a potential source of
confusion when code is written and whenever it is debugged.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1701>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list