-
Notifications
You must be signed in to change notification settings - Fork 39
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
Converting from scikit-hep histogram to Table #243
Conversation
Thanks, this looks useful! I've triggered the tests, but we should have tests as you also point out to make sure this is working and will continue to work in the future. I'll wait for you to add some. Let me know if you need help. |
Cool! If the developers think this contribution is in the right direction, I will continue rounding out the features, testing and the linting! More to come over the next few days. |
@clelange I have included all the features that for testing. Also checked with against |
@yimuchen : can you please also check the linting of |
tests/test_histread.py
Outdated
@@ -47,8 +47,10 @@ def test_default_read(self): | |||
""" | |||
try: | |||
readout = read_hist(TestHistUtils.base_hist) | |||
# pylint: disable=W0702 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you using this try
-except
block here (and also below) in the first place? Does it ever fail? If so, you should know which kind of exception is thrown and use that. Please do not disable pylint warnings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is following the format that was found in cfilereader
and other tests [1].
Hm... I guess since the format parsing is pure python. I should actually remove the try/except all together, and simply have pytest
handle the exception?
[1] https://github.com/HEPData/hepdata_lib/blob/main/tests/test_cfilereader.py#L48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, OK, I had forgotten that this is used elsewhere. I think also in https://github.com/HEPData/hepdata_lib/blob/main/tests/test_cfilereader.py#L48 it should actually not be used, but let's not worry about that here.
I'm wondering what test_default_read
is meant to test. Can read_hist(TestHistUtils.base_hist)
actually fail? I would think that it can only happen if the hist.Hist()
interface changes. So I would think that you can just read in the file and get rid of the try
-except
. However, there might be other ways that reading fails. For example, is it possible that an invalid hist is provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of the test function is to check if axis information is properly formatted into compatible lists (hepdata_lib
basically wants everything to be in 1D list, so all axis information needs to be multiplied out)
Technically, yes, the read_hist
function can fail, as it depends on the storage format of the histogram entries [1], which can be user defined. For completeness’ sake, let me work on getting all official storage formats [2] into the package, and just have the function throw an error for user-defined formats for now.
[1] https://github.com/yimuchen/hepdata_lib/blob/hist_reader/hepdata_lib/hist_utils.py#L39
[2] https://github.com/scikit-hep/hist/blob/main/src/hist/storage.py#L14
Hm... I just checked, the |
Yes, there's a way, but I need to look it up. We could either deprecate Python 3.6 since it's EOL anyway or do that. I'll get back to you later (hopefully tomorrow) in case nobody else has done so in the meantime. |
…e types and removing exception handling
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. @@ Coverage Diff @@
## main #243 +/- ##
==========================================
- Coverage 88.54% 88.04% -0.51%
==========================================
Files 4 5 +1
Lines 978 1079 +101
Branches 203 229 +26
==========================================
+ Hits 866 950 +84
- Misses 82 91 +9
- Partials 30 38 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Thinking about this a bit more, I would say we should just get rid of Python 3.6 support. It's not great since lots of systems we use still have 3.6 as system Python, but then again there are relatively easy ways to get to Python >= 3.7 and we need to make sure we document them. |
The last version of |
Let me quickly compare what are the minimum set of features required for hist==2.4.0 |
…lity for hist==2.4.0 for python==3.6)
This new readout method should work with both older versions of hist, as well as user defined accumulators. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the delay, looks good to me. I'll create a new release soon (might be tomorrow though).
📚 Documentation preview 📚: https://hepdata-lib--243.org.readthedocs.build/en/243/