bamboost.core.utilities
Utility functions used by bamboost.
Attributes
- __all__=
['flatten_dict', 'unflatten_dict', 'tree', 'h5_tree', 'show_differences', 'to_camel_case']
- space=
' '
- branch=
'│ '
- tee=
'├── '
- last=
'└── '
- JobArguments=
NamedTuple('JobArguments', [('db_path', Path), ('name', str), ('submit', bool), ('note', str)])
- ScriptArguments=
NamedTuple('ScriptArguments', [('simulation', str)])
Functions
(dictionary, parent_key='', seperator='.') -> dict
Arguments:
- dictionary:
typing.Mapping
- parent_key=
''
- seperator=
'.'
(dictionary, seperator='.') -> dict
Arguments:
- dictionary:
dict
- seperator:
str
='.'
(dir_path, level=-1, limit_to_directories=False, length_limit=1000) -> str
Given a directory Path object print a visual tree structure
Arguments:
- dir_path:
pathlib.Path
- level:
int
=-1
- limit_to_directories:
bool
=False
- length_limit:
int
=1000
(val, pre='')
Arguments:
- val
- pre=
''
(df) -> DataFrame
This function takes a pandas DataFrame as input and returns a modified DataFrame that shows only the columns which have differences.
The function first creates a copy of the input DataFrame to work with. It then iterates over each column in the DataFrame and tries to calculate the number of unique values in that column. If successful, it adds the column name and number of unique values to a list of good results. If there is an error, it attempts to apply json.dumps to the column and then calculate the number of unique values again. If this is successful, it also adds the column name and number of unique values to the list of good results. If there is still an error, it adds the column name and the error to a list of errors.
After processing all columns, the function removes any columns that had errors from the DataFrame. It then sets the index of the DataFrame to 'id' and filters out any columns that have only one unique value. The modified DataFrame is then returned.
Arguments:
- df:
pd.pd.DataFrame
The input DataFrame to analyze
Returns
pandas.DataFrame
pd.DataFrame(s) -> str
Arguments:
- s:
str
() -> JobArguments
Parse command-line arguments for submitting a job to a bamboost database.
Returns
JobArguments
A named tuple containing the parsed arguments.() -> ScriptArguments
Parse command-line arguments for a script using the bamboost system.
Returns
ScriptArguments
A named tuple containing the parsed arguments.Classes
FilePicker
(self, path)
Arguments:
- path:
pathlib.Path
Attributes:
- path=
bamboost.core.utilities.FilePicker(path)
- _dict=
self._build_file_dict(path)
(self, *_args)
Arguments:
- _args=
()
(self, key) -> Path
Arguments:
- key
(self, path) -> dict
Arguments:
- path:
pathlib.Path