Skip to content

Commit

Permalink
fix: add magnitude type column to empty catalog so that de-/serializa…
Browse files Browse the repository at this point in the history
…tion works
  • Loading branch information
schmidni committed Aug 5, 2024
1 parent a010548 commit bf77418
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion seismostats/catalogs/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def from_dict(cls,
df = Catalog(df)

if df.empty:
df = Catalog(columns=REQUIRED_COLS_CATALOG)
df = Catalog(columns=REQUIRED_COLS_CATALOG + ['magnitude_type'])

return df

Expand Down
3 changes: 2 additions & 1 deletion seismostats/catalogs/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def test_empty_catalog():

catalog = Catalog.from_dict({})
assert catalog.empty
assert catalog.columns.tolist() == REQUIRED_COLS_CATALOG
assert catalog.columns.tolist() == REQUIRED_COLS_CATALOG + \
['magnitude_type']

catalog = Catalog.from_dict({'magnitude': []}, include_ids=False)
assert isinstance(catalog, Catalog)

0 comments on commit bf77418

Please sign in to comment.