def test_vectors_as_mixed_matrices_and_ndarrays(self):
        x = array([[1., 2., 3.]])
        y = asmatrix(array([[4., 5., 6.]]))

        expected = x.tolist()
        self.assertEqual(copy(x, y).tolist(), expected)
        self.assertEqual(y.tolist(), expected)
    def test_row_and_col_vectors_as_ndarrays(self):
        x = array([[1., 2., 3.]])
        y = array([[4.], [5.], [6.]])

        expected = [[1.], [2.], [3.]]
        self.assertEqual(copy(x, y).tolist(), expected)
        self.assertEqual(y.tolist(), expected)
    def test_negative_element(self):
        x = array([[1., -2., 3.]])
        y = array([[4., 5., 6.]])

        expected = x.tolist()
        self.assertEqual(copy(x, y).tolist(), expected)
        self.assertEqual(y.tolist(), expected)
    def test_two_row_vectors_as_ndarrays(self):
        x = array([[1., 2., 3.]])
        y = array([[4., 5., 6.]])

        expected = x.tolist()
        self.assertEqual(copy(x, y).tolist(), expected)
        self.assertEqual(y.tolist(), expected)
    def test_two_column_vectors_as_ndarrays(self):
        x = array([[1.], [2.], [3.]])
        y = array([[4.], [5.], [6.]])

        expected = x.tolist()
        self.assertEqual(copy(x, y).tolist(), expected)
        self.assertEqual(y.tolist(), expected)
    def test_scalar_as_ndarray(self):
        x = array([[1.]])
        y = array([[2.]])

        expected = x.tolist()
        self.assertEqual(copy(x, y).tolist(), expected)
        self.assertEqual(y.tolist(), expected)
    def test_unequal_strides(self):
        x = array([[1., 2., 3., 4., 5., 6.]])
        y = array([[4., 5., 6.]])

        expected = [[1., 3., 5.]]
        self.assertListEqual(copy(x, y, inc_x=2, inc_y=1).tolist(), expected)
        self.assertListEqual(y.tolist(), expected)
    def test_strides_greater_than_length(self):
        x = array([[1., 2., 3.]])
        y = array([[4., 5., 6.]])

        expected = [[1., 5., 6.]]
        self.assertListEqual(copy(x, y, inc_x=3, inc_y=3).tolist(), expected)
        self.assertListEqual(y.tolist(), expected)
    def test_float64_dtype(self):
        x = array([[1., 2., 3.]], dtype='float64')
        y = array([[3., 2., 1.]], dtype='float64')
        self.assertEqual(x.dtype, 'float64')
        self.assertEqual(y.dtype, 'float64')

        expected = x.tolist()
        self.assertListEqual(copy(x, y).tolist(), expected)
        self.assertListEqual(y.tolist(), expected)
def passed_test(dtype, as_matrix, x_is_row, y_is_row, provide_y, stride):
    """
    Run one vector copy test.

    Arguments:
        dtype:        either 'float64' or 'float32', the NumPy dtype to test
        as_matrix:    True to test a NumPy matrix, False to test a NumPy ndarray
        x_is_row:     True to test a row vector as parameter x, False to test a column vector
        y_is_row:     True to test a row vector as parameter y, False to test a column vector
        provide_y:    True if y is to be provided to the BLASpy function, False otherwise
        stride:       stride of x and y to test; if None, a random stride is assigned

    Returns:
        True if the expected result is within the margin of error of the actual result,
        False otherwise.
    """

    # generate random sizes for vector dimensions and vector stride (if necessary)
    length = randint(N_MIN, N_MAX)
    stride = randint(N_MIN, STRIDE_MAX) if stride is None else stride

    # create random vectors to test
    x = random_vector(length, x_is_row, dtype, as_matrix)
    y = random_vector(length, y_is_row, dtype, as_matrix) if provide_y else None

    # create view of x that can be used to calculate the expected result
    x_2 = x.T if x_is_row else x

    # compute the expected result
    if stride == 1:
        y_2 = x_2
    else:  # y is provided
        if provide_y:
            y_2 = np_copy(y.T) if y_is_row else np_copy(y)
        for i in range(0, length, stride):
            y_2[i, 0] = x_2[i, 0]

    # get the actual result
    y = copy(x, y, stride, stride)

    # if y is a row vector, make y_2 a row vector as well
    if y.shape[0] == 1:
        y_2 = y_2.T

    # compare the actual result to the expected result and return result of the test
    return allclose(y, y_2)
    def test_y_not_provided_with_stride_greater_than_one(self):
        x = array([[1., -2., 3.]])

        expected = [[1., 3.]]
        self.assertEqual(copy(x, inc_x=2).tolist(), expected)
    def test_y_not_provided_with_column_vector(self):
        x = array([[1.], [2.], [3.]])

        expected = x.tolist()
        self.assertEqual(copy(x).tolist(), expected)
    def test_y_not_provided_with_row_vector(self):
        x = array([[1., -2., 3.]])

        expected = x.tolist()
        self.assertEqual(copy(x).tolist(), expected)