-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Take advantage of class serialization
Pass cutout parameters to the backend as dataclasses instead of dicts and use this to simplify the code. Add a test to ensure that the parameters will be able to be pickled. Rename access_token to token, following the terminology that we use elsewhere.
- Loading branch information
Showing
8 changed files
with
107 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Tests for cutout parameter models.""" | ||
|
||
from __future__ import annotations | ||
|
||
import pickle | ||
|
||
from vocutouts.models.parameters import CutoutParameters | ||
from vocutouts.models.stencils import ( | ||
CircleStencil, | ||
PolygonStencil, | ||
RangeStencil, | ||
) | ||
|
||
|
||
def test_pickle() -> None: | ||
params = CutoutParameters( | ||
ids=["foo", "bar"], | ||
stencils=[ | ||
CircleStencil.from_string("1 1.42 1"), | ||
PolygonStencil.from_string("1 0 1 1 0 1 0 0"), | ||
RangeStencil.from_string("-Inf 1 0 1"), | ||
], | ||
) | ||
params_pickle = pickle.loads(pickle.dumps(params)) | ||
assert params.ids == params_pickle.ids | ||
expected = [s.to_dict() for s in params.stencils] | ||
seen = [s.to_dict() for s in params_pickle.stencils] | ||
assert expected == seen |