Skip to content

Restricted: allow more numpy dtypes

Xiaowu Zhang requested to merge xiaowu.zhang/erp5:feature into master

i observe new behavior of numpy dtype, it seems they already introduce New and extensible DTypes in recent numpy , at lease 1.26.4

in numpy 1.16.6

import numpy as np

for dtype in ('int8', 'int16', 'int32', 'int64',
              'uint8', 'uint16', 'uint32', 'uint64',
              'float16', 'float32', 'float64',
              'complex64', 'complex128']
             ):
  print(type(np.dtype(dtype)))
return printed

return always <type 'numpy.dtype'>, there has only one dtype

but in numpy 1.26.4, it returns differently

<class 'numpy.dtypes.Int8DType'>
<class 'numpy.dtypes.Int16DType'>
<class 'numpy.dtypes.Int32DType'>
<class 'numpy.dtypes.Int64DType'>
<class 'numpy.dtypes.UInt8DType'>
<class 'numpy.dtypes.UInt16DType'>
<class 'numpy.dtypes.UInt32DType'>
<class 'numpy.dtypes.UInt64DType'>
<class 'numpy.dtypes.Float16DType'>
<class 'numpy.dtypes.Float32DType'>
<class 'numpy.dtypes.Float64DType'>
<class 'numpy.dtypes.Complex64DType'>
<class 'numpy.dtypes.Complex128DType'>

from what i know, it miss <class 'numpy.dtypes.BoolDType'> and <class 'numpy.dtypes.VoidDType'>

if we access attribute of those missing dtypes, we'll get Unauthorized error, like the error message below:

  zbigarray = out_data_array.initArray(shape=(0,), dtype= ndarray.dtype.fields) 
AccessControl.unauthorized.Unauthorized: You are not allowed to access 'fields' in this context

this merge request aim to allow more dtype

Edited by Xiaowu Zhang

Merge request reports