-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
epilogos/src/computeEpilogosExpectedMaster.py
Lines 87 to 113 in 80bf1f5
| def s1Calc(file1Path, file2Path, rowsToCalc, numStates, verbose): | |
| """ | |
| Function responsible for expected frequency calculation over a set of rows for a saliency metric of 1 | |
| Input: | |
| file1Path -- The path of the only (single epilogos) or first (paired epilogos) file to read states from | |
| file2Path -- The path of the second file to read states from (paired epilogos) | |
| rowsToCalc -- The rows to count expected frequencies from the files | |
| numStates -- The number of states in the state model | |
| verbose -- Boolean which if True, causes much more detailed prints | |
| Output: | |
| A numpy array containing the counts of each state within the specified rows of the file | |
| """ | |
| dataArr = readStates(file1Path=file1Path, file2Path=file2Path, rowsToCalc=rowsToCalc, verbose=verbose) | |
| expFreqArr = np.zeros(numStates, dtype=np.int32) | |
| if verbose and rowsToCalc[0] == 0: print("Calculating expected frequencies...", flush=True); tExp = time() | |
| # Simply count all states across out our subset of data | |
| uniqueStates, stateCounts = np.unique(dataArr, return_counts=True) | |
| for i, state in enumerate(uniqueStates): | |
| expFreqArr[state] += stateCounts[i] | |
| if verbose and rowsToCalc[0] == 0: print(" Time:", time() - tExp, flush=True) | |
| return expFreqArr |
Type hints can be passed into documentation and linter scripts to automate writing docs and checking the types of data being passed around, including Python primitives (str, int, etc.) and numpy data:
https://www.python.org/dev/peps/pep-0484/
https://numpy.org/devdocs/reference/typing.html
This can also be useful to read the function at a glance, to see what goes in and out, and help with debugging.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels