Skip to content

Commit

Permalink
Fix seralising ndarrays
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons committed Oct 30, 2024
1 parent 93a0034 commit f344ce9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/data_common/dataset/resource_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from urllib.parse import urlencode

import geopandas as gpd
import numpy as np
import pandas as pd
import pytest
import rich
Expand Down Expand Up @@ -1338,8 +1339,12 @@ def convert_to_array_from_comma(value: t) -> list[t]:
else:
raise ValueError(f"Unrecognised modify type {modify_type}")

def custom_converter(o):
if isinstance(o, np.ndarray):
return list(o)

with open(self.build_path() / f"{self.slug}.json", "w") as f:
json.dump(datapackage, f, indent=4)
json.dump(datapackage, f, indent=4, default=custom_converter)

def build_composites(self):
"""
Expand Down

0 comments on commit f344ce9

Please sign in to comment.