From 01413b03f3530664420d6fae8e144d3fd40a864c Mon Sep 17 00:00:00 2001 From: Khoroshevskyi Date: Thu, 11 Jan 2024 13:10:57 -0500 Subject: [PATCH] fixed bugs in nan tests --- peppy/__init__.py | 2 +- peppy/project.py | 11 +++++------ tests/test_Project.py | 7 +------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/peppy/__init__.py b/peppy/__init__.py index bce94377..1b958c15 100644 --- a/peppy/__init__.py +++ b/peppy/__init__.py @@ -14,6 +14,6 @@ from .sample import Sample __classes__ = ["Project", "Sample"] -__all__ = __classes__ + ["PeppyError"] +__all__ = __classes__ + ["PeppyError", "__version__"] LOGGING_LEVEL = "INFO" diff --git a/peppy/project.py b/peppy/project.py index 9fb177aa..7e0abcfe 100644 --- a/peppy/project.py +++ b/peppy/project.py @@ -6,7 +6,7 @@ from collections.abc import Mapping, MutableMapping from contextlib import suppress from logging import getLogger -from typing import Iterable, List, Tuple, Union, Literal, NoReturn +from typing import Iterable, List, Tuple, Union, Literal import numpy as np import pandas as pd @@ -223,15 +223,13 @@ def _from_dict(self, pep_dictionary) -> "Project": _samples: list | dict, _subsamples: list[list | dict]} """ - self[SAMPLE_DF_KEY] = pd.DataFrame(pep_dictionary[SAMPLE_RAW_DICT_KEY]).replace( - np.nan, "None" - ) + self[SAMPLE_DF_KEY] = pd.DataFrame(pep_dictionary[SAMPLE_RAW_DICT_KEY]).replace(np.nan, None) self[CONFIG_KEY] = pep_dictionary[CONFIG_KEY] if SUBSAMPLE_RAW_LIST_KEY in pep_dictionary: if pep_dictionary[SUBSAMPLE_RAW_LIST_KEY]: self[SUBSAMPLE_DF_KEY] = [ - pd.DataFrame(sub_a).replace(np.nan, "None") + pd.DataFrame(sub_a).replace(np.nan, None) for sub_a in pep_dictionary[SUBSAMPLE_RAW_LIST_KEY] ] if NAME_KEY in self[CONFIG_KEY]: @@ -469,7 +467,7 @@ def parse_config_file( relative_vars = [CFG_SAMPLE_TABLE_KEY, CFG_SUBSAMPLE_TABLE_KEY] _make_sections_absolute(self[CONFIG_KEY], relative_vars, cfg_path) - def _set_indexes(self, config: Mapping) -> NoReturn: + def _set_indexes(self, config: Mapping) -> None: """ Set sample and subsample indexes if they are different then Default @@ -485,6 +483,7 @@ def _set_indexes(self, config: Mapping) -> NoReturn: if SUBSAMPLE_TABLE_INDEX_KEY in config else SUBSAMPLE_NAME_ATTR ) + return None def load_samples(self): """ diff --git a/tests/test_Project.py b/tests/test_Project.py index b2241f2f..c77439ec 100644 --- a/tests/test_Project.py +++ b/tests/test_Project.py @@ -10,7 +10,6 @@ from yaml import dump, safe_load import pickle -import peppy from peppy import Project from peppy.const import SAMPLE_NAME_ATTR, SAMPLE_TABLE_FILE_KEY from peppy.exceptions import ( @@ -350,10 +349,6 @@ def test_from_dict_instatiation(self, example_pep_cfg_path): representation. """ p1 = Project(cfg=example_pep_cfg_path) - ff = p1.to_dict(extended=True) - import pprint - - pprint.pprint(ff) p2 = Project.from_dict(p1.to_dict(extended=True)) assert p1 == p2 @@ -694,7 +689,7 @@ def test_sample_getattr(self, example_pep_cfg_path): assert s2.organism == s2["organism"] @pytest.mark.parametrize("example_pep_cfg_path", ["append"], indirect=True) - def test_sample_getattr(self, example_pep_cfg_path): + def test_sample_settatr(self, example_pep_cfg_path): """ Verify that the setattr works """