| 50 | pass |
| 51 | else: |
| 52 | class _numpy_array(numpy.ndarray): |
| 53 | def __deepcopy__(self, memo): |
| 54 | """Overrides the deepcopy from numpy.ndarray that does not copy |
| 55 | the object's attributes. This one will deepcopy the array and its |
| 56 | :attr:`__dict__` attribute. |
| 57 | """ |
| 58 | copy_ = numpy.ndarray.copy(self) |
| 59 | copy_.__dict__.update(copy.deepcopy(self.__dict__, memo)) |
| 60 | return copy_ |
| 61 | |
| 62 | @staticmethod |
| 63 | def __new__(cls, iterable): |
| 64 | """Creates a new instance of a numpy.ndarray from a function call. |
| 65 | Adds the possibility to instantiate from an iterable.""" |
| 66 | return numpy.array(list(iterable)).view(cls) |
| 67 | |
| 68 | def __setstate__(self, state): |
| 69 | self.__dict__.update(state) |
| 70 | |
| 71 | def __reduce__(self): |
| 72 | return (self.__class__, (list(self),), self.__dict__) |
| 73 | |
| 74 | class_replacers[numpy.ndarray] = _numpy_array |
| 75 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…