pyfibre.io.utilities module

pyfibre.io.utilities.check_file_name(file_name, file_type="", extension="")[source]

Checks file_name for file_type or extension. If present, returns amended file_name without extension or file_type

pyfibre.io.utilities.check_string(string, pos, sep, word)[source]

Checks index ‘pos’ of ‘string’ seperated by ‘sep’ for substring ‘word’ If present, removes ‘word’ and returns amended string

pyfibre.io.utilities.deserialize_networkx_graph(data)[source]

Transform JSON serialised data into a networkx Graph object

pyfibre.io.utilities.get_file_names(prefix)[source]

Return set of paths determined from file prefix

pyfibre.io.utilities.load_json(file_name)[source]

Loads JSON file as data

pyfibre.io.utilities.load_numpy(file_name)[source]

Loads numpy binary file as array

pyfibre.io.utilities.numpy_to_python_recursive(dictionary)[source]

Convert all numpy values in nested dictionary to pure python values

pyfibre.io.utilities.parse_file_path(file_path, key=None)[source]

Parse input path in order to extract all files

Parameters
  • file_path (str) – Path to either a file or directory

  • key (str, optional) – Section of file name to filter

Returns

input_files – Parsed file names

Return type

list of str

pyfibre.io.utilities.pop_dunder_recursive(dictionary)[source]

Recursively removes all dunder keys from a nested dictionary.

pyfibre.io.utilities.pop_recursive(dictionary, pop_func)[source]

Recursively remove a named key from dictionary and any contained dictionaries.

pyfibre.io.utilities.pop_under_recursive(dictionary)[source]

Recursively removes all under keys from a nested dictionary.

pyfibre.io.utilities.python_to_numpy_recursive(dictionary)[source]

Convert all numpy values in nested dictionary to pure python values

pyfibre.io.utilities.remove_contraction(dictionary)[source]

Remove any keys from nested dictionary beginning with the word contraction

pyfibre.io.utilities.remove_dunder(dictionary)[source]

Remove any keys from dictionary beginning with an double underscore

pyfibre.io.utilities.remove_under(dictionary)[source]

Remove any keys from dictionary beginning with an underscore

pyfibre.io.utilities.replace_ext(file_name, extension)[source]

If an extension exists on file_name, replace it with new extension. Otherwise add new extension

pyfibre.io.utilities.save_json(data, file_name)[source]

Saves data as JSON file

pyfibre.io.utilities.save_numpy(file_name, array)[source]

Saves array as numpy binary

pyfibre.io.utilities.serialize_networkx_graph(graph)[source]

Transform a networkx Graph object into a JSON serialised dictionary