hsf-training / hsf-training-scikit-hep-webpage

https://hsf-training.github.io/hsf-training-scikit-hep-webpage/
Other
9 stars 19 forks source link

Lorentz vectors, particle PDG, jet-clustering, oh my! -> some problems with examples #55

Open JacekHoleczek opened 1 year ago

JacekHoleczek commented 1 year ago

I've met some problems with the examples in the "Lorentz vectors, particle PDG, jet-clustering, oh my!" chapter.

In the "Particle PDG" section: particle.Particle.from_string("p~") z_boson = particle.Particle.from_string("Z0") and in the "Jet clustering" section: probable_mass = particle.Particle.from_string("pi+").mass / GeV generate warnings in the form: <stdin>:1: DeprecationWarning: Call to deprecated class method from_string. (This method is deprecated and will be removed from version 0.23.0. Use finditer or findall instead.) -- Deprecated since version 0.22.

In the "Jet clustering" section, in the "fastjet" example: good_pseudojets = pseudojets[pseudojets.pt > 0.1] generates an error in the form:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../tutorial/lib/python3.11/site-packages/awkward/highlevel.py", line 1108, in __getattr__
    raise AttributeError(f"no field named {where!r}")
AttributeError: no field named 'pt'. Did you mean: 'px'?

Then I cannot "import fastjet" ... and when I try to "install fastjet" (from conda-forge), I get:

error    libmamba Could not solve for environment specs
    The following package could not be installed
    └─ fastjet does not exist (perhaps a typo or a missing channel).
critical libmamba Could not solve for environment specs
jpivarski commented 1 year ago

Then I cannot "import jetset"

I don't know what "jetset" is. Do you mean fastjet?

AttributeError: no field named 'pt'. Did you mean: 'px'?

It sounds like an array of Lorentz vectors was loaded without

vector.register_awkward()

Call to deprecated class method from_string.

Again, the tutorial is showing its age. If Particle is deprecating from_string, it should be replaced with finditer or findall. Both of these allow for the possibility of multiple matches. Maybe

particle.Particle.from_string("pi+")

should become

next(particle.Particle.finditer("pi+"))

(to bake-in the assumption that there's only one, or we're only interested in the first)?

eduardo-rodrigues commented 1 year ago

See also https://github.com/scikit-hep/particle#getting-started-particles and of course the extensive docstrings :-).

jpivarski commented 1 year ago

Sorry, I get GitHub notifications via email, which can be out of date.

On fastjet in conda-forge—you're right, it's not done: scikit-hep/fastjet#133.

JacekHoleczek commented 1 year ago

To my new pull request, I added the missing "vector.register_vawkward()" call (in the last example to make it fully self-contained), and I replaced from_string with findall in one place (as it returns a bit funny result there for the "p~"). I'm not sure if finditer or findall should be used elsewhere, so please fix the 2 remaining from_string places. I assume, when replacing "particle.Particle.from_string("name")", one should use "particle.Particle.findall("name")[0]" or "next(particle.Particle.finditer("name"))" (not sure what to do when these methods return a list with more than one entries, like for the "p~").

stale[bot] commented 12 months ago

This issue or pull request has been automatically marked as stale because it has not had recent activity. Please manually close it, if it is no longer relevant, or ask for help or support to help getting it unstuck. Let me bring this to the attention of @klieret @wdconinc @michmx for now.