Custom data types in numpy arrays

后端 未结 3 1327
小蘑菇
小蘑菇 2020-12-02 23:09

I\'m creating a numpy array which is to be filled with objects of a particular class I\'ve made. I\'d like to initialize the array such that it will only ever contain object

3条回答
  •  感情败类
    2020-12-03 00:04

    It has to be a Numpy scalar type:

    http://docs.scipy.org/doc/numpy/reference/arrays.scalars.html#arrays-scalars-built-in

    or a subclass of ndarray:

    http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray

提交回复
热议问题