From da396c486c375d24f205f38bdae991f18f3e3906 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 12 Sep 2024 16:45:23 +0100 Subject: [PATCH] feat(nml): invalidate cached property when new segment is added Since the property is now out of date. --- neuroml/nml/helper_methods.py | 6 ++++++ neuroml/nml/nml.py | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/neuroml/nml/helper_methods.py b/neuroml/nml/helper_methods.py index 08c07f7..126bd6b 100644 --- a/neuroml/nml/helper_methods.py +++ b/neuroml/nml/helper_methods.py @@ -1617,6 +1617,12 @@ def add_segment( self.morphology.segments.append(segment) + # remove cached property since it is now outdated + try: + del self.__dict__['segment_ids_vs_segments'] + except KeyError: + pass + if optimise_segment_groups: self.optimise_segment_groups() diff --git a/neuroml/nml/nml.py b/neuroml/nml/nml.py index 8e08329..9146c24 100644 --- a/neuroml/nml/nml.py +++ b/neuroml/nml/nml.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # -# Generated Wed Sep 11 17:09:38 2024 by generateDS.py version 2.44.1. +# Generated Thu Sep 12 16:44:57 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: @@ -49179,6 +49179,12 @@ def add_segment( self.morphology.segments.append(segment) + # remove cached property since it is now outdated + try: + del self.__dict__["segment_ids_vs_segments"] + except KeyError: + pass + if optimise_segment_groups: self.optimise_segment_groups()