From 2149e2235ecfac365ff97cd2de1b7bd375cf1aa6 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Wed, 11 Sep 2024 15:54:43 +0100 Subject: [PATCH] chore(nml): make `segment_ids_vs_segment` a `cached_property` https://docs.python.org/3/library/functools.html#functools.cached_property --- neuroml/nml/gds_imports-template.py | 2 +- neuroml/nml/helper_methods.py | 9 ++++++++- neuroml/nml/nml.py | 13 ++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/neuroml/nml/gds_imports-template.py b/neuroml/nml/gds_imports-template.py index 60b7672..797beb0 100644 --- a/neuroml/nml/gds_imports-template.py +++ b/neuroml/nml/gds_imports-template.py @@ -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 diff --git a/neuroml/nml/helper_methods.py b/neuroml/nml/helper_methods.py index 3b0b453..f208e15 100644 --- a/neuroml/nml/helper_methods.py +++ b/neuroml/nml/helper_methods.py @@ -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 """ diff --git a/neuroml/nml/nml.py b/neuroml/nml/nml.py index e5d5932..4fec9c0 100644 --- a/neuroml/nml/nml.py +++ b/neuroml/nml/nml.py @@ -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: @@ -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 @@ -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 """