MilesCranmer / PySR

High-Performance Symbolic Regression in Python and Julia
https://astroautomata.com/PySR
Apache License 2.0
2.4k stars 214 forks source link

Unclear error message when constraints passed as list #179

Open MilesCranmer opened 2 years ago

MilesCranmer commented 2 years ago

Passing

PySRRegressor(constraints={"/": [-1, 9]})

gives a strange error:

JULIA: ArgumentError: Dict(kv): kv needs to be an iterator of tuples or pairs
Stacktrace:
 [1] Dict(kv::Matrix{Int64})
   @ Base ./dict.jl:132
 [2] build_constraints(una_constraints::Vector{Int64}, bin_constraints::Matrix{Int64}, unary_operators::Tuple{typeof(square), typeof(cube), typeof(cos), typeof(sin), typeof(exp), typeof(slog), typeof(ssqrt)}, binary_operators::Tuple{typeof(+), typeof(-), typeof(*), typeof(/)}, nuna::Int64, nbin::Int64)

This goes away if constraints={"/": (-1, 9)}. So, it should be automatically converted to a tuple, or a better error message should be given.