From 40f59561f26c4319bf9965b0376e50b6d0eaf1d3 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 25 Jul 2020 22:38:01 +0100 Subject: [PATCH] compiler: Add test for length of empty arrays [nfc] This makes sure we are actually emitting this as an 1D array (like NumPy does). --- artiq/test/lit/integration/array.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/artiq/test/lit/integration/array.py b/artiq/test/lit/integration/array.py index c85ebaac1..d8e8ab15c 100644 --- a/artiq/test/lit/integration/array.py +++ b/artiq/test/lit/integration/array.py @@ -6,5 +6,10 @@ assert len(ary) == 3 # FIXME: Implement ndarray indexing # assert [x*x for x in ary] == [1, 4, 9] +# Reassign to an existing value to disambiguate type of empty array. +empty_array = array([1]) +empty_array = array([]) +assert len(empty_array) == 0 + matrix = array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]) assert len(matrix) == 2