[NumPy-Tickets] [NumPy] #1701: Accessing Type Conversion/Promotion/Coercion Rules (was: NumPy dtype arithmetic is the opposite of Python type arithmetic!)

NumPy Trac numpy-tickets@scipy....
Tue Jan 4 21:46:38 CST 2011

#1701: Accessing Type Conversion/Promotion/Coercion Rules
  Reporter:  pv00        |       Owner:  somebody
      Type:  defect      |      Status:  reopened
  Priority:  normal      |   Milestone:  2.0.0   
 Component:  numpy.core  |     Version:  1.5.0   
Resolution:              |    Keywords:  dtype   
Changes (by pv00):

  * status:  closed => reopened
  * resolution:  invalid =>


 Ah you are right about the consequence of bool(dtype(...)) == False; my
 sample code is useless.

 What I was trying to do is access NumPy's type conversion / coercion

 My question should have been: if I want this to work:
 def make_new_array(ndarrayOfArbitraryShape_A, ndarrayOfArbitraryShape_B):
     new_dtype = common_dtype(ndarrayOfArbitraryShape_A.dtype,
     new_array = numpy.zeros(BigShape, dtype=new_dtype)
     return new_array

 is there a better way than the ugly and awkward:

 def common_dtype(A,B):
     return (numpy.zeros((1),dtype=B.dtype) +

Ticket URL: <http://projects.scipy.org/numpy/ticket/1701#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project

More information about the NumPy-Tickets mailing list