Skip to content

Bug in enqueue in Queue class #4

Description

@vstadnytskyi

The enqueue doesn't behave right if you try to append a single data point to the queue. Currently, it requires the enqueued data point to have shape (1, data_shape) to be enqueue properly.

In [55]: from circular_buffer_numpy.queue import Queue    
In [56]: queue = Queue(shape = (100,2), dtype = 'float64')        
                                       
In [57]: data_point = empty((2))                                                                       
In [58]: data_point[0] = time()                                                                        
In [59]: data_point[1] = random.randint(0,4096)        

In [60]: data_point                                                                                      
Out[60]: array([1.61452788e+09, 3.69000000e+03])

In [61]: queue.peek_all()                                                                                
Out[61]: array([], shape=(0, 2), dtype=float64)

In [62]: queue.enqueue(data_point)                                                                       

In [63]: queue.peek_all()                                                                                
Out[63]: 
array([[1.61452788e+09, 1.61452788e+09],
       [3.69000000e+03, 3.69000000e+03]])

The [out 60] should have given only one data point but returned two identical. and it has wrong orientation in the queue.

The temporary fix has to be the following:

In [61]: data_point = empty((1,2))                                                                       

In [62]: data_point[0,0] = time()                                                                        

In [63]: data_point[0,1] = random.randint(0,4096)                                                        

In [64]: queue.enqueue(data_point)                                                                       

In [65]: queue.peek_all()                                                                                
Out[65]: 
array([[1.61452788e+09, 1.61452788e+09],
       [3.69000000e+03, 3.69000000e+03],
       [1.61452918e+09, 1.19300000e+03]])

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions