MCPcopy Create free account
hub / github.com/numpy/numpy / container

Class container

numpy/lib/user_array.py:16–264  ·  view source on GitHub ↗

container(data, dtype=None, copy=True) Standard container-class for easy multiple-inheritance. Methods ------- copy tostring byteswap astype

Source from the content-addressed store, hash-verified

14
15
16class container:
17 """
18 container(data, dtype=None, copy=True)
19
20 Standard container-class for easy multiple-inheritance.
21
22 Methods
23 -------
24 copy
25 tostring
26 byteswap
27 astype
28
29 """
30 def __init__(self, data, dtype=None, copy=True):
31 self.array = array(data, dtype, copy=copy)
32
33 def __repr__(self):
34 if self.ndim > 0:
35 return self.__class__.__name__ + repr(self.array)[len("array"):]
36 else:
37 return self.__class__.__name__ + "(" + repr(self.array) + ")"
38
39 def __array__(self, t=None):
40 if t:
41 return self.array.astype(t)
42 return self.array
43
44 # Array as sequence
45 def __len__(self):
46 return len(self.array)
47
48 def __getitem__(self, index):
49 return self._rc(self.array[index])
50
51 def __setitem__(self, index, value):
52 self.array[index] = asarray(value, self.dtype)
53
54 def __abs__(self):
55 return self._rc(absolute(self.array))
56
57 def __neg__(self):
58 return self._rc(-self.array)
59
60 def __add__(self, other):
61 return self._rc(self.array + asarray(other))
62
63 __radd__ = __add__
64
65 def __iadd__(self, other):
66 add(self.array, other, self.array)
67 return self
68
69 def __sub__(self, other):
70 return self._rc(self.array - asarray(other))
71
72 def __rsub__(self, other):
73 return self._rc(asarray(other) - self.array)

Callers 1

user_array.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected