python - Shape of numpy array is changing while saving the data -


i've defined following arrays:

self._list = np.zeros((1, 180)) 

in init method of class

and

lidar_data = np.zeros((1, 180)) 

in call method of same class

call method called indefinitely.

i save data lidar sensor , analyze i'm doing,

self._list = np.vstack((self._list, lidar_data[none, :])) 

when print lidar_data.shape, comes (1, 180) when

self._list = np.vstack((self._list, lidar_data[none, :])) 

is commented out, when not commented,

lidar_data.shape comes out (1, 0)

and because of i'm unable save data , following error

  file "/usr/local/lib/python2.7/dist-packages/numpy/core/shape_base.py", line 230, in vstack     return _nx.concatenate([atleast_2d(_m) _m in tup], 0) valueerror: input array dimensions except concatenation axis must match 

why value of lidar_data.shape changing? better way of saving data this?

edit:

though lidar_data has shape of (1, 180) initially, after data taken it's shape (180, ) doing lidar_data[none, :] shape (1, 180).

edit 2:

lidar_data = np.zeros((1, 180)) lidar_data = controller.sensor(33).getmeasurements() lidar_data = np.array(lidar_data) #shape (180, ) lidar_data = lidar_data[none, :]  #shape (1, 180)   print 'self._list: ', self._list.shape #shape (1, 180) print 'lidar_data: ', lidar_data.shape #shape(1, 180) #self._list = np.vstack((self._list, lidar_data))   works fine,and output   self._list:  (1, 180) lidar_data:  (1, 180)   problem arises when  print 'self._list: ', self._list.shape print 'lidar_data: ', lidar_data.shape self._list = np.vstack((self._list, lidar_data)) 

when run script, following errors,

self._list:  (1, 180) lidar_data:  (1, 0)  file "/usr/local/lib/python2.7/dist-packages/numpy/core/shape_base.py", line 230, in vstack     return _nx.concatenate([atleast_2d(_m) _m in tup], 0) valueerror: input array dimensions except concatenation axis must match 


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -