-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples for writing data #71
Comments
Ah, so I've been poking around the test files, and found this: The naming here is a bit confusing, as Anyway, I'm sorted now, thank you! (I'll leave open in case you want to add some more docs for numpy stuff etc.) |
Sorry for the late reply. I agree that it would be more pythonic if Perhaps The numpy-friendlyness is discussed here: https://scikit-hep.org/pyhepmc/examples/processing.html |
For the record, this works class Foo:
def from_bar(*args, **kwargs):
if isinstance(args[0], Foo):
print("method", args[1:], kwargs)
else:
print("classmethod", args, kwargs) |
Sorry I missed this! I can see from the docs on the numpy stuff, it's mainly regarding computation rather than IO, which is a bit different to my use-case, but cool neverthless. :) Also, fun example! Though, I think this would be closer to accessing it as a staticmethod? Decorated classmethods receive the class type constructor as the first argument, whereas if you were to do Foo.from_bar("spam") The first argument here would be "spam", not the |
Hi there! I see that there is good coverage in the docs for reading data from HepMC files, but I can't see much information on how to write data to one. I also notice the docs say the library is "numpy-friendly", but I can't really see much in the way of numpy integration.
I have my simulation data in numpy arrays, and would love a way of writing out to file objects in the HepMC format. I tried using the
GenEvent.from_hepevt()
method, since it seemed to take in the numpy data and spit out aGenEvent
instance, but I kept getting confusing errorsAs far as I can tell I added everything correctly. I found this from the HepMC3 GitLab for converting directly from a
pythia8.Pythia
instance, but it's a bit hard to read, given there's no docs, type annotations, and the whole method for writing it is done in one monolithic chunk. I've managed to make it work, but will take a while unpacking what's going on to be able to just throw in numpy data.Can you offer any help? Examples or advice greatly appreciated.
The text was updated successfully, but these errors were encountered: