pogona.util

Miscellaneous utility functions for the Pogona simulator.

Functions

check_enum_key(enum_class, key, param_name)

Raise a ValueError if key is not a valid key for enum_class.

check_vector(value, component_name, key)

get_random_points_in_cube_local(n, rng)

get_random_points_in_geometry_local(n, ...)

grouper(iterable, n[, fillvalue])

Iterate over an iterable in n-sized chunks.

is_power_of_two(n)

Check if a number is a power of 2.

mlpmin_to_lps(mlpmin)

Convert millilitres per minute to litres per second.

mlpmin_to_m3ps(mlpmin)

Convert millilitres per minute to cubic metres per second.

pogona.util.check_enum_key(enum_class: Type[enum.Enum], key: str, param_name: str)[source]

Raise a ValueError if key is not a valid key for enum_class.

pogona.util.check_vector(value: list, component_name: str, key: str)[source]
pogona.util.get_random_points_in_cube_local(n: int, rng: numpy.random.mtrand.RandomState) List[numpy.ndarray][source]
pogona.util.get_random_points_in_geometry_local(n: int, geometry: pogona.geometry.Geometry, rng: numpy.random.mtrand.RandomState) List[numpy.ndarray][source]
pogona.util.grouper(iterable: Iterable, n: int, fillvalue=None)[source]

Iterate over an iterable in n-sized chunks. Based on https://stackoverflow.com/a/434411/1018176

Parameters
  • iterable

  • n

  • fillvalue

Returns

pogona.util.is_power_of_two(n)[source]

Check if a number is a power of 2. Based on https://stackoverflow.com/a/57025941/1018176

Parameters

n

Returns

True iff n is a power of 2.

pogona.util.mlpmin_to_lps(mlpmin: float) float[source]

Convert millilitres per minute to litres per second.

pogona.util.mlpmin_to_m3ps(mlpmin: float) float[source]

Convert millilitres per minute to cubic metres per second.