codezonediitj / pydatastructs

A python package for data structures and algorithms
https://pydatastructs.readthedocs.io/en/stable/
Other
202 stars 270 forks source link

CI Failure for `select()` in `test_select_rank()`. Works locally. #566

Open Kishan-Ved opened 4 months ago

Kishan-Ved commented 4 months ago

Description of the problem

In the file: pydatastructs/trees/tests/test_binary_trees.py, inside the _test_AVLTree() function, there is a function called test_select_rank(). This contains a code snippet (that tests the select() method) which is run only when the backend is Python. This is because if we run them in C++ backend, some CI checks fail. However, the code passes when run on my local machine (laptop - Ubuntu). This is the test_select_rank() function:

    def test_select_rank(expected_output):
        if backend==Backend.PYTHON:
            output = []
            for i in range(len(expected_output)):
                output.append(a5.select(i + 1).key)
            assert output == expected_output
        output = []
        expected_ranks = [i + 1 for i in range(len(expected_output))]
        for i in range(len(expected_output)):
            output.append(a5.rank(expected_output[i]))
        assert output == expected_ranks

Notice the snippet that runs only when the backend is PYTHON:

        if backend==Backend.PYTHON:
            output = []
            for i in range(len(expected_output)):
                output.append(a5.select(i + 1).key)
            assert output == expected_output

This was added in the PR: https://github.com/codezonediitj/pydatastructs/pull/564