Beispiel #1
0
    def test_lt(self):
        T_r = ht.uint8([[1, 0], [0, 0]])

        T_inv = ht.uint8([[0, 0], [1, 1]])

        self.assertTrue(ht.equal(ht.lt(s, s), ht.uint8([0])))
        self.assertTrue(ht.equal(ht.lt(T, s), T_r))
        self.assertTrue(ht.equal(ht.lt(s, T), T_inv))
        self.assertTrue(ht.equal(ht.lt(T, T1), T_r))
        self.assertTrue(ht.equal(ht.lt(T, v), T_r))
        self.assertTrue(ht.equal(ht.lt(T, s_int), T_r))
        self.assertTrue(ht.equal(ht.lt(T_s, T), T_inv))

        with self.assertRaises(ValueError):
            ht.lt(T, v2)
        with self.assertRaises(NotImplementedError):
            ht.lt(T, Ts)
        with self.assertRaises(TypeError):
            ht.lt(T, otherType)
        with self.assertRaises(TypeError):
            ht.lt('T', 's')
Beispiel #2
0
    def test_lt(self):
        result = ht.uint8([[1, 0], [0, 0]], device=ht_device)
        commutated_result = ht.uint8([[0, 0], [1, 1]], device=ht_device)

        self.assertTrue(
            ht.equal(ht.lt(self.a_scalar, self.a_scalar), ht.uint8([0])))
        self.assertTrue(ht.equal(ht.lt(self.a_tensor, self.a_scalar), result))
        self.assertTrue(
            ht.equal(ht.lt(self.a_scalar, self.a_tensor), commutated_result))
        self.assertTrue(
            ht.equal(ht.lt(self.a_tensor, self.another_tensor), result))
        self.assertTrue(ht.equal(ht.lt(self.a_tensor, self.a_vector), result))
        self.assertTrue(
            ht.equal(ht.lt(self.a_tensor, self.an_int_scalar), result))
        self.assertTrue(
            ht.equal(ht.lt(self.a_split_tensor, self.a_tensor),
                     commutated_result))

        with self.assertRaises(ValueError):
            ht.lt(self.a_tensor, self.another_vector)
        with self.assertRaises(TypeError):
            ht.lt(self.a_tensor, self.errorneous_type)
        with self.assertRaises(TypeError):
            ht.lt("self.a_tensor", "s")
    def test_lt(self):
        result = ht.array([[True, False], [False, False]])
        commutated_result = ht.array([[False, False], [True, True]])

        self.assertTrue(
            ht.equal(ht.lt(self.a_scalar, self.a_scalar), ht.array(False)))
        self.assertTrue(ht.equal(ht.lt(self.a_tensor, self.a_scalar), result))
        self.assertTrue(
            ht.equal(ht.lt(self.a_scalar, self.a_tensor), commutated_result))
        self.assertTrue(
            ht.equal(ht.lt(self.a_tensor, self.another_tensor), result))
        self.assertTrue(ht.equal(ht.lt(self.a_tensor, self.a_vector), result))
        self.assertTrue(
            ht.equal(ht.lt(self.a_tensor, self.an_int_scalar), result))
        self.assertTrue(
            ht.equal(ht.lt(self.a_split_tensor, self.a_tensor),
                     commutated_result))

        self.assertEqual(
            ht.lt(self.a_split_tensor, self.a_tensor).dtype, ht.bool)

        with self.assertRaises(ValueError):
            ht.lt(self.a_tensor, self.another_vector)
        with self.assertRaises(TypeError):
            ht.lt(self.a_tensor, self.errorneous_type)
        with self.assertRaises(TypeError):
            ht.lt("self.a_tensor", "s")