Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minor lint/docs changes, and prevent Windows systems from crashing #58

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading