Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe6bcf8

Browse filesBrowse files
authored
do get_ipython() only once in import (#611)
* get_ipython() only once in imports * black
1 parent 1d38861 commit fe6bcf8
Copy full SHA for fe6bcf8

File tree

1 file changed

+5
-5
lines changed
Filter options

1 file changed

+5
-5
lines changed

‎fastplotlib/layouts/_plot_area.py

Copy file name to clipboardExpand all lines: fastplotlib/layouts/_plot_area.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515

1616

1717
try:
18-
ip = get_ipython()
18+
get_ipython()
1919
except NameError:
2020
IS_IPYTHON = False
21+
IPYTHON = None
2122
else:
2223
IS_IPYTHON = True
24+
IPYTHON = get_ipython()
2325

2426

2527
class PlotArea:
@@ -673,15 +675,13 @@ def delete_graphic(self, graphic: Graphic):
673675

674676
if IS_IPYTHON:
675677
# remove any references that ipython might have made
676-
ip = get_ipython()
677-
678678
# check both namespaces
679-
for namespace in [ip.user_ns, ip.user_ns_hidden]:
679+
for namespace in [IPYTHON.user_ns, IPYTHON.user_ns_hidden]:
680680
# find the reference
681681
for ref, obj in namespace.items():
682682
if graphic is obj:
683683
# we found the reference, remove from ipython
684-
ip.del_var(ref)
684+
IPYTHON.del_var(ref)
685685
break
686686

687687
def clear(self):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.