Skip to content

Commit

Permalink
add pickable
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Jul 23, 2020
1 parent b0860b0 commit cd5b3ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions tests/base/test_datasets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pickle

import cloudpickle
import pytest

from tests.base.datasets import MNIST, TrialMNIST, AverageDataset


@pytest.mark.parametrize('dataset_cls', [MNIST, TrialMNIST, AverageDataset])
def test_pickling_dataset_mnist(tmpdir, dataset_cls):
mnist = dataset_cls()

mnist_pickled = pickle.dumps(mnist)
mnist_loaded = pickle.loads(mnist_pickled)
# assert vars(mnist) == vars(mnist_loaded)

mnist_pickled = cloudpickle.dumps(mnist)
mnist_loaded = cloudpickle.loads(mnist_pickled)
# assert vars(mnist) == vars(mnist_loaded)
2 changes: 1 addition & 1 deletion tests/callbacks/test_callbacks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pickle
from pathlib import Path

import pytest
Expand Down Expand Up @@ -291,7 +292,6 @@ def training_step(self, *args, **kwargs):


def test_pickling(tmpdir):
import pickle
early_stopping = EarlyStopping()
ckpt = ModelCheckpoint(tmpdir)

Expand Down

0 comments on commit cd5b3ef

Please sign in to comment.