No copy conversion from TTreeReaderArray<float> to numpy.array

So, I checked: PyROOT converts pointers to python buffer objects of 1 element, but there is a SetSize method to change the buffer size.

@mverzett1 maybe, if all array elements are contiguous in memory, you can do

size = arr.GetSize() # force loading of array contents for this entry
buf = arr.GetAddress() # still not sure this is always equivalent to `&arr[0]`
buf.SetSize(size)
np.frombuffer(buf, count=size, dtype='float32')
1 Like