From 4ff9f8a25988b9d6a6da75700241c7e5af950b96 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Fri, 15 Nov 2024 13:16:00 +0100 Subject: [PATCH 1/2] [bug fix] fix read_as() with file list of length 1 --- src/lgdo/lh5/core.py | 4 ++++ tests/lh5/test_core.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/lgdo/lh5/core.py b/src/lgdo/lh5/core.py index b78a3217..1fad8232 100644 --- a/src/lgdo/lh5/core.py +++ b/src/lgdo/lh5/core.py @@ -120,6 +120,7 @@ def read( lh5_obj = lh5_file[name] else: lh5_files = list(lh5_file) + n_rows_read = 0 obj_buf_is_new = False @@ -353,5 +354,8 @@ def read_as( # NOTE: providing a buffer does not make much sense obj = read(name, lh5_file, **kwargs1) + if isinstance(obj, tuple): + obj = obj[0] + # and finally return a view return obj.view_as(library, **kwargs2) diff --git a/tests/lh5/test_core.py b/tests/lh5/test_core.py index 2db57634..5bf4f877 100644 --- a/tests/lh5/test_core.py +++ b/tests/lh5/test_core.py @@ -38,6 +38,8 @@ def test_read_as(lh5_file): ) assert obj1.equals(obj2) + obj2 = lh5.read_as("/data/struct/table", [lh5_file], "ak") + def test_read_multiple_files(lh5_file): lh5_obj = lh5.read("/data/struct/array", [lh5_file, lh5_file, lh5_file]) From 4fd74eebf3a7f569c8b518e193711ed6fb860971 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Fri, 15 Nov 2024 13:45:03 +0100 Subject: [PATCH 2/2] Fix for recent Awkward release --- src/lgdo/types/vectorofvectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lgdo/types/vectorofvectors.py b/src/lgdo/types/vectorofvectors.py index 3af27fde..cb36f438 100644 --- a/src/lgdo/types/vectorofvectors.py +++ b/src/lgdo/types/vectorofvectors.py @@ -503,7 +503,7 @@ def __iter__(self) -> Iterator[NDArray]: def __str__(self) -> str: string = self.view_as("ak").show(stream=None) - string = string.strip().removesuffix("]") + string = str(string).strip().removesuffix("]") string += "\n]" tmp_attrs = self.attrs.copy()