[yt-svn] commit/yt: ngoldbaum: Merged in MatthewTurk/yt (pull request #2218)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Jun 15 11:12:21 PDT 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/9599fdb0dbbf/
Changeset:   9599fdb0dbbf
Branch:      yt
User:        ngoldbaum
Date:        2016-06-15 18:12:04+00:00
Summary:     Merged in MatthewTurk/yt (pull request #2218)

Adding validation checks for data types in callbacks.  Closes #1222
Affected #:  11 files

diff -r b4f9e4c9baeda6a9c9dd92bd026ca8dc86fc8afe -r 9599fdb0dbbff7a81094afdd237a3f844ab5f055 yt/geometry/coordinates/cartesian_coordinates.py
--- a/yt/geometry/coordinates/cartesian_coordinates.py
+++ b/yt/geometry/coordinates/cartesian_coordinates.py
@@ -29,6 +29,7 @@
 
 
 class CartesianCoordinateHandler(CoordinateHandler):
+    name = "cartesian"
 
     def __init__(self, ds, ordering = ('x','y','z')):
         super(CartesianCoordinateHandler, self).__init__(ds, ordering)

diff -r b4f9e4c9baeda6a9c9dd92bd026ca8dc86fc8afe -r 9599fdb0dbbff7a81094afdd237a3f844ab5f055 yt/geometry/coordinates/coordinate_handler.py
--- a/yt/geometry/coordinates/coordinate_handler.py
+++ b/yt/geometry/coordinates/coordinate_handler.py
@@ -71,6 +71,7 @@
                     ds.quan(width[0], fix_unitary(width[1])))
 
 class CoordinateHandler(object):
+    name = None
     
     def __init__(self, ds, ordering):
         self.ds = weakref.proxy(ds)

diff -r b4f9e4c9baeda6a9c9dd92bd026ca8dc86fc8afe -r 9599fdb0dbbff7a81094afdd237a3f844ab5f055 yt/geometry/coordinates/cylindrical_coordinates.py
--- a/yt/geometry/coordinates/cylindrical_coordinates.py
+++ b/yt/geometry/coordinates/cylindrical_coordinates.py
@@ -29,6 +29,7 @@
 #
 
 class CylindricalCoordinateHandler(CoordinateHandler):
+    name = "cylindrical"
 
     def __init__(self, ds, ordering = ('r', 'z', 'theta')):
         super(CylindricalCoordinateHandler, self).__init__(ds, ordering)

diff -r b4f9e4c9baeda6a9c9dd92bd026ca8dc86fc8afe -r 9599fdb0dbbff7a81094afdd237a3f844ab5f055 yt/geometry/coordinates/geographic_coordinates.py
--- a/yt/geometry/coordinates/geographic_coordinates.py
+++ b/yt/geometry/coordinates/geographic_coordinates.py
@@ -23,6 +23,7 @@
     pixelize_cylinder, pixelize_aitoff
 
 class GeographicCoordinateHandler(CoordinateHandler):
+    name = "geographic"
 
     def __init__(self, ds, ordering = ('latitude', 'longitude', 'altitude')):
         super(GeographicCoordinateHandler, self).__init__(ds, ordering)

diff -r b4f9e4c9baeda6a9c9dd92bd026ca8dc86fc8afe -r 9599fdb0dbbff7a81094afdd237a3f844ab5f055 yt/geometry/coordinates/polar_coordinates.py
--- a/yt/geometry/coordinates/polar_coordinates.py
+++ b/yt/geometry/coordinates/polar_coordinates.py
@@ -18,6 +18,7 @@
 
 
 class PolarCoordinateHandler(CylindricalCoordinateHandler):
+    name = "polar"
 
     def __init__(self, ds, ordering = ('r', 'theta', 'z')):
         super(PolarCoordinateHandler, self).__init__(ds, ordering)

diff -r b4f9e4c9baeda6a9c9dd92bd026ca8dc86fc8afe -r 9599fdb0dbbff7a81094afdd237a3f844ab5f055 yt/geometry/coordinates/spec_cube_coordinates.py
--- a/yt/geometry/coordinates/spec_cube_coordinates.py
+++ b/yt/geometry/coordinates/spec_cube_coordinates.py
@@ -20,6 +20,7 @@
     _get_coord_fields
 
 class SpectralCubeCoordinateHandler(CartesianCoordinateHandler):
+    name = "spectral_cube"
 
     def __init__(self, ds, ordering = ('x', 'y', 'z')):
         ordering = tuple("xyz"[axis] for axis in

diff -r b4f9e4c9baeda6a9c9dd92bd026ca8dc86fc8afe -r 9599fdb0dbbff7a81094afdd237a3f844ab5f055 yt/geometry/coordinates/spherical_coordinates.py
--- a/yt/geometry/coordinates/spherical_coordinates.py
+++ b/yt/geometry/coordinates/spherical_coordinates.py
@@ -23,6 +23,7 @@
     pixelize_cylinder, pixelize_aitoff
 
 class SphericalCoordinateHandler(CoordinateHandler):
+    name = "spherical"
 
     def __init__(self, ds, ordering = ('r', 'theta', 'phi')):
         super(SphericalCoordinateHandler, self).__init__(ds, ordering)

diff -r b4f9e4c9baeda6a9c9dd92bd026ca8dc86fc8afe -r 9599fdb0dbbff7a81094afdd237a3f844ab5f055 yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -558,3 +558,13 @@
 
     def __str__(self):
         return "Can't determine size specification for %s" % (self.size_spec)
+
+class YTDataTypeUnsupported(YTException):
+    def __init__(self, this, supported):
+        self.supported = supported
+        self.this = this
+
+    def __str__(self):
+        v = "This operation is not supported for data of geometry %s; " % self.this
+        v += "It supports data of geometries %s" % (self.supported,)
+        return v

diff -r b4f9e4c9baeda6a9c9dd92bd026ca8dc86fc8afe -r 9599fdb0dbbff7a81094afdd237a3f844ab5f055 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -21,6 +21,7 @@
 import numpy as np
 
 from distutils.version import LooseVersion
+from functools import wraps
 
 from yt.funcs import \
     mylog, iterable
@@ -37,21 +38,49 @@
     line_integral_convolution_2d
 from yt.geometry.unstructured_mesh_handler import UnstructuredIndex
 from yt.utilities.lib.mesh_triangulation import triangulate_indices
+from yt.utilities.exceptions import \
+    YTDataTypeUnsupported
 
 from . import _MPL
 
 callback_registry = {}
 
+def _verify_geometry(func):
+    @wraps(func)
+    def _check_geometry(self, plot):
+        geom = plot.data.ds.coordinates.name
+        supp = self._supported_geometries
+        cs = getattr(self, "coord_system", None)
+        if supp is None or geom in supp:
+            return func(self, plot)
+        if cs in ("axis", "figure") and "force" not in supp:
+            return func(self, plot)
+        raise YTDataTypeUnsupported(geom, supp)
+    return _check_geometry
+
 class RegisteredCallback(type):
     def __init__(cls, name, b, d):
         type.__init__(cls, name, b, d)
         callback_registry[name] = cls
+        cls.__call__ = _verify_geometry(cls.__call__)
 
 @add_metaclass(RegisteredCallback)
 class PlotCallback(object):
+    # _supported_geometries is set by subclasses of PlotCallback to a tuple of
+    # strings corresponding to the names of the geometries that a callback
+    # supports.  By default it is None, which means it supports everything.
+    # Note that if there's a coord_system parameter that is set to "axis" or
+    # "figure" this is disregarded.  If "force" is included in the tuple, it
+    # will *not* check whether or not the coord_system is in axis or figure,
+    # and will only look at the geometries.
+    _supported_geometries = None
+
     def __init__(self, *args, **kwargs):
         pass
 
+    def __call__(self, plot):
+        raise NotImplementedError
+
     def project_coords(self, plot, coord):
         """
         Convert coordinates from simulation data coordinates to projected
@@ -248,6 +277,7 @@
     Cutting Planes).
     """
     _type_name = "velocity"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, factor=16, scale=None, scale_units=None, normalize=False):
         PlotCallback.__init__(self)
         self.factor = factor
@@ -293,6 +323,7 @@
     clearly seen for fields with substantial variation in field strength.
     """
     _type_name = "magnetic_field"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, factor=16, scale=None, scale_units=None, normalize=False):
         PlotCallback.__init__(self)
         self.factor = factor
@@ -326,6 +357,7 @@
     (see matplotlib.axes.Axes.quiver for more info)
     """
     _type_name = "quiver"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, field_x, field_y, factor=16, scale=None,
                  scale_units=None, normalize=False, bv_x=0, bv_y=0):
         PlotCallback.__init__(self)
