utils

class rbf.utils.KDTree

Same as scipy.spatial.cKDTree, except when calling query with k=1, the output does not get squeezed to 1D. Also, an error will be raised if query is called with k larger than the number of points in the tree.

query(x, k=1, **kwargs)

query the KD-tree for nearest neighbors

class rbf.utils.Memoize(*args, **kwargs)

An memoizing decorator. The max cache size is hard-coded at 128. When the limit is reached, the least recently used (LRU) item is dropped.

clear_cache()

Clear the cached function output

class rbf.utils.MemoizeArrayInput(*args, **kwargs)

A memoizing decorator for functions that take only numpy arrays as input. The max cache size is hard-coded at 128. When the limit is reached, the least recently used (LRU) item is dropped.

rbf.utils.assert_shape(arr, shape, label='array')

Raises a ValueError if arr does not have the specified shape

Parameters:
  • arr (array-like) –

  • shape (tuple) – The shape requirement for arr. This can have None to indicate that an axis can have any length. This can also have an Ellipsis to only enforce the shape for the first and/or last dimensions of arr

  • label (str) – What to call arr in the error

rbf.utils.clear_memoize_caches()

Clear the caches for all instances of MemoizeArrayInput

rbf.utils.get_arg_count(func)

Returns the number of arguments that can be specified positionally for a function. If this cannot be inferred then -1 is returned.

rbf.utils.no_shape_assertions()

Context manager that causes assert_shape to do nothing