-
Notifications
You must be signed in to change notification settings - Fork 54
Conversation
I believe array2root is a single output file, when you run it twice, it
|
It depends on the mode you pass to array2root. |
A wrapper for pandas! Nice! Yes, array2root just writes out a file and will overwrite an existing file (the mode keyword argument can be used to update an existing file, but a tree with the same name would just be "overwritten"). Use array2tree instead of array2root. array2tree will extend an existing tree: 315 def array2tree(arr, name='tree', tree=None):
316 """Convert a numpy structured array into a ROOT TTree.
317
318 .. warning::
319 This function is experimental. Please report problems.
320 Not all data types are supported (``np.object`` and ``np.float16``).
321
322 Parameters
323 ----------
324 arr : array
325 A numpy structured array
326 name : str (optional, default='tree')
327 Name of the created ROOT TTree if ``tree`` is None.
328 tree : existing ROOT TTree (optional, default=None)
329 Any branch with the same name as a field in the
330 numpy array will be extended as long as the types are compatible,
331 otherwise a TypeError is raised. New branches will be created
332 and filled for all new fields. |
Although, this would be a nice feature to add. I think we should enable growing an existing TTree with array2root also. But for now, array2tree should do the job. |
Checking the diff and will merge. |
@ibab what version of Cython did you run? 0.21.2? |
(Sorry, originally thought this was an issue report, but then realised it is a pull request!) |
I think I ran 0.21, but I could rerun with 0.21.2. |
Great, yes better to use the latest. Then I will merge. |
Ok, I ran 0.21.2 and amended the commit. |
Append to existing tree in array2root
thanks! |
Thanks! That will make stream processing of ROOT files very convenient. |
3.4.0 is released: https://pypi.python.org/pypi/root_numpy |
Hi,
while working on a pandas wrapper for root_numpy (https://github.com/ibab/root_pandas) I noticed that
array2root
doesn't properly append to existing TTrees: the file just gets larger and larger, but only the last saved version of the tree is accessible.As far as I can tell, this can be fixed by looking for an existing tree and passing it to array2tree.
What do you think?