Comments (4)
Hmm, you need to have consistency across the board. No other way possible. So if I start with a ROOT expression that explicitly uses TMath::G()
(for whatever reason) then whatever expression is returned at any point, it should have precisely the value behind TMath::G()
. If I start from another backend and then ask for the ROOT-like expression then you cannot or should not use TMath::G()
but rather the actual number you start from.
from formulate.
You mean the constants in backends/numexpr.py
? Are there are other constants defined elsewhere?
In any case it is probably a good idea to move all those to a separate file, to be easily checked and seen.
As for whether they should all come from ROOT, that needs a discussion perhaps, as I am pretty sure ROOT does not have all you need. In fact, why do you need all those constants?
from formulate.
Note that we have constants defined in scikit-hep, which we do want to use throughout the Scikit-HEP project for consistency ...
from formulate.
These constants are only used for compatibility with TFormula style expressions as numexpr doesn't have an equivalent. See backends/ROOT.py
.
I see 4 options for how to interpret a constant from ROOT, for example using TMath::G()
which is defined as exactly 6.673e-11
in ROOT but ~100x more precisely known to be 6.67408e-11
.
"TMath::G()"
goes to"TMath::G()"
in ROOT and"6.67408e-11"
in numexpr (currently used)"TMath::G()"
goes to"TMath::G()"
in ROOT and"6.673e-11"
in numexpr"TMath::G()"
goes to"6.673e-11"
in ROOT and"6.673e-11"
in numexpr"TMath::G()"
goes to"6.67408e-11"
in ROOT and"6.67408e-11"
in numexpr
(2)/(3) have the benefit that we exactly mirror ROOT's behaviour instead of assuming users just want the best possible value, and (3)/(4) would be simpler as it would allow me to remove the special named constants, at the cost making the result of from_root("...").to_root()
ROOT uglier.
I'm inclined to use (2), in part due to the comments of @jpivarski:
it may even be preferable to hard-code them in formulate. Hear me out: users want formulate because it lets them run TFormula expressions in numexpr, without ROOT. They want these expressions to return the same result as they did in TFormula. If there are any differences between ROOT's values of these constants and Scipy's, or skhep's, the users would prefer ROOT's values. I believe the users would want all of the constants in formulate/backends/numexpr.py to be copied from ROOT, not taken from another authority, such as Scipy or skhep!
but I'm open to hearing other opinions.
from formulate.
Related Issues (20)
- Add documentation to README
- Add constants
- Test against ROOT and numexpr
- Optimise deep recursion HOT 1
- Add ROOT to travis tests HOT 1
- Add support for comparing Expression objects
- Add support for dividing Expression objects HOT 1
- Add support for TMath::Functions with variable numbers of arguments
- Add support for converting more TMath functions to numexpr equivlents
- Drop all dependencies except pyparsing HOT 1
- Evaluate Expression objects directly
- Return numexpr expression for given container HOT 3
- Add support for variable scoping HOT 6
- parsing `from_root` can be slow HOT 9
- more flexible to_string conversion to support ternary operators
- BUG: pow operator without whitespace errors HOT 1
- Add pypi password as secret for CD HOT 2
- Release tagging HOT 4
- idea: add sympy conversion HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formulate.