|
1 | 1 | from __future__ import division, generators |
2 | | -import math, sys, warnings, datetime, new, types |
| 2 | +import math, sys, warnings, datetime, new |
3 | 3 |
|
4 | 4 | import numpy as np |
5 | 5 | from numpy import ma |
|
31 | 31 | is_string_like = cbook.is_string_like |
32 | 32 |
|
33 | 33 |
|
34 | | -def delete_masked_points(*args): |
35 | | - """ |
36 | | - Find all masked points in a set of arguments, and return |
37 | | - the arguments with only the unmasked points remaining. |
38 | | -
|
39 | | - This will also delete any points that are not finite (nan or inf). |
40 | | -
|
41 | | - The overall mask is calculated from any masks that are present. |
42 | | - If a mask is found, any argument that does not have the same |
43 | | - dimensions is left unchanged; therefore the argument list may |
44 | | - include arguments that can take string or array values, for |
45 | | - example. |
46 | | -
|
47 | | - Array arguments must have the same length; masked arguments must |
48 | | - be one-dimensional. |
49 | | -
|
50 | | - Written as a helper for scatter, but may be more generally |
51 | | - useful. |
52 | | - """ |
53 | | - masks = [ma.getmaskarray(x) for x in args if hasattr(x, 'mask')] |
54 | | - isfinite = [np.isfinite(x) for x in args] |
55 | | - masks.extend( [~x for x in isfinite if not isinstance(x,types.NotImplementedType)] ) |
56 | | - if len(masks) == 0: |
57 | | - return args |
58 | | - mask = reduce(np.logical_or, masks) |
59 | | - margs = [] |
60 | | - for x in args: |
61 | | - if (not is_string_like(x) |
62 | | - and iterable(x) |
63 | | - and len(x) == len(mask)): |
64 | | - if (hasattr(x, 'get_compressed_copy')): |
65 | | - compressed_x = x.get_compressed_copy(mask) |
66 | | - else: |
67 | | - compressed_x = ma.masked_array(x, mask=mask).compressed() |
68 | | - margs.append(compressed_x) |
69 | | - else: |
70 | | - margs.append(x) |
71 | | - return margs |
72 | | - |
73 | 34 | def _process_plot_format(fmt): |
74 | 35 | """ |
75 | 36 | Process a matlab(TM) style color/line style format string. Return a |
@@ -4827,7 +4788,7 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None, |
4827 | 4788 |
|
4828 | 4789 | self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs) |
4829 | 4790 |
|
4830 | | - x, y, s, c = delete_masked_points(x, y, s, c) |
| 4791 | + x, y, s, c = cbook.delete_masked_points(x, y, s, c) |
4831 | 4792 |
|
4832 | 4793 | # The inherent ambiguity is resolved in favor of color |
4833 | 4794 | # mapping, not interpretation as rgb or rgba. |
@@ -5091,7 +5052,7 @@ def hexbin(self, x, y, gridsize = 100, bins = None, |
5091 | 5052 |
|
5092 | 5053 | self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs) |
5093 | 5054 |
|
5094 | | - x, y = delete_masked_points(x, y) |
| 5055 | + x, y = cbook.delete_masked_points(x, y) |
5095 | 5056 |
|
5096 | 5057 | # Set the size of the hexagon grid |
5097 | 5058 | if iterable(gridsize): |
|
0 commit comments