예제 #1
0
    def test_none_to_nan_long(self):
        result = none_to_nan([np.arange(1, 100), np.arange(1, 100), None, np.arange(1, 100).tolist()])

        self.assertTrue(np.array_equal(result[0], np.arange(1, 100)))
        self.assertTrue(np.array_equal(result[1], np.arange(1, 100)))
        self.assertTrue(np.isnan(result[2]))
        self.assertEqual(result[3], np.arange(1, 100).tolist())
예제 #2
0
    def test_none_to_nan_nested(self):
        values_irregular = [None, [1, 2, 3], None]

        result = none_to_nan(values_irregular)

        self.assertEqual(len(result), 3)
        self.assertTrue(np.isnan(result[0]))
        self.assertEqual(result[1], [1, 2, 3])
        self.assertTrue(np.isnan(result[2]))
예제 #3
0
    def test_none_to_nan_nested_array_single_no_none(self):
        values_irregular = np.array([np.array(1), np.array(2), np.array(3)])

        result = none_to_nan(values_irregular)

        values_correct = np.array([np.array(1), np.array(2), np.array(3)])

        self.assertTrue(np.array_equal(result, np.array([np.array(1), np.array(2), np.array(3)])))


        values_irregular = np.array([None, None, None])

        result = none_to_nan(values_irregular)

        self.assertEqual(len(result), 3)
        self.assertTrue(np.isnan(result[0]))
        self.assertTrue(np.isnan(result[1]))
        self.assertTrue(np.isnan(result[2]))
예제 #4
0
    def test_none_to_nan_nested_no_none(self):
        values_irregular = np.array([np.array([1, 2, 3]), np.array([1, 2, 3]),
                                     np.array([1, 2, 3]), np.array([1, 2, 3])])

        values_correct = np.array([np.array([1, 2, 3]), np.array([1, 2, 3]),
                                   np.array([1, 2, 3]), np.array([1, 2, 3])])

        result = none_to_nan(values_irregular)

        self.assertTrue(np.array_equal(result, values_correct))
예제 #5
0
    def test_none_to_nan_nested_none(self):
        values_irregular = np.array([None, np.array([None, np.array([1, 2, 3])])])

        result = none_to_nan(values_irregular)

        self.assertEqual(len(result), 2)
        self.assertEqual(len(result[1]), 2)
        self.assertTrue(np.isnan(result[0]))
        self.assertTrue(np.isnan(result[1][0]))
        self.assertTrue(np.array_equal(result[1][1], [1, 2, 3]))
예제 #6
0
    def test_none_to_nan_empty_list(self):
        values_irregular = np.array([[], np.array([1, 2, 3]), None, [[], None, 3]])

        result = none_to_nan(values_irregular)

        self.assertEqual(len(result), 4)
        self.assertEqual(result[0], [])
        self.assertTrue(np.isnan(result[2]))
        self.assertTrue(np.array_equal(result[1], np.array([1, 2, 3])))
        self.assertEqual(result[3][0], [])
        self.assertTrue(np.isnan(result[3][1]))
        self.assertEqual(result[3][2], 3)
예제 #7
0
    def test_none_to_nan_list(self):
        result = none_to_nan([1, 2, 3])

        self.assertEqual(result, [1, 2, 3])
예제 #8
0
    def test_none_to_nan_str(self):
        result = none_to_nan("time")

        self.assertEqual(result, "time")
예제 #9
0
    def test_none_to_nan_int(self):
        result = none_to_nan(2)

        self.assertEqual(result, 2)