Skip to content

Commit

Permalink
fix import issues
Browse files Browse the repository at this point in the history
  • Loading branch information
psmyth94 committed Oct 18, 2024
1 parent eaad9fe commit 9281fb6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/biosets/packaged_modules/biodata/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ruff: noqa
from .biodata import BioData, BioDataConfig
29 changes: 14 additions & 15 deletions tests/packaged_modules/test_biodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
import pandas as pd
import pyarrow as pa
import pytest
from biosets.features import Abundance
from biosets.load import load_dataset
from biosets.packaged_modules.biodata.biodata import BioData, BioDataConfig
from biosets.packaged_modules.csv.csv import Csv
from biosets.packaged_modules.npz.npz import SparseReader
from biosets.utils import logging
from datasets.data_files import (
DataFilesDict,
DataFilesList,
Expand All @@ -15,13 +21,6 @@
from datasets.features import Features, Value
from datasets.packaged_modules.json.json import Json

from biosets.features import Abundance
from biosets.load import load_dataset
from biosets.packaged_modules.biodata.biodata import BioData, BioDataConfig
from biosets.packaged_modules.csv.csv import Csv
from biosets.packaged_modules.npz.npz import SparseReader
from biosets.utils import logging

logger = logging.get_logger(__name__)


Expand Down Expand Up @@ -344,15 +343,15 @@ def test_post_init_feature_metadata_as_list(self):

def test_get_builder_kwargs_none_files(self):
with unittest.mock.patch(
"biosets.packaged_modules.biodata.biodata.BioDataConfig.__post_init__"
"biosets.packaged_modules.biodata.BioDataConfig.__post_init__"
):
config = BioDataConfig(name="test_config")
builder_kwargs = config._get_builder_kwargs(None)
self.assertEqual(builder_kwargs, {})

def test_get_builder_kwargs_empty_files(self):
with unittest.mock.patch(
"biosets.packaged_modules.biodata.biodata.BioDataConfig.__post_init__"
"biosets.packaged_modules.biodata.BioDataConfig.__post_init__"
):
config = BioDataConfig(name="test_config")
files = {}
Expand All @@ -361,7 +360,7 @@ def test_get_builder_kwargs_empty_files(self):

def test_get_builder_kwargs_mixed_extensions(self):
with unittest.mock.patch(
"biosets.packaged_modules.biodata.biodata.BioDataConfig.__post_init__"
"biosets.packaged_modules.biodata.BioDataConfig.__post_init__"
):
config = BioDataConfig(name="test_config")
files = {"train": [self.csv_file, "data/train.unsupported"]}
Expand All @@ -372,7 +371,7 @@ def test_get_builder_kwargs_mixed_extensions(self):

def test_get_builder_kwargs_conflicting_builder_kwargs(self):
with unittest.mock.patch(
"biosets.packaged_modules.biodata.biodata.BioDataConfig.__post_init__"
"biosets.packaged_modules.biodata.BioDataConfig.__post_init__"
):
config = BioDataConfig(name="test_config")
config.builder_kwargs = {"separator": ",", "sep": ";"}
Expand All @@ -383,7 +382,7 @@ def test_get_builder_kwargs_conflicting_builder_kwargs(self):

def test_get_builder_kwargs_valid(self):
with unittest.mock.patch(
"biosets.packaged_modules.biodata.biodata.BioDataConfig.__post_init__"
"biosets.packaged_modules.biodata.BioDataConfig.__post_init__"
):
config = BioDataConfig(name="test_config")
files = {"train": [self.csv_file]}
Expand All @@ -393,7 +392,7 @@ def test_get_builder_kwargs_valid(self):

def test_get_builder_kwargs_invalid_extension(self):
with unittest.mock.patch(
"biosets.packaged_modules.biodata.biodata.BioDataConfig.__post_init__"
"biosets.packaged_modules.biodata.BioDataConfig.__post_init__"
):
config = BioDataConfig(name="test_config")
files = {"train": ["data/train.unsupported"]}
Expand Down Expand Up @@ -447,7 +446,7 @@ def inject_fixtures(

def setUp(self):
with unittest.mock.patch(
"biosets.packaged_modules.biodata.biodata.BioDataConfig.__post_init__"
"biosets.packaged_modules.biodata.BioDataConfig.__post_init__"
):
self.data = BioData()
self.data.config = BioDataConfig(name="test_config")
Expand Down Expand Up @@ -1037,7 +1036,7 @@ def test_biodata_load_dataset_with_sparse_reader(self):
pd_data = data.to_pandas()
assert pd_data["sample"].tolist() == ["sample1", "sample2"]
assert pd_data["target"].tolist() == ["a", "b"]
assert pd_data["labels"].tolist() == [1, 0]
assert set(pd_data["labels"].tolist()) == set([0, 1])

def test_biodata_load_dataset_with_multiple_files_and_without_labels(self):
with self.assertRaises(DatasetGenerationError) as context:
Expand Down

0 comments on commit 9281fb6

Please sign in to comment.