Skip to content

Commit

Permalink
Merge pull request #9 from jung235/hotfix/fix-ens-load
Browse files Browse the repository at this point in the history
fix: fix ensemble load error
  • Loading branch information
jung235 authored Mar 6, 2024
2 parents cd76733 + ce90c83 commit db21564
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ coverage:
range: 80..100
round: down
precision: 2
status:
project: off
patch: off
2 changes: 1 addition & 1 deletion pydiffuser/tracer/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def get_velocity_autocorrelation(
def __reduce__(self) -> Tuple[Any, ...]:
info = super().__reduce__()
args = self.dt
new_info = (self.__class__, args, *info[2:])
new_info = (self.__class__, (args,), *info[2:])
return new_info

def to_npy(self, npy_path: PathType) -> None:
Expand Down
9 changes: 8 additions & 1 deletion pydiffuser/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,16 @@ def to_json(self, json_path: PathType) -> None:
json.dump(info, f, indent=4)

def to_dataclass(self) -> object:
info = copy.deepcopy(vars(self))
info = self.to_dict()
obj = make_dataclass(self.__class__.__name__, info.keys())
return obj(**info)

def to_dict(self) -> Dict[str, Any]:
info = copy.deepcopy(vars(self))
return info

def __repr__(self) -> str:
return f"{self.__class__.__name__}(name={self.name})"

def __contains__(self, param: str) -> bool:
return param in self.to_dict()

0 comments on commit db21564

Please sign in to comment.