def test_index_error(self):
        d = Domain((age, gender, income), metas=(ssn, race))
        for idx in (3, np.int(3), -3, np.int(-3), incomeA, "no_such_thing"):
            with self.assertRaises(ValueError):
                d.index(idx)

        with self.assertRaises(TypeError):
            d.index([2])
Esempio n. 2
0
    def test_index_error(self):
        d = Domain((age, gender, income), metas=(ssn, race))
        for idx in (3, np.int(3), -3, np.int(-3), incomeA, "no_such_thing"):
            with self.assertRaises(ValueError):
                d.index(idx)

        with self.assertRaises(TypeError):
            d.index([2])
Esempio n. 3
0
 def test_index_error(self):
     d = Domain((age, gender, income), metas=(ssn, race))
     with self.assertRaises(ValueError):
         d.index(3)
     with self.assertRaises(ValueError):
         d.index(-3)
     with self.assertRaises(ValueError):
         d.index(incomeA)
     with self.assertRaises(ValueError):
         d.index("no_such_thing")
     with self.assertRaises(TypeError):
         d.index([2])
Esempio n. 4
0
    def test_index(self):
        d = Domain((age, gender, income), metas=(ssn, race))
        self.assertEqual(d.index(age), 0)
        self.assertEqual(d.index("AGE"), 0)
        self.assertEqual(d.index(0), 0)

        self.assertEqual(d.index(income), 2)
        self.assertEqual(d.index("income"), 2)
        self.assertEqual(d.index(2), 2)

        self.assertEqual(d.index(ssn), -1)
        self.assertEqual(d.index("SSN"), -1)
        self.assertEqual(d.index(-1), -1)

        self.assertEqual(d.index(-2), -2)
Esempio n. 5
0
 def test_index(self):
     d = Domain((age, gender, income), metas=(ssn, race))
     for idx, var in [(age, 0), ("AGE", 0), (0, 0), (np.int_(0), 0),
                      (income, 2), ("income", 2), (2, 2), (np.int_(2), 2),
                      (ssn, -1), ("SSN", -1), (-1, -1), (np.int_(-1), -1),
                      (-2, -2), (np.int_(-2), -2)]:
         self.assertEqual(d.index(idx), var)
Esempio n. 6
0
 def test_index(self):
     d = Domain((age, gender, income), metas=(ssn, race))
     for idx, var in [(age, 0),
                      ("AGE", 0),
                      (0, 0),
                      (np.int_(0), 0),
                      (income, 2),
                      ("income", 2),
                      (2, 2),
                      (np.int_(2), 2),
                      (ssn, -1),
                      ("SSN", -1),
                      (-1, -1),
                      (np.int_(-1), -1),
                      (-2, -2), (np.int_(-2), -2)]:
         self.assertEqual(d.index(idx), var)