예제 #1
0
 def __init__(self, *args, **kwargs):
     if "map_projection" in kwargs:
         map_projection=kwargs.pop("map_projection")
     else:
         map_projection = cartopy.crs.NorthPolarStereo()
         print("map_projection keyword not set, setting it to cartopy.crs.NorthPolarStereo()")
     GeoAxes.__init__(self, map_projection=map_projection,*args, **kwargs)
예제 #2
0
    def test_styler_kwarg(self, ShapelyFeature, add_feature_method):
        ax = GeoAxes(plt.figure(), [0, 0, 1, 1],
                     map_projection=ccrs.Robinson())
        ax.add_geometries(mock.sentinel.geometries, mock.sentinel.crs,
                          styler=mock.sentinel.styler, wibble='wobble')

        ShapelyFeature.assert_called_once_with(
            mock.sentinel.geometries, mock.sentinel.crs, wibble='wobble')

        add_feature_method.assert_called_once_with(
            ShapelyFeature(), styler=mock.sentinel.styler)
예제 #3
0
    def test_styler_kwarg(self, ShapelyFeature, add_feature_method):
        ax = GeoAxes(plt.figure(), [0, 0, 1, 1],
                     map_projection=ccrs.Robinson())
        ax.add_geometries(mock.sentinel.geometries, mock.sentinel.crs,
                          styler=mock.sentinel.styler, wibble='wobble')

        ShapelyFeature.assert_called_once_with(
            mock.sentinel.geometries, mock.sentinel.crs, wibble='wobble')

        add_feature_method.assert_called_once_with(
            ShapelyFeature(), styler=mock.sentinel.styler)
예제 #4
0
def test_gridliner_specified_lines():
    xs = [0, 60, 120, 180, 240, 360]
    ys = [-90, -60, -30, 0, 30, 60, 90]
    ax = mock.Mock(_gridliners=[], spec=GeoAxes)
    gl = GeoAxes.gridlines(ax, xlocs=xs, ylocs=ys)
    assert isinstance(gl.xlocator, mticker.FixedLocator)
    assert isinstance(gl.ylocator, mticker.FixedLocator)
    assert gl.xlocator.tick_values(None, None).tolist() == xs
    assert gl.ylocator.tick_values(None, None).tolist() == ys
예제 #5
0
def test_gridliner_specified_lines():
    xs = [0, 60, 120, 180, 240, 360]
    ys = [-90, -60, -30, 0, 30, 60, 90]
    ax = mock.Mock(_gridliners=[], spec=GeoAxes)
    gl = GeoAxes.gridlines(ax, xlocs=xs, ylocs=ys)
    assert isinstance(gl.xlocator, mticker.FixedLocator)
    assert isinstance(gl.ylocator, mticker.FixedLocator)
    assert gl.xlocator.tick_values(None, None).tolist() == xs
    assert gl.ylocator.tick_values(None, None).tolist() == ys
예제 #6
0
def test_gridliner_specified_lines():
    meridians = [0, 60, 120, 180, 240, 360]
    parallels = [-90, -60, -30, 0, 30, 60, 90]

    ax = plt.subplot(1, 1, 1, projection=ccrs.PlateCarree())
    gl = GeoAxes.gridlines(ax, xlocs=meridians, ylocs=parallels)
    assert isinstance(gl.xlocator, mticker.FixedLocator)
    assert isinstance(gl.ylocator, mticker.FixedLocator)
    assert gl.xlocator.tick_values(None, None).tolist() == meridians
    assert gl.ylocator.tick_values(None, None).tolist() == parallels
예제 #7
0
def test_gridliner_specified_lines():
    meridians = [0, 60, 120, 180, 240, 360]
    parallels = [-90, -60, -30, 0, 30, 60, 90]

    def mpl_connext(*args):
        pass

    canvas = mock.Mock(mpl_connext=mpl_connext)
    fig = mock.Mock(spec=matplotlib.figure.Figure, canvas=canvas)
    ax = mock.Mock(_gridliners=[], spec=GeoAxes, figure=fig)
    gl = GeoAxes.gridlines(ax, xlocs=meridians, ylocs=parallels)
    assert isinstance(gl.xlocator, mticker.FixedLocator)
    assert isinstance(gl.ylocator, mticker.FixedLocator)
    assert gl.xlocator.tick_values(None, None).tolist() == meridians
    assert gl.ylocator.tick_values(None, None).tolist() == parallels
예제 #8
0
 def test_single_geometry(self):
     # A single geometry is acceptable
     proj = ccrs.PlateCarree()
     ax = GeoAxes(plt.figure(), [0, 0, 1, 1], map_projection=proj)
     ax.add_geometries(next(cfeature.COASTLINE.geometries()), crs=proj)