pynbody.util

pynbody.util#

Routines used internally by pynbody.

Functions

arrays_are_same(a1, a2)

Returns True if a1 and a2 are numpy views pointing to the exact same underlying data; False otherwise.

bisect(left, right, f[, epsilon, eta, niter_max])

Finds the value x such that f(x)=0 for a monotonically increasing function f, using a binary search.

cutgz(x)

Strip the .gz ending off a string or path

deprecated(func[, message])

Mark a method or function as deprecated, optionally with a custom message.

equipartition(ar, nbins[, vmin, vmax])

Return nbins+1 monotonically increasing bin edges such that the number of items from ar in each bin is ~equal

gamma_inc(a, z[, eps])

Incomplete gamma function accepting complex z, based on algorithm given in numerical recipes (3rd ed)

open_(filename, *args, **kwargs)

Open a file, enabling use of gzip decompression

random_rotation_matrix()

Return a random rotation matrix (Haar measure for 3x3 case), using fast algorithm from Graphics Gems III

rational_matrix_inv(matrix)

A replacement for numpy linalg matrix inverse which handles fractions exactly.

set_array_if_not_same(a_store, a_in[, index])

Checks whether a_store and a_in ultimately point to the same buffer; if not, copy a_in into a_store.

thread_map(func, *args)

Run func in separate threads, mapping over the arguments in the same way as map(...)

Classes

ExecutionControl()

Class to control execution flow in a with statement.

SettingControl(dictionary, key, value)

Class to control a setting using a with statement.

Modules

hdf_vds

Toolset for creating a virtual dataset from multiple HDF5 files.

indexing_tricks

Tricks for manipulating indexes and slices into arrays for internal use by pynbody.

iter_subclasses

Provides a mix-in class for iterating over all subclasses of a given class, possibly in a user-specified order.