cmomy.wrap#
- cmomy.wrap(obj, *, mom_ndim=None, mom_axes=None, mom_dims=None, mom_params=None, dtype=None, copy=False, fastpath=False)[source]#
Wrap object with central moments class.
- Overloads:
obj (
DataT), *, dtype (dtype[Any] |None|type[Any] |str|tuple[Any,int] |tuple[Any,SupportsIndex|Sequence[SupportsIndex]] |tuple[Any,Any] |list[Any] |_SupportsDType[dtype[Any]] |Mapping[Any,dtype[Any] |None|type[Any] |str|tuple[Any,int] |tuple[Any,SupportsIndex|Sequence[SupportsIndex]] |tuple[Any,Any] |list[Any] |_SupportsDType[dtype[Any]]]) =..., **kwargs (Unpack[WrapKwargs]) →CentralMomentsData[DataT]obj (
_SupportsArray[dtype[FloatT]] | _NestedSequence[_SupportsArray[np.dtype[_ScalarT]]]), *, dtype (None) =..., **kwargs (Unpack[WrapKwargs]) →CentralMomentsArray[FloatT]obj (
Buffer|_SupportsArray[dtype[Any]] |_NestedSequence[_SupportsArray[dtype[Any]]] |complex|bytes|str|_NestedSequence[complex|bytes|str]), *, dtype (DTypeLikeArg[FloatT]), **kwargs (Unpack[WrapKwargs]) →CentralMomentsArray[FloatT]obj (
Buffer|_SupportsArray[dtype[Any]] |_NestedSequence[_SupportsArray[dtype[Any]]] |complex|bytes|str|_NestedSequence[complex|bytes|str]), *, dtype (dtype[Any] |None|type[Any] |str|tuple[Any,int] |tuple[Any,SupportsIndex|Sequence[SupportsIndex]] |tuple[Any,Any] |list[Any] |_SupportsDType[dtype[Any]]) =..., **kwargs (Unpack[WrapKwargs]) →CentralMomentsArray[Any]obj (
Buffer|_SupportsArray[dtype[Any]] |_NestedSequence[_SupportsArray[dtype[Any]]] |complex|bytes|str|_NestedSequence[complex|bytes|str] |DataT), *, dtype (dtype[Any] |None|type[Any] |str|tuple[Any,int] |tuple[Any,SupportsIndex|Sequence[SupportsIndex]] |tuple[Any,Any] |list[Any] |_SupportsDType[dtype[Any]] |Mapping[Any,dtype[Any] |None|type[Any] |str|tuple[Any,int] |tuple[Any,SupportsIndex|Sequence[SupportsIndex]] |tuple[Any,Any] |list[Any] |_SupportsDType[dtype[Any]]]) =..., **kwargs (Unpack[WrapKwargs]) →CentralMomentsArray[Any] |CentralMomentsData[DataT]
This will choose the correct wrapper class given the type of array (
ndarrayorxarrayobject).- Parameters:
obj (
Buffer|_SupportsArray[dtype[Any]] |_NestedSequence[_SupportsArray[dtype[Any]]] |complex|bytes|str|_NestedSequence[complex|bytes|str] |DataT) – Central Moments array.mom_ndim (MomNDim | None, default:
None) – Value indicates if moments (mom_ndim = 1) or comoments (mom_ndim=2). If not specified and data is anxarrayobject attempt to infermom_ndimfrommom_dims. Otherwise, default tomom_ndim = 1.mom_dims (MomDims |
None, default:None) – Name of moment dimensions. If specified, infermom_ndimfrommom_dims. If also passmom_ndim, check thatmom_dimsis consistent withmom_dims. If not specified, defaults todata.dims[-mom_ndim:]. This is primarily used ifdatais aDataset, or ifmom_dimsare not the last dimensions.dtype (
dtype[Any] |None|type[Any] |str|tuple[Any,int] |tuple[Any,SupportsIndex|Sequence[SupportsIndex]] |tuple[Any,Any] |list[Any] |_SupportsDType[dtype[Any]] |Mapping[Any,dtype[Any] |None|type[Any] |str|tuple[Any,int] |tuple[Any,SupportsIndex|Sequence[SupportsIndex]] |tuple[Any,Any] |list[Any] |_SupportsDType[dtype[Any]]], default:None) – Optionaldtypefor output data.copy (
bool|None, default:False) – If True, copy the data. If None or False, attempt to use view. Note thatFalsevalues will be converted toNonefor numpy versions>2.0. This will be changed to reflect the new behavior of thecopyparameter tonumpy.array()when the minimum numpy version>2.0.fastpath (
bool, default:False) – Internal variable.
- Returns:
wrapped (
CentralMomentsArrayorCentralMomentsData) – Wrapped object. If input data is anxarrayobject, then returnCentralMomentsDatainstance. Otherwise, returnCentralMomentsArrayinstance.
See also
Examples
>>> data = [10.0, 2.0, 3.0] >>> wrap(data) <CentralMomentsArray(mom_ndim=1)> array([10., 2., 3.])
>>> xdata = xr.DataArray(data, dims="mom") >>> wrap(xdata) <CentralMomentsData(mom_ndim=1)> <xarray.DataArray (mom: 3)> Size: 24B array([10., 2., 3.]) Dimensions without coordinates: mom