@@ -405,6 +437,7 @@
     queried.
     """
     _type_name = "contour"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, field, ncont=5, factor=4, clim=None,
                  plot_args=None, label=False, take_log=None,
                  label_args=None, text_args=None, data_source=None):
@@ -538,6 +571,7 @@
     can change the linewidth of the displayed grids.
     """
     _type_name = "grids"
+    _supported_geometries = ("cartesian", "spectral_cube")
 
     def __init__(self, alpha=0.7, min_pix=1, min_pix_ids=20, draw_ids=False,
                  periodic=True, min_level=None, max_level=None,
@@ -652,6 +686,7 @@
     *field_color* is a field to be used to colormap the streamlines.
     """
     _type_name = "streamlines"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, field_x, field_y, factor=16,
                  density=1, field_color=None, plot_args=None):
         PlotCallback.__init__(self)
@@ -758,6 +793,7 @@
 
     """
     _type_name = "line"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, p1, p2, data_coords=False, coord_system="data",
                  plot_args=None):
         PlotCallback.__init__(self)
@@ -798,6 +834,7 @@
 
     """
     _type_name = "image_line"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, p1, p2, data_coords=False, coord_system='axis',
                  plot_args=None):
         super(ImageLineCallback, self).__init__(p1, p2, data_coords,
@@ -817,6 +854,7 @@
     *field_y*, skipping every *factor* datapoint in the discretization.
     """
     _type_name = "cquiver"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, field_x, field_y, factor):
         PlotCallback.__init__(self)
         self.field_x = field_x
@@ -862,6 +900,7 @@
     Take a list of *clumps* and plot them as a set of contours.
     """
     _type_name = "clumps"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, clumps, plot_args=None):
         self.clumps = clumps
         if plot_args is None: plot_args = {}
@@ -990,6 +1029,7 @@
 
     """
     _type_name = "arrow"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, pos, code_size=None, length=0.03, width=0.0001,
                  head_width=0.01, head_length=0.01,
                  starting_pos=None, coord_system='data', plot_args=None):
@@ -1105,6 +1145,7 @@
 
     """
     _type_name = "marker"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, pos, marker='x', coord_system="data", plot_args=None):
         def_plot_args = {'color':'w', 's':50}
         self.pos = pos
@@ -1178,6 +1219,7 @@
 
     """
     _type_name = "sphere"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, center, radius, circle_args=None,
                  text=None, coord_system='data', text_args=None):
         def_text_args = {'color':'white'}
@@ -1293,6 +1335,7 @@
     >>> s.save()
     """
     _type_name = "text"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, pos, text, data_coords=False, coord_system='data',
                  text_args=None, inset_box_args=None):
         def_text_args = {'color':'white'}
@@ -1337,6 +1380,7 @@
 
     """
     _type_name = "point"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, pos, text, data_coords=False, coord_system='data',
                  text_args=None, inset_box_args=None):
         super(PointAnnotateCallback, self).__init__(pos, text, data_coords,
@@ -1379,6 +1423,7 @@
     _type_name = 'halos'
     region = None
     _descriptor = None
+    _supported_geometries = ("cartesian", "spectral_cube")
 
     def __init__(self, halo_catalog, circle_args=None, circle_kwargs=None,
                  width=None, annotate_field=None, text_args=None,
@@ -1486,6 +1531,7 @@
     _type_name = "particles"
     region = None
     _descriptor = None
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, width, p_size=1.0, col='k', marker='o', stride=1.0,
                  ptype='all', minimum_mass=None, alpha=1.0):
         PlotCallback.__init__(self)
@@ -1626,6 +1672,7 @@
 
     """
     _type_name = "mesh_lines"
+    _supported_geometries = ("cartesian", "spectral_cube")
 
     def __init__(self, plot_args=None):
         super(MeshLinesCallback, self).__init__()
@@ -1690,6 +1737,7 @@
     of the geometry represented by the triangles.
     """
     _type_name = "triangle_facets"
+    _supported_geometries = ("cartesian", "spectral_cube")
 
     def __init__(self, triangle_vertices, plot_args=None):
         super(TriangleFacetsCallback, self).__init__()
@@ -1814,6 +1862,7 @@
     >>> s.annotate_timestamp()
     """
     _type_name = "timestamp"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, x_pos=None, y_pos=None, corner='lower_left', time=True,
                  redshift=False, time_format="t = {time:.1f} {units}",
                  time_unit=None, redshift_format="z = {redshift:.2f}",
@@ -1999,6 +2048,7 @@
     >>> s.annotate_scale()
     """
     _type_name = "scale"
+    _supported_geometries = ("cartesian", "spectral_cube", "force")
     def __init__(self, corner='lower_right', coeff=None, unit=None, pos=None,
                  max_frac=0.16, min_frac=0.015, coord_system='axis',
                  text_args=None, size_bar_args=None, draw_inset_box=False,
@@ -2176,6 +2226,7 @@
 
     """
     _type_name = "ray"
+    _supported_geometries = ("cartesian", "spectral_cube", "force")
     def __init__(self, ray, arrow=False, plot_args=None):
         PlotCallback.__init__(self)
         def_plot_args = {'color':'white', 'linewidth':2}
@@ -2322,6 +2373,7 @@
                                              lim=(0.5,0.65))
     """
     _type_name = "line_integral_convolution"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, field_x, field_y, texture=None, kernellen=50.,
                  lim=(0.5,0.6), cmap='binary', alpha=0.8, const_alpha=False):
         PlotCallback.__init__(self)
@@ -2417,6 +2469,7 @@
     >>> s.save()
     """
     _type_name = "cell_edges"
+    _supported_geometries = ("cartesian", "spectral_cube")
     def __init__(self, line_width=1.0, alpha = 1.0, color=(0.0, 0.0, 0.0)):
         PlotCallback.__init__(self)
         self.line_width = line_width

diff -r b4f9e4c9baeda6a9c9dd92bd026ca8dc86fc8afe -r 9599fdb0dbbff7a81094afdd237a3f844ab5f055 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -64,7 +64,8 @@
     YTUnitNotRecognized, \
     YTCannotParseUnitDisplayName, \
     YTUnitConversionError, \
-    YTPlotCallbackError
+    YTPlotCallbackError, \
+    YTDataTypeUnsupported
 
 # Some magic for dealing with pyparsing being included or not
 # included in matplotlib (not in gentoo, yes in everything else)
@@ -984,6 +985,8 @@
                 callback = CallbackMaker(*args[1:], **kwargs)
                 try:
                     callback(cbw)
+                except YTDataTypeUnsupported as e:
+                    six.reraise(YTDataTypeUnsupported, e)
                 except Exception as e:
                     six.reraise(YTPlotCallbackError,
                                 YTPlotCallbackError(callback._type_name, e),

diff -r b4f9e4c9baeda6a9c9dd92bd026ca8dc86fc8afe -r 9599fdb0dbbff7a81094afdd237a3f844ab5f055 yt/visualization/tests/test_callbacks.py
--- a/yt/visualization/tests/test_callbacks.py
+++ b/yt/visualization/tests/test_callbacks.py
@@ -27,7 +27,8 @@
 import yt.units as u
 from .test_plotwindow import assert_fname
 from yt.utilities.exceptions import \
-    YTPlotCallbackError
+    YTPlotCallbackError, \
+    YTDataTypeUnsupported
 from yt.visualization.api import \
     SlicePlot, ProjectionPlot, OffAxisSlicePlot
 import contextlib
@@ -90,6 +91,15 @@
                              draw_inset_box=True)
         p.save(prefix)
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density",), geometry="spherical")
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_timestamp(coord_system="data")
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_timestamp(coord_system="axis")
+        yield assert_fname, p.save(prefix)[0]
+
 def test_scale_callback():
     with _cleanup_fname() as prefix:
         ax = 'z'
@@ -115,6 +125,15 @@
         p.annotate_scale(text_args={"font": 24})
         yield assert_raises, YTPlotCallbackError
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density",), geometry="spherical")
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_scale()
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_scale(coord_system="axis")
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+
 def test_line_callback():
     with _cleanup_fname() as prefix:
         ax = 'z'
@@ -135,6 +154,15 @@
                         plot_args={'color':'red'})
         p.save(prefix)
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density",), geometry="spherical")
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_line([0.1,0.1,0.1],[0.5,0.5,0.5])
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_line([0.1,0.1],[0.5,0.5], coord_system="axis")
+        yield assert_fname, p.save(prefix)[0]
+
 def test_ray_callback():
     with _cleanup_fname() as prefix:
         ax = 'z'
@@ -160,6 +188,17 @@
         p.annotate_ray(ray, plot_args={'color':'red'})
         p.save(prefix)
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density",), geometry="spherical")
+        ray = ds.ray((0.1, 0.2, 0.3), (1.6, 1.8, 1.5))
+        oray = ds.ortho_ray(0, (0.3, 0.4))
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_ray(oray)
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_ray(ray)
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+
 def test_arrow_callback():
     with _cleanup_fname() as prefix:
         ax = 'z'
@@ -179,6 +218,15 @@
         p.annotate_arrow([0.5,0.5], coord_system='axis', length=0.05)
         p.save(prefix)
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density",), geometry="spherical")
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_arrow([0.5,0.5,0.5])
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_arrow([0.5,0.5], coord_system="axis")
+        yield assert_fname, p.save(prefix)[0]
+
 def test_marker_callback():
     with _cleanup_fname() as prefix:
         ax = 'z'
@@ -198,6 +246,15 @@
         p.annotate_marker([0.5,0.5], coord_system='axis', marker='*')
         p.save(prefix)
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density",), geometry="spherical")
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_marker([0.5,0.5,0.5])
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_marker([0.5,0.5], coord_system="axis")
+        yield assert_fname, p.save(prefix)[0]
+
 def test_sphere_callback():
     with _cleanup_fname() as prefix:
         ax = 'z'
@@ -217,6 +274,15 @@
         p.annotate_sphere([0.5,0.5], 0.1, coord_system='axis', text='blah')
         p.save(prefix)
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density",), geometry="spherical")
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_sphere([0.5,0.5,0.5], 0.1)
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_sphere([0.5,0.5], 0.1, coord_system='axis', text='blah')
+        yield assert_fname, p.save(prefix)[0]
+
 def test_text_callback():
     with _cleanup_fname() as prefix:
         ax = 'z'
@@ -237,6 +303,16 @@
                         text_args={'color':'red'})
         p.save(prefix)
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density",), geometry="spherical")
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_text([0.5,0.5,0.5], 'dinosaurs!')
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_text([0.5,0.5], 'dinosaurs!', coord_system='axis',
+                        text_args={'color':'red'})
+        yield assert_fname, p.save(prefix)[0]
+
 def test_velocity_callback():
     with _cleanup_fname() as prefix:
         ds = fake_amr_ds(fields =
@@ -258,6 +334,14 @@
                             normalize = True)
         yield assert_fname, p.save(prefix)[0]
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = 
+            ("density", "velocity_r", "velocity_theta", "velocity_phi"),
+            geometry="spherical")
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_velocity(factor=40, normalize=True)
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+
 def test_magnetic_callback():
     with _cleanup_fname() as prefix:
         ds = fake_amr_ds(fields = ("density", "magnetic_field_x",
@@ -279,6 +363,15 @@
             scale_units="inches", normalize = True)
         yield assert_fname, p.save(prefix)[0]
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density", "magnetic_field_r",
+          "magnetic_field_theta", "magnetic_field_phi"),
+          geometry="spherical")
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_magnetic_field(factor=8, scale=0.5,
+            scale_units="inches", normalize = True)
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+
 def test_quiver_callback():
     with _cleanup_fname() as prefix:
         ds = fake_amr_ds(fields =
@@ -301,6 +394,17 @@
             bv_y = 0.5 * u.cm / u.s)
         yield assert_fname, p.save(prefix)[0]
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = 
+            ("density", "velocity_x", "velocity_theta", "velocity_phi"),
+            geometry="spherical")
+        p = ProjectionPlot(ds, "r", "density")
+        p.annotate_quiver("velocity_theta", "velocity_phi", factor=8, scale=0.5,
+            scale_units="inches", normalize = True,
+            bv_x = 0.5 * u.cm / u.s,
+            bv_y = 0.5 * u.cm / u.s)
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+
 def test_contour_callback():
     with _cleanup_fname() as prefix:
         ds = fake_amr_ds(fields = ("density", "temperature"))
@@ -331,6 +435,17 @@
             data_source=s2)
         p.save(prefix)
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density", "temperature"),
+                         geometry="spherical")
+        p = SlicePlot(ds, "r", "density")
+        p.annotate_contour("temperature", ncont=10, factor=8,
+            take_log=False, clim=(0.4, 0.6),
+            plot_args={'lw':2.0}, label=True,
+            text_args={'text-size':'x-large'})
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+
+
 def test_grids_callback():
     with _cleanup_fname() as prefix:
         ds = fake_amr_ds(fields = ("density",))
@@ -351,6 +466,15 @@
             max_level=3, cmap="gist_stern")
         p.save(prefix)
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density",), geometry="spherical")
+        p = SlicePlot(ds, "r", "density")
+        p.annotate_grids(alpha=0.7, min_pix=10, min_pix_ids=30,
+            draw_ids=True, periodic=False, min_level=2,
+            max_level=3, cmap="gist_stern")
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+
+
 def test_cell_edges_callback():
     with _cleanup_fname() as prefix:
         ds = fake_amr_ds(fields = ("density",))
@@ -370,6 +494,12 @@
                               color=(0.0, 1.0, 1.0))
         p.save(prefix)
 
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = ("density",), geometry="spherical")
+        p = SlicePlot(ds, "r", "density")
+        p.annotate_cell_edges()
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+
 def test_mesh_lines_callback():
     with _cleanup_fname() as prefix:
 
@@ -408,4 +538,10 @@
                                              alpha=0.9, const_alpha=True)
         p.save(prefix)
 
-
+    with _cleanup_fname() as prefix:
+        ds = fake_amr_ds(fields = 
+            ("density", "velocity_r", "velocity_theta", "velocity_phi"),
+            geometry="spherical")
+        p = SlicePlot(ds, "r", "density")
+        p.annotate_line_integral_convolution("velocity_theta", "velocity_phi")
+        yield assert_raises, YTDataTypeUnsupported, p.save, prefix

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the yt-svn mailing list