Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for issue#145 #146

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 78 additions & 8 deletions gridappsd-python-lib/gridappsd/json_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,90 @@ def default(self, obj: Any) -> Any:
return rv


def dump(data: Any, fo: TextIO):
rv = _json.dump(data, fo, cls=JsonEncoderExtension)
def dump(data: Any,
fo: TextIO,
*,
skipkeys=False,
ensure_ascii=True,
check_circular=True,
allow_nan=True,
indent=None,
separators=None,
default=None,
sort_keys=False,
**kw):
rv = _json.dump(data,
fo,
skipkeys=skipkeys,
ensure_ascii=ensure_ascii,
check_circular=check_circular,
allow_nan=allow_nan,
cls=JsonEncoderExtension,
indent=indent,
separators=separators,
default=default,
sort_keys=sort_keys,
**kw)


def dumps(data: Any) -> str:
rv = _json.dumps(data, cls=JsonEncoderExtension)
def dumps(data: Any,
*,
skipkeys=False,
ensure_ascii=True,
check_circular=True,
allow_nan=True,
indent=None,
separators=None,
default=None,
sort_keys=False,
**kw) -> str:
rv = _json.dumps(data,
skipkeys=skipkeys,
ensure_ascii=ensure_ascii,
check_circular=check_circular,
allow_nan=allow_nan,
cls=JsonEncoderExtension,
indent=indent,
separators=separators,
default=default,
sort_keys=sort_keys,
**kw)
return rv


def load(fo: TextIO) -> Any:
rv = _json.load(fo, object_hook=jsonDecoderExtension)
def load(fo: TextIO,
*,
cls=None,
parse_float=None,
parse_int=None,
parse_constant=None,
object_pairs_hook=None,
**kw) -> Any:
rv = _json.load(fo,
cls=cls,
object_hook=jsonDecoderExtension,
parse_float=parse_float,
parse_int=parse_int,
parse_constant=parse_constant,
object_pairs_hook=object_pairs_hook,
**kw)
return rv


def loads(data: str) -> Any:
rv = _json.loads(data, object_hook=jsonDecoderExtension)
def loads(data: str,
*,
cls=None,
parse_float=None,
parse_int=None,
parse_constant=None,
object_pairs_hook=None,
**kw) -> Any:
rv = _json.loads(data,
cls=cls,
object_hook=jsonDecoderExtension,
parse_float=parse_float,
parse_int=parse_int,
parse_constant=parse_constant,
object_pairs_hook=object_pairs_hook,
**kw)
return rv
8 changes: 6 additions & 2 deletions gridappsd-python-lib/gridappsd/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ class Simulation:

def __init__(self, gapps: 'GridAPPSD', run_config: Union[Dict, SimulationConfig]):
assert type(gapps).__name__ == 'GridAPPSD', "Must be an instance of GridAPPSD"

self._run_config = run_config
if isinstance(run_config, SimulationConfig):
self._run_config = run_config.asdict()
elif isinstance(run_config, dict):
self._run_config = run_config
else:
raise TypeError("run_config must be a dictionary or a SimulationConfig")
# if isinstance(run_config, SimulationConfig):
# self._run_config = run_config
# else:
Expand Down
Loading