misc#

a collection of useful functions

atomsmltr.utils.misc.check_position_array(position, nocheck=False)[source]#

Checks that a position array matches our vectorization convention.

It raises an error if the shape is not good.

Parameters:
  • position (array) – the array to check

  • nocheck (bool, optional) – if set to True, the function is bypasses

Returns:

the array

Return type:

position

Notes

positions array should have a shape (3,) or (n1, n2, .., 3).

In all cases, the last dimension contains cordinates (x, y, z), in meter and in the lab frame

atomsmltr.utils.misc.check_position_speed_array(position, nocheck=False)[source]#

Checks that a position array matches our vectorization convention.

It raises an error if the shape is not good.

Parameters:
  • position (array) – the array to check

  • nocheck (bool, optional) – if set to True, the function is bypasses

Returns:

the array

Return type:

position

Notes

positions array should have a shape (6,) or (n1, n2, .., 6).

In all cases, the last dimension contains cordinates (x, y, z, vx, vy, vz), in meter and in the lab frame

atomsmltr.utils.misc.check_positive_float(param_name: str, value: float) None[source]#

internal function to check that a parameter is a positive float, raises a ValueError if not.

Parameters:
  • param_name (str) – name of the checked parameter, to give context in the exception

  • value (float) – value of the paramater to check

atomsmltr.utils.misc.check_scalar_field_value_function(func)[source]#

Used in tests : checks that a function yielding values of a 3D scalar field field behaves correctly with numpy arrays.

for input of shape (…, 1) should return shape (…, 1)

Parameters:

func (function) – the function to check

atomsmltr.utils.misc.check_vector_field_value_function(func)[source]#

Used in tests : checks that a function yielding values of a 3D vector field field behaves correctly with numpy arrays.

for input of shape (…, 3) should return shape (…, 3)

Parameters:

func (function) – the function to check

atomsmltr.utils.misc.random_word(syl=3)[source]#

Generates a random word

Parameters:

syl (int, optional) – number of syllabs, by default 3

Returns:

word – the random word

Return type:

str