From 49b3ab96c5b22e8613ab37e4fd6f9737901a57f6 Mon Sep 17 00:00:00 2001 From: Sponge166 <115596620+Sponge166@users.noreply.github.com> Date: Thu, 11 Jun 2026 11:52:20 -0400 Subject: [PATCH 1/2] Update digital_rf_hdf5.py read_vector_raw would error if vector_length==1 and only one subchannel is read from, due to z.squeeze() returning a scalar when z contains one sample. --- python/digital_rf/digital_rf_hdf5.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/digital_rf/digital_rf_hdf5.py b/python/digital_rf/digital_rf_hdf5.py index 4b57f1c..74c27b5 100644 --- a/python/digital_rf/digital_rf_hdf5.py +++ b/python/digital_rf/digital_rf_hdf5.py @@ -1492,7 +1492,12 @@ def read_vector_raw( key, z = data_dict.popitem() # always return 1-D if possible - z = z.squeeze() + if all([d == 1 for d in z.shape]): + # if z contains only one sample, then z.squeeze() returns a scalar + # which makes len(z) error, hence: + z = z.flatten() + else: + z = z.squeeze() if len(z) != vector_length: errstr = "Requested %i samples, but got %i" From e6a92c446019ed71ded8ed519457a71eea2f6eea Mon Sep 17 00:00:00 2001 From: Ryan Volz Date: Thu, 11 Jun 2026 12:05:32 -0400 Subject: [PATCH 2/2] digital_rf_hdf5: Use np.atleast_1d to ensure no scalar is returned --- python/digital_rf/digital_rf_hdf5.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/python/digital_rf/digital_rf_hdf5.py b/python/digital_rf/digital_rf_hdf5.py index 74c27b5..a00d3a7 100644 --- a/python/digital_rf/digital_rf_hdf5.py +++ b/python/digital_rf/digital_rf_hdf5.py @@ -1491,13 +1491,8 @@ def read_vector_raw( raise IOError(errstr % (start_sample, vector_length, channel_name)) key, z = data_dict.popitem() - # always return 1-D if possible - if all([d == 1 for d in z.shape]): - # if z contains only one sample, then z.squeeze() returns a scalar - # which makes len(z) error, hence: - z = z.flatten() - else: - z = z.squeeze() + # always return 1-D if possible, need atleast_1d in case 1 sample was requested + z = np.atleast_1d(z.squeeze()) if len(z) != vector_length: errstr = "Requested %i samples, but got %i"