container(data, dtype=None, copy=True) Standard container-class for easy multiple-inheritance. Methods ------- copy byteswap astype
| 41 | |
| 42 | @set_module("numpy.lib.user_array") |
| 43 | class container: |
| 44 | """ |
| 45 | container(data, dtype=None, copy=True) |
| 46 | |
| 47 | Standard container-class for easy multiple-inheritance. |
| 48 | |
| 49 | Methods |
| 50 | ------- |
| 51 | copy |
| 52 | byteswap |
| 53 | astype |
| 54 | |
| 55 | """ |
| 56 | def __init_subclass__(cls) -> None: |
| 57 | # Deprecated in NumPy 2.4, 2025-11-24 |
| 58 | import warnings |
| 59 | |
| 60 | warnings.warn( |
| 61 | "The numpy.lib.user_array.container class is deprecated and will be " |
| 62 | "removed in a future version.", |
| 63 | DeprecationWarning, |
| 64 | stacklevel=2, |
| 65 | ) |
| 66 | |
| 67 | def __init__(self, data, dtype=None, copy=True): |
| 68 | self.array = array(data, dtype, copy=copy) |
| 69 | |
| 70 | def __repr__(self): |
| 71 | if self.ndim > 0: |
| 72 | return self.__class__.__name__ + repr(self.array)[len("array"):] |
| 73 | else: |
| 74 | return self.__class__.__name__ + "(" + repr(self.array) + ")" |
| 75 | |
| 76 | def __array__(self, t=None): |
| 77 | if t: |
| 78 | return self.array.astype(t) |
| 79 | return self.array |
| 80 | |
| 81 | # Array as sequence |
| 82 | def __len__(self): |
| 83 | return len(self.array) |
| 84 | |
| 85 | def __getitem__(self, index): |
| 86 | return self._rc(self.array[index]) |
| 87 | |
| 88 | def __setitem__(self, index, value): |
| 89 | self.array[index] = asarray(value, self.dtype) |
| 90 | |
| 91 | def __abs__(self): |
| 92 | return self._rc(absolute(self.array)) |
| 93 | |
| 94 | def __neg__(self): |
| 95 | return self._rc(-self.array) |
| 96 | |
| 97 | def __add__(self, other): |
| 98 | return self._rc(self.array + asarray(other)) |
| 99 | |
| 100 | __radd__ = __add__ |
no outgoing calls
no test coverage detected
searching dependent graphs…