Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
a664d90
1
Parent(s):
fe186d6
chore: move autload extensions to juliacall; update juliacall
Browse files- pysr/julia_import.py +5 -22
- requirements.txt +1 -1
pysr/julia_import.py
CHANGED
@@ -35,32 +35,15 @@ else:
|
|
35 |
os.environ[k] = os.environ.get(k, default)
|
36 |
|
37 |
|
|
|
|
|
|
|
|
|
|
|
38 |
from juliacall import Main as jl # type: ignore
|
39 |
|
40 |
jl_version = (jl.VERSION.major, jl.VERSION.minor, jl.VERSION.patch)
|
41 |
|
42 |
-
# Next, automatically load the juliacall extension if we're in a Jupyter notebook
|
43 |
-
autoload_extensions = os.environ.get("PYSR_AUTOLOAD_EXTENSIONS", "yes")
|
44 |
-
if autoload_extensions in {"yes", ""} and jl_version >= (1, 9, 0):
|
45 |
-
try:
|
46 |
-
get_ipython = sys.modules["IPython"].get_ipython
|
47 |
-
|
48 |
-
if "IPKernelApp" not in get_ipython().config:
|
49 |
-
raise ImportError("console")
|
50 |
-
|
51 |
-
print(
|
52 |
-
"Detected Jupyter notebook. Loading juliacall extension. Set `PYSR_AUTOLOAD_EXTENSIONS=no` to disable."
|
53 |
-
)
|
54 |
-
|
55 |
-
# TODO: Turn this off if juliacall does this automatically
|
56 |
-
get_ipython().run_line_magic("load_ext", "juliacall")
|
57 |
-
except Exception:
|
58 |
-
pass
|
59 |
-
elif autoload_extensions not in {"no", "yes", ""}:
|
60 |
-
warnings.warn(
|
61 |
-
"PYSR_AUTOLOAD_EXTENSIONS environment variable is set to something other than 'yes' or 'no' or ''."
|
62 |
-
)
|
63 |
-
|
64 |
jl.seval("using SymbolicRegression")
|
65 |
SymbolicRegression = jl.SymbolicRegression
|
66 |
|
|
|
35 |
os.environ[k] = os.environ.get(k, default)
|
36 |
|
37 |
|
38 |
+
autoload_extensions = os.environ.get("PYSR_AUTOLOAD_EXTENSIONS")
|
39 |
+
if autoload_extensions is not None:
|
40 |
+
# Deprecated; so just pass to juliacall
|
41 |
+
os.environ["PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION"] = autoload_extensions
|
42 |
+
|
43 |
from juliacall import Main as jl # type: ignore
|
44 |
|
45 |
jl_version = (jl.VERSION.major, jl.VERSION.minor, jl.VERSION.patch)
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
jl.seval("using SymbolicRegression")
|
48 |
SymbolicRegression = jl.SymbolicRegression
|
49 |
|
requirements.txt
CHANGED
@@ -2,7 +2,7 @@ sympy>=1.0.0,<2.0.0
|
|
2 |
pandas>=0.21.0,<3.0.0
|
3 |
numpy>=1.13.0,<2.0.0
|
4 |
scikit_learn>=1.0.0,<2.0.0
|
5 |
-
juliacall==0.9.
|
6 |
click>=7.0.0,<9.0.0
|
7 |
setuptools>=50.0.0
|
8 |
typing_extensions>=4.0.0,<5.0.0; python_version < "3.8"
|
|
|
2 |
pandas>=0.21.0,<3.0.0
|
3 |
numpy>=1.13.0,<2.0.0
|
4 |
scikit_learn>=1.0.0,<2.0.0
|
5 |
+
juliacall==0.9.20
|
6 |
click>=7.0.0,<9.0.0
|
7 |
setuptools>=50.0.0
|
8 |
typing_extensions>=4.0.0,<5.0.0; python_version < "3.8"
|