MilesCranmer commited on
Commit
de38458
1 Parent(s): b00f082

Test operators before running

Browse files
Files changed (2) hide show
  1. julia/sr.jl +25 -0
  2. setup.py +1 -1
julia/sr.jl CHANGED
@@ -745,6 +745,28 @@ mutable struct HallOfFame
745
  end
746
 
747
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
748
  function fullRun(niterations::Integer;
749
  npop::Integer=300,
750
  ncyclesperiteration::Integer=3000,
@@ -752,6 +774,9 @@ function fullRun(niterations::Integer;
752
  verbosity::Integer=0,
753
  topn::Integer=10
754
  )
 
 
 
755
  # 1. Start a population on every process
756
  allPops = Future[]
757
  # Set up a channel to send finished populations back to head node
 
745
  end
746
 
747
 
748
+ # Check for errors before they happen
749
+ function testConfiguration()
750
+ test_input = LinRange(-100f0, 100f0, 99)
751
+
752
+ try
753
+ for left in test_input
754
+ for right in test_input
755
+ for binop in binops
756
+ test_output = binop.(left, right)
757
+ end
758
+ end
759
+ for unaop in unaops
760
+ test_output = unaop.(left)
761
+ end
762
+ end
763
+ catch
764
+ @printf("\n\nYour configuration is invalid - one of your operators is not well-defined over the real line.\n\n\n")
765
+ throw(error)
766
+ end
767
+ end
768
+
769
+
770
  function fullRun(niterations::Integer;
771
  npop::Integer=300,
772
  ncyclesperiteration::Integer=3000,
 
774
  verbosity::Integer=0,
775
  topn::Integer=10
776
  )
777
+
778
+ testConfiguration()
779
+
780
  # 1. Start a population on every process
781
  allPops = Future[]
782
  # Set up a channel to send finished populations back to head node
setup.py CHANGED
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
 
6
  setuptools.setup(
7
  name="pysr", # Replace with your own username
8
- version="0.3.11",
9
  author="Miles Cranmer",
10
  author_email="[email protected]",
11
  description="Simple and efficient symbolic regression",
 
5
 
6
  setuptools.setup(
7
  name="pysr", # Replace with your own username
8
+ version="0.3.12",
9
  author="Miles Cranmer",
10
  author_email="[email protected]",
11
  description="Simple and efficient symbolic regression",