Skip to content

Commit

Permalink
fixed #454
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Aug 15, 2023
1 parent e21c547 commit df76b04
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions peppy/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,9 @@ def __delitem__(self, key):
def __repr__(self):
return str(self)

# def __reduce__(self):
# return (self.__class__,)


def infer_delimiter(filepath):
"""
Expand Down
3 changes: 2 additions & 1 deletion peppy/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ def project(self):
def __reduce__(self):
return (
self.__class__,
(self.as_series(),),
(pd.Series(self.to_dict()),),
# (self.as_series(),),
(None, {}),
iter([]),
iter({PRJ_REF: self[PRJ_REF]}.items()),
Expand Down
11 changes: 11 additions & 0 deletions tests/test_Project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import pytest
from pandas import DataFrame
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 @@ -391,6 +393,15 @@ def test_peppy_initializes_samples_with_correct_attributes(
p = Project(example_pep_cfg_path, sample_table_index="sample")
assert all([expected_attribute in sample for sample in p.samples])

@pytest.mark.parametrize("example_pep_cfg_path", ["basic", "imply"], indirect=True)
def test_correct_pickle(self, example_pep_cfg_path):
proj = Project(example_pep_cfg_path)

pickled_data = pickle.dumps(proj)
unpickled_project = pickle.loads(pickled_data)

assert proj == unpickled_project


class TestProjectManipulationTests:
@pytest.mark.parametrize("example_pep_cfg_path", ["amendments1"], indirect=True)
Expand Down

0 comments on commit df76b04

Please sign in to comment.