General Helper Functions¶
This module contains from miscellaneous functions and some global paths.
- class aurora.general_helper_functions.DotDict[source]¶
Bases:
dict
Helper function for debugging, casts a dict so that its values can be accessed via dict.key as well as dict[“key”]
Usage: dot_dict = DotDict(basic_dict)
Methods
clear
()copy
()fromkeys
(iterable[, value])Create a new dictionary with keys from iterable and values set to value.
get
(key[, default])Return the value for key if key is in the dictionary, else default.
items
()keys
()pop
(k[,d])If key is not found, d is returned if given, otherwise KeyError is raised
popitem
(/)Remove and return a (key, value) pair as a 2-tuple.
setdefault
(key[, default])Insert key with a value of default if key is not in the dictionary.
update
([E, ]**F)If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values
()
- aurora.general_helper_functions.count_lines(file_name)[source]¶
acts like wc -l in unix, raise FileNotFoundError: if file_name does not exist.
- Parameters:
file_name (str or pathlib.Path) – The file to apply line counting to
- Returns:
num_lines – Number of lines present in fileName or -1 if file does not exist
- Return type:
- aurora.general_helper_functions.execute_subprocess(cmd, **kwargs)[source]¶
A wrapper for subprocess.call
- Parameters:
cmd (string) – command as it would be typed in a terminal
kwargs (denotes keyword arguments that would be passed to subprocess) –
- aurora.general_helper_functions.get_test_path() Path [source]¶
Gets the path to where the test are.
- Returns:
test_path – Object that points to where aurora’s tests are.
- Return type:
- aurora.general_helper_functions.save_to_mat(data, variable_name, filename)[source]¶
Saves numpy array in matlab format.
Example Usage: x = X.to_array(dim=”channel”) save_to_mat(x.data, “x”, “x.mat”)
Reading into matlab or Octave: tmp = load(“x.mat”); data = tmp.x;
- Parameters:
data (numpy array) – the data to save to file. its fine if this is complex-valued.
variable_name (string) – The name that we use to reference the variable within the struct in the matfile.
filename (string) – The filepath to output