inf treated as a number, which is very weird
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start in patsy.parse_formula._read_python_expr and reproduce the failure with patsy.ModelDesc.from_formula("inf ~ x"). Inspect the tokenize output for the expression and compare it with the current int() and float() checks. Done means inf and nan can be used as formula variable names without being classified as numeric literals.
Written by the indexing model from the issue text.
Description
As noted here: https://stackoverflow.com/questions/48371747/how-to-modify-a-liner-regression-in-python-3-6
This formula causes patsy to raise an error:
patsy.ModelDesc.from_formula("inf ~ x")
the problem is that in patsy.parse_formula._read_python_expr, patsy tries to figure out whether an arbitrary Python expression is a numeric literal, and the way it does this is by calling int(...) and float(...) on the expression, and seeing if they work.
In this case, float("inf") does work, so patsy decides that the Python expression inf is a numeric literal. Whoops.
The same thing probably happens if you try to use nan as a variable name in a formula.
I guess a more reliable way of checking for numeric literals would be to check the tokenize output: if an expression is a single token, and that token has type tokenize.NUMBER, then it's a numeric literal.
- Dominant language
- Python
- Stars
- 989
- Forks
- 106
- Avg merge
- 7d 34m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pydata/patsy
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Similar issues
-
New InternshipOpennew_internship
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
[BUG] Reports tab: "Unban" button tooltip shows raw `{{ip}}` placeholder instead of the IP addressOpenbug javascript ui
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
bunkerity/bunkerweb#4001 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
PedestrianDynamics/pyFDS-Evac#476 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google/differential-privacy#516 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
adobe-fonts/source-serif#153 ·