Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
44ff874
1
Parent(s):
d72c643
Fix hanging with GC disabled
Browse files- pysr/julia_helpers.py +1 -0
- pysr/sr.py +3 -1
pysr/julia_helpers.py
CHANGED
@@ -23,6 +23,7 @@ from juliacall import Main as jl
|
|
23 |
from juliacall import convert as jl_convert
|
24 |
|
25 |
jl.seval("using Serialization: Serialization")
|
|
|
26 |
|
27 |
juliainfo = None
|
28 |
julia_initialized = False
|
|
|
23 |
from juliacall import convert as jl_convert
|
24 |
|
25 |
jl.seval("using Serialization: Serialization")
|
26 |
+
jl.seval("using PythonCall: PythonCall")
|
27 |
|
28 |
juliainfo = None
|
29 |
julia_initialized = False
|
pysr/sr.py
CHANGED
@@ -1765,6 +1765,7 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
|
|
1765 |
progress=progress and self.verbosity > 0 and len(y.shape) == 1,
|
1766 |
verbosity=int(self.verbosity),
|
1767 |
)
|
|
|
1768 |
output_stream = jl.seval(
|
1769 |
"""
|
1770 |
let args = deepcopy(_equation_search_args), kwargs=deepcopy(_equation_search_kwargs)
|
@@ -1775,9 +1776,10 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
|
|
1775 |
end
|
1776 |
"""
|
1777 |
)
|
|
|
1778 |
jl._equation_search_args = None
|
1779 |
jl._equation_search_kwargs = None
|
1780 |
-
self.raw_julia_state_stream_ = np.array(output_stream)
|
1781 |
|
1782 |
# Set attributes
|
1783 |
self.equations_ = self.get_hof()
|
|
|
1765 |
progress=progress and self.verbosity > 0 and len(y.shape) == 1,
|
1766 |
verbosity=int(self.verbosity),
|
1767 |
)
|
1768 |
+
jl.PythonCall.GC.disable()
|
1769 |
output_stream = jl.seval(
|
1770 |
"""
|
1771 |
let args = deepcopy(_equation_search_args), kwargs=deepcopy(_equation_search_kwargs)
|
|
|
1776 |
end
|
1777 |
"""
|
1778 |
)
|
1779 |
+
jl.PythonCall.GC.enable()
|
1780 |
jl._equation_search_args = None
|
1781 |
jl._equation_search_kwargs = None
|
1782 |
+
self.raw_julia_state_stream_ = np.array(output_stream)
|
1783 |
|
1784 |
# Set attributes
|
1785 |
self.equations_ = self.get_hof()
|