Changelog for cmomy
See the fragment files in changelog.d
-
Routines now accept
mom_axes
parameter. This allows for moment axes to be in arbitrary location -
Routines now accept
mom_params
parameter. This object contains all the logic for working with moment arrays. This Also simplifies calling routines from other classes/routines. -
Update requirements, typing, and linting
-
Routines now correctly respect the
order
parameter. Passing inNone
will lead to arrays that arec
ordered when "normalized" (i.e., which haveaxis
andmom_axes
at the end), which is the default behavior ofnumb.guvectorize
. Passing orderc
will lead to outputs that arec
ordered regardless ofmom_axes
location. -
Negative axis/axes are now treated relative to the end of the array (just like python lists and numpy ndarrays). To get the old behavior of counting relative to the
mom_ndim
, pass in imaginary axis. For example, passingaxis=-1j
withmom_ndim=1
is equivalent to passingaxis=-2
. -
renamed parameter
move_axes_to_end
toaxes_to_end
. This will lead to axes being in the form(..., *mom_axes)
ifaxes
are reduced or(..., *axes, *mom_axes)
ifaxes
are kept. -
Applying routines to
dataset
objects now keeps correct order ifaxes_to_end
isFalse
.
- For xarray (DataArray and Dataset) central moments data, routines will infer
mom_ndim
frommom_dims
. For example, can callingcmomy.reduce_data(data, mom_dims=("mom_0", "mom_1"), dim="a")
will infermom_ndim=1
.
cmomy.randsamp_freq
has been replaced withcmomy.factory_sampler
cmomy.factory_sampler
to create a sampler for resample routines.cmomy.IndexSampler
to wrap resample "indices" and "freq" table.
- Added
IndexSampler
class to handle resampling. This wraps either resamplingindices
or a "frequency" tablefreq
, and can produce whichever is not provided. - replace
randsamp_freq
withfactory_sampler
which createsIndexSampler
from parameters or a mapping. - Removed arguments
freq
,nrep
,rng
,paired
from resampling routines (resample_data
, etc). This was replaced by an argumentssampler
which can be either anIndexSampler
or a mapping which is passed tofactory_sampler
. This means that to call the resampling routines, you'll have to pass a sampler or a dict of parameters. While this is a little annoying, it greatly cleans up a bunch of parameters that may not be used. For example, the callcmomy.resample_data(data, axis=0, nrep=10, rng=0)
is nowcmomy.resampler_data(data, axis=0, sampler={"nrep": 10, "rng": 0})
. Plus, you can now passindices
withcmomy.resample_data(data, axis=0, sampler={"indices": indices})
- Removed parameter
on_missing_core_dim
from routines that callxarray.apply_ufunc
behind the scenese. You can still pass this parameter usingapply_ufunc_kwargs
. For example,cmomy.reduce_data(data, axis=0, apply_ufunc_kwargs={"on_missing_core_dim": "drop"})
.
- Made
cmomy.resample.freq_to_indices
andcmomy.resample.indices_to_freq
gufunc's. Much faster than old code (freq_to_indices
was a bottleneck).
- Added
cmomy.convert.comoments_to_moments
routine, which is the inverse ofcmomy.convert.moments_to_comoments
.
cmomy.assign_moment
andcmomy.select_moment
now accept optionsxmom_0
,xmom_1
,ymom_0
, andymom_1
. These allow selecting/assigning to slices. Useful when convertering values to central moments array.
- Now fully support wrapping
xarray.Dataset
objects - Complete rewrite of wrapper classes
- Added
wrapper
factory methodscmomy.wrap
,cmomy.wrap_reduce_vals
, etc. These automatically select fromCentralMomentsArray
andCentralMomentsData
. - Renamed
CentralMoments
toCentralMomentsArray
andxCentralMoments
toCentralMomentsData
. The former is parametrized across numpy arrays. The later is parametrized to work with eitherxarray.DataArray
orxarray.Dataset
objects. - Full support
dask
backedxarray
objects. This will be lazily evaluated. - Removed
CentralMomentsArray/Data.block
method. Instead, there is ablock
keyword inreduce
method. to_dataarray
,to_dataset
, etc, method ofCentralMomentsArray/Data
now return a wrapped object instead of anxarray
object. To access the underlyingxarray
object, use theobj
attribute.- Removed
values
anddata
attributes fromCentralMomentsArray/Data
wrapper classes. Now wrap either an array orxarray
object directly (instead of only really wrappingnumpy
arrays in the old code). To access the wrapped object, now useobj
attribute. - Now include testing of typing (
mypy
andpyright
) support.
- Added
rolling
module for rolling mean and exponential rolling mean. - Added
bootstrap_confidence_interval
method to calculate confidence intervals - Added
moveaxis
function to cleanly handle axes movement of central moments array - Added
select_moment
method to select specific moments (weight, average, etc) from a central moments array - Added
assign_moment
method to assign values to specific moments. - Added
vals_to_data
to simplify using_data
methods for raw values. - Added
jackknife_
an routines to perform jackknife analysis. - Update
_vals
routines to properly place theaxis
parameter in result. - Added
axes_to_end
option to most routines. - Added
keepdims
option fromreduce_data
andreduce_vals
-
Added
cmomy.concat
method to concatenate moments objects. -
Added
__getitem__
to(x)CentralMoments
objects. This method does not* allow changing the moments shape. If you want to do that, you'll need to work directly with(x)CentralMoments.to_values()
- added
cmomy.resample.select_ndat
to select data size along reduction dimension - Added
cmomy.randsamp_freq
to top level api
- Updated
cmomy.resample.randsamp_freq
to select ndat from array
-
Added
cmomy.convert.moments_to_comoments
(and(x)CentralMoments.moments_to_comoments
)to convert from single variable moments to comoments. This is useful inthermoextrap
. -
Added
cmomy.convert.assign_weight
(and(x)CentralMoments.assign_weights
) to update weights (useful inthermoextrap
). -
Added support for
numpy>=2.0.0
. Because we still support older versions, we still use the old convention for thecopy
parameter tonumpy.array
. Will change this when minimum numpy is 2.0.
- Renamed
cmomy.convert
function tocmomy.convert.moments_type
A bullet item for the Changed category.
- Now supports python3.12
- Switch to underlying numba functions using
guvectorize
. This significantly simplifies the code. Previously, we had separate functions for "vector" vs "scalar" moments. To handle arbitrary vector dimensions, the arrays were reshaped behind the scenes (to a single "meta" dimension). Now, this is all handled by thegufunc
based library code. - Typing support improved.
- Added
(x)CentralMoments.astype
- Added
(x)CentralMoments.
- Added alias
CentralMoments.to_x
which is the same asCentralMoments.to_xcentralmoments
. - Added alias
xCentralMoments.to_c
which is the same asxCentralMoments.to_centralmoments
. - Most constructors now accept
order
anddtype
arguments. - Most routines that process central moments accept a
parallel
parameter. - Instead of complicated internal validation routines in
(x)CentralMoments
, most of this is now handled bycmomy.reduction
or similar routines. - Now using
xr.apply_ufunc
for most of thexarray.DataArray
based calculations.
- Removed classmethods
(x)CentralMoments.from_raws
. Instead, use(x)CentralMoments.from_raw(...).reduce(...)
. - Removed classmethods
(x)CentralMoments.from_datas
. Instead, use(x)CentralMoments.from_data(...).reduce(...)
. - Removed classmethod
(x)CentralMoments.from_data
. Instead, use(x)CentralMoments(....)
. - Removed ability to create
xCentralMoments
objects directly fromnumpy.ndarray
objects. (e.g., passing in array-like toxCentralmoments.from_vals
doesn't work anymore). Instead useCentralMoments.from_vals(....).to_xcentralmoments(...)
, etc. - Removed methods
push_stat
,push_stats
,from_stat
,from_stats
. Instead use, for example,numpy.concatenate
, to combine weights, average, and variance into adata
array. A helper function may be added if called for. (x)CentralMoments.resample_and_reduce
and(x)CentralMoments.from_resample_vals
no longer acceptnrep=...
orindices=...
. They only acceptfreq=...
.
- Can now resample with an arbitrary number of samples. Previously, it was
assumed that resampling should be done with a shape
(nrep, ndat)
, wherenrep
is the number of replicates andndat
is the shape of the data along the resampled axis. Now you can pass sample with shape(nrep, nsamp)
wherensamp
is the specified number of samples in a replicate (defaulting tondat
). This allows users to do things like jacknife resampling, etc, withresample_and_reduce
methods. - Preliminary support for using type hints in generated documentation. The
standard sphinx autodoc support doesn't quite work for
cmomy
, as it requires type hints to be accessible at run time, and not inTYPE_CHECKING
blocks. Instead, we usesphinx_autodoc_type
. This has the downside of expanding type aliases, but handles (most things) being inTYPE_CHECKING
blocks. Over time, we'll replace some of the explicit parameter type documentation with those from type hints. - Fixed creation of templates in reduction routines of
xCentralMoments
. Previously, we build the template for the result using something likeda.isel(dim=0)
. This kept scalar coordinates ofda
withdim
. Now we useda.isel(dim=0, drop=True)
to drop these. - Updated dependencies.
-
Added
to_values
method to access underlying array data. This should be preferred to.values
attribute. -
Added
to_numpy
method to access underlyingnumpy.ndarray
. -
Added
to_dataarray
method to access underlyingxarray.DataArray
inxCentralMoment s
-
Added submodule
cmomy.random
to handle random numbers generation. This usesnumpy.random.Generator
behind the scenes. -
Updated
ruff
lintering rules -
Now using
hatchling
for package building -
Update repo template
- Now CentralMoments and xCentralMoments ensure that data/data_flat share memory. This may result in passed data not being the same as the internal data, if reshaping data creates a copy.
- Made little used arguments keyword only
-
Now use lazy_loader to speed up initial load time.
-
Now using
module_utilities >=0.6
. -
Changed from
custom-inherit
todocstring-inheritance
-
Now fully supports typing (passing mypy --stict and pyright)
-
Relocated numba functions to submodule
cmomy._lib
.
- Moved tests to top level of repo (
src/cmomy/tests
totests
)
-
Package now available on conda-forge
-
Bumped maximum python version to 3.11
- Testing now handled with nox.
- Moved module
_docstrings_
todocstrings
. This can be used by other modules.
-
Update package layout
-
New linters via pre-commit
-
Development env now handled by tox
-
Now use
module-utilities
to handle caching and docfiller.
Full set of changes:
v0.2.2...v0.3.0
Full set of changes:
v0.2.1...v0.2.2
Full set of changes:
v0.2.0...v0.2.1
Full set of changes:
v0.1.9...v0.2.0
Full set of changes:
v0.1.8...v0.1.9
Full set of changes:
v0.1.7...v0.1.8
Full set of changes:
v0.1.6...v0.1.7
Full set of changes:
v0.1.5...v0.1.6
Full set of changes:
v0.1.4...v0.1.5
Full set of changes:
v0.1.3...v0.1.4
Full set of changes:
v0.1.2...v0.1.3
Full set of changes:
v0.1.1...v0.1.2
Full set of changes:
v0.1.0...v0.1.1
Full set of changes:
v0.0.7...v0.1.0
Full set of changes:
v0.0.6...v0.0.7
Full set of changes:
v0.0.4...v0.0.6
Full set of changes:
v0.0.3...v0.0.4