Skip to content

Commit

Permalink
Update json encoder to handle pathlib objects
Browse files Browse the repository at this point in the history
  • Loading branch information
aspeake committed Jan 4, 2024
1 parent 362bc10 commit 4b7b032
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scout/ecm_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import math
import pandas as pd
from datetime import datetime
from pathlib import PurePath
import argparse
from scout.ecm_prep_args import ecm_args
from scout.constants import FilePaths as fp
Expand All @@ -32,6 +33,8 @@ def default(self, obj):
# Case where object to be serialized is numpy array
if isinstance(obj, numpy.ndarray):
return obj.tolist()
if isinstance(obj, PurePath):
return str(obj)
# All other cases
else:
return super(MyEncoder, self).default(obj)
Expand Down

0 comments on commit 4b7b032

Please sign in to comment.