Skip to content
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

feat: Add LHE writing functionality #233

Merged
merged 16 commits into from
Aug 23, 2024

Conversation

APN-Pucky
Copy link
Member

@APN-Pucky APN-Pucky commented Feb 20, 2024

I decided to add a tolhe() function to every class (since it is neither xml nor a simple string).
The format strings can maybe still be improved?
read_lhe_init() now returns a LHEInit object combining weights, procinfo and initinfo. For backwards compatibility I added the get/set there so that LHEInit will still behave as previous LHEInit, what is now LHEInitInfo.

The tests can probably still be extended, but for the first draft I just hardcoded them for one file.

Already includes #232 and #231
Closes: #229

Squash Commit summary:

feat: Add LHE writing functionality

* Add `LHEInitInfo` dict class that contains only the first line of the <init> block.
  Previously this was in `LHEInit`. The new `LHEInit` contains more lhe-init variables
  `procInfo`, `weightgroup` and `LHEVersion` needed for writing LHE files. For
  backwards compatibility `LHEInit` maps to `LHEInitInfo` unless `procInfo`,
  `weightgroup` or `LHEVersion` are requested.
* Implemented `tolhe` methods for `LHEEvent`, `LHEEventInfo`, `LHEParticle`, `LHEInit`, 
  `LHEInitInfo`, and `LHEProcInfo` classes to support converting objects to LHE
  formatted strings.
* Added new functionality to write LHE files to both string and file, with options for
  gzip compression and different weight formats.

@APN-Pucky APN-Pucky changed the title feature: add write lhe file functions feat: add write lhe file functions Feb 20, 2024
Copy link

codecov bot commented Feb 20, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 8 lines in your changes missing coverage. Please review.

Project coverage is 91.17%. Comparing base (584c03f) to head (ef0376f).
Report is 2 commits behind head on main.

Files Patch % Lines
src/pylhe/__init__.py 90.00% 1 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #233      +/-   ##
==========================================
- Coverage   91.48%   91.17%   -0.32%     
==========================================
  Files           2        2              
  Lines         235      306      +71     
  Branches       54       78      +24     
==========================================
+ Hits          215      279      +64     
- Misses         16       17       +1     
- Partials        4       10       +6     
Flag Coverage Δ
unittests-3.10 90.84% <90.00%> (-0.22%) ⬇️
unittests-3.8 90.84% <90.00%> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@APN-Pucky APN-Pucky marked this pull request as ready for review February 20, 2024 17:47
Copy link
Member

@matthewfeickert matthewfeickert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @APN-Pucky. I'm going to say LGTM as it passes CI.

Maybe @eduardo-rodrigues can give it a look over too?

@APN-Pucky can you please add a summary commit message to the PR body that can be copy-pasted in for the squash and merge?

@APN-Pucky
Copy link
Member Author

@APN-Pucky can you please add a summary commit message to the PR body that can be copy-pasted in for the squash and merge?

Done.

@matthewfeickert matthewfeickert changed the title feat: add write lhe file functions feat: Add LHE writing functionality Aug 22, 2024
@matthewfeickert
Copy link
Member

Done.

Thanks @APN-Pucky! Can you now rebase this off of main now that PR #232 is in (and fixup the merge conflict there)? After that I think this is good to go.

@APN-Pucky
Copy link
Member Author

Thanks @APN-Pucky! Can you now rebase this off of main now that PR #232 is in (and fixup the merge conflict there)? After that I think this is good to go.

✔️

@matthewfeickert
Copy link
Member

Thanks @APN-Pucky. I'll leave this open for @eduardo-rodrigues to look at, but if he hasn't reviewed it by Friday 2024-08-22 I'll merge this.

We can then get a minor release out to PyPI as @agbuckley asked about in Discussion #238.

@matthewfeickert matthewfeickert merged commit 8a9b3f5 into scikit-hep:main Aug 23, 2024
10 checks passed
@agbuckley
Copy link

Thanks!!

@eduardo-rodrigues
Copy link
Member

Hi everyone. As you could guess I had been away and offline.

This is a really nice addition :+1!

My only comment to you @APN-Pucky is that the functionality should be visible as an example notebook for sure, probably in a dedicated new notebook (otherwise many will not realise writing is now available).
Likewise I would add a little paragraph/sentence in the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write LHE file function
4 participants