def test_enqueue_array(inputs):
    n = inputs.shape[0]
    q = SimpleLabellingQueue()
    q.enqueue_many(inputs)
    assert len(q.data) == n
    # assert we can pop everything:
    for _ in range(n):
        id_, val = q.pop()
        assert isinstance(val, np.ndarray)
        assert len(val.shape) == 1
        assert val.size == inputs.shape[-1]
    # assert there's nothing else to pop:
    with pytest.raises(IndexError):
        q.pop()
    # assert it re-constructs a df on list all
    if n > 0:
        ids, X, y = q.list_all()
        assert isinstance(X, np.ndarray)
def test_list_all(inputs, labels):
    q = SimpleLabellingQueue()
    q.enqueue_many(inputs)

    popped_ids = []
    for i in range(5):
        id_, val = q.pop()
        q.submit(id_, labels[i])

        popped_ids.append(id_)

    ids, x, y = q.list_all()

    assert len(ids) == len(inputs)
    assert all(label in labels for label in y if label is not None)
    assert all(label is None or id_ in popped_ids
               for id_, label in zip(ids, y))
    assert Counter(y)[None] == (len(inputs) - 5)
    assert pytest.helpers.same_elements(ids, range(len(inputs)))
def test_enqueue_dataframe(inputs):
    n = len(inputs)
    q = SimpleLabellingQueue()
    q.enqueue_many(inputs)
    assert len(q.data) == n
    # assert we can pop everything:
    for _ in range(n):
        id_, val = q.pop()
        assert isinstance(val, pd.Series)
    # assert there's nothing else to pop:
    with pytest.raises(IndexError):
        q.pop()
    # assert it re-constructs a df on list all
    if n > 0:
        ids, X, y = q.list_all()
        assert isinstance(X, pd.DataFrame) or len(X) == 0
        # assert it re-constructs a df on list uncomplete
        q.submit(ids[0], "hello")
        ids, X = q.list_uncompleted()
        assert isinstance(X, pd.DataFrame) or len(X) == 0
        # assert it re-constructs a df on list uncomplete
        ids, X, y = q.list_completed()
        assert isinstance(X, pd.DataFrame) or len(X) == 0