Utility functions¶
Submodule pyiomica.utilityFunctions
Utility functions
Functions:
|
Read text files exported by MathIOmica and convert to Python data |
|
Parallelize function call with multiprocessing.Pool. |
|
Efficient way to create a reverse dictionary from a dictionary. |
|
Create a path of directories, unless the path already exists. |
- readMathIOmicaData(fileName)[source]¶
Read text files exported by MathIOmica and convert to Python data
- Parameters:
- fileName: str
Path of directories and name of the file containing data
- Returns:
- data
Python data
- Usage:
data = readMathIOmicaData(“../../MathIOmica/MathIOmica/MathIOmicaData/ExampleData/rnaExample”)
- runCPUs(NumberOfAvailableCPUs, func, list_of_tuples_of_func_params)[source]¶
Parallelize function call with multiprocessing.Pool.
- Parameters:
- NumberOfAvailableCPUs: int
Number of processes to create
- func: function
Function to apply, must take at most one argument
- list_of_tuples_of_func_params: list
Function parameters
- Returns:
- 2d numpy.array
Results of func in a numpy array
- Usage:
results = runCPUs(4, pAutocorrelation, [(times[i], data[i], allTimes) for i in range(10)])
- createReverseDictionary(inputDictionary)[source]¶
Efficient way to create a reverse dictionary from a dictionary. Utilizes Pandas.Dataframe.groupby and Numpy arrays indexing.
- Parameters:
- inputDictionary: dictionary
Dictionary to reverse
- Returns:
- dictionary
Reversed dictionary
- Usage:
revDict = createReverseDictionary(Dict)