Skip to content

Commit

Permalink
Merge pull request #3145 from heplesser/fix-slow-ipython
Browse files Browse the repository at this point in the history
Stop IPython from time consuming deep inspection of NodeCollection objects
  • Loading branch information
heplesser authored Mar 13, 2024
2 parents 6ab67c5 + 49009d9 commit 7b9e2a4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pynest/nest/lib/hl_api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,13 @@ def __getattr__(self, attr):
if not self:
raise AttributeError("Cannot get attribute of empty NodeCollection")

# IPython looks up this method when doing pretty printing
# As long as we do not provide special methods to support IPython prettyprinting,
# HTML-rendering, etc, we stop IPython from time-consuming checks by raising an
# exception here. The exception must *not* be AttributeError.
if attr == "_ipython_canary_method_should_not_exist_":
raise NotImplementedError("_ipython_canary_method_should_not_exist_")

if attr == "spatial":
metadata = sli_func("GetMetadata", self._datum)
val = metadata if metadata else None
Expand Down

0 comments on commit 7b9e2a4

Please sign in to comment.