Exemplo n.º 1
0
    def test_contains_type(self):
        d = Dataset(self.X, self.y, self.data_info, '?', '%Y-%m-%d', True)

        self.assertEqual(d.contains_type('numeric'), True)
        self.assertEqual(d.contains_type('string'), False)

        d.remove_type('numeric')
        self.assertEqual(d.contains_type('numeric'), False)
Exemplo n.º 2
0
    def test_extend(self):
        d = Dataset(self.X, self.y, self.data_info, '?', '%Y-%m-%d', True)

        d.extend(np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]),
                 ['numeric', 'numeric', 'aaa'])

        expected_X = np.array([[1.0, 0.5, 1.0, 1355266800.0, 1, 2],
                               [1.0, 0.5, 0.0, 1355266800.0, 3, 4],
                               [1.0, 0, 1.0, 1385161200.0, 5, 6],
                               [1.0, 0.5, 0, 1326236400.0, 7, 8],
                               [0, 0.5, 1.0, 955749600.0, 9, 10]])
        expected_data_info = [
            'numeric', 'numeric', 'nominal', 'timestamp', 'numeric', 'numeric',
            'aaa'
        ]

        np.testing.assert_equal(d.X, expected_X)
        self.assertEqual(d.data_info, expected_data_info)
        self.assertEqual(d.X.dtype, 'float64')
        self.assertEqual(d.contains_type('aaa'), True)