Skip to content

Commit

Permalink
fix dataset by fixing getstate
Browse files Browse the repository at this point in the history
  • Loading branch information
misko committed Dec 29, 2023
1 parent 0cf4778 commit ce9e4aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 8 additions & 0 deletions spf/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class dotdict(dict):
__getattr__ = dict.get

def __getstate__(self):
return vars(self)

def __setstate__(self, state):
vars(self).update(state)
12 changes: 3 additions & 9 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@

from spf.dataset.spf_generate import generate_session_and_dump


class dotdict(dict):
"""dot.notation access to dictionary attributes"""

__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
from spf.utils import dotdict


@pytest.fixture
Expand Down Expand Up @@ -52,7 +46,7 @@ def test_data_generation(default_args):
args = default_args
args.output = tmp
dump(
{k: v for k, v in args.items()},
args,
"/".join([args.output, "args.pkl"]),
compression="lzma",
)
Expand All @@ -68,7 +62,7 @@ def test_live_data_generation(default_args):
args = default_args
args.output = tmp
dump(
{k: v for k, v in args.items()},
args,
"/".join([args.output, "args.pkl"]),
compression="lzma",
)
Expand Down

0 comments on commit ce9e4aa

Please sign in to comment.