From 3a22dd49f4e5f60729e5f3d15058ae0f65d8e1e8 Mon Sep 17 00:00:00 2001 From: Vasileios Georgios Vasilopoulos Date: Mon, 29 Jul 2024 14:28:00 +0200 Subject: [PATCH] Fix error on yakut/cmd/monitor/_model.py (#108) While passing a Node List (7519.List.1.0.dsdl) from a hardware node to Ubuntu, yakut monitor produces the following error: pycyphal.util._broadcast: Unhandled exception in : The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() File "/home/$USER/.local/lib/python3.12/site-packages/yakut/cmd/monitor/_model.py", line 195, in expand_subjects if m.mask: ^^^^^^ ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() The node list is produced using .h files produced by nnvg and the "mask_bitpacked_" field is used instead of "sparse_list" The error is solved by first checking that the mask is not None and then checking if it is empty with .any(). --------- Authored-by" Vasileios Vasilopoulos Co-authored-by: Pavel Kirienko --- .github/workflows/test-and-release.yml | 10 +++++++--- yakut/VERSION | 2 +- yakut/cmd/monitor/_model.py | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index ebf768c..9ea622c 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -1,5 +1,5 @@ -name: 'Test and Release Yakut' -on: push +name: 'Test and release Yakut' +on: [ push, pull_request ] # Ensures that only one workflow is running at a time concurrency: @@ -9,6 +9,8 @@ concurrency: jobs: yakut-test: name: Test Yakut + # https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=edited#pull_request + if: (github.event_name == 'push') || github.event.pull_request.head.repo.fork strategy: fail-fast: false matrix: @@ -71,7 +73,9 @@ jobs: yakut-release: name: Release Yakut runs-on: ubuntu-latest - if: contains(github.event.head_commit.message, '#release') || contains(github.ref, '/main') + if: > + (github.event_name == 'push') && + (contains(github.event.head_commit.message, '#release') || contains(github.ref, '/main')) needs: yakut-test steps: - name: Check out diff --git a/yakut/VERSION b/yakut/VERSION index 9beb74d..288adf5 100644 --- a/yakut/VERSION +++ b/yakut/VERSION @@ -1 +1 @@ -0.13.2 +0.13.3 diff --git a/yakut/cmd/monitor/_model.py b/yakut/cmd/monitor/_model.py index 8add024..eaa28e9 100644 --- a/yakut/cmd/monitor/_model.py +++ b/yakut/cmd/monitor/_model.py @@ -191,8 +191,8 @@ def __repr__(self) -> str: def expand_subjects(m: uavcan.node.port.SubjectIDList_1) -> AbstractSet[int]: if m.sparse_list is not None: return frozenset(int(x.value) for x in m.sparse_list) - if m.mask: - return expand_mask(m.mask) + if m.mask is not None and m.mask.any(): + return expand_mask(m.mask) if m.total: return _COMPLETE_SUBJECT_SET assert False