Skip to content

Commit

Permalink
change default behavior for json writer
Browse files Browse the repository at this point in the history
  • Loading branch information
daico007 committed Jan 11, 2024
1 parent 89efe3a commit 1071b02
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gmso/formats/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from gmso.formats.formats_registry import loads_as, saves_as


def _to_json(top, types=False, update=True):
def _to_json(top, types=True, update=False):
"""Return a json serializable dictionary from a topology.
This method is used for json serializing the topology
Expand All @@ -30,7 +30,7 @@ def _to_json(top, types=False, update=True):
----------
top: gmso.Topology, required
The topology
types: bool, default=False
types: bool, default=True
If true, include type info (i.e. Potentials)
update: bool, default=False
If true, update the topology before iterating through the files
Expand Down Expand Up @@ -282,7 +282,7 @@ def _from_json(json_dict):


@saves_as(".json")
def write_json(top, filename, **kwargs):
def write_json(top, filename, types=True, update=False, **kwargs):
"""Save the topology as a JSON file.
Parameters
Expand All @@ -291,11 +291,15 @@ def write_json(top, filename, **kwargs):
The topology to save
filename: str, pathlib.Path
The file to save to topology to, must be suffixed with .json
types: bool, default=True
If true, include type info (i.e. Potentials)
update: bool, default=False
If true, update the topology before iterating through the files
**kwargs: dict
The keyword arguments to _to_json and json.dump methods
"""
json_dict = _to_json(
top, update=kwargs.pop("update", True), types=kwargs.pop("types", False)
top, update=update, types=types,
)
if not isinstance(filename, Path):
filename = Path(filename).resolve()
Expand Down

0 comments on commit 1071b02

Please sign in to comment.