Skip to content

Commit

Permalink
feat(barplot): add bioset type check in plot_dataset
Browse files Browse the repository at this point in the history
Added a check to determine if the input is a Bioset in the
`plot_dataset` method of `BarPlotter` class. This ensures that the
input is decoded correctly before plotting. Updated the import
statement to include `is_bioset` from `biocore.utils.py_util`.
  • Loading branch information
psmyth94 committed Nov 18, 2024
1 parent 76f40a1 commit b018a86
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/biofit/visualization/barplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import List, Optional, Type

from biocore import DataHandler
from biocore.utils.py_util import is_bioset

import biofit.config as config
from biofit.integration.biosets import get_feature
Expand Down Expand Up @@ -181,12 +182,13 @@ def plot(
)

def plot_dataset(self, x, y, group):
from datasets import Dataset as HfDataset
if is_bioset(x):
from biosets import decode

if isinstance(x, (Dataset, HfDataset)):
x = decode(x)
if isinstance(group, (Dataset, HfDataset)):
if is_bioset(group):
group = decode(group)

return self.plot_arrow(
DataHandler.to_arrow(x),
DataHandler.to_arrow(y) if y is not None else None,
Expand Down

0 comments on commit b018a86

Please sign in to comment.