|
12 | 12 | import pandas.core.common as com |
13 | 13 | import pandas.util.testing as tm |
14 | 14 | import pandas.core.config as cf |
15 | | -from pandas.core import nanops |
16 | 15 |
|
17 | 16 | _multiprocess_can_split_ = True |
18 | 17 |
|
@@ -394,54 +393,6 @@ def test_ensure_int32(): |
394 | 393 | assert(result.dtype == np.int32) |
395 | 394 |
|
396 | 395 |
|
397 | | -class TestEnsureNumeric(tm.TestCase): |
398 | | - def test_numeric_values(self): |
399 | | - # Test integer |
400 | | - self.assertEqual(nanops._ensure_numeric(1), 1, 'Failed for int') |
401 | | - # Test float |
402 | | - self.assertEqual(nanops._ensure_numeric(1.1), 1.1, 'Failed for float') |
403 | | - # Test complex |
404 | | - self.assertEqual(nanops._ensure_numeric(1 + 2j), 1 + 2j, |
405 | | - 'Failed for complex') |
406 | | - |
407 | | - def test_ndarray(self): |
408 | | - # Test numeric ndarray |
409 | | - values = np.array([1, 2, 3]) |
410 | | - self.assertTrue(np.allclose(nanops._ensure_numeric(values), values), |
411 | | - 'Failed for numeric ndarray') |
412 | | - |
413 | | - # Test object ndarray |
414 | | - o_values = values.astype(object) |
415 | | - self.assertTrue(np.allclose(nanops._ensure_numeric(o_values), values), |
416 | | - 'Failed for object ndarray') |
417 | | - |
418 | | - # Test convertible string ndarray |
419 | | - s_values = np.array(['1', '2', '3'], dtype=object) |
420 | | - self.assertTrue(np.allclose(nanops._ensure_numeric(s_values), values), |
421 | | - 'Failed for convertible string ndarray') |
422 | | - |
423 | | - # Test non-convertible string ndarray |
424 | | - s_values = np.array(['foo', 'bar', 'baz'], dtype=object) |
425 | | - self.assertRaises(ValueError, |
426 | | - lambda: nanops._ensure_numeric(s_values)) |
427 | | - |
428 | | - def test_convertable_values(self): |
429 | | - self.assertTrue(np.allclose(nanops._ensure_numeric('1'), 1.0), |
430 | | - 'Failed for convertible integer string') |
431 | | - self.assertTrue(np.allclose(nanops._ensure_numeric('1.1'), 1.1), |
432 | | - 'Failed for convertible float string') |
433 | | - self.assertTrue(np.allclose(nanops._ensure_numeric('1+1j'), 1 + 1j), |
434 | | - 'Failed for convertible complex string') |
435 | | - |
436 | | - def test_non_convertable_values(self): |
437 | | - self.assertRaises(TypeError, |
438 | | - lambda: nanops._ensure_numeric('foo')) |
439 | | - self.assertRaises(TypeError, |
440 | | - lambda: nanops._ensure_numeric({})) |
441 | | - self.assertRaises(TypeError, |
442 | | - lambda: nanops._ensure_numeric([])) |
443 | | - |
444 | | - |
445 | 396 | def test_ensure_platform_int(): |
446 | 397 |
|
447 | 398 | # verify that when we create certain types of indices |
|
0 commit comments