From 9281fb63cb0bd95eba816dc9ac75e08df4986868 Mon Sep 17 00:00:00 2001 From: Patrick Smyth Date: Fri, 18 Oct 2024 15:55:59 -0500 Subject: [PATCH] fix import issues --- .../packaged_modules/biodata/__init__.py | 2 ++ tests/packaged_modules/test_biodata.py | 29 +++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/biosets/packaged_modules/biodata/__init__.py b/src/biosets/packaged_modules/biodata/__init__.py index e69de29..a385458 100644 --- a/src/biosets/packaged_modules/biodata/__init__.py +++ b/src/biosets/packaged_modules/biodata/__init__.py @@ -0,0 +1,2 @@ +# ruff: noqa +from .biodata import BioData, BioDataConfig diff --git a/tests/packaged_modules/test_biodata.py b/tests/packaged_modules/test_biodata.py index 5bb8324..5fa7fbb 100644 --- a/tests/packaged_modules/test_biodata.py +++ b/tests/packaged_modules/test_biodata.py @@ -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, @@ -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__) @@ -344,7 +343,7 @@ 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) @@ -352,7 +351,7 @@ def test_get_builder_kwargs_none_files(self): 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 = {} @@ -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"]} @@ -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": ";"} @@ -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]} @@ -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"]} @@ -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") @@ -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: