-
Notifications
You must be signed in to change notification settings - Fork 67
Add support for writing 2 and 3 dimensional histograms #269
Conversation
@jpivarski there seems to be a Travis issue with trying to install numpy on Python 3.6. Could you take a look? |
Hi @reikdas (coming from Though I don't think this is a Travis issue, but a Conda issue. The |
Yes! Thank you for your help! |
Sure, but don't thank me yet. ;) I've been poking at this as well and it seems to be a complicated issue (as you already well know). |
@reikdas I'm going to do a rebase and force push to drop the commits you grabbed from my test branch. They have so far been unsuccessful and I think don't add anything helpful. |
8efcf13
to
811f5d9
Compare
Removing mamba fixed the issue. |
d1419a0
to
3ec9fce
Compare
@reikdas Forgive my interactive rebases and force pushes. I'm not trying to get in your way, but just squashing some commits in which necessary experimentation happens that isn't too relevant to the final PR's purpose. I can of course hold off on this until things are actually done, so I'll stop poking at that until the CI is all happy. |
Thanks for doing that!
Perhaps, that would be best. The issue seems to have been solved by going back to conda but appveyor throws an error and the build stalls on travis for a particular instance of python 2.7. |
344e906
to
4be5678
Compare
@reikdas Hm, this is strange. The fix doesn't seem to be stable in all situations. Everything ran okay with your last push, but then I squashed commits and rebased against Also if might be worth to do a |
4be5678
to
152c441
Compare
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.
I know that an awful lot of work went into this and I don't want to give a too cursory review, but this all is looking good to me.
I think we'll have to rethink the conda/mamba stuff. The faster builds were very nice, but correctness is most important.
I see various corrections to the testing and example-generating code, and each one looks right (as in, "of course; that was a typo").
I don't know about the wisdom of inventing a superclass TH
that doesn't exist in ROOT. It already bit us in uproot-methods. In ROOT, TH1
is the superclass of 2 and 3 dimensional histograms, though that's a little nutty. Maybe that's a good enough argument for breaking pattern with the original ROOT hierarchy. (I made the same decision to simplify TFile/TDirectory/TDirectoryFile.)
I say it's good. There's not a lot to say beyond the fact that the tests are successful and the code is clean and easy to read.
Are the builds still unstable? Like, sometimes passing, sometimes failing? Or has that problem been fixed?
elif self.fClassName == b"TProfile3D": | ||
raise NotImplementedError(self.fClassName) | ||
else: | ||
raise ValueError("unrecognized histogram class name {0}".format(self.fClassName)) | ||
|
||
self.fields["_fNcells"] = len(self.valuesarray) | ||
self.fields["_fNcells"] = self.valuesarray.size |
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.
I prefer using len(array)
rather than array.size
, but I wouldn't make a big deal about it.
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.
Using len(array)
instead of array.size
would break the code for TH2 and TH3.
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.
Yes, sorry about not thinking this through before shoving stuff @reikdas. I'm fixing this now.
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.
@reikdas Okay, I have now unreverted the change. I am going to just leave this alone until tomorrow when there has been more time to debug the test suite.
I ran the test suit on my Linux machine and everything passed fine, so I'm confused as to what it going on here. :? Sorry for causing extra annoyances here.
@jpivarski I'll let @reikdas comment on the above as he was the one to do the work.
With regards to this it seems that they are mostly stable, but there was some instances in which Appveyor would fail, but then when I would Let me implement your |
152c441
to
b3ccf40
Compare
So I see what appears to be a similar issue,
for the test script: from uproot_methods.classes.TH1 import from_numpy
import uproot
import numpy as np
import os
outname = "test_output.root"
try:
edges = np.array((0., 1., 2.))
values = np.array([2, 3])
h = from_numpy((values, edges))
with uproot.create(outname) as f:
f["a histo"] = h
finally:
if os.path.exists(outname):
os.remove(outname) |
@nsmith- It is the same issue as scikit-hep/uproot3-methods#53. It will be fixed once this PR has been merged. |
Ok yeah I can confirm it doesn't fail if I checkout this branch, cool. |
I can look into why things are failing again in about an hour. |
I made a lot of the travis-fixing commits using the web interface(since they were mostly removing a single line or a word), so this would probably not help. But, I took a look at the code and it seems to be the same. :) |
5bac959
to
0200aa7
Compare
All the checks are passing currently. (Note that I don't think the travis build is stable yet, but I really do not know how to debug this - This seems like an appveyor issue.) |
Yes, earlier it seemed like the appveyor errors were because appveyor was having trouble downloading ROOT files before timing out/giving up, and not that the code itself was the issue. |
AppVeyor had trouble downloading Event.root, so I put in a skip for that test (it also took a long time). If you know which ones are failing for the download, we can just put in a skip for them (the explicit I'm surprised about |
The use of mamba is causing issues with Python 3.6 and some instances of Python 2.7. By using Conda this fixes the issue until mamba is more stable (and out of alpha stage)
Skipping the occasionally failed test (and a few minor changes in the appveyor config file) seems to have fixed the issue. |
…as less variance than sys.platform
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 good: the test-skipping is localized to Windows because of AppVeyor, so it still runs in most of the matrix (on Travis). I changed the sys.platform
check to os.name
because the latter is less variable, and moved the imports to the top of the file. Also, there were two places where Event.root is read over the network; you were just lucky last time in that the other one didn't fail.
I think this PR is ready for merging (thank you for all your hard work!). Give me a quick response so that I know you agree.
👍 |
Thank you both @reikdas @matthewfeickert! |
Uproot is able to write TH2s and TH3s.
This PR has to be merged with its corresponding PR in uproot-methods. (Also tests will not pass unless the uproot-methods PR has been merged)