Ejemplo n.º 1
0
    def test_empty(self):

        A, B, C, D = self.data()

        expected = cupy.empty((0, 0), dtype=self.dtype)
        testing.assert_array_equal(
            construct.bmat([[None, None]]).todense(), expected)
        testing.assert_array_equal(
            construct.bmat([[None, D], [D, None]]).todense(), expected)
Ejemplo n.º 2
0
    def test_failure_cases(self):

        A, B, C, D = self.data()

        match = r'.*Got blocks\[{}\]\.shape\[{}\] == 1, expected 2'

        # test failure cases
        message1 = re.compile(match.format('1,0', '1'))
        with pytest.raises(ValueError, match=message1):
            construct.bmat([[A], [B]], dtype=self.dtype)

        message2 = re.compile(match.format('0,1', '0'))
        with pytest.raises(ValueError, match=message2):
            construct.bmat([[A, C]], dtype=self.dtype)
Ejemplo n.º 3
0
    def test_edge_cases(self):
        """Catch-all for small edge cases"""

        A, B, C, D = self.data()

        expected = cupy.asarray([[7]], dtype=self.dtype)
        testing.assert_array_equal(
            construct.bmat([[None, D], [C, None]]).todense(), expected)
Ejemplo n.º 4
0
    def test_basic_inputs(self):

        A, B, C, D = self.data()

        expected = cupy.asarray([[1, 2, 5], [3, 4, 6], [0, 0, 7]],
                                dtype=self.dtype)

        testing.assert_array_equal(
            construct.bmat([[A, B], [None, C]]).todense(), expected)

        expected = cupy.asarray([[1, 2, 0], [3, 4, 0], [0, 0, 7]])
        testing.assert_array_equal(
            construct.bmat([[A, None], [None, C]]).todense(), expected)

        expected = cupy.asarray([[0, 5], [0, 6], [7, 0]])

        testing.assert_array_equal(
            construct.bmat([[None, B], [C, None]]).todense(), expected)