impy.arrays.bases package¶
Submodules¶
impy.arrays.bases.metaarray module¶
- class impy.arrays.bases.metaarray.MetaArray(obj, name: str | None = None, axes: Iterable[Hashable] | None = None, source: str | Path | None = None, metadata: dict[str, Any] | None = None, dtype: DTypeLike = None)[source]¶
Bases:
AxesMixin
,ndarray
[Any
,dtype
[number
]]- NP_DISPATCH = {<function squeeze>: <function _>, <function take>: <function _>, <function stack>: <function _>, <function concatenate>: <function _>, <function block>: <function _>, <function zeros_like>: <function _>, <function empty_like>: <function _>, <function expand_dims>: <function _>, <function transpose>: <function _>, <function split>: <function _>, <function broadcast_to>: <function _>, <function moveaxis>: <function _>, <function swapaxes>: <function _>, <function argmax>: <function _>, <function argmin>: <function _>, <function cross>: <function _>, <function diff>: <function _>, <function gradient>: <function _>}¶
- property T: Self¶
View of the transposed array.
Same as
self.transpose()
.Examples
>>> a = np.array([[1, 2], [3, 4]]) >>> a array([[1, 2], [3, 4]]) >>> a.T array([[1, 3], [2, 4]])
>>> a = np.array([1, 2, 3, 4]) >>> a array([1, 2, 3, 4]) >>> a.T array([1, 2, 3, 4])
See also
- additional_props = ['_source', '_metadata', '_name']¶
- argmax_nd() tuple[int, ...] [source]¶
N-dimensional version of argmax.
For instance, if yx-array takes its maximum at (5, 8), this function returns
AxesShape(y=5, x=8)
.- Returns:
Argmax of the array.
- Return type:
AxesShape
- as_rgba(cmap: str | Callable[[np.ndarray], np.ndarray], *, axis: AxisLike = 'c', clim: tuple[float, float] | None = None, alpha: np.ndarray | None = None) Self [source]¶
Convert array to an RGBA image with given colormap.
- Parameters:
cmap (str or callable) – Colormap. Can be a string name of a colormap registered in vispy.
axis (AxisLike, default is "c") – The axis name used for the color axis.
clim ((float, float), optional) – Contrast limits. If not given, the minimum and maximum values of the array will be used.
- Returns:
Colored image.
- Return type:
- broadcast_to(shape: tuple[int, ...], axes: AxesLike | None = None) Self [source]¶
Broadcast array to specified shape and axes.
- Parameters:
shape (shape-like) – Shape of output array.
axes (AxesLike, optional) – Axes of output array. If given, it must match the dimensionality of input shape.
- Returns:
Broadcasted array.
- Return type:
- classmethod implements(numpy_function)[source]¶
Add functions to NP_DISPATCH so that numpy functions can be overloaded.
- isel(indexer=None, /, **kwargs: dict[str, Any]) Self [source]¶
A index based indexing method, mimicking
xarray.isel
.Example
>>> img.isel(c=3) >>> img.isel(t=slice(4, 7))
- max(axis=None, out: None = None, keepdims: bool = False, *, where: ~numpy.ndarray = <no value>)[source]¶
Maximum value of the array along a given axis.
- mean(axis=None, dtype: ~numpy.dtype[~typing.Any] | None | type[typing.Any] | ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]] | str | tuple[typing.Any, int] | tuple[typing.Any, typing.Union[typing.SupportsIndex, collections.abc.Sequence[typing.SupportsIndex]]] | list[typing.Any] | ~numpy._typing._dtype_like._DTypeDict | tuple[typing.Any, typing.Any] = None, out: None = None, keepdims: bool = False, *, where: ~numpy.ndarray = <no value>)[source]¶
Mean value of the array along a given axis.
- property metadata: dict[str, Any]¶
Metadata dictionary of the array.
- min(axis=None, out: None = None, keepdims: bool = False, *, where: ~numpy.ndarray = <no value>)[source]¶
Minimum value of the array along a given axis.
- property name: str¶
Name of the array.
- reshape(shape, order='C')[source]¶
Returns an array containing the same data with a new shape.
Refer to numpy.reshape for full documentation.
See also
numpy.reshape
equivalent function
Notes
Unlike the free function numpy.reshape, this method on ndarray allows the elements of the shape parameter to be passed in as separate arguments. For example,
a.reshape(10, 11)
is equivalent toa.reshape((10, 11))
.
- sel(indexer=None, /, **kwargs: dict[str, Any]) Self [source]¶
A label based indexing method, mimicking
xarray.sel
.Example
>>> img.sel(c="Red") >>> img.sel(t=slice("frame 3", "frame, 5"))
- property shape¶
Tuple of array dimensions.
The shape property is usually used to get the current shape of an array, but may also be used to reshape the array in-place by assigning a tuple of array dimensions to it. As with numpy.reshape, one of the new shape dimensions can be -1, in which case its value is inferred from the size of the array and the remaining dimensions. Reshaping an array in-place will fail if a copy is required.
Warning
Setting
arr.shape
is discouraged and may be deprecated in the future. Using ndarray.reshape is the preferred approach.Examples
>>> x = np.array([1, 2, 3, 4]) >>> x.shape (4,) >>> y = np.zeros((2, 3, 4)) >>> y.shape (2, 3, 4) >>> y.shape = (3, 8) >>> y array([[ 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0.]]) >>> y.shape = (3, 6) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: total size of new array must be unchanged >>> np.zeros((4,2))[::2].shape = (-1,) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: Incompatible shape for in-place modification. Use `.reshape()` to make a copy with the desired shape.
See also
numpy.shape
Equivalent getter function.
numpy.reshape
Function similar to setting
shape
.ndarray.reshape
Method similar to setting
shape
.
- property source¶
The source file path.
- split(axis=None) DataList[Self] [source]¶
Split n-dimensional image into (n-1)-dimensional images.
- Parameters:
axis (str or int, optional) – Along which axis the original image will be split, by default “c”
- Returns:
Separate images
- Return type:
list of arrays
- std(axis=None, dtype: ~numpy.dtype[~typing.Any] | None | type[typing.Any] | ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]] | str | tuple[typing.Any, int] | tuple[typing.Any, typing.Union[typing.SupportsIndex, collections.abc.Sequence[typing.SupportsIndex]]] | list[typing.Any] | ~numpy._typing._dtype_like._DTypeDict | tuple[typing.Any, typing.Any] = None, out: None = None, ddof: int = 0, keepdims: bool = False, *, where: ~numpy.ndarray = <no value>)[source]¶
Standard deviation of the array along a given axis.
- sum(axis=None, dtype: ~numpy.dtype[~typing.Any] | None | type[typing.Any] | ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]] | str | tuple[typing.Any, int] | tuple[typing.Any, typing.Union[typing.SupportsIndex, collections.abc.Sequence[typing.SupportsIndex]]] | list[typing.Any] | ~numpy._typing._dtype_like._DTypeDict | tuple[typing.Any, typing.Any] = None, out: None = None, keepdims: bool = False, *, where: ~numpy.ndarray = <no value>)[source]¶
Sum value of the array along a given axis.
- transpose(axes=None) Self [source]¶
change the order of image dimensions. ‘axes’ will also be arranged.
- property value: ndarray¶
Numpy view of the array.