class RealisticInfoArray(np.ndarray):

    def __new__(cls, input_array, info=None):
        obj = np.asarray(input_array).view(cls)
obj.info = info
return obj

def __array_finalize__(self, obj):
    if obj is None:
        return
self.info = getattr(obj, 'info', None)

def __reduce__(self):
    pickled_state = super(RealisticInfoArray, self).__reduce__()
new_state = pickled_state[2] + (self.info,)
return pickled_state[0], pickled_state[1], new_state

def __setstate__(self, state):
    self.info = state[-1]
super(RealisticInfoArray, self).__setstate__(state[0:-1])
Preserve custom attributes when pickling subclass of numpy array