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())
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]))
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]))
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))
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]))
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)
def test_none_to_nan_list(self): result = none_to_nan([1, 2, 3]) self.assertEqual(result, [1, 2, 3])
def test_none_to_nan_str(self): result = none_to_nan("time") self.assertEqual(result, "time")
def test_none_to_nan_int(self): result = none_to_nan(2) self.assertEqual(result, 2)