scikit-hep / uproot3

ROOT I/O in pure Python and NumPy.
BSD 3-Clause "New" or "Revised" License
314 stars 67 forks source link

Unable to create unsigned integer branches #505

Open masonproffitt opened 4 years ago

masonproffitt commented 4 years ago

This is what I get when I try to make an unsigned integer branch:

>>> import numpy as np
>>> import uproot
>>> file = uproot.recreate('test.root')
>>> file['tree'] = uproot.newtree({'branch': np.uint32})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/uproot/write/TFile.py", line 84, in __setitem__
    what = TTree(where, what, self)
  File "/usr/lib/python3.8/site-packages/uproot/write/objects/TTree.py", line 85, in __init__
    self._branches[name] = TBranch(name, branch, compression, self, file)
  File "/usr/lib/python3.8/site-packages/uproot/write/objects/TTree.py", line 252, in __init__
    self._branch = TBranchImpl(name, branchobj, compression, file)
  File "/usr/lib/python3.8/site-packages/uproot/write/objects/TTree.py", line 820, in __init__
    raise NotImplementedError
NotImplementedError
jpivarski commented 4 years ago

Yup:

https://github.com/scikit-hep/uproot/blob/634667fad826ec6c86e2df442887b1024c2cfee8/uproot/write/objects/TTree.py#L797-L820

Handling unsigned integers will involve setting fIsUnsigned, a TLeaf attribute.

https://github.com/scikit-hep/uproot/blob/634667fad826ec6c86e2df442887b1024c2cfee8/uproot/write/objects/TTree.py#L898-L907