Vstack() arrays must have same attributes


#1

Hello,

This is related to my other post on incrementally populating a matrix. Another way I way I thought I could do it is by stacking arrays. Can anyone help explain why the following doesn’t work? All I am doing is adding a new row to a matrix with the same number of columns. Thank you!

A = sdb.from_array([0,1,2,3])
B = sdb.from_array([3,2,1,0])
C = sdb.vstack(A,B)
C.shape
Out[135]: (2, 4)
B.shape
Out[136]: (4,)
D = sdb.vstack([C,B])
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-134-2fc7fc891395> in <module>()
----> 1 D = sdb.vstack([C,B])

/home/scidb/anaconda3/lib/python3.5/site-packages/scidbpy/interface.py in vstack(self, arrays)
   1543         hstack(), dstack(), concatenate()
   1544         """
-> 1545         return self.concatenate(arrays, axis=0)
   1546 
   1547     def dstack(self, arrays):

/home/scidb/anaconda3/lib/python3.5/site-packages/scidbpy/interface.py in concatenate(self, arrays, axis)
   1450         hstack(), vstack(), dstack()
   1451         """
-> 1452         assert_schema(arrays, bounded=True, same_attributes=True)
   1453         slice_at_end = arrays[0].ndim == 1 and axis == 1
   1454 

/home/scidb/anaconda3/lib/python3.5/site-packages/scidbpy/schema_utils.py in assert_schema(arrays, zero_indexed, bounded, same_attributes, same_dimension)
   1020                              "all dimensions")
   1021         if same_attributes and ds.sdbtype.full_rep != ds0.sdbtype.full_rep:
-> 1022             raise ValueError("Input arrays must have the same attributes")
   1023 
   1024     return tuple(arrays)

ValueError: Input arrays must have the same attributes

D = sdb.vstack([C,B.reshape(1,4)])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-137-17039ce9df06> in <module>()
----> 1 D = sdb.vstack([C,B.reshape(1,4)])

TypeError: reshape() takes 2 positional arguments but 3 were given

D = sdb.vstack([C,B.reshape([1,4])])
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-138-b9e5e50e1ec0> in <module>()
----> 1 D = sdb.vstack([C,B.reshape([1,4])])

/home/scidb/anaconda3/lib/python3.5/site-packages/scidbpy/interface.py in vstack(self, arrays)
   1543         hstack(), dstack(), concatenate()
   1544         """
-> 1545         return self.concatenate(arrays, axis=0)
   1546 
   1547     def dstack(self, arrays):

/home/scidb/anaconda3/lib/python3.5/site-packages/scidbpy/interface.py in concatenate(self, arrays, axis)
   1450         hstack(), vstack(), dstack()
   1451         """
-> 1452         assert_schema(arrays, bounded=True, same_attributes=True)
   1453         slice_at_end = arrays[0].ndim == 1 and axis == 1
   1454 

/home/scidb/anaconda3/lib/python3.5/site-packages/scidbpy/schema_utils.py in assert_schema(arrays, zero_indexed, bounded, same_attributes, same_dimension)
   1020                              "all dimensions")
   1021         if same_attributes and ds.sdbtype.full_rep != ds0.sdbtype.full_rep:
-> 1022             raise ValueError("Input arrays must have the same attributes")
   1023 
   1024     return tuple(arrays)

ValueError: Input arrays must have the same attributes