Skip to content

Commit

Permalink
feat(lemssimulation): store lems file name for easy access
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayankur31 committed Sep 13, 2024
1 parent 088a727 commit 85377ed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pyneuroml/lems/LEMSSimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LEMSSimulation:

TEMPLATE_FILE = "%s/LEMS_TEMPLATE.xml" % (os.path.dirname(__file__))

lems_info = {} # type: dict[str, typing.Any]
lems_info: typing.Dict[str, typing.Any] = {}
my_random = random.Random()

def __init__(
Expand Down Expand Up @@ -128,6 +128,8 @@ def __init__(
else:
self.my_random.seed(12345)

self.lems_file_name = f"LEMS_{self.lems_info['sim_id']}.xml"

def __setattr__(self, attr: typing.Any, value: typing.Any) -> None:
"""Set an attribute value.
Expand Down Expand Up @@ -411,14 +413,18 @@ def save_to_file(self, file_name: typing.Optional[str] = None):
:param file_name: name of file to store to.
`LEMS_<some id string>.xml` is the suggested format. Leave empty
to use `LEMS_<sim_id>.xml`
to use `LEMS_<sim_id>.xml`. If provided, this also sets the
`lems_file_name` attribute of the class so that it can be accessed
later.
:type file_name: str
:returns: name of file
:rtype: str
"""

if file_name is None:
file_name = "LEMS_%s.xml" % self.lems_info["sim_id"]
file_name = self.lems_file_name
else:
self.lems_file_name = file_name

logger.info(
"Writing LEMS Simulation %s to file: %s..."
Expand Down

0 comments on commit 85377ed

Please sign in to comment.