diff --git a/README.md b/README.md index c048e1a..cd381c0 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,15 @@ Python interfaces should be Pythonic, this wrapper offers just that: - Correct garbage collection, objects connected to eachother don't dissapear: Objects that rely on eachother store a reference to eachother. As is the basis for any sane object oriented interface. + - Explicit exceptions: I catch silent failures and gotchas and raise + semantic errors with a class hierarchy instead for granular + exception handling. + +**Warning:** When running MPI simulations errors cannot be caught due to a +[bug](https://github.com/neuronsimulator/nrn/issues/1112) in NEURON where every +exception results in NEURON calling `MPI_Abort` and shutting down the +simulation. If this leads to confusing failure modes please post an issue with +your Patch code to the GitHub repo! # Basic usage diff --git a/patch/__init__.py b/patch/__init__.py index 4612c8d..5031896 100644 --- a/patch/__init__.py +++ b/patch/__init__.py @@ -16,7 +16,7 @@ class PythonHocModule(types.ModuleType): transform_record = staticmethod(transform_record) transform_arc = staticmethod(transform_arc) - __version__ = "3.0.0b4" + __version__ = "3.0.0b5" __path__ = __path__ @property diff --git a/patch/interpreter.py b/patch/interpreter.py index 4bf43ab..50e5f38 100644 --- a/patch/interpreter.py +++ b/patch/interpreter.py @@ -20,7 +20,7 @@ ) from .exceptions import * from .error_handler import catch_hoc_error, CatchNetCon, CatchSectionAccess, _suppress_nrn -from functools import wraps +from functools import wraps, cached_property # We don't need to reraise ImportErrors, they should be clear enough by themselves. If not # and you're reading this: Fix the NEURON install, it's currently not importable ;) @@ -229,20 +229,14 @@ def SEClamp(self, sec, x=0.5): sec.__ref__(clamp) return clamp - @property + @cached_property def time(self): - if not hasattr(self, "_time"): - t = self.Vector() - # Fix for upstream NEURON bug. See https://github.com/neuronsimulator/nrn/issues/416 - try: - with catch_hoc_error(CatchSectionAccess): - t.record(self._ref_t) - except HocSectionAccessError as e: - self.__dud_section = self.Section(name="this_is_here_to_record_time") - # Recurse to try again. - return self.time - self._time = t - return self._time + t = self.Vector() + # Fix for upstream NEURON bug. See https://github.com/neuronsimulator/nrn/issues/416 + if not any(self.allsec()): + self.__dud_section = self.Section(name="this_is_here_to_record_time") + t.record(self._ref_t) + return t def load_extension(self, extension): # pragma: nocover if extension in self.__loaded_extensions: