John Hunter wrote:
On Sat, Jul 19, 2008 at 8:58 PM, Ryan May <[EMAIL PROTECTED]> wrote:
Hi,

In integrating my barbs work, I'm having trouble that causes a circular
import. I used delete_masked_points from axes.  The problem here is that
axes imports quiver (where I put barbs) which then has to (in some form)
import axes to get delete_masked_points.  Anyone have something I'm
missing here? Or can I move delete_masked_points to a better location?

mlab or cbook would be fine

JDH
Take this one instead.  I missed some imports on the last one (oops).

Ryan

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
--- axes.py	(revision 5793)
+++ axes.py	(working copy)
@@ -1,5 +1,5 @@
 from __future__ import division, generators
-import math, sys, warnings, datetime, new, types
+import math, sys, warnings, datetime, new
 
 import numpy as np
 from numpy import ma
@@ -31,45 +31,6 @@
 is_string_like = cbook.is_string_like
 
 
-def delete_masked_points(*args):
-    """
-    Find all masked points in a set of arguments, and return
-    the arguments with only the unmasked points remaining.
-
-    This will also delete any points that are not finite (nan or inf).
-
-    The overall mask is calculated from any masks that are present.
-    If a mask is found, any argument that does not have the same
-    dimensions is left unchanged; therefore the argument list may
-    include arguments that can take string or array values, for
-    example.
-
-    Array arguments must have the same length; masked arguments must
-    be one-dimensional.
-
-    Written as a helper for scatter, but may be more generally
-    useful.
-    """
-    masks = [ma.getmaskarray(x) for x in args if hasattr(x, 'mask')]
-    isfinite = [np.isfinite(x) for x in args]
-    masks.extend( [~x for x in isfinite if not isinstance(x,types.NotImplementedType)] )
-    if len(masks) == 0:
-        return args
-    mask = reduce(np.logical_or, masks)
-    margs = []
-    for x in args:
-        if (not is_string_like(x)
-            and iterable(x)
-            and len(x) == len(mask)):
-            if (hasattr(x, 'get_compressed_copy')):
-                compressed_x = x.get_compressed_copy(mask)
-            else:
-                compressed_x = ma.masked_array(x, mask=mask).compressed()
-            margs.append(compressed_x)
-        else:
-            margs.append(x)
-    return margs
-
 def _process_plot_format(fmt):
     """
     Process a matlab(TM) style color/line style format string.  Return a
@@ -4827,7 +4788,7 @@
 
         self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
 
-        x, y, s, c = delete_masked_points(x, y, s, c)
+        x, y, s, c = cbook.delete_masked_points(x, y, s, c)
 
         # The inherent ambiguity is resolved in favor of color
         # mapping, not interpretation as rgb or rgba.
@@ -5091,7 +5052,7 @@
 
         self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
 
-        x, y = delete_masked_points(x, y)
+        x, y = cbook.delete_masked_points(x, y)
 
         # Set the size of the hexagon grid
         if iterable(gridsize):
--- cbook.py	(revision 5793)
+++ cbook.py	(working copy)
@@ -3,9 +3,10 @@
 from the Python Cookbook -- hence the name cbook
 """
 from __future__ import generators
-import re, os, errno, sys, StringIO, traceback, locale, threading
+import re, os, errno, sys, StringIO, traceback, locale, threading, types
 import time, datetime
 import numpy as np
+from numpy import ma
 from weakref import ref
 
 major, minor1, minor2, s, tmp = sys.version_info
@@ -1165,8 +1166,46 @@
     else:
         os.remove(path)
 
+def delete_masked_points(*args):
+    """
+    Find all masked points in a set of arguments, and return
+    the arguments with only the unmasked points remaining.
 
+    This will also delete any points that are not finite (nan or inf).
 
+    The overall mask is calculated from any masks that are present.
+    If a mask is found, any argument that does not have the same
+    dimensions is left unchanged; therefore the argument list may
+    include arguments that can take string or array values, for
+    example.
+
+    Array arguments must have the same length; masked arguments must
+    be one-dimensional.
+
+    Written as a helper for scatter, but may be more generally
+    useful.
+    """
+    masks = [ma.getmaskarray(x) for x in args if hasattr(x, 'mask')]
+    isfinite = [np.isfinite(x) for x in args]
+    masks.extend( [~x for x in isfinite if not isinstance(x,types.NotImplementedType)] )
+    if len(masks) == 0:
+        return args
+    mask = reduce(np.logical_or, masks)
+    margs = []
+    for x in args:
+        if (not is_string_like(x)
+            and iterable(x)
+            and len(x) == len(mask)):
+            if (hasattr(x, 'get_compressed_copy')):
+                compressed_x = x.get_compressed_copy(mask)
+            else:
+                compressed_x = ma.masked_array(x, mask=mask).compressed()
+            margs.append(compressed_x)
+        else:
+            margs.append(x)
+    return margs
+
+
 # a dict to cross-map linestyle arguments
 _linestyles = [('-', 'solid'),
     ('--', 'dashed'),
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to