|
| 1 | +import unittest |
| 2 | +import numpy as np |
| 3 | +import matplotlib.axes as axes |
| 4 | + |
| 5 | +class TestAxes(unittest.TestCase): |
| 6 | + def test_delete_masked_points_arrays(self): |
| 7 | + input = ( [1,2,3,np.nan,5], |
| 8 | + np.array((1,2,3,4,5)), |
| 9 | + ) |
| 10 | + expected = [np.array((1,2,3,5))]*2 |
| 11 | + actual = axes.delete_masked_points(*input) |
| 12 | + assert np.allclose(actual, expected) |
| 13 | + |
| 14 | + input = ( np.ma.array( [1,2,3,4,5], mask=[False,False,False,True,False] ), |
| 15 | + np.array((1,2,3,4,5)), |
| 16 | + ) |
| 17 | + expected = [np.array((1,2,3,5))]*2 |
| 18 | + actual = axes.delete_masked_points(*input) |
| 19 | + assert np.allclose(actual, expected) |
| 20 | + |
| 21 | + input = ( [1,2,3,np.nan,5], |
| 22 | + np.ma.array( [1,2,3,4,5], mask=[False,False,False,True,False] ), |
| 23 | + np.array((1,2,3,4,5)), |
| 24 | + ) |
| 25 | + expected = [np.array((1,2,3,5))]*3 |
| 26 | + actual = axes.delete_masked_points(*input) |
| 27 | + assert np.allclose(actual, expected) |
| 28 | + |
| 29 | + input = () |
| 30 | + expected = () |
| 31 | + actual = axes.delete_masked_points(*input) |
| 32 | + assert np.allclose(actual, expected) |
| 33 | + |
| 34 | + |
| 35 | + input = ( [1,2,3,np.nan,5], |
| 36 | + ) |
| 37 | + expected = [np.array((1,2,3,5))]*1 |
| 38 | + actual = axes.delete_masked_points(*input) |
| 39 | + assert np.allclose(actual, expected) |
| 40 | + |
| 41 | + input = ( np.array((1,2,3,4,5)), |
| 42 | + ) |
| 43 | + expected = [np.array((1,2,3,4,5))]*1 |
| 44 | + actual = axes.delete_masked_points(*input) |
| 45 | + assert np.allclose(actual, expected) |
| 46 | + |
| 47 | + def test_delete_masked_points_strings(self): |
| 48 | + input = ( 'hello', |
| 49 | + ) |
| 50 | + expected = ('hello',) |
| 51 | + actual = axes.delete_masked_points(*input) |
| 52 | + assert actual == expected |
| 53 | + |
| 54 | + input = ( u'hello', |
| 55 | + ) |
| 56 | + expected = (u'hello',) |
| 57 | + actual = axes.delete_masked_points(*input) |
| 58 | + assert actual == expected |
| 59 | + |
| 60 | + |
| 61 | +if __name__=='__main__': |
| 62 | + unittest.main() |
0 commit comments