Giter VIP home page Giter VIP logo

Comments (4)

eduardo-rodrigues avatar eduardo-rodrigues commented on July 20, 2024 1

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.

eduardo-rodrigues avatar eduardo-rodrigues commented on July 20, 2024

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.

eduardo-rodrigues avatar eduardo-rodrigues commented on July 20, 2024

Note that we have constants defined in scikit-hep, which we do want to use throughout the Scikit-HEP project for consistency ...

from formulate.

chrisburr avatar chrisburr commented on July 20, 2024

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.

  1. "TMath::G()" goes to "TMath::G()" in ROOT and "6.67408e-11" in numexpr (currently used)
  2. "TMath::G()" goes to "TMath::G()" in ROOT and "6.673e-11" in numexpr
  3. "TMath::G()" goes to "6.673e-11" in ROOT and "6.673e-11" in numexpr
  4. "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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.