Пример #1
0
    def test_is_equal_incorrect(self):
        # Tests that a ValueError is raised when called on one 1D array with
        # another array of different shape and the wrong data type
        array1 = Array((3, ), 1, 2, 3)
        array2 = Array((2, ), 2, 3)

        with pytest.raises(ValueError):
            array1.is_equal(array2)
            array1.is_equal("string")
Пример #2
0
def test_is_equal(arg, other, expected):
    """
    Verify that comparison of arrays evaluates correctly
    """
    my_arr = Array(arg[0], *arg[1])
    other_arr = Array(other[0], *other[1])
    assert my_arr.is_equal(other_arr).flatten == expected
Пример #3
0
    def test_is_equal_2d_array(self):
        # Tests two 2D arrays with integers
        array1 = Array((2, 3), 1, 2, 3, 4, 5, 6)
        array2 = Array((2, 3), 2, 3, 3, 5, 6, 6)
        result = array1.is_equal(array2)
        expected = Array((2, 3), False, False, True, False, False, True)

        assert result == expected
Пример #4
0
    def test_is_equal_int(self):
        # Tests one 1D array with integers and a integer as parameter
        array1 = Array((3, ), 1, 2, 3)
        number = 2
        result = array1.is_equal(number)
        expected = Array((3, ), False, True, False)

        assert result == expected
Пример #5
0
    def test_is_equal_array(self):
        # Tests two 1D arrays with integers
        array1 = Array((3, ), 1, 2, 3)
        array2 = Array((3, ), 1, 5, -3)
        result = array1.is_equal(array2)
        expected = Array((3, ), True, False, False)

        assert result == expected