Utils

mlptrain.utils.convert_ase_energy(energy_array: ndarray, units: str) ndarray
mlptrain.utils.convert_ase_energy(energy_array: float, units: str) float

Converts ASE energy units to different energy units.

Returns:

Numpy array containing energy in the other units

Return type:

(np.ndarray)

mlptrain.utils.convert_ase_time(time_array: ndarray | float, units: str) ndarray | float

Converts ASE time units to different time units.

Returns:

Numpy array containing time in the other units

Return type:

(np.ndarray)

mlptrain.utils.convert_exponents(string: str) str

Finds exponents in a string and modifies the string such that the exponents are shown as exponents in plots.

Returns

(str): The modified string

mlptrain.utils.move_files(moved_substrings: List[str], dst_folder: str, src_folder: str | None = None, unique: bool = True, regex: bool = False) None

Move files with given regex or regular substrings from a directory src_folder to a directory dst_folder. If dst_folder already exists the function renames the existing folder (in the case of unique == True).

Parameters:
  • dst_folder – Name of the new directory where files are moved

  • src_folder – Name of the directory where files are located

  • unique – (bool) If False the existing directory is not renamed and the files are moved to that directory

  • regex – (bool) If True the supplied substrings will be interpreted as regex patterns

mlptrain.utils.unique_name(name: str, path: str | None = None) str

Returns a unique name for a file or directory in the specified directory by adding bck0, bck1, … to the front of the name until a unique name is found.

is checked

Returns:

Unique name

Return type:

(str)

mlptrain.utils.work_in_dir(dirname: str)

Execute a function in a different directory.

mlptrain.utils.work_in_tmp_dir(kept_substrings: Sequence[str] | None = None, copied_substrings: Sequence[str] | None = None)

Execute a function in a temporary directory

e.g. ‘.json’, ‘trajectory_1.traj’

Parameters:

copied_substrings – List of substrings with which files are copied to the temporary directory