Skip to content

Commit

Permalink
chore(nml): make segment_ids_vs_segment a cached_property
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayankur31 committed Sep 11, 2024
1 parent 1a27696 commit 2149e22
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion neuroml/nml/gds_imports-template.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import inspect
import math
import typing
from functools import lru_cache
from functools import cached_property, lru_cache
from math import pi, sqrt
from operator import attrgetter

Expand Down
9 changes: 8 additions & 1 deletion neuroml/nml/helper_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,10 +1031,17 @@ def get_segment_volume(self, segment_id: str) -> float:
return temp_seg.volume
@lru_cache(maxsize=1000)
def get_segment_ids_vs_segments(self) -> typing.Dict[str, Segment]:
"""Get a dictionary of segment IDs and the segments in the cell.
:return: dictionary with segment ID as key, and segment as value
"""
return self.segment_ids_vs_segments
@cached_property
def segment_ids_vs_segments(self) -> typing.Dict[str, Segment]:
"""Get a dictionary of segment IDs and the segments in the cell.
:return: dictionary with segment ID as key, and segment as value
"""
Expand Down
13 changes: 10 additions & 3 deletions neuroml/nml/nml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

#
# Generated Wed Sep 11 15:35:00 2024 by generateDS.py version 2.44.1.
# Generated Wed Sep 11 15:53:47 2024 by generateDS.py version 2.44.1.
# Python 3.11.9 (main, Aug 23 2024, 00:00:00) [GCC 14.2.1 20240801 (Red Hat 14.2.1-1)]
#
# Command line options:
Expand Down Expand Up @@ -36,7 +36,7 @@
import os
import re as re_
import typing
from functools import lru_cache
from functools import cached_property, lru_cache
from math import pi, sqrt
from operator import attrgetter

Expand Down Expand Up @@ -48560,10 +48560,17 @@ def get_segment_volume(self, segment_id: str) -> float:

return temp_seg.volume

@lru_cache(maxsize=1000)
def get_segment_ids_vs_segments(self) -> typing.Dict[str, Segment]:
"""Get a dictionary of segment IDs and the segments in the cell.

:return: dictionary with segment ID as key, and segment as value
"""
return self.segment_ids_vs_segments

@cached_property
def segment_ids_vs_segments(self) -> typing.Dict[str, Segment]:
"""Get a dictionary of segment IDs and the segments in the cell.

:return: dictionary with segment ID as key, and segment as value
"""

Expand Down

0 comments on commit 2149e22

Please sign in to comment.