slitflow.info module
- class Info(Data, info_path=None)[source]
Bases:
objectData information class.
- Parameters:
Data (Data) – Parent Data class.
- column
Column information dictionaries. The dictionary should contain
depth,name,type,unitanddescription.
- param
Parameter dictionaries. The dictionary should contain
name,value,unitanddescription.
- path
Absolute path to save this Info object in JSON format with an extension of
.sf, including column, param, and meta dictionaries.- Type:
- index
Index table to describe the data hierarchy.
- Type:
- set_path(info_path)[source]
Set path string to this object.
- Parameters:
info_path (str) – Absolute path to the information file.
- load(info_path=None)[source]
Load information file.
- Parameters:
info_path (str, optional) – Absolute path to the information file. Defaults to None.
- load_index()[source]
Load index table from the index file.
Info object should have the
pathattribute. Seesave_index()docstring for the index file format.
- save_index(load_index=True)[source]
Update index information file.
The file size is reduced by excluding duplicate higher-level hierarchical numbers as follows:
img_no frm_no 1 1 1,1 1 2 -> ,2 1 3 ,3
Caution
This method updates rather than overwrites existing index files. This process is necessary to save the split file, but if there is an unrelated index file with the same name, it must be deleted.
- file_index()[source]
Return index table of current file number.
- Returns:
Index table of current split file
- Return type:
- save(info_path=None)[source]
Save data information as a JSON file.
- Parameters:
info_path (str, optional) – Path to the info file. Defaults to None.
- split(split_depth=None)[source]
Add a _split column to the index table.
Caution
This split depth is used to save newly generated data. Do not use
set_split_depth()for this usage. If you useset_split_depth(), an error will occur when loading data that has already been saved.- Parameters:
split_depth (int, optional) – Split depth for the save data. Defaults to None.
- get_dict()[source]
Return a dictionary of all information for saving.
- Returns:
Dictionary of column, param and meta dictionaries
- Return type:
- add_column(depth, name, type, unit, description)[source]
Add column information of data hierarchy.
Frequently used in
slitflow.data.Data.set_info().
- insert_depth(insert_depth)[source]
Add 1 to the depth after the specified depth.
- Parameters:
insert_depth (int) – First index depth at which you want to shift depth.
- copy_req_columns(req_no=0, names=None)[source]
Import column info from required data info.
Frequently used in
slitflow.data.Data.set_info().
- delete_column(names=None, keeps=None)[source]
Delete column information.
Frequently used in
slitflow.data.Data.set_info().
- change_column_item(name, item, new_value)[source]
Change a column item.
Used when you want to change a item in the column information. e.g. int32 to float32 in “type”.
- get_column_type()[source]
Get column type dict for DataFrame dtype.
- Returns:
Dictionary of column types
- Return type:
- add_param(name, value, unit, description)[source]
Add parameter dictionary to the param property.
Frequently used in
slitflow.data.Data.set_info().
- addel_param(new_params, name, name_temp, unit, description, init_val=None)[source]
Add a parameter dictionary to
paramproperty if name is exist in temporal parameter dictionary else if init_val is not None. Else delete selected parameter fromparamproperty.
- copy_req_params(req_no=0, names=None)[source]
Reuse parameters from the information of required data.
Frequently used in
slitflow.data.Data.set_info().
- delete_param(name)[source]
Delete selected parameter from params.
- Parameters:
name (str) – Parameter name to delete.
- delete_private_param()[source]
Delete parameters containing _ prefix.
The parameter prefixed with “_” is used when the same large parameter is needed for all processes. This method is used in
slitflow.data.Data.post_run()when you have registered withslitflow.data.Data.set_info()but do not want to save it in the info file.
- get_param_value(name)[source]
Return parameter value from the param property.
- Parameters:
name (str) – Parameter name to get the value.
- Returns:
Value of selected parameter
- Return type:
any
- set_split_depth(depth)[source]
Set split depth into parameter dictionary.
Caution
This method is used in
slitflow.data.Data.set_info()to set how to split the result data. If you want split load data, please usesplit().- Parameters:
depth (int) – File split depth number.
- set_group_depth(depth)[source]
Add index_cols into param.
This method adds the “index_cols” parameter to split data using
pandas.DataFrame.groupby().- Parameters:
depth (int) – Data grouping depth number.
- copy_req(req_no=0, type='all', names=None)[source]
Import column and parameter info from required data.
- set_meta()[source]
Set meta data.
Analysis records, including path, timestamp, and required data information, are created in
metaproperty to save them into the info file.
- to_json()[source]
Returns a string representation of info file to export.
Caution
Private parameters will be removed.
- Returns:
a string representation of info file
- Return type: