def test_lu_basic_returns_expected_shapes(self, arrays):
        m_sb, m_bb, m_bs = arrays
        wide, big, tall = [arr.shape for arr in arrays]
        hy.assume(hn.wide(m_sb))

        # with self.subTest(msg="square"):
        self.assertArrayShapesAre(gfl.lu_m(m_bb), (big, big, big[:-1]))
        self.assertArrayShapesAre(gfl.lu_n(m_bb), (big, big, big[:-1]))
        # with self.subTest(msg="wide"):
        self.assertArrayShapesAre(gfl.lu_m(m_sb),
                                  (utn.chop(wide), wide, wide[:-1]))
        self.assertArrayShapesAre(gfl.lu_n(m_sb),
                                  (wide, utn.grow(wide), utn.drop(wide)))
        # with self.subTest(msg="tall"):
        self.assertArrayShapesAre(gfl.lu_m(m_bs),
                                  (utn.grow(tall), tall, tall[:-1]))
        self.assertArrayShapesAre(gfl.lu_n(m_bs),
                                  (tall, utn.chop(tall), utn.drop(tall)))
Пример #2
0
    def test_lqr(self, arrays):
        m_sb, m_bs = arrays
        wide, tall = [arr.shape for arr in arrays]
        hy.assume(hn.wide(m_sb))

        # with self.subTest("reduced"):
        self.assertArrayShapesAre(la.lqr(m_bs, 'reduced'),
                                  (tall, utn.chop(tall)))
        self.assertArrayShapesAre(la.lqr(m_sb, 'reduced'),
                                  (utn.chop(wide), wide))
        # with self.subTest("complete"):
        self.assertArrayShapesAre(la.lqr(m_bs, 'complete'),
                                  (utn.grow(tall), tall))
        self.assertArrayShapesAre(la.lqr(m_sb, 'complete'),
                                  (wide, utn.grow(wide)))
        # with self.subTest("r/l/raw"):
        self.assertArrayShape(la.lqr(m_bs, 'l'), utn.chop(tall))
        self.assertArrayShape(la.lqr(m_sb, 'l'), utn.chop(wide))
        self.assertArrayShape(la.lqr(m_bs, 'r'), utn.chop(tall))
        self.assertArrayShape(la.lqr(m_sb, 'r'), utn.chop(wide))
        self.assertArrayShapesAre(la.lqr(m_bs, 'raw'),
                                  (utn.trnsp(tall), utn.drop(tall)))
        self.assertArrayShapesAre(la.lqr(m_sb, 'raw'),
                                  (utn.trnsp(wide), wide[:-1]))
Пример #3
0
    def test_lq_returns_expected_shapes(self, arrays):
        m_sb, m_bs = arrays
        wide, tall = [arr.shape for arr in arrays]
        hy.assume(hn.wide(m_sb))

        # with self.subTest(msg='wide'):
        self.assertArrayShapesAre(gfl.lq_m(m_sb), (utn.chop(wide), wide))
        self.assertArrayShape(gfl.lq_lm(m_sb), utn.chop(wide))
        # with self.subTest(msg='tall'):
        self.assertArrayShapesAre(gfl.lq_n(m_bs), (tall, utn.chop(tall)))
        self.assertArrayShape(gfl.lq_ln(m_bs), tall)
        with self.assertRaisesRegex(*utn.invalid_err):
            gfl.lq_m(m_bs)
        # with self.subTest(msg='complete'):
        self.assertArrayShapesAre(gfl.lq_n(m_sb), (wide, utn.grow(wide)))
        # with self.subTest(msg='raw'):
        self.assertArrayShapesAre(gfl.lq_rawm(m_sb),
                                  (utn.trnsp(wide), wide[:-1]))
        self.assertArrayShapesAre(gfl.lq_rawn(m_bs),
                                  (utn.trnsp(tall), utn.drop(tall)))