Edit: this is a version problem. Uproot 4.3.7 produces the expected result, while the error below occurred in 4.0.0
I am creating 1-D histograms in ROOT with non-uniform bin sizes, then accessing them with uproot. The bin edges are not returned properly by uproot.
Creating test histogram (tested with root 6.22/06):
{
TFile *f = new TFile("uproot_test.root","new");
Double_t binedges[6] = {0.1, 0.158489, 0.251189, 0.398107, 0.630957, 1};
TH1D *h = new TH1D("hist","hist",5, binedges);
h->Write();
f->Close();
//reopen and print bins to verify they're right in root file
TFile *f2 = new TFile("uproot_test.root");
TH1D *h2 = (TH1D*)f2->Get("hist");
TArrayD binEdges = *(h2->GetXaxis()->GetXbins());
for (Int_t iX = 0; iX < binEdges.GetSize(); iX++) {
std::cout << binEdges[iX] << std::endl;
}
}
This produces the input bin edges as output: 0.1 0.158489 0.251189 0.398107 0.630957 1
Now, read with uproot 4.0.0 (running python 3.8.5)
import uproot
f = uproot.open('uproot_test.root')
h = f['hist']
print(h.axis().edges())
Bin edges output: [0.1 0.28 0.46 0.64 0.82 1. ]
It appears that uproot is grabbing the first and last bin edge and assuming a linear spacing in between, which is clearly the wrong behavior in this case. Is this a true bug? An option that I can't find? Some incompatibility between code versions?