nifty7.utilities module

class NiftyMeta(name, bases, clsdict)[source]

Bases: nifty7.utilities._DocStringInheritor

check_MPI_equality(obj, comm)[source]

Check that object is the same on all MPI tasks associated to a given communicator.

Raises a RuntimeError if it differs.

Parameters
  • obj – Any Python object that implements __eq__.

  • comm (MPI communicator or None) – If comm is None, no check will be performed

check_MPI_synced_random_state(comm)[source]

Check that random state is the same on all MPI tasks associated to a given communicator.

Raises a RuntimeError if it differs.

Parameters

comm (MPI communicator or None) – If comm is None, no check will be performed

class frozendict(*args, **kwargs)[source]

Bases: collections.abc.Mapping

An immutable wrapper around dictionaries that implements the complete collections.Mapping interface. It can be used as a drop-in replacement for dictionaries where immutability is desired.

copy(**add_or_replace)[source]
dict_cls

alias of dict

get_slice_list(shape, axes)[source]

Helper function which generates slice list(s) to traverse over all combinations of axes, other than the selected axes.

Parameters
  • shape (tuple) – Shape of the data array to traverse over.

  • axes (tuple) – Axes which should not be iterated over.

Yields

list – The next list of indices and/or slice objects for each dimension.

Raises

ValueError – If shape is empty. If axes(axis) does not match shape.

indent(inp)[source]
infer_space(domain, space)[source]
iscomplextype(dtype)[source]
lognormal_moments(mean, sigma, N=0)[source]

Calculates the parameters for a normal distribution n(x) such that exp(n)(x) has the mean and standard deviation given.

Used in LognormalTransform().

memo(f)[source]
my_lincomb(terms, factors)[source]
my_lincomb_simple(terms, factors)[source]
my_product(iterable)[source]
my_sum(iterable)[source]
parse_spaces(spaces, nspc)[source]
safe_cast(tfunc, val)[source]
special_add_at(a, axis, index, b)[source]
value_reshaper(x, N)[source]

Produce arrays of shape (N,). If x is a scalar or array of length one, fill the target array with it. If x is an array, check if it has the right shape.