Skip to content

Commit

Permalink
Simplify the factorization of the labels.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Dec 28, 2024
1 parent 660431e commit 777ff98
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/singler/train_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ def train_single(
keep.append(i)
ref_data = delayedarray.DelayedArray(ref_data)[:,keep]
ref_labels = biocutils.subset_sequence(ref_labels, keep)
ref_labels = biocutils.Factor.from_sequence(ref_labels, sort_levels=True) # TODO: add a dtype= option.
unique_labels = ref_labels.levels
label_idx = ref_labels.codes.astype(dtype=numpy.uint32, copy=False)
unique_labels, label_idx = biocutils.factorize(ref_labels, sort_levels=True, dtype=numpy.uint32, fail_missing=True)

markers = _identify_genes(
ref_data=ref_data,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_train_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_train_single_basic():
assert built.num_labels() == 5
assert built.num_markers() < len(features)
assert built.features == features
assert built.labels.as_list() == ["A", "B", "C", "D", "E"]
assert built.labels == ["A", "B", "C", "D", "E"]

all_markers = built.marker_subset()
assert len(all_markers) == built.num_markers()
Expand Down

0 comments on commit 777ff98

Please sign in to comment.