The utilities.py module#

Summary#

WorkingFolders

folder/file utilities for multiple runs.

where_element_in_array_1d

Find number of occurrence and indices of the target value in an array.

bisect

Use bisectional method to find the largest index in the array.

find_interpolate_parameters

Find the indices branket the given value.

interpolate_array

Find the y-value corresponding to the x-value in data pairs.

random

Generate a (reproducible) random floating number.

random_pick_integers

Return a list of random integers from a given integer list.

find_file

Find the correct version of the given partial file name.

copy_file

Copy a file from the source folder to the target folder.

delete_files_by_extension

Delete files with specified extensions.

check_jupyter_notebook

Check if Pychemkin is running in any Jupyter environment.

interpolate_point

Interpolate value from a binary data array.

Description#

pychemkin utilities.

Module detail#

utilities.where_element_in_array_1d(arr: numpy.typing.NDArray[numpy.double] | numpy.typing.NDArray[numpy.int32], target: float) tuple[int, numpy.typing.NDArray[numpy.int32]]#

Find number of occurrence and indices of the target value in an array.

utilities.bisect(ileft: int, iright: int, x: float, xarray) int#

Use bisectional method to find the largest index in the array.

utilities.find_interpolate_parameters(x: float, xarray: numpy.typing.NDArray[numpy.double]) tuple[int, float]#

Find the indices branket the given value.

utilities.interpolate_array(x: float, x_array: numpy.typing.NDArray[numpy.double], y_array: numpy.typing.NDArray[numpy.double]) float#

Find the y-value corresponding to the x-value in data pairs.

utilities.random(range: None | tuple[float, float] = None) float#

Generate a (reproducible) random floating number.

utilities.random_pick_integers(numb_picks: int, source_integers: list[int]) tuple[list[int], list[int]]#

Return a list of random integers from a given integer list.

utilities.find_file(filepath: str, partialfilename: str, fileext: str) str#

Find the correct version of the given partial file name.

utilities.copy_file(sourcepath: str, targetpath: str, filename: str, new_file_name: str | None = None)#

Copy a file from the source folder to the target folder.

utilities.delete_files_by_extension(targetpath: str, extensions: list[str])#

Delete files with specified extensions.

utilities.check_jupyter_notebook() bool#

Check if Pychemkin is running in any Jupyter environment.

utilities.interpolate_point(x_value: float, x_array: list[float] | numpy.typing.NDArray[numpy.double], y_array: list[float] | numpy.typing.NDArray[numpy.double]) tuple[int, float]#

Interpolate value from a binary data array.

utilities.ck_rng = None#