MCPcopy Create free account
hub / github.com/DEAP/deap / _numpy_array

Class _numpy_array

deap/creator.py:52–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 pass
51else:
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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…