Skip to content

Commit

Permalink
Add minor lint/docs changes, and prevent Windows systems from crashing (
Browse files Browse the repository at this point in the history
#58)

add docs for p_values function - make cache dir compatible with WIN
  • Loading branch information
afermg authored Feb 29, 2024
1 parent 12bc9ec commit ab8b688
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/copairs/compute.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import itertools
import os
from multiprocessing.pool import ThreadPool
from pathlib import Path
from typing import Callable
Expand Down Expand Up @@ -135,7 +135,7 @@ def null_dist_cached(num_pos, total, seed, null_size, cache_dir):


def get_null_dists(confs, null_size, seed):
cache_dir = Path.home() / f".copairs/seed{seed}/ns{null_size}"
cache_dir = Path.home() / ".copairs" / f"seed{seed}" / f"ns{null_size}"
cache_dir.mkdir(parents=True, exist_ok=True)
num_confs = len(confs)
rng = np.random.default_rng(seed)
Expand All @@ -151,7 +151,27 @@ def par_func(i):
return null_dists


def p_values(ap_scores, null_confs, null_size: int, seed):
def p_values(ap_scores: np.ndarray, null_confs: np.ndarray, null_size: int, seed: int):
"""Calculate p values for an array of ap_scores and null configurations. It uses the path
folder to cache null calculations.
Parameters
----------
ap_scores : np.ndarray
Ap scores for which to calculate p value.
null_confs : np.ndarray
Number of average precisions calculated. It serves as an indicator of
how relevant is the resultant score.
null_size : int
seed : int
Random initializing value.
Examples
--------
FIXME: Add docs.
"""
confs, rev_ix = np.unique(null_confs, axis=0, return_inverse=True)
null_dists = get_null_dists(confs, null_size, seed)
null_dists.sort(axis=1)
Expand Down

0 comments on commit ab8b688

Please sign in to comment.