Skip to content

Commit

Permalink
make sure serde defaults get carried to through python side
Browse files Browse the repository at this point in the history
  • Loading branch information
jinlow committed Dec 12, 2023
1 parent 7b05ba0 commit 7aac829
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions py-forust/forust/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,13 @@ def __setstate__(self, d: dict[Any, Any]) -> None:
# Load the booster object the pickled JSon string.
booster_object = CrateGradientBooster.from_json(d["__booster_json_file__"])
d["booster"] = booster_object
# Are there any new parameters, that need to be added to the python object,
# that would have been loaded in as defaults on the json object?
# This makes sure that defaults set with a serde default function get
# carried through to the python object.
for p, v in booster_object.get_params():
if p not in d:
d[p] = v
del d["__booster_json_file__"]
self.__dict__ = d

Expand Down

0 comments on commit 7aac829

Please sign in to comment.