scikit-hep / scikit-hep/formulate
Add support for variable scoping
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14
- Forks
- 6
- Avg merge
- 4h 20m
- Merged PRs (30d)
- 4
Description
I've started looking into using this package for a project I'm working on. We'll want to be able to specify branches which might be nested within our trees, eg. branch.sub_branch. I've tested this briefly with version 0.0.7 of formulate though and I see that such variables cannot be identified:
$ python -m formulate --from-numexpr 'branch.sub_branch < 4' --variables
ERROR:formulate:TODO TRACEBACK: ('branch.sub_branch < 4', 6, 'Expected end of text')
ERROR:formulate:Error parsing: branch.sub_branch < 4
ERROR:formulate: ▲
ERROR:formulate: ┃
ERROR:formulate: ┗━━━━━━ Error here or shortly after
Would it be possible to add support for this? PyParsing has a specific helper method which might be useful here, delimitedList. I think the easiest for the user is to return a single variable in this case branch.sub_branch in the example above. That might mean just including the . in the definition of the Word for Variables?
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Reproduce the issue with python -m formulate --from-numexpr 'branch.sub_branch < 4' --variables, then trace the expression parser's variable definition and pyparsing integration. Done means dotted names such as branch.sub_branch parse successfully and are returned as one variable without breaking existing variable parsing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100