Skip to content

compute.compute_ap_contiguos returns NaNs silently #45

@afermg

Description

@afermg

When using map.run_pipeline(), if some samples are only present once in the dataset compute.ap_contiguos returns zeros. This is due to compute.to_cutoffs being applied to an array of length 1, so the line in

cutoffs[0], cutoffs[1:] = 0, counts.cumsum()[:-1]
always returns [0].

These 0s are propagated to num_pos

num_pos = np.add.reduceat(rel_k_list, cutoffs)
and thus things are divided by zero, as this vector is used as a divisor
ap_scores = np.add.reduceat(pr_k * rel_k_list, cutoffs) / num_pos
.

It was a bit puzzling to figure out why my test with a small number of plates was plagued with nans, so it is probably worth adding a warning when 1 (or maybe a fraction, i.e., 1/4) of all elements appear only once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions