utils#

Utility functions for basic functionality of the py:module:cluster_generator package.

Functions

ensure_list(x)

Force x to be a list

ensure_ytarray(arr, units)

Ensures the array is a united array

ensure_ytquantity(x, default_units)

Ensures the quantity has units

generate_particle_radii(r, m, num_particles)

Inverse sampling method to generate particle radii.

integrate(profile, rr)

Integrate over the radii

integrate_mass(profile, rr)

Integrates over a profile with spherical volume element

integrate_toinf(profile, rr)

Integrate to infinity

parse_prng(prng)

Grabs random state

time_limit(function, max_execution_time, ...)

Assert a maximal time limit on functions with potentially problematic / unbounded execution times.

Classes

LogMute(logger)

Context manager for muting logging output.

Exceptions

TimeoutException([msg, func, max_time])

Exception raised when function runs out of runtime allocaiton.