0

I was trying to use the forloop to yield the new value into the a numpy array, then used the generated arry to make an animation of points' movement. However, there are two bugs keep showing up:

  1. I was trying to yield new value to data at end of the loop, but I was not able to replace the value into the data. the value in the data never changes throughout the iteration
  2. at the line "data = next(self.stream)", it keep showing that ‘Stop iteration’. Any idea of how to fix this?

Here is the code:

delta_dist = np.array([0,0,-0.33])
    
def data_stream(self):
        # data = np.zeros(( self.numpoints , 3 ))
        data = np.array([[0,0,0],[0,1,0],[1,0,0],[1,1,0],[0,0,1],[0,1,1],[1,0,1],[1,1,1]],dtype= 'f')
        position_coord = data[:,:3]
        p_coord_list=[]
        for N_LOOP in range(100):
            position_coord = data[:,:3] + N_LOOP*delta_dist
            print(position_coord)
            yield data
    def update(self, i):
      data = next(self.stream)
      print(data)
      self.scat._offsets3d = ( np.ma.ravel(data[:,0]) , np.ma.ravel(data[:,1]) , np.ma.ravel(data[:,2]) )
      return self.scat,

    def show(self):
        plt.show()
Jonas
  • 121,568
  • 97
  • 310
  • 388
mzzz
  • 11
  • 1

0 Answers0