MilesCranmer / PySR

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

fix TypeError when a variable name matches a builtin python function #558

Closed tomjelen closed 3 months ago

tomjelen commented 4 months ago

For example, fitting on a dataset with a column named 'exec' fails with:

ValueError: Error from parse_expr with transformed code: "(Float ('86.76248' )-exec )" 
... snip ...
TypeError: unsupported operand type(s) for -: 'Float' and 'builtin_function_or_method'

This change maps the feature names to sympy.Symbol when parsing the pysr-equation in pysr2sympy.

MilesCranmer commented 4 months ago

Thanks!

MilesCranmer commented 4 months ago

@tomjelen can you enable push access for maintainers? Then I can edit the PR directly.

tomjelen commented 4 months ago

Hey there, thanks for looking into the failed build. I don't have much experience with Conda, so could take me a while to figure out whats going on.

"Allow edits by maintainers" is checked. That's what you need right?

MilesCranmer commented 4 months ago

Perfect, thanks!

The segfault looks to be unrelated. Sometimes the GitHub action runners simply don't enough memory to use for the builds. But I will take a look.

MilesCranmer commented 4 months ago

Hm, nope, it's still not letting me push to your branch. It says

! [remote rejected] tomjelen/master -> tomjelen/master (permission denied)

I'll try to figure this out... Not sure why it's doing that

I can also make a new PR from my local branch if needed, including your commit as the base.

MilesCranmer commented 4 months ago

Nevermind, seems like it was some issue on my side with remotes and what URL I used... Sorry for the confusion

tomjelen commented 4 months ago

Ah, okay. No worries :)