quvac.utils

Useful generic utilities.

Functions

read_yaml(yaml_file)

Read a YAML file and return its contents.

write_yaml(yaml_file, data)

Write data to a YAML file.

format_time(seconds)

Format time in seconds to a human-readable string.

format_memory(mem)

Format memory in kilobytes to a human-readable string.

save_wisdom(ini_file[, wisdom_file, add_host_name])

Save FFTW wisdom to a file.

load_wisdom(wisdom_file)

Load FFTW wisdom from a file.

get_maxrss()

Get the maximum resident set size used (in kilobytes).

zip_directory_shutil(directory_path, output_path)

Zip a directory using shutil.

find_classes_in_package(package_name)

Find all class names in a given package.

round_to_n(x, n)

Module Contents

quvac.utils.read_yaml(yaml_file)[source]

Read a YAML file and return its contents.

Parameters:

yaml_file (str) – Path to the YAML file.

Returns:

Contents of the YAML file.

Return type:

dict

quvac.utils.write_yaml(yaml_file, data)[source]

Write data to a YAML file.

Parameters:
  • yaml_file (str) – Path to the YAML file.

  • data (dict) – Data to write to the YAML file.

quvac.utils.format_time(seconds)[source]

Format time in seconds to a human-readable string.

Parameters:

seconds (float) – Time in seconds.

Returns:

Formatted time string.

Return type:

str

quvac.utils.format_memory(mem)[source]

Format memory in kilobytes to a human-readable string.

Parameters:

mem (float) – Memory in kilobytes.

Returns:

Formatted memory string.

Return type:

str

quvac.utils.save_wisdom(ini_file, wisdom_file=None, add_host_name=False)[source]

Save FFTW wisdom to a file.

Parameters:
  • ini_file (str) – Path to the initialization file.

  • wisdom_file (str, optional) – Path to save the FFTW wisdom, by default None.

  • add_host_name (bool, optional) – Whether to add the host name to the wisdom file name, by default False.

quvac.utils.load_wisdom(wisdom_file)[source]

Load FFTW wisdom from a file.

Parameters:

wisdom_file (str) – Path to the FFTW wisdom file.

Returns:

FFTW wisdom.

Return type:

tuple

quvac.utils.get_maxrss()[source]

Get the maximum resident set size used (in kilobytes).

Returns:

Maximum resident set size used.

Return type:

int

quvac.utils.zip_directory_shutil(directory_path, output_path)[source]

Zip a directory using shutil.

Parameters:
  • directory_path (str) – Path to the directory to zip.

  • output_path (str) – Path to save the zipped directory.

quvac.utils.find_classes_in_package(package_name)[source]

Find all class names in a given package.

Parameters:

package_name (str) – Name of the package.

Returns:

List of class names in the package.

Return type:

list of str

quvac.utils.round_to_n(x, n)[source]