scikit-hep / uproot3

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

flushsize argument for newtree raises TypeError #522

Closed lkorley closed 3 years ago

lkorley commented 3 years ago

I am running into a TypeError when trying to set flushsize for calls to newtree. Running this using uproot 3.12.0 installed with pip Code that recreates the problem:

import uproot
import numpy
with uproot.recreate("tst.root") as uf:
    uf["TstTree"] = uproot.newtree({"branch1":np.int64},flushsize="10 MB")
    #uf["TstTree"].extend({"branch1":numpy.random.poisson(1,1000)})

The error message:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-da1c50e99eff> in <module>
      2 import numpy
      3 with uproot.recreate("tst.root") as uf:
----> 4     uf["TstTree"] = uproot.newtree({"branch1":np.int64},flushsize="10 MB")
      5     #uf["TstTree"].extend({"branch1":numpy.random.poisson(1,1000)})

~/miniconda3/envs/DDC10Ana/lib/python3.6/site-packages/uproot/write/objects/TTree.py in __init__(self, branches, title, **options)
     45             del options["compression"]
     46         if len(options) > 0:
---> 47             raise TypeError("{0} not supported".format(options))
     48 
     49 class TTree(object):

TypeError: {'flushsize': '10 MB'} not supported
jpivarski commented 3 years ago

@reikdas, do you remember if flushsize is a part of the final newtree interface? Is that a hold-over from an old tutorial? I think it's not a meaningful option because the final API doesn't flush automatically, right? (To get 10 MB baskets, one has to call extend with 10 MB arrays...)

@lkorley, I know that the proper thing to do is to document the final API, and file-writing doesn't have documentation right now. The next step is to port file-writing to Uproot 4 and fully document it in that version.

reikdas commented 3 years ago

@reikdas, do you remember if flushsize is a part of the final newtree interface? Is that a hold-over from an old tutorial? I think it's not a meaningful option because the final API doesn't flush automatically, right? (To get 10 MB baskets, one has to call extend with 10 MB arrays...)

We had the flushsize option for a while, but we dropped it later. The current version does not support it I think.

lkorley commented 3 years ago

Ahh okay. Thanks