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

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

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

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

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

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

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

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

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