scikit-hep / pyhepmc

Easy-to-use Python bindings for HepMC3
https://scikit-hep.org/pyhepmc/
BSD 3-Clause "New" or "Revised" License
21 stars 11 forks source link

Simple saving event as image #52

Closed amanmdesai closed 1 year ago

amanmdesai commented 1 year ago

Hi @HDembinski, I would be happy to know if this PR resolves #46.

I have not yet included tests (and formatting).

amanmdesai commented 1 year ago

To use this:

from pyhepmc.view import save_event

save_event(event,'evt.svg') #or .png to save as png
HDembinski commented 1 year ago

Thanks for this contribution! I added some comments.

amanmdesai commented 1 year ago

Hi @HDembinski Thanks a lot for your comments. I have implemented all of them except -

Ideally, name should also accept a file handle from a file that was already opened. The implementation then becomes more complex. You don't have to implement that, I can do it, but if you feel up to it, give it a try.

Please let me know me if the implementation looks fine.

For the tests, shall I write a test that call the function and see if that works? as we need to test if the function works. (or is something additional required?)

amanmdesai commented 1 year ago

Ideally, name should also accept a file handle from a file that was already opened. The implementation then becomes more complex. You don't have to implement that, I can do it, but if you feel up to it, give it a try.

I do not know how this is implemented.

coveralls commented 1 year ago

Coverage Status

Coverage: 99.732% (+0.05%) from 99.681% when pulling a695984ba85a81fe39087d9794a7958b3fa938a1 on amanmdesai:simpler-event-save into b133b30750f8e2798e3619e305c316aa26ec0694 on scikit-hep:main.

HDembinski commented 1 year ago

@amanmdesai I implemented saving to more formats supported by graphviz, and the option to save to an existing file-like object. I also added a test. I made some unrelated changes to, which fix issues with colors.

amanmdesai commented 1 year ago

@amanmdesai I implemented saving to more formats supported by graphviz, and the option to save to an existing file-like object. I also added a test. I made some unrelated changes to, which fix issues with colors.

@HDembinski Thanks very much.

HDembinski commented 1 year ago

@amanmdesai Fixing and upgrading the tests took me way too long, but I am going to merge now. Thank for you very much for contributing to this patch!

amanmdesai commented 1 year ago

Thanks @HDembinski