[med-svn] [Git][med-team/augur][upstream] New upstream version 22.0.3
Étienne Mollier (@emollier)
gitlab at salsa.debian.org
Sat Jun 24 15:02:47 BST 2023
Étienne Mollier pushed to branch upstream at Debian Med / augur
Commits:
7510d302 by Étienne Mollier at 2023-06-24T15:56:25+02:00
New upstream version 22.0.3
- - - - -
4 changed files:
- CHANGES.md
- augur/__version__.py
- augur/utils.py
- tests/test_utils.py
Changes:
=====================================
CHANGES.md
=====================================
@@ -3,6 +3,14 @@
## __NEXT__
+## 22.0.3 (14 June 2023)
+
+### Bug fixes
+
+* utils: Serialize pandas Series in `write_json`. [#1213][] (@victorlin)
+
+[#1213]: https://github.com/nextstrain/augur/pull/1213
+
## 22.0.2 (26 May 2023)
### Bug fixes
=====================================
augur/__version__.py
=====================================
@@ -1,4 +1,4 @@
-__version__ = '22.0.2'
+__version__ = '22.0.3'
def is_augur_version_compatible(version):
=====================================
augur/utils.py
=====================================
@@ -127,11 +127,14 @@ def write_json(data, file_name, indent=(None if os.environ.get("AUGUR_MINIFY_JSO
data["generated_by"] = {"program": "augur", "version": get_augur_version()}
with open(file_name, 'w', encoding='utf-8') as handle:
sort_keys = False if isinstance(data, OrderedDict) else True
- json.dump(data, handle, indent=indent, sort_keys=sort_keys, cls=NumpyJSONEncoder)
+ json.dump(data, handle, indent=indent, sort_keys=sort_keys, cls=AugurJSONEncoder)
-class NumpyJSONEncoder(json.JSONEncoder):
- """A custom JSONEncoder subclass to serialize additional numpy data types."""
+class AugurJSONEncoder(json.JSONEncoder):
+ """
+ A custom JSONEncoder subclass to serialize data types used for various data
+ stored in dictionary format.
+ """
def default(self, obj):
if isinstance(obj, np.integer):
return int(obj)
@@ -139,6 +142,8 @@ class NumpyJSONEncoder(json.JSONEncoder):
return float(obj)
if isinstance(obj, np.ndarray):
return obj.tolist()
+ if isinstance(obj, pd.Series):
+ return obj.tolist()
return super().default(obj)
=====================================
tests/test_utils.py
=====================================
@@ -2,6 +2,7 @@ import json
import numpy as np
from pathlib import Path
from unittest.mock import patch
+import pandas as pd
import pytest
@@ -93,12 +94,13 @@ class TestUtils:
assert len(strains) == 3
assert "strain1" in strains
- def test_write_json_numpy_types(self, tmpdir):
- """write_json should be able to serialize numpy data types."""
+ def test_write_json_data_types(self, tmpdir):
+ """write_json should be able to serialize various data types."""
data = {
'int': np.int64(1),
'float': np.float64(2.0),
- 'array': np.array([3,4,5])
+ 'array': np.array([3,4,5]),
+ 'series': pd.Series([6,7,8])
}
file = Path(tmpdir) / Path("data.json")
utils.write_json(data, file, include_version=False)
@@ -106,5 +108,6 @@ class TestUtils:
assert json.load(f) == {
'int': 1,
'float': 2.0,
- 'array': [3,4,5]
+ 'array': [3,4,5],
+ 'series': [6,7,8]
}
View it on GitLab: https://salsa.debian.org/med-team/augur/-/commit/7510d302c514390b6db253106ca7221cf43182ef
--
View it on GitLab: https://salsa.debian.org/med-team/augur/-/commit/7510d302c514390b6db253106ca7221cf43182ef
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20230624/25529e39/attachment-0001.htm>
More information about the debian-med-commit
mailing list