Skip to content

Commit

Permalink
Merge pull request #146 from afisher1/bugfix/145
Browse files Browse the repository at this point in the history
fix for issue#145
  • Loading branch information
craig8 authored May 2, 2024
2 parents c245124 + 70a5911 commit f7868be
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 10 deletions.
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 @@ -123,8 +123,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

0 comments on commit f7868be

Please sign in to comment.