Utils¶
colfi.utils¶
- class colfi.utils.FilePath(filedir='ann', randn_num='', suffix='.pt', separator='_', raise_err=True)[source]¶
Bases:
object
- class colfi.utils.Logger(path='logs', fileName='log', stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]¶
Bases:
objectRecord the output of the terminal and write it to disk.
- class colfi.utils.LrDecay(iter_mid, iteration=10000, lr=0.1, lr_min=1e-06)[source]¶
Bases:
objectLet the learning rate decay with iteration.
- colfi.utils.mkdir(path)[source]¶
Make a directory in a particular location if it is not exists.
- Parameters:
path (str) – The path of a file.
Examples
>>> mkdir('/home/UserName/test') >>> mkdir('test/one') >>> mkdir('../test/one')
- colfi.utils.remove_nan(obs, params)[source]¶
Remove the ‘nan’ in the numpy array, used for the simulated observations.
- Parameters:
obs (array-like) – The simulated observations, Numpy array with one or multi dimension.
params (array-like) – The simulated parameters, Numpy array with one or multi dimension.
- Returns:
obs_new (array-like) – The new observations that do not contain nan.
params_new (array-like) – The new parameters that do not contain nan.
- colfi.utils.saveTorchPt(path, FileName, File)[source]¶
Save the .pt files using
torch.save()funtion.
- colfi.utils.save_predict(path='ann', nde_type='ANN', randn_num=1.123, file_identity_str='', chain_true_path='', label_true='True', fiducial_params=[])[source]¶