Skip to content

Commit

Permalink
fix #770 date keyword in Python >= 3.7 (#856)
Browse files Browse the repository at this point in the history
* fix #770 date keyword in Python >= 3.7

* Apply suggestions from code review

Co-authored-by: Daniel McDonald <d3mcdonald@eng.ucsd.edu>

Co-authored-by: Daniel McDonald <d3mcdonald@eng.ucsd.edu>
  • Loading branch information
schferbe and wasade authored May 5, 2021
1 parent 166d2dd commit caf2c7d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
8 changes: 8 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
BIOM-Format ChangeLog
=====================

biom 2.1.11-dev
-----------

Bug fixes:

* `Table.from_json` now respects the creation date [issue #770](https://github.com/biocore/biom-format/issues/770) in Python 3.7 and higher

biom 2.1.10
-----------

Expand Down Expand Up @@ -84,6 +91,7 @@ Bug fixes:
* Tables of shape `(0, n)` or `(n, 0)` were raising exceptions when being written out. See [issue #619](https://github.com/biocore/biom-format/issues/619).
* Tables loaded with a `list` of empty `dict`s will have their metadata attributes set to None. See [issue #594](https://github.com/biocore/biom-format/issues/594).


biom 2.1.6
----------

Expand Down
30 changes: 16 additions & 14 deletions biom/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -4562,21 +4562,23 @@ def from_json(self, json_table, data_pump=None,
type_ = json_table['type']

if data_pump is None:
table_obj = Table(json_table['data'], obs_ids, sample_ids,
obs_metadata, sample_metadata,
shape=json_table['shape'],
dtype=dtype,
type=type_,
generated_by=json_table['generated_by'],
input_is_dense=input_is_dense)
data = json_table['data']
else:
table_obj = Table(data_pump, obs_ids, sample_ids,
obs_metadata, sample_metadata,
shape=json_table['shape'],
dtype=dtype,
type=type_,
generated_by=json_table['generated_by'],
input_is_dense=input_is_dense)
data = data_pump
create_date = None
if hasattr(datetime, "fromisoformat"):
try:
create_date = datetime.fromisoformat(json_table['date'])
except (TypeError, ValueError):
pass
table_obj = Table(data, obs_ids, sample_ids,
obs_metadata, sample_metadata,
shape=json_table['shape'],
dtype=dtype,
type=type_,
create_date=create_date,
generated_by=json_table['generated_by'],
input_is_dense=input_is_dense)
return table_obj

def to_json(self, generated_by, direct_io=None):
Expand Down

0 comments on commit caf2c7d

Please sign in to comment.