MilesCranmer commited on
Commit
20646f9
1 Parent(s): 2600822

Simplify IPython detection

Browse files
Files changed (1) hide show
  1. pysr/julia_import.py +4 -6
pysr/julia_import.py CHANGED
@@ -31,15 +31,13 @@ for k, default in (
31
 
32
 
33
  def is_in_jupyter() -> bool:
34
- try:
35
- ipy = get_ipython().__class__.__name__ # type: ignore
36
- return ipy == "ZMQInteractiveShell"
37
- except NameError:
38
- return False
39
 
40
 
41
  if is_in_jupyter():
42
- get_ipython().run_line_magic("load_ext", "julia.ipython") # type: ignore
 
 
43
 
44
 
45
  from juliacall import Main as jl # type: ignore
 
31
 
32
 
33
  def is_in_jupyter() -> bool:
34
+ return hasattr(__builtins__, "__IPYTHON__")
 
 
 
 
35
 
36
 
37
  if is_in_jupyter():
38
+ from IPython import get_ipython
39
+
40
+ get_ipython().run_line_magic("load_ext", "juliacall")
41
 
42
 
43
  from juliacall import Main as jl # type: ignore