Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
1ba0d77
1
Parent(s):
a2a6814
Add Project.toml file and initialization
Browse files- Project.toml +5 -0
- pysr/sr.py +11 -5
Project.toml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[deps]
|
2 |
+
SymbolicRegression = "8254be44-1295-4e6a-a16d-46603ac705cb"
|
3 |
+
|
4 |
+
[compat]
|
5 |
+
SymbolicRegression = "0.4"
|
pysr/sr.py
CHANGED
@@ -319,16 +319,18 @@ def _final_pysr_process(julia_optimization, runfile_filename, timeout, **kwargs)
|
|
319 |
def _create_julia_files(dataset_filename, def_datasets, hyperparam_filename, def_hyperparams,
|
320 |
fractionReplaced, ncyclesperiteration, niterations, npop,
|
321 |
runfile_filename, topn, verbosity, julia_project, procs, weights,
|
322 |
-
X, variable_names, **kwargs):
|
323 |
with open(hyperparam_filename, 'w') as f:
|
324 |
print(def_hyperparams, file=f)
|
325 |
with open(dataset_filename, 'w') as f:
|
326 |
print(def_datasets, file=f)
|
327 |
with open(runfile_filename, 'w') as f:
|
328 |
-
if julia_project is
|
|
|
|
|
329 |
julia_project = Path(julia_project)
|
330 |
-
|
331 |
-
|
332 |
print(f'using SymbolicRegression', file=f)
|
333 |
print(f'include("{_escape_filename(hyperparam_filename)}")', file=f)
|
334 |
print(f'include("{_escape_filename(dataset_filename)}")', file=f)
|
@@ -527,6 +529,8 @@ def _handle_feature_selection(X, select_k_features, use_custom_variable_names, v
|
|
527 |
|
528 |
def _set_paths(tempdir):
|
529 |
# System-independent paths
|
|
|
|
|
530 |
tmpdir = Path(tempfile.mkdtemp(dir=tempdir))
|
531 |
hyperparam_filename = tmpdir / f'hyperparams.jl'
|
532 |
dataset_filename = tmpdir / f'dataset.jl'
|
@@ -534,7 +538,9 @@ def _set_paths(tempdir):
|
|
534 |
X_filename = tmpdir / "X.csv"
|
535 |
y_filename = tmpdir / "y.csv"
|
536 |
weights_filename = tmpdir / "weights.csv"
|
537 |
-
return dict(
|
|
|
|
|
538 |
dataset_filename=dataset_filename,
|
539 |
hyperparam_filename=hyperparam_filename,
|
540 |
runfile_filename=runfile_filename, tmpdir=tmpdir,
|
|
|
319 |
def _create_julia_files(dataset_filename, def_datasets, hyperparam_filename, def_hyperparams,
|
320 |
fractionReplaced, ncyclesperiteration, niterations, npop,
|
321 |
runfile_filename, topn, verbosity, julia_project, procs, weights,
|
322 |
+
X, variable_names, pkg_directory, **kwargs):
|
323 |
with open(hyperparam_filename, 'w') as f:
|
324 |
print(def_hyperparams, file=f)
|
325 |
with open(dataset_filename, 'w') as f:
|
326 |
print(def_datasets, file=f)
|
327 |
with open(runfile_filename, 'w') as f:
|
328 |
+
if julia_project is None:
|
329 |
+
julia_project = pkg_directory
|
330 |
+
else:
|
331 |
julia_project = Path(julia_project)
|
332 |
+
print(f'import Pkg', file=f)
|
333 |
+
print(f'Pkg.activate("{_escape_filename(julia_project)}")', file=f)
|
334 |
print(f'using SymbolicRegression', file=f)
|
335 |
print(f'include("{_escape_filename(hyperparam_filename)}")', file=f)
|
336 |
print(f'include("{_escape_filename(dataset_filename)}")', file=f)
|
|
|
529 |
|
530 |
def _set_paths(tempdir):
|
531 |
# System-independent paths
|
532 |
+
pkg_directory = Path(__file__).parents[1]
|
533 |
+
default_project_file = pkg_directory / "Project.toml"
|
534 |
tmpdir = Path(tempfile.mkdtemp(dir=tempdir))
|
535 |
hyperparam_filename = tmpdir / f'hyperparams.jl'
|
536 |
dataset_filename = tmpdir / f'dataset.jl'
|
|
|
538 |
X_filename = tmpdir / "X.csv"
|
539 |
y_filename = tmpdir / "y.csv"
|
540 |
weights_filename = tmpdir / "weights.csv"
|
541 |
+
return dict(pkg_directory=pkg_directory,
|
542 |
+
default_project_file=default_project_file,
|
543 |
+
X_filename=X_filename,
|
544 |
dataset_filename=dataset_filename,
|
545 |
hyperparam_filename=hyperparam_filename,
|
546 |
runfile_filename=runfile_filename, tmpdir=tmpdir,
|