utils¶
This module provides some functions that may be useful in other modules.
-
check_positive_definite
(m)[source]¶ check if matrix m is postive definite
>>> check_positive_definite([[1.0,0.0],[0.0, 0.1]]) True
>>> check_positive_definite([[1.0,0.0],[1.0,-0.1]]) eigvalues: [-0.1 1. ] False
-
error_print
(x, err=None)[source]¶ It returns a format string “value +/- error”. The precision is modified according to
err
- Parameters
x – Value
err – Error
- Returns
String
-
flatten_dict_data
(data, fun=<built-in method format of str object>)[source]¶ Flatten nested dictionary data into one layer dictionary.
- Returns
Dictionary
-
flatten_np_data
(data)¶
-
load_config_file
(name)[source]¶ Load config file such as Resonances.yml.
- Parameters
name – File name. Either yml file or json file.
- Returns
Dictionary read from the file.
-
std_periodic_var
(p, mid=0.0, pi=3.141592653589793)[source]¶ Transform a periodic variable into its range.
>>> std_periodic_var(math.pi) -3.1415...
>>> std_periodic_var(2*math.pi + 0.01) 0.0...
- Parameters
p – Value
mid – The middle value
pi – Half-range
- Returns
The transformed value