Skip to content

TypeError while reading branch containing vector of custom objects containing TArrayF #1529

@renyhp

Description

@renyhp

uproot version: 5.6.8

Here is the test file: test.root

And here is the simple code that breaks:

>>> uproot.open('test.root')['Test/Event/fTracks/fTracks.fPositions'].arrays()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "lib/python3.10/site-packages/uproot/behaviors/TBranch.py", line 874, in arrays
    return self._eager_arrays(
  File "lib/python3.10/site-packages/uproot/behaviors/TBranch.py", line 1135, in _eager_arrays
    return self.parent._eager_arrays(
  File "lib/python3.10/site-packages/uproot/behaviors/TBranch.py", line 1198, in _eager_arrays
    _ranges_or_baskets_to_arrays(
  File "lib/python3.10/site-packages/uproot/behaviors/TBranch.py", line 3513, in _ranges_or_baskets_to_arrays
    uproot.source.futures.delayed_raise(*obj)
  File "lib/python3.10/site-packages/uproot/source/futures.py", line 38, in delayed_raise
    raise exception_value.with_traceback(traceback)
  File "lib/python3.10/site-packages/uproot/behaviors/TBranch.py", line 3449, in basket_to_array
    basket_array = interpretation.basket_array(
  File "lib/python3.10/site-packages/uproot/interpretation/objects.py", line 175, in basket_array
    output = self.basket_array_forth(
  File "lib/python3.10/site-packages/uproot/interpretation/objects.py", line 261, in basket_array_forth
    output = self._discover_forth(
  File "lib/python3.10/site-packages/uproot/interpretation/objects.py", line 421, in _discover_forth
    output[i] = self._model.read(
  File "lib/python3.10/site-packages/uproot/containers.py", line 765, in read
    while cursor.displacement(start_cursor) < num_bytes:
TypeError: '<' not supported between instances of 'int' and 'NoneType'

Thanks!

PS: Here is the ROOT code to make the test file, if that's useful:

class MyTrack {
public:
  MyTrack(int n) {fPositions.Set(n);};
private:
  TArrayF fPositions;
};


class MyEvent {
public:
  void ClearTracks() { fTracks.clear(); };
  void AddTrack(MyTrack track) { fTracks.push_back(track); };
  
private:
  std::vector<MyTrack> fTracks;
};


void test() {
  auto f = new TFile("test.root", "RECREATE");
  auto t = new TTree("Test", "Test");
  auto ev = new MyEvent();
  t->Branch("Event", &ev);
  ev->AddTrack(MyTrack(3));
  t->Fill();
  t->Write();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThe problem described is something that must be fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions