util

Various utility routines

cmepy.util.consecutive_pairs(p)

Returns (p0, p1), (p1, p2), ...

where p is an iterator

cmepy.util.indices_ext(shape, slices=None, origin=None)

Returns an array of indices.

An interface to numpy’s mgrid routine, supporting simpler slicing notation.

Arguments:

shape : tuple of positive integers giving dimensions of array

slices : (optional) tuple of (abstract) slices indicating which indices
we want from each dimension
origin : (optional) tuple of integers giving origin, used to offset
the returned indices
cmepy.util.non_neg(x)
Returns max(x, 0) [array operation]
cmepy.util.shape_invariant(f)

Returns wrapped copy of f that ensures output shape matches input shape.

Details : if the shapes of the first argument and output of the function f do not agree, the output will be expanded via numpy.tile until it is the same shape as the first input. Shapes are computed via numpy.shape.

Previous topic

tests

This Page