From bf5c1575b2ab594c795e93564f0e8b5c727d48c4 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Tue, 3 Oct 2023 15:23:57 +0100 Subject: [PATCH] fix: allow known-buffers in unknown-length contexts --- src/awkward/operations/ak_from_buffers.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/awkward/operations/ak_from_buffers.py b/src/awkward/operations/ak_from_buffers.py index f877630a81..593677fa41 100644 --- a/src/awkward/operations/ak_from_buffers.py +++ b/src/awkward/operations/ak_from_buffers.py @@ -149,9 +149,8 @@ def _from_buffer( # for the parent of this node. Thus, this node and its children *must* only # contain placeholders if count is unknown_length: - # Only placeholders can have unknown lengths - if not isinstance(buffer, PlaceholderArray): - raise AssertionError("Encountered unknown length for concrete buffer") + # We may actually have a known buffer here, but as we do not know the length, + # we cannot safely trim it. Thus, introduce a placeholder anyway return PlaceholderArray(nplike, (unknown_length,), dtype) # Known-length information implies that we should have known-length buffers here # We could choose to make this an error, and have the caller re-implement some