Skip to content

Commit

Permalink
fixed bugs in nan tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Jan 11, 2024
1 parent 0872352 commit 01413b0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion peppy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
from .sample import Sample

__classes__ = ["Project", "Sample"]
__all__ = __classes__ + ["PeppyError"]
__all__ = __classes__ + ["PeppyError", "__version__"]

LOGGING_LEVEL = "INFO"
11 changes: 5 additions & 6 deletions peppy/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]:
Expand Down Expand Up @@ -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
Expand All @@ -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):
"""
Expand Down
7 changes: 1 addition & 6 deletions tests/test_Project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
"""
Expand Down

0 comments on commit 01413b0

Please sign in to comment.