-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename
consensus.subset_clust
to consensus.downsample_by_label
to…
… clarify the function's purpose.
- Loading branch information
Showing
1 changed file
with
13 additions
and
13 deletions.
There are no files selected for viewing
26 changes: 13 additions & 13 deletions
26
tests/src/consensus/test_clust_subsetter.py → tests/src/consensus/test_clust_formatter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
from DAJIN2.core.consensus.clust_formatter import subset_clust | ||
from DAJIN2.core.consensus.clust_formatter import downsample_by_label | ||
|
||
|
||
def test_basic_subset_clust(): | ||
def test_basic_downsample_by_label(): | ||
sample = [{"LABEL": 1, "DATA": i} for i in range(1500)] | ||
subset = subset_clust(sample) | ||
subset = downsample_by_label(sample) | ||
assert len(subset) == 1000 # Default num value is 1000 | ||
assert all(item["LABEL"] == 1 for item in subset) | ||
|
||
|
||
def test_subset_clust_with_custom_num(): | ||
def test_downsample_by_label_with_custom_num(): | ||
sample = [{"LABEL": 1, "DATA": i} for i in range(1500)] | ||
subset = subset_clust(sample, num=500) | ||
subset = downsample_by_label(sample, num=500) | ||
assert len(subset) == 500 | ||
|
||
|
||
def test_subset_clust_with_multiple_labels(): | ||
def test_downsample_by_label_with_multiple_labels(): | ||
sample = [{"LABEL": 1, "DATA": i} for i in range(500)] + [{"LABEL": 2, "DATA": i} for i in range(500)] | ||
subset = subset_clust(sample) | ||
subset = downsample_by_label(sample) | ||
assert len(subset) == 1000 | ||
assert len([item for item in subset if item["LABEL"] == 1]) == 500 | ||
assert len([item for item in subset if item["LABEL"] == 2]) == 500 | ||
|
||
|
||
def test_subset_clust_with_less_than_num(): | ||
def test_downsample_by_label_with_less_than_num(): | ||
sample = [{"LABEL": 1, "DATA": i} for i in range(400)] | ||
subset = subset_clust(sample, num=500) | ||
subset = downsample_by_label(sample, num=500) | ||
assert len(subset) == 400 | ||
|
||
|
||
def test_subset_clust_with_multiple_labels_with_less_than_nu(): | ||
def test_downsample_by_label_with_multiple_labels_with_less_than_nu(): | ||
sample = [{"LABEL": 1, "DATA": i} for i in range(500)] + [{"LABEL": 2, "DATA": i} for i in range(500)] | ||
subset = subset_clust(sample, num=200) | ||
subset = downsample_by_label(sample, num=200) | ||
assert len(subset) == 400 | ||
assert len([item for item in subset if item["LABEL"] == 1]) == 200 | ||
assert len([item for item in subset if item["LABEL"] == 2]) == 200 | ||
|
||
|
||
def test_subset_clust_with_empty_sample(): | ||
def test_downsample_by_label_with_empty_sample(): | ||
sample = [] | ||
subset = subset_clust(sample) | ||
subset = downsample_by_label(sample) | ||
assert len(subset) == 0 |