Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 17, 2024
1 parent aff8dbc commit b866870
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions gufe/compression.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import zstandard as zstd
from zstandard import ZstdError


def zst_compress(data: bytes):
compressor = zstd.ZstdCompressor()
return compressor.compress(data)


def zst_decompress(data: bytes):
try:
decompressor = zstd.ZstdDecompressor()
Expand Down
3 changes: 1 addition & 2 deletions gufe/custom_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
from openff.units import DEFAULT_UNIT_REGISTRY

import gufe
from gufe.compression import zst_compress, zst_decompress
from gufe.custom_json import JSONCodec
from gufe.settings.models import SettingsBaseModel

from gufe.compression import zst_compress, zst_decompress


def default_from_dict(dct):
dct = dict(dct) # make a copy
Expand Down
12 changes: 6 additions & 6 deletions gufe/tests/test_custom_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
SETTINGS_CODEC,
UUID_CODEC,
)
from gufe.custom_json import JSONSerializerDeserializer, custom_json_factory, JSONCodec
from gufe.custom_json import JSONCodec, JSONSerializerDeserializer, custom_json_factory
from gufe.settings import models


Expand Down Expand Up @@ -106,13 +106,13 @@ def test_legacy_bytes_uncompressed(self):
legacy_bytes_codec = JSONCodec(
cls=bytes,
to_dict=lambda obj: {"latin-1": obj.decode("latin-1")},
from_dict=lambda dct: dct["latin-1"].encode("latin-1")
)
from_dict=lambda dct: dct["latin-1"].encode("latin-1"),
)

required_codecs = [codec for codec in self.required_codecs if not codec is BYTES_CODEC]

legacy_encoder, _ = custom_json_factory([legacy_bytes_codec, *required_codecs])
_, decoder= custom_json_factory([BYTES_CODEC, *required_codecs])
_, decoder = custom_json_factory([BYTES_CODEC, *required_codecs])

self._test_round_trip(legacy_encoder, decoder)

Expand Down Expand Up @@ -201,13 +201,13 @@ class TestBytesCodec(CustomJSONCodingTest):
def setup_method(self):
self.codec = BYTES_CODEC
self.required_codecs = [self.codec]
self.objs =[b'a test string']
self.objs = [b"a test string"]
self.dcts = [
{
":is_custom:": True,
"__class__": "bytes",
"__module__": "builtins",
"latin-1": '(µ/ý \ri\x00\x00a test string'
"latin-1": "(µ/ý \ri\x00\x00a test string",
}
]

Expand Down

0 comments on commit b866870

Please sign in to comment.