Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/uproot/reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,18 @@ def class_named(self, classname, version=None):
if len(streamers) == 0 and self._custom_classes is not None:
cls = uproot.classes.get(classname)

if (
cls is None
and re.match(
r"(std\s*::\s*)?(vector)?(map)?(set)?(string)?(bitset)?\s*<", classname
)
is not None
):
cls = uproot.interpretation.identify.parse_typename(classname)
cls._header = False

return cls

if cls is None:
if len(streamers) == 0:
unknown_cls = uproot.unknown_classes.get(classname)
Expand Down
25 changes: 25 additions & 0 deletions tests/test_1180_read_free_floating_vector_issue_1179.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE

import pytest
import uproot
import os
import numpy as np

ROOT = pytest.importorskip("ROOT")


def test_read_free_floating_vector(tmp_path):
newfile = os.path.join(tmp_path, "test_freevec.root")
f = ROOT.TFile(newfile, "recreate")
a = np.array([1.0, 2.0, 3.0, 4.0], dtype=np.float64)
c = np.array([0, 1, 4, 5, 6, 7, 8, 9], dtype=np.uint32)
avec = ROOT.std.vector("double")(a)
bvec = ROOT.std.vector("unsigned int")(c)
f.WriteObject(avec, "avec")
f.WriteObject(bvec, "bvec")
f.Write()
f.Close()

with uproot.open(newfile) as f:
assert f["avec"].tolist() == [1.0, 2.0, 3.0, 4.0]
assert f["bvec"].tolist() == [0, 1, 4, 5, 6, 7, 8, 9]