I was trying to concatenate 1-D two arrays in Python, using numpy. One of the arrays might potentially be empty (a2 in this case). a1 and a2 are the results from some computation over which I have no control. When a1 and a2 are non-empty they both have shapes of the form (n,2), so concatenation is not a problem. However it could turn out that one of them is empty, in which case its size becomes (0,). Hence the concatenation throws up an error.
s1=array(a1).shape
s2=array(a2).shape
print(s1) #(5,2)
print(s2) #(0,)
s3=hstack((a1, a2))
s3=concatenate((a1, a2), 0)
Error: ValueError: all the input arrays must have same number of dimensions
I see other stackoverflow questions where it is said that it is possible to concatenate an empty array. How do I ensure that the empty array's size is (0,2)? Can someone help me out?