Skip to content

Commit

Permalink
Pass along names= to constructor in Factor.from_sequence.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Jan 19, 2024
1 parent 5ae14e6 commit da758a5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/biocutils/Factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ def from_sequence(
levels: Optional[Sequence[str]] = None,
sort_levels: bool = True,
ordered: bool = False,
names: Optional[Sequence[str]] = None,
) -> "Factor":
"""Convert a sequence of hashable values into a factor.
Expand All @@ -686,11 +687,15 @@ def from_sequence(
this refers to their importance and has nothing to do with
their sorting order or with the setting of ``sort_levels``.
names:
List of names. This should have same length as ``x``.
Alternatively None, if the factor has no names.
Returns:
A ``Factor`` object.
"""
levels, indices = factorize(x, levels=levels, sort_levels=sort_levels)
return Factor(indices, levels=levels, ordered=ordered)
return Factor(indices, levels=levels, ordered=ordered, names=names)


@subset_sequence.register
Expand Down

0 comments on commit da758a5

Please sign in to comment.