c3.utils.utils

Miscellaneous, general utilities.

Module Contents

c3.utils.utils.log_setup(data_path: str = None, run_name: str = 'run') str[source]

Make sure the file path to save data exists. Create an appropriately named folder with date and time. Also creates a symlink “recent” to the folder.

Parameters
  • data_path (str) – File path of where to store any data.

  • run_name (str) – User specified name for the run.

Returns

The file path to store new data.

Return type

str

Create a symbolic link.

c3.utils.utils.eng_num(val: float) Tuple[float, str][source]

Convert a number to engineering notation by returning number and prefix.

c3.utils.utils.num3str(val: float, use_prefix: bool = True) str[source]

Convert a number to a human readable string in engineering notation.

c3.utils.utils.ask_yn() bool[source]

Ask for y/n user decision in the command line.

c3.utils.utils.deprecated(message: str)[source]

Decorator for deprecating functions

Parameters

message (str) – Message to display along with DeprecationWarning

Examples

Add a @deprecated("message") decorator to the function:

@deprecated("Using standard width. Better use gaussian_sigma.")
def gaussian(t, params):
    ...
c3.utils.utils.flatten(lis: List, ltypes=(list, tuple)) List[source]

Flatten lists of arbitrary lengths https://rightfootin.blogspot.com/2006/09/more-on-python-flatten.html

Parameters
  • lis (List) – The iterable to flatten

  • ltypes (tuple, optional) – Possibly the datatype of the iterable, by default (list, tuple)

Returns

Flattened list

Return type

List