From dfcd80d3c8160f2941e9bb32e1c64d7913481214 Mon Sep 17 00:00:00 2001 From: Bill Little Date: Sun, 12 Mar 2023 21:25:11 +0000 Subject: [PATCH] pre-commit: adopt isort hook --- .pre-commit-config.yaml | 6 ++++++ benchmarks/cases/mpl_redraw.py | 5 +++-- benchmarks/cases/project_linear.py | 2 +- docs/make_projection.py | 5 +++++ docs/source/conf.py | 3 ++- examples/gridlines_and_labels/gridliner.py | 4 ++-- examples/gridlines_and_labels/tick_labels.py | 5 +++-- examples/lines_and_polygons/effects_of_the_ellipse.py | 9 +++++---- examples/lines_and_polygons/feature_creation.py | 3 ++- examples/lines_and_polygons/features.py | 3 ++- examples/lines_and_polygons/nightshade.py | 3 ++- examples/miscellanea/animate_surface.py | 3 ++- examples/miscellanea/axes_grid_basic.py | 7 ++++--- examples/miscellanea/eccentric_ellipse.py | 5 +++-- examples/miscellanea/favicon.py | 7 ++++--- examples/miscellanea/logo.py | 7 ++++--- examples/miscellanea/un_flag.py | 8 ++++---- examples/miscellanea/utm_all_zones.py | 3 ++- examples/scalar_data/aurora_forecast.py | 5 +++-- examples/scalar_data/contour_labels.py | 3 ++- examples/scalar_data/contour_transforms.py | 3 ++- examples/scalar_data/geostationary.py | 3 ++- examples/scalar_data/wrapping_global.py | 3 ++- examples/web_services/image_tiles.py | 2 +- examples/web_services/reprojected_wmts.py | 1 + examples/web_services/wms.py | 3 ++- examples/web_services/wmts.py | 1 + examples/web_services/wmts_time.py | 2 +- lib/cartopy/__init__.py | 2 +- lib/cartopy/_epsg.py | 3 ++- lib/cartopy/crs.py | 3 +-- lib/cartopy/feature/__init__.py | 3 +-- lib/cartopy/img_transform.py | 1 + lib/cartopy/io/img_nest.py | 3 +-- lib/cartopy/io/img_tiles.py | 4 ++-- lib/cartopy/io/ogc_clients.py | 6 +++--- lib/cartopy/io/shapereader.py | 5 +++-- lib/cartopy/io/srtm.py | 2 +- lib/cartopy/mpl/feature_artist.py | 6 ++++-- lib/cartopy/mpl/geoaxes.py | 5 ++--- lib/cartopy/mpl/gridliner.py | 9 ++++----- lib/cartopy/mpl/patch.py | 2 +- lib/cartopy/mpl/slippy_image_artist.py | 2 +- lib/cartopy/mpl/style.py | 1 - lib/cartopy/mpl/ticker.py | 2 +- lib/cartopy/tests/crs/__init__.py | 1 - lib/cartopy/tests/crs/test_aitoff.py | 1 + lib/cartopy/tests/crs/test_albers_equal_area.py | 1 + lib/cartopy/tests/crs/test_azimuthal_equidistant.py | 1 + lib/cartopy/tests/crs/test_eckert.py | 1 + lib/cartopy/tests/crs/test_equal_earth.py | 1 + lib/cartopy/tests/crs/test_equidistant_conic.py | 1 + lib/cartopy/tests/crs/test_geostationary.py | 1 + lib/cartopy/tests/crs/test_gnomonic.py | 1 + lib/cartopy/tests/crs/test_hammer.py | 1 + .../tests/crs/test_interrupted_goode_homolosine.py | 1 + .../tests/crs/test_lambert_azimuthal_equal_area.py | 1 + lib/cartopy/tests/crs/test_lambert_conformal.py | 1 + lib/cartopy/tests/crs/test_mercator.py | 1 + lib/cartopy/tests/crs/test_miller.py | 1 + lib/cartopy/tests/crs/test_mollweide.py | 1 + lib/cartopy/tests/crs/test_nearside_perspective.py | 1 + lib/cartopy/tests/crs/test_oblique_mercator.py | 1 + lib/cartopy/tests/crs/test_orthographic.py | 1 + lib/cartopy/tests/crs/test_robinson.py | 2 +- lib/cartopy/tests/crs/test_rotated_geodetic.py | 2 +- lib/cartopy/tests/crs/test_rotated_pole.py | 2 +- lib/cartopy/tests/crs/test_sinusoidal.py | 1 + lib/cartopy/tests/crs/test_stereographic.py | 1 + lib/cartopy/tests/crs/test_utm.py | 1 + lib/cartopy/tests/feature/test_nightshade.py | 2 +- lib/cartopy/tests/io/test_ogc_clients.py | 2 +- lib/cartopy/tests/io/test_srtm.py | 7 ++----- lib/cartopy/tests/mpl/__init__.py | 3 +-- lib/cartopy/tests/mpl/test_axes.py | 4 ++-- lib/cartopy/tests/mpl/test_caching.py | 4 ++-- lib/cartopy/tests/mpl/test_feature_artist.py | 6 +++--- lib/cartopy/tests/mpl/test_gridliner.py | 8 +++----- lib/cartopy/tests/mpl/test_images.py | 8 +++----- lib/cartopy/tests/mpl/test_img_transform.py | 2 +- lib/cartopy/tests/mpl/test_mpl_integration.py | 3 +-- lib/cartopy/tests/mpl/test_quiver.py | 4 ++-- lib/cartopy/tests/mpl/test_shapely_to_mpl.py | 6 +++--- lib/cartopy/tests/mpl/test_ticker.py | 6 +++--- lib/cartopy/tests/mpl/test_ticks.py | 2 +- lib/cartopy/tests/test_coding_standards.py | 3 +-- lib/cartopy/tests/test_crs.py | 3 ++- lib/cartopy/tests/test_features.py | 3 ++- lib/cartopy/tests/test_img_nest.py | 7 +++---- lib/cartopy/tests/test_img_transform.py | 2 +- lib/cartopy/tests/test_util.py | 2 +- lib/cartopy/tests/test_vector_transform.py | 4 ++-- lib/cartopy/trace.pyx | 7 +++++-- lib/cartopy/vector_transform.py | 1 + pyproject.toml | 8 ++++++++ setup.py | 7 +++---- tools/cartopy_feature_download.py | 1 - 97 files changed, 184 insertions(+), 132 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5df8321aa..a79e3bc5a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,3 +24,9 @@ repos: hooks: - id: sort-all types: [file, python] + - repo: https://github.com/PyCQA/isort + rev: "5.12.0" + hooks: + - id: isort + types: [file, python] + args: [--filter-files] diff --git a/benchmarks/cases/mpl_redraw.py b/benchmarks/cases/mpl_redraw.py index db3926063..9f4d743a2 100644 --- a/benchmarks/cases/mpl_redraw.py +++ b/benchmarks/cases/mpl_redraw.py @@ -4,10 +4,11 @@ # See COPYING and COPYING.LESSER in the root of the repository for full # licensing details. -import cartopy.crs as ccrs -import matplotlib.pyplot as plt import io +import matplotlib.pyplot as plt + +import cartopy.crs as ccrs # No need for anything other than the agg backend, and we don't want # windows popping up as we are running these tests. diff --git a/benchmarks/cases/project_linear.py b/benchmarks/cases/project_linear.py index df40698bf..5f0b53a31 100644 --- a/benchmarks/cases/project_linear.py +++ b/benchmarks/cases/project_linear.py @@ -4,8 +4,8 @@ # See COPYING and COPYING.LESSER in the root of the repository for full # licensing details. -import cartopy.io.shapereader as shpreader import cartopy.crs as ccrs +import cartopy.io.shapereader as shpreader class Suite: diff --git a/docs/make_projection.py b/docs/make_projection.py index 0ce381294..886c476f2 100644 --- a/docs/make_projection.py +++ b/docs/make_projection.py @@ -7,7 +7,9 @@ import inspect from pathlib import Path import textwrap + import numpy as np + import cartopy.crs as ccrs #: A dictionary to allow examples to use non-default parameters to the CRS @@ -26,6 +28,7 @@ def plate_carree_plot(): import matplotlib.pyplot as plt + import cartopy.crs as ccrs nplots = 2 @@ -43,6 +46,7 @@ def plate_carree_plot(): def igh_plot(): import matplotlib.pyplot as plt + import cartopy.crs as ccrs fig = plt.figure(figsize=(6.9228, 6)) @@ -62,6 +66,7 @@ def igh_plot(): def utm_plot(): import matplotlib.pyplot as plt + import cartopy.crs as ccrs nplots = 60 diff --git a/docs/source/conf.py b/docs/source/conf.py index 90dfdc3f7..30c07b24a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -20,10 +20,11 @@ from pathlib import Path import sys -import cartopy import matplotlib from sphinx_gallery.sorting import ExampleTitleSortKey, ExplicitOrder +import cartopy + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. sys.path.insert(0, str(Path(__file__).parent.resolve())) diff --git a/examples/gridlines_and_labels/gridliner.py b/examples/gridlines_and_labels/gridliner.py index 3d8e413d2..112400ea1 100755 --- a/examples/gridlines_and_labels/gridliner.py +++ b/examples/gridlines_and_labels/gridliner.py @@ -17,11 +17,11 @@ In the third example, labels are drawn only on the left and bottom sides. """ +import matplotlib.pyplot as plt + import cartopy.crs as ccrs import cartopy.feature as cfeature -import matplotlib.pyplot as plt - def main(): diff --git a/examples/gridlines_and_labels/tick_labels.py b/examples/gridlines_and_labels/tick_labels.py index c60ce8588..4ad95ce45 100644 --- a/examples/gridlines_and_labels/tick_labels.py +++ b/examples/gridlines_and_labels/tick_labels.py @@ -6,10 +6,11 @@ projections using special tick formatters. """ -import cartopy.crs as ccrs -from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter import matplotlib.pyplot as plt +import cartopy.crs as ccrs +from cartopy.mpl.ticker import LatitudeFormatter, LongitudeFormatter + def main(): fig = plt.figure(figsize=(8, 10)) diff --git a/examples/lines_and_polygons/effects_of_the_ellipse.py b/examples/lines_and_polygons/effects_of_the_ellipse.py index f1404c582..e0992bbad 100644 --- a/examples/lines_and_polygons/effects_of_the_ellipse.py +++ b/examples/lines_and_polygons/effects_of_the_ellipse.py @@ -14,16 +14,17 @@ coastlines are shifted as a result of referencing the incorrect ellipse. """ -import cartopy.crs as ccrs -import cartopy.feature as cfeature -from cartopy.io.img_tiles import Stamen -import matplotlib.pyplot as plt from matplotlib.lines import Line2D as Line from matplotlib.patheffects import Stroke +import matplotlib.pyplot as plt import numpy as np import shapely.geometry as sgeom from shapely.ops import transform as geom_transform +import cartopy.crs as ccrs +import cartopy.feature as cfeature +from cartopy.io.img_tiles import Stamen + def transform_fn_factory(target_crs, source_crs): """ diff --git a/examples/lines_and_polygons/feature_creation.py b/examples/lines_and_polygons/feature_creation.py index f7ff9c0d8..f1faf2615 100644 --- a/examples/lines_and_polygons/feature_creation.py +++ b/examples/lines_and_polygons/feature_creation.py @@ -13,10 +13,11 @@ pre-defined :data:`cartopy.feature.STATES` constant. """ +from matplotlib.offsetbox import AnchoredText import matplotlib.pyplot as plt + import cartopy.crs as ccrs import cartopy.feature as cfeature -from matplotlib.offsetbox import AnchoredText def main(): diff --git a/examples/lines_and_polygons/features.py b/examples/lines_and_polygons/features.py index bc1f569ff..69808e779 100644 --- a/examples/lines_and_polygons/features.py +++ b/examples/lines_and_polygons/features.py @@ -6,9 +6,10 @@ in cartopy. """ +import matplotlib.pyplot as plt + import cartopy.crs as ccrs import cartopy.feature as cfeature -import matplotlib.pyplot as plt def main(): diff --git a/examples/lines_and_polygons/nightshade.py b/examples/lines_and_polygons/nightshade.py index 1face4aa6..788f244d9 100644 --- a/examples/lines_and_polygons/nightshade.py +++ b/examples/lines_and_polygons/nightshade.py @@ -6,11 +6,12 @@ """ import datetime + import matplotlib.pyplot as plt + import cartopy.crs as ccrs from cartopy.feature.nightshade import Nightshade - fig = plt.figure(figsize=(10, 5)) ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree()) diff --git a/examples/miscellanea/animate_surface.py b/examples/miscellanea/animate_surface.py index a44a574fb..beb8853c2 100644 --- a/examples/miscellanea/animate_surface.py +++ b/examples/miscellanea/animate_surface.py @@ -5,9 +5,10 @@ This example demonstrates how to animate gridded data using `pcolormesh()`. """ -import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation +import matplotlib.pyplot as plt import numpy as np + import cartopy.crs as ccrs fig = plt.figure(figsize=(10, 5)) diff --git a/examples/miscellanea/axes_grid_basic.py b/examples/miscellanea/axes_grid_basic.py index 926a962b0..4228ab5ce 100644 --- a/examples/miscellanea/axes_grid_basic.py +++ b/examples/miscellanea/axes_grid_basic.py @@ -9,13 +9,14 @@ labelling is switched off, and instead a standard procedure of creating grid lines is used. Then some fake data is plotted. """ -import cartopy.crs as ccrs -from cartopy.mpl.geoaxes import GeoAxes -from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import AxesGrid import numpy as np +import cartopy.crs as ccrs +from cartopy.mpl.geoaxes import GeoAxes +from cartopy.mpl.ticker import LatitudeFormatter, LongitudeFormatter + def sample_data_3d(shape): """Return `lons`, `lats`, `times` and fake `data`""" diff --git a/examples/miscellanea/eccentric_ellipse.py b/examples/miscellanea/eccentric_ellipse.py index 235b001c0..06ff85fa9 100644 --- a/examples/miscellanea/eccentric_ellipse.py +++ b/examples/miscellanea/eccentric_ellipse.py @@ -13,10 +13,11 @@ from io import BytesIO from urllib.request import urlopen -import cartopy.crs as ccrs +from PIL import Image import matplotlib.pyplot as plt import numpy as np -from PIL import Image + +import cartopy.crs as ccrs def vesta_image(): diff --git a/examples/miscellanea/favicon.py b/examples/miscellanea/favicon.py index b1398ea58..ca9bd49e2 100644 --- a/examples/miscellanea/favicon.py +++ b/examples/miscellanea/favicon.py @@ -5,11 +5,12 @@ The actual code to generate cartopy's favicon. """ -import cartopy.crs as ccrs +from matplotlib.font_manager import FontProperties +import matplotlib.patches import matplotlib.pyplot as plt import matplotlib.textpath -import matplotlib.patches -from matplotlib.font_manager import FontProperties + +import cartopy.crs as ccrs def main(): diff --git a/examples/miscellanea/logo.py b/examples/miscellanea/logo.py index d7030c9b4..bb56b6d66 100644 --- a/examples/miscellanea/logo.py +++ b/examples/miscellanea/logo.py @@ -5,12 +5,13 @@ The actual code to produce cartopy's logo. """ -import cartopy.crs as ccrs +from matplotlib.font_manager import FontProperties +import matplotlib.patches import matplotlib.pyplot as plt import matplotlib.textpath -import matplotlib.patches import matplotlib.transforms -from matplotlib.font_manager import FontProperties + +import cartopy.crs as ccrs def main(): diff --git a/examples/miscellanea/un_flag.py b/examples/miscellanea/un_flag.py index f2730d2cc..78b98a1ba 100644 --- a/examples/miscellanea/un_flag.py +++ b/examples/miscellanea/un_flag.py @@ -6,15 +6,15 @@ Equidistant projection to reproduce the UN flag. """ -import cartopy.crs as ccrs -import cartopy.feature as cfeature -import matplotlib.pyplot as plt from matplotlib.patches import PathPatch import matplotlib.path +import matplotlib.pyplot as plt import matplotlib.ticker -from matplotlib.transforms import BboxTransform, Bbox +from matplotlib.transforms import Bbox, BboxTransform import numpy as np +import cartopy.crs as ccrs +import cartopy.feature as cfeature # When drawing the flag, we can either use white filled land, or be a little # more fancy and use the Natural Earth shaded relief imagery. diff --git a/examples/miscellanea/utm_all_zones.py b/examples/miscellanea/utm_all_zones.py index 51f16554e..56c51095d 100644 --- a/examples/miscellanea/utm_all_zones.py +++ b/examples/miscellanea/utm_all_zones.py @@ -10,9 +10,10 @@ Then we add coastlines, gridlines and the number of the zone. Finally we add a supertitle and display the figure. """ -import cartopy.crs as ccrs import matplotlib.pyplot as plt +import cartopy.crs as ccrs + def main(): # Create a list of integers from 1 - 60 diff --git a/examples/scalar_data/aurora_forecast.py b/examples/scalar_data/aurora_forecast.py index 454df9d25..7939f167c 100644 --- a/examples/scalar_data/aurora_forecast.py +++ b/examples/scalar_data/aurora_forecast.py @@ -16,11 +16,12 @@ from io import StringIO from urllib.request import urlopen +from matplotlib.colors import LinearSegmentedColormap +import matplotlib.pyplot as plt import numpy as np + import cartopy.crs as ccrs from cartopy.feature.nightshade import Nightshade -import matplotlib.pyplot as plt -from matplotlib.colors import LinearSegmentedColormap def aurora_forecast(): diff --git a/examples/scalar_data/contour_labels.py b/examples/scalar_data/contour_labels.py index 679e8f76b..4c1d2b59f 100644 --- a/examples/scalar_data/contour_labels.py +++ b/examples/scalar_data/contour_labels.py @@ -5,9 +5,10 @@ An example of adding contour labels to matplotlib contours. """ -import cartopy.crs as ccrs import matplotlib.pyplot as plt +import cartopy.crs as ccrs + def sample_data(shape=(73, 145)): """Return ``lons``, ``lats`` and ``data`` of some fake data.""" diff --git a/examples/scalar_data/contour_transforms.py b/examples/scalar_data/contour_transforms.py index 80dbff82b..ecaa696e3 100644 --- a/examples/scalar_data/contour_transforms.py +++ b/examples/scalar_data/contour_transforms.py @@ -11,9 +11,10 @@ have a negative impact on the wrapped coordinates as one can see in the second axes that the data does not extend to the full global extent. """ -import cartopy.crs as ccrs import matplotlib.pyplot as plt +import cartopy.crs as ccrs + def sample_data(shape=(73, 145)): """Return ``lons``, ``lats`` and ``data`` of some fake data.""" diff --git a/examples/scalar_data/geostationary.py b/examples/scalar_data/geostationary.py index 36dcf4d46..fddffa78b 100644 --- a/examples/scalar_data/geostationary.py +++ b/examples/scalar_data/geostationary.py @@ -14,9 +14,10 @@ from io import BytesIO from urllib.request import urlopen -import cartopy.crs as ccrs import matplotlib.pyplot as plt +import cartopy.crs as ccrs + def geos_image(): """ diff --git a/examples/scalar_data/wrapping_global.py b/examples/scalar_data/wrapping_global.py index d4ef32b9c..2a067b221 100644 --- a/examples/scalar_data/wrapping_global.py +++ b/examples/scalar_data/wrapping_global.py @@ -14,8 +14,9 @@ data values at the ending longitudes will be closed to the wrap point. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import cartopy.crs as ccrs import cartopy.util as cutil diff --git a/examples/web_services/image_tiles.py b/examples/web_services/image_tiles.py index e80a61bc8..7b6d24dc1 100644 --- a/examples/web_services/image_tiles.py +++ b/examples/web_services/image_tiles.py @@ -7,8 +7,8 @@ """ import matplotlib.pyplot as plt -import cartopy.crs as ccrs +import cartopy.crs as ccrs from cartopy.io.img_tiles import Stamen diff --git a/examples/web_services/reprojected_wmts.py b/examples/web_services/reprojected_wmts.py index b4eaf8932..0fa1daefb 100644 --- a/examples/web_services/reprojected_wmts.py +++ b/examples/web_services/reprojected_wmts.py @@ -17,6 +17,7 @@ """ import matplotlib.pyplot as plt + import cartopy.crs as ccrs diff --git a/examples/web_services/wms.py b/examples/web_services/wms.py index 372feadf0..4de888b50 100644 --- a/examples/web_services/wms.py +++ b/examples/web_services/wms.py @@ -6,9 +6,10 @@ supported by an OGC web services Web Map Service (WMS) aware axes. """ -import cartopy.crs as ccrs import matplotlib.pyplot as plt +import cartopy.crs as ccrs + def main(): fig = plt.figure(figsize=(10, 5)) diff --git a/examples/web_services/wmts.py b/examples/web_services/wmts.py index f839b41f1..1f31721c2 100644 --- a/examples/web_services/wmts.py +++ b/examples/web_services/wmts.py @@ -15,6 +15,7 @@ """ import matplotlib.pyplot as plt + import cartopy.crs as ccrs diff --git a/examples/web_services/wmts_time.py b/examples/web_services/wmts_time.py index c51242c03..7dc966584 100644 --- a/examples/web_services/wmts_time.py +++ b/examples/web_services/wmts_time.py @@ -12,8 +12,8 @@ the left, with the MODIS false color 'snow RGB' shown on the right. """ -import matplotlib.pyplot as plt from matplotlib import patheffects +import matplotlib.pyplot as plt from owslib.wmts import WebMapTileService import cartopy.crs as ccrs diff --git a/lib/cartopy/__init__.py b/lib/cartopy/__init__.py index 96e0b79ae..4b08efcd0 100644 --- a/lib/cartopy/__init__.py +++ b/lib/cartopy/__init__.py @@ -5,9 +5,9 @@ # licensing details. import os from pathlib import Path +import tempfile from ._version import version as __version__ # noqa: F401 -import tempfile __document_these__ = ['config'] diff --git a/lib/cartopy/_epsg.py b/lib/cartopy/_epsg.py index e48491fd0..0d0d07d1c 100644 --- a/lib/cartopy/_epsg.py +++ b/lib/cartopy/_epsg.py @@ -7,9 +7,10 @@ Provide support for converting EPSG codes to Projection instances. """ -import cartopy.crs as ccrs from pyproj.crs import CRS as _CRS +import cartopy.crs as ccrs + class _EPSGProjection(ccrs.Projection): def __init__(self, code): diff --git a/lib/cartopy/crs.py b/lib/cartopy/crs.py index fcbdd6c5c..5185bd1ee 100644 --- a/lib/cartopy/crs.py +++ b/lib/cartopy/crs.py @@ -19,14 +19,13 @@ import warnings import numpy as np -import shapely.geometry as sgeom from pyproj import Transformer from pyproj.exceptions import ProjError +import shapely.geometry as sgeom from shapely.prepared import prep import cartopy.trace - try: # https://github.com/pyproj4/pyproj/pull/912 from pyproj.crs import CustomConstructorCRS as _CRS diff --git a/lib/cartopy/feature/__init__.py b/lib/cartopy/feature/__init__.py index 1342dcade..61d3d198b 100644 --- a/lib/cartopy/feature/__init__.py +++ b/lib/cartopy/feature/__init__.py @@ -15,9 +15,8 @@ import numpy as np import shapely.geometry as sgeom -import cartopy.io.shapereader as shapereader import cartopy.crs - +import cartopy.io.shapereader as shapereader COLORS = {'land': np.array((240, 240, 220)) / 256., 'land_alt1': np.array((220, 220, 220)) / 256., diff --git a/lib/cartopy/img_transform.py b/lib/cartopy/img_transform.py index dbc748817..f8e19c62d 100644 --- a/lib/cartopy/img_transform.py +++ b/lib/cartopy/img_transform.py @@ -10,6 +10,7 @@ """ import numpy as np + try: import pykdtree.kdtree _is_pykdtree = True diff --git a/lib/cartopy/io/img_nest.py b/lib/cartopy/io/img_nest.py index 8ad19004f..5a1502a6f 100644 --- a/lib/cartopy/io/img_nest.py +++ b/lib/cartopy/io/img_nest.py @@ -8,11 +8,10 @@ import collections from pathlib import Path -import numpy as np from PIL import Image +import numpy as np import shapely.geometry as sgeom - _img_class_attrs = ['filename', 'extent', 'origin', 'pixel_size'] diff --git a/lib/cartopy/io/img_tiles.py b/lib/cartopy/io/img_tiles.py index 744dde9b1..6b6dc8c3e 100644 --- a/lib/cartopy/io/img_tiles.py +++ b/lib/cartopy/io/img_tiles.py @@ -24,8 +24,8 @@ import warnings from PIL import Image -import shapely.geometry as sgeom import numpy as np +import shapely.geometry as sgeom import cartopy import cartopy.crs as ccrs @@ -202,7 +202,7 @@ def _image_url(self, tile): pass def get_image(self, tile): - from urllib.request import urlopen, Request, HTTPError, URLError + from urllib.request import HTTPError, Request, URLError, urlopen if self.cache_path is not None: filename = "_".join([str(i) for i in tile]) + ".npy" diff --git a/lib/cartopy/io/ogc_clients.py b/lib/cartopy/io/ogc_clients.py index 7d6009dbc..49f00e833 100644 --- a/lib/cartopy/io/ogc_clients.py +++ b/lib/cartopy/io/ogc_clients.py @@ -28,9 +28,9 @@ import shapely.geometry as sgeom try: - from owslib.wms import WebMapService - from owslib.wfs import WebFeatureService import owslib.util + from owslib.wfs import WebFeatureService + from owslib.wms import WebMapService import owslib.wmts _OWSLIB_AVAILABLE = True @@ -40,8 +40,8 @@ _OWSLIB_AVAILABLE = False import cartopy.crs as ccrs -from cartopy.io import LocatedImage, RasterSource from cartopy.img_transform import warp_array +from cartopy.io import LocatedImage, RasterSource _OWSLIB_REQUIRED = 'OWSLib is required to use OGC web services.' diff --git a/lib/cartopy/io/shapereader.py b/lib/cartopy/io/shapereader.py index e2cd5332a..e2df8a08e 100644 --- a/lib/cartopy/io/shapereader.py +++ b/lib/cartopy/io/shapereader.py @@ -32,11 +32,12 @@ from pathlib import Path from urllib.error import HTTPError -import shapely.geometry as sgeom import shapefile +import shapely.geometry as sgeom -from cartopy.io import Downloader from cartopy import config +from cartopy.io import Downloader + _HAS_FIONA = False try: import fiona diff --git a/lib/cartopy/io/srtm.py b/lib/cartopy/io/srtm.py index 8f136c40b..75972de4a 100644 --- a/lib/cartopy/io/srtm.py +++ b/lib/cartopy/io/srtm.py @@ -22,7 +22,7 @@ from cartopy import config import cartopy.crs as ccrs -from cartopy.io import fh_getter, Downloader, RasterSource, LocatedImage +from cartopy.io import Downloader, LocatedImage, RasterSource, fh_getter class _SRTMSource(RasterSource): diff --git a/lib/cartopy/mpl/feature_artist.py b/lib/cartopy/mpl/feature_artist.py index 6a84d7e12..5d940b017 100644 --- a/lib/cartopy/mpl/feature_artist.py +++ b/lib/cartopy/mpl/feature_artist.py @@ -14,12 +14,14 @@ import warnings import weakref -import numpy as np import matplotlib.artist import matplotlib.collections +import numpy as np import cartopy.mpl.patch as cpatch -from .style import merge as style_merge, finalize as style_finalize + +from .style import finalize as style_finalize +from .style import merge as style_merge class _GeomKey: diff --git a/lib/cartopy/mpl/geoaxes.py b/lib/cartopy/mpl/geoaxes.py index d5ae50b10..8f6c0907b 100644 --- a/lib/cartopy/mpl/geoaxes.py +++ b/lib/cartopy/mpl/geoaxes.py @@ -26,10 +26,10 @@ import matplotlib.axes import matplotlib.contour from matplotlib.image import imread -import matplotlib.transforms as mtransforms import matplotlib.patches as mpatches import matplotlib.path as mpath import matplotlib.spines as mspines +import matplotlib.transforms as mtransforms import numpy as np import numpy.ma as ma import shapely.geometry as sgeom @@ -38,12 +38,11 @@ import cartopy.crs as ccrs import cartopy.feature import cartopy.mpl.contour -import cartopy.mpl.geocollection import cartopy.mpl.feature_artist as feature_artist +import cartopy.mpl.geocollection import cartopy.mpl.patch as cpatch from cartopy.mpl.slippy_image_artist import SlippyImageArtist - assert mpl.__version__ >= '3.1', \ 'Cartopy is only supported with Matplotlib 3.1 or greater.' diff --git a/lib/cartopy/mpl/gridliner.py b/lib/cartopy/mpl/gridliner.py index 9eddc9a37..cbc31ffea 100644 --- a/lib/cartopy/mpl/gridliner.py +++ b/lib/cartopy/mpl/gridliner.py @@ -10,17 +10,16 @@ import matplotlib import matplotlib.collections as mcollections +import matplotlib.path as mpath import matplotlib.ticker as mticker import matplotlib.transforms as mtrans -import matplotlib.path as mpath import numpy as np import shapely.geometry as sgeom import cartopy -from cartopy.crs import Projection, _RectangularProjection, PlateCarree -from cartopy.mpl.ticker import ( - LongitudeLocator, LatitudeLocator, - LongitudeFormatter, LatitudeFormatter) +from cartopy.crs import PlateCarree, Projection, _RectangularProjection +from cartopy.mpl.ticker import (LatitudeFormatter, LatitudeLocator, + LongitudeFormatter, LongitudeLocator) degree_locator = mticker.MaxNLocator(nbins=9, steps=[1, 1.5, 1.8, 2, 3, 6, 10]) classic_locator = mticker.MaxNLocator(nbins=9) diff --git a/lib/cartopy/mpl/patch.py b/lib/cartopy/mpl/patch.py index 045899178..10732ec69 100644 --- a/lib/cartopy/mpl/patch.py +++ b/lib/cartopy/mpl/patch.py @@ -14,8 +14,8 @@ """ -import numpy as np from matplotlib.path import Path +import numpy as np import shapely.geometry as sgeom diff --git a/lib/cartopy/mpl/slippy_image_artist.py b/lib/cartopy/mpl/slippy_image_artist.py index 4fa9d6480..6f8fb2dfc 100644 --- a/lib/cartopy/mpl/slippy_image_artist.py +++ b/lib/cartopy/mpl/slippy_image_artist.py @@ -10,8 +10,8 @@ """ -from matplotlib.image import AxesImage import matplotlib.artist +from matplotlib.image import AxesImage class SlippyImageArtist(AxesImage): diff --git a/lib/cartopy/mpl/style.py b/lib/cartopy/mpl/style.py index 01eafdf24..13a643528 100644 --- a/lib/cartopy/mpl/style.py +++ b/lib/cartopy/mpl/style.py @@ -11,7 +11,6 @@ import warnings - # Define the matplotlib style aliases that cartopy can expand. # Note: This should not contain the plural aliases # (e.g. linewidths -> linewidth). diff --git a/lib/cartopy/mpl/ticker.py b/lib/cartopy/mpl/ticker.py index 5843dcbb9..8f894864d 100644 --- a/lib/cartopy/mpl/ticker.py +++ b/lib/cartopy/mpl/ticker.py @@ -5,9 +5,9 @@ # licensing details. """This module contains tools for handling tick marks in cartopy.""" -import numpy as np import matplotlib as mpl from matplotlib.ticker import Formatter, MaxNLocator +import numpy as np import cartopy.crs as ccrs from cartopy.mpl.geoaxes import GeoAxes diff --git a/lib/cartopy/tests/crs/__init__.py b/lib/cartopy/tests/crs/__init__.py index f34a3bd1c..1ac643e7d 100644 --- a/lib/cartopy/tests/crs/__init__.py +++ b/lib/cartopy/tests/crs/__init__.py @@ -10,5 +10,4 @@ import pytest - pytest.register_assert_rewrite('cartopy.tests.crs.helpers') diff --git a/lib/cartopy/tests/crs/test_aitoff.py b/lib/cartopy/tests/crs/test_aitoff.py index dbd11648d..817c65a08 100644 --- a/lib/cartopy/tests/crs/test_aitoff.py +++ b/lib/cartopy/tests/crs/test_aitoff.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_albers_equal_area.py b/lib/cartopy/tests/crs/test_albers_equal_area.py index 5700a10c8..8e6e3daea 100644 --- a/lib/cartopy/tests/crs/test_albers_equal_area.py +++ b/lib/cartopy/tests/crs/test_albers_equal_area.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_azimuthal_equidistant.py b/lib/cartopy/tests/crs/test_azimuthal_equidistant.py index 1d93819c0..fc700c4fc 100644 --- a/lib/cartopy/tests/crs/test_azimuthal_equidistant.py +++ b/lib/cartopy/tests/crs/test_azimuthal_equidistant.py @@ -8,6 +8,7 @@ from numpy.testing import assert_almost_equal, assert_array_almost_equal import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_eckert.py b/lib/cartopy/tests/crs/test_eckert.py index 66f0fd2ec..2bd1fc8a9 100644 --- a/lib/cartopy/tests/crs/test_eckert.py +++ b/lib/cartopy/tests/crs/test_eckert.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_equal_earth.py b/lib/cartopy/tests/crs/test_equal_earth.py index 4ab904d90..a50195993 100644 --- a/lib/cartopy/tests/crs/test_equal_earth.py +++ b/lib/cartopy/tests/crs/test_equal_earth.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_equidistant_conic.py b/lib/cartopy/tests/crs/test_equidistant_conic.py index 045c87e5d..96da304a7 100644 --- a/lib/cartopy/tests/crs/test_equidistant_conic.py +++ b/lib/cartopy/tests/crs/test_equidistant_conic.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_geostationary.py b/lib/cartopy/tests/crs/test_geostationary.py index fd35f3130..4b4622120 100644 --- a/lib/cartopy/tests/crs/test_geostationary.py +++ b/lib/cartopy/tests/crs/test_geostationary.py @@ -11,6 +11,7 @@ from numpy.testing import assert_almost_equal import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_gnomonic.py b/lib/cartopy/tests/crs/test_gnomonic.py index 8ff31cde0..195136e5a 100644 --- a/lib/cartopy/tests/crs/test_gnomonic.py +++ b/lib/cartopy/tests/crs/test_gnomonic.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_hammer.py b/lib/cartopy/tests/crs/test_hammer.py index cab78c6dc..d10471b30 100644 --- a/lib/cartopy/tests/crs/test_hammer.py +++ b/lib/cartopy/tests/crs/test_hammer.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_interrupted_goode_homolosine.py b/lib/cartopy/tests/crs/test_interrupted_goode_homolosine.py index 30383073b..5ff16c036 100644 --- a/lib/cartopy/tests/crs/test_interrupted_goode_homolosine.py +++ b/lib/cartopy/tests/crs/test_interrupted_goode_homolosine.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_lambert_azimuthal_equal_area.py b/lib/cartopy/tests/crs/test_lambert_azimuthal_equal_area.py index a06c89067..b9f5c4a78 100644 --- a/lib/cartopy/tests/crs/test_lambert_azimuthal_equal_area.py +++ b/lib/cartopy/tests/crs/test_lambert_azimuthal_equal_area.py @@ -9,6 +9,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_lambert_conformal.py b/lib/cartopy/tests/crs/test_lambert_conformal.py index 6032d2e5c..d1bcd58b7 100644 --- a/lib/cartopy/tests/crs/test_lambert_conformal.py +++ b/lib/cartopy/tests/crs/test_lambert_conformal.py @@ -8,6 +8,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_mercator.py b/lib/cartopy/tests/crs/test_mercator.py index b9db14fd8..2963c67bb 100644 --- a/lib/cartopy/tests/crs/test_mercator.py +++ b/lib/cartopy/tests/crs/test_mercator.py @@ -8,6 +8,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_miller.py b/lib/cartopy/tests/crs/test_miller.py index 9288b9351..d8da14d00 100644 --- a/lib/cartopy/tests/crs/test_miller.py +++ b/lib/cartopy/tests/crs/test_miller.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_mollweide.py b/lib/cartopy/tests/crs/test_mollweide.py index 58cbd4ecc..9ed312e4a 100644 --- a/lib/cartopy/tests/crs/test_mollweide.py +++ b/lib/cartopy/tests/crs/test_mollweide.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_nearside_perspective.py b/lib/cartopy/tests/crs/test_nearside_perspective.py index b9f36b204..0fe3c7865 100644 --- a/lib/cartopy/tests/crs/test_nearside_perspective.py +++ b/lib/cartopy/tests/crs/test_nearside_perspective.py @@ -11,6 +11,7 @@ from numpy.testing import assert_almost_equal import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_oblique_mercator.py b/lib/cartopy/tests/crs/test_oblique_mercator.py index 9ee670619..b2da3a5c6 100644 --- a/lib/cartopy/tests/crs/test_oblique_mercator.py +++ b/lib/cartopy/tests/crs/test_oblique_mercator.py @@ -15,6 +15,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_orthographic.py b/lib/cartopy/tests/crs/test_orthographic.py index 0b4c1254b..db26488a5 100644 --- a/lib/cartopy/tests/crs/test_orthographic.py +++ b/lib/cartopy/tests/crs/test_orthographic.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_robinson.py b/lib/cartopy/tests/crs/test_robinson.py index 77f85624e..d843a795d 100644 --- a/lib/cartopy/tests/crs/test_robinson.py +++ b/lib/cartopy/tests/crs/test_robinson.py @@ -13,8 +13,8 @@ import pytest import cartopy.crs as ccrs -from .helpers import check_proj_params +from .helpers import check_proj_params _CRS_PC = ccrs.PlateCarree() _CRS_ROB = ccrs.Robinson() diff --git a/lib/cartopy/tests/crs/test_rotated_geodetic.py b/lib/cartopy/tests/crs/test_rotated_geodetic.py index 229d45519..657e32ba9 100644 --- a/lib/cartopy/tests/crs/test_rotated_geodetic.py +++ b/lib/cartopy/tests/crs/test_rotated_geodetic.py @@ -9,8 +9,8 @@ """ import cartopy.crs as ccrs -from .helpers import check_proj_params +from .helpers import check_proj_params common_other_args = {'o_proj=latlon', 'to_meter=111319.4907932736', 'a=6378137.0'} diff --git a/lib/cartopy/tests/crs/test_rotated_pole.py b/lib/cartopy/tests/crs/test_rotated_pole.py index c59dc612b..988495fd9 100644 --- a/lib/cartopy/tests/crs/test_rotated_pole.py +++ b/lib/cartopy/tests/crs/test_rotated_pole.py @@ -9,8 +9,8 @@ """ import cartopy.crs as ccrs -from .helpers import check_proj_params +from .helpers import check_proj_params common_other_args = {'o_proj=latlon', 'to_meter=111319.4907932736'} diff --git a/lib/cartopy/tests/crs/test_sinusoidal.py b/lib/cartopy/tests/crs/test_sinusoidal.py index 2f2a1821a..79700791b 100644 --- a/lib/cartopy/tests/crs/test_sinusoidal.py +++ b/lib/cartopy/tests/crs/test_sinusoidal.py @@ -9,6 +9,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_stereographic.py b/lib/cartopy/tests/crs/test_stereographic.py index 2644198e4..654fc5e79 100644 --- a/lib/cartopy/tests/crs/test_stereographic.py +++ b/lib/cartopy/tests/crs/test_stereographic.py @@ -8,6 +8,7 @@ from numpy.testing import assert_almost_equal import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/crs/test_utm.py b/lib/cartopy/tests/crs/test_utm.py index 13dcd412a..241915cae 100644 --- a/lib/cartopy/tests/crs/test_utm.py +++ b/lib/cartopy/tests/crs/test_utm.py @@ -13,6 +13,7 @@ import pytest import cartopy.crs as ccrs + from .helpers import check_proj_params diff --git a/lib/cartopy/tests/feature/test_nightshade.py b/lib/cartopy/tests/feature/test_nightshade.py index 753d193ac..0b964a6e2 100644 --- a/lib/cartopy/tests/feature/test_nightshade.py +++ b/lib/cartopy/tests/feature/test_nightshade.py @@ -8,7 +8,7 @@ import pytest -from cartopy.feature.nightshade import _julian_day, _solar_position, Nightshade +from cartopy.feature.nightshade import Nightshade, _julian_day, _solar_position def test_julian_day(): diff --git a/lib/cartopy/tests/io/test_ogc_clients.py b/lib/cartopy/tests/io/test_ogc_clients.py index bbe26bab8..a6577905d 100644 --- a/lib/cartopy/tests/io/test_ogc_clients.py +++ b/lib/cartopy/tests/io/test_ogc_clients.py @@ -8,6 +8,7 @@ from xml.etree.ElementTree import ParseError import numpy as np + try: from owslib.wfs import WebFeatureService from owslib.wms import WebMapService @@ -22,7 +23,6 @@ import cartopy.io.ogc_clients as ogc from cartopy.io.ogc_clients import _OWSLIB_AVAILABLE - RESOLUTION = (30, 30) diff --git a/lib/cartopy/tests/io/test_srtm.py b/lib/cartopy/tests/io/test_srtm.py index 94d363bf0..bc6185c2b 100644 --- a/lib/cartopy/tests/io/test_srtm.py +++ b/lib/cartopy/tests/io/test_srtm.py @@ -13,7 +13,6 @@ from .test_downloaders import download_to_temp # noqa: F401 (used as fixture) - pytestmark = [pytest.mark.network, pytest.mark.filterwarnings('ignore:SRTM requires an account'), pytest.mark.usefixtures('srtm_login_or_skip')] @@ -31,11 +30,9 @@ def srtm_login_or_skip(monkeypatch): except KeyError: pytest.skip('SRTM_PASSWORD environment variable is unset.') - from urllib.request import (HTTPBasicAuthHandler, - HTTPCookieProcessor, - HTTPPasswordMgrWithDefaultRealm, - build_opener) from http.cookiejar import CookieJar + from urllib.request import (HTTPBasicAuthHandler, HTTPCookieProcessor, + HTTPPasswordMgrWithDefaultRealm, build_opener) password_manager = HTTPPasswordMgrWithDefaultRealm() password_manager.add_password( diff --git a/lib/cartopy/tests/mpl/__init__.py b/lib/cartopy/tests/mpl/__init__.py index 7f3273312..63a0b8046 100644 --- a/lib/cartopy/tests/mpl/__init__.py +++ b/lib/cartopy/tests/mpl/__init__.py @@ -5,11 +5,10 @@ # licensing details. import matplotlib as mpl -import matplotlib.pyplot as plt import matplotlib.patches as mpatches +import matplotlib.pyplot as plt import packaging.version - MPL_VERSION = packaging.version.parse(mpl.__version__) diff --git a/lib/cartopy/tests/mpl/test_axes.py b/lib/cartopy/tests/mpl/test_axes.py index d4e37a113..559c838a7 100644 --- a/lib/cartopy/tests/mpl/test_axes.py +++ b/lib/cartopy/tests/mpl/test_axes.py @@ -13,8 +13,8 @@ import cartopy.crs as ccrs import cartopy.feature as cfeature -from cartopy.mpl.geoaxes import ( - InterProjectionTransform, GeoAxes, GeoAxesSubplot) +from cartopy.mpl.geoaxes import (GeoAxes, GeoAxesSubplot, + InterProjectionTransform) class TestNoSpherical: diff --git a/lib/cartopy/tests/mpl/test_caching.py b/lib/cartopy/tests/mpl/test_caching.py index d1e8332e6..f767719d3 100644 --- a/lib/cartopy/tests/mpl/test_caching.py +++ b/lib/cartopy/tests/mpl/test_caching.py @@ -16,9 +16,9 @@ import pytest import cartopy.crs as ccrs -from cartopy.mpl.feature_artist import FeatureArtist -from cartopy.io.ogc_clients import WMTSRasterSource, _OWSLIB_AVAILABLE +from cartopy.io.ogc_clients import _OWSLIB_AVAILABLE, WMTSRasterSource import cartopy.io.shapereader +from cartopy.mpl.feature_artist import FeatureArtist import cartopy.mpl.geoaxes as cgeoaxes import cartopy.mpl.patch diff --git a/lib/cartopy/tests/mpl/test_feature_artist.py b/lib/cartopy/tests/mpl/test_feature_artist.py index 7c1e3bbe2..de4872bff 100644 --- a/lib/cartopy/tests/mpl/test_feature_artist.py +++ b/lib/cartopy/tests/mpl/test_feature_artist.py @@ -6,16 +6,16 @@ from unittest import mock +from matplotlib.transforms import IdentityTransform import numpy as np import pytest import shapely.geometry as sgeom -from matplotlib.transforms import IdentityTransform import cartopy.crs as ccrs -import cartopy.mpl.geoaxes as geoaxes from cartopy.feature import ShapelyFeature -from cartopy.mpl.feature_artist import FeatureArtist, _freeze, _GeomKey from cartopy.mpl import style +from cartopy.mpl.feature_artist import FeatureArtist, _freeze, _GeomKey +import cartopy.mpl.geoaxes as geoaxes @pytest.mark.parametrize("source, expected", [ diff --git a/lib/cartopy/tests/mpl/test_gridliner.py b/lib/cartopy/tests/mpl/test_gridliner.py index ba1614f95..cfc750a22 100644 --- a/lib/cartopy/tests/mpl/test_gridliner.py +++ b/lib/cartopy/tests/mpl/test_gridliner.py @@ -12,11 +12,9 @@ import cartopy.crs as ccrs from cartopy.mpl.geoaxes import GeoAxes -from cartopy.mpl.ticker import LongitudeLocator, LongitudeFormatter -from cartopy.mpl.gridliner import ( - LATITUDE_FORMATTER, LONGITUDE_FORMATTER, - classic_locator, classic_formatter) - +from cartopy.mpl.gridliner import (LATITUDE_FORMATTER, LONGITUDE_FORMATTER, + classic_formatter, classic_locator) +from cartopy.mpl.ticker import LongitudeFormatter, LongitudeLocator TEST_PROJS = [ ccrs.PlateCarree, diff --git a/lib/cartopy/tests/mpl/test_images.py b/lib/cartopy/tests/mpl/test_images.py index d7e18d3fb..3185a3a51 100644 --- a/lib/cartopy/tests/mpl/test_images.py +++ b/lib/cartopy/tests/mpl/test_images.py @@ -6,20 +6,18 @@ import types -import numpy as np -import matplotlib.pyplot as plt -import matplotlib.colors as colors from PIL import Image +import matplotlib.colors as colors +import matplotlib.pyplot as plt +import numpy as np import pytest import shapely.geometry as sgeom from cartopy import config import cartopy.crs as ccrs import cartopy.io.img_tiles as cimgt - import cartopy.tests.test_img_tiles as ctest_tiles - NATURAL_EARTH_IMG = (config["repo_data_dir"] / 'raster' / 'natural_earth' / '50-natural-earth-1-downsampled.png') REGIONAL_IMG = (config['repo_data_dir'] / 'raster' / 'sample' diff --git a/lib/cartopy/tests/mpl/test_img_transform.py b/lib/cartopy/tests/mpl/test_img_transform.py index 31dd0fab9..e73724ca6 100644 --- a/lib/cartopy/tests/mpl/test_img_transform.py +++ b/lib/cartopy/tests/mpl/test_img_transform.py @@ -4,6 +4,7 @@ # See COPYING and COPYING.LESSER in the root of the repository for full # licensing details. +from functools import reduce import operator import matplotlib as mpl @@ -14,7 +15,6 @@ from cartopy import config import cartopy.crs as ccrs import cartopy.img_transform as im_trans -from functools import reduce class TestRegrid: diff --git a/lib/cartopy/tests/mpl/test_mpl_integration.py b/lib/cartopy/tests/mpl/test_mpl_integration.py index 8abbf9e81..e15f2ac4c 100644 --- a/lib/cartopy/tests/mpl/test_mpl_integration.py +++ b/lib/cartopy/tests/mpl/test_mpl_integration.py @@ -6,12 +6,11 @@ import re -import numpy as np import matplotlib.pyplot as plt +import numpy as np import pytest import cartopy.crs as ccrs - from cartopy.tests.mpl import MPL_VERSION diff --git a/lib/cartopy/tests/mpl/test_quiver.py b/lib/cartopy/tests/mpl/test_quiver.py index 17f50ee3d..b744e9a1b 100644 --- a/lib/cartopy/tests/mpl/test_quiver.py +++ b/lib/cartopy/tests/mpl/test_quiver.py @@ -6,15 +6,15 @@ from unittest import mock -import numpy as np import matplotlib.pyplot as plt +import numpy as np import pytest import cartopy.crs as ccrs - # Note, other tests for quiver exist in test_mpl_integration. + class TestQuiverShapes: def setup_method(self): self.x = np.linspace(-60, 42.5, 10) diff --git a/lib/cartopy/tests/mpl/test_shapely_to_mpl.py b/lib/cartopy/tests/mpl/test_shapely_to_mpl.py index 2d47c1669..5a633516f 100644 --- a/lib/cartopy/tests/mpl/test_shapely_to_mpl.py +++ b/lib/cartopy/tests/mpl/test_shapely_to_mpl.py @@ -4,11 +4,11 @@ # See COPYING and COPYING.LESSER in the root of the repository for full # licensing details. -import numpy as np -import matplotlib.pyplot as plt -import matplotlib.patches as mpatches from matplotlib.collections import PatchCollection +import matplotlib.patches as mpatches from matplotlib.path import Path +import matplotlib.pyplot as plt +import numpy as np import pytest import shapely.geometry as sgeom diff --git a/lib/cartopy/tests/mpl/test_ticker.py b/lib/cartopy/tests/mpl/test_ticker.py index b66d63435..b9d236381 100644 --- a/lib/cartopy/tests/mpl/test_ticker.py +++ b/lib/cartopy/tests/mpl/test_ticker.py @@ -7,13 +7,13 @@ from unittest.mock import Mock import matplotlib.pyplot as plt -import pytest import numpy as np +import pytest import cartopy.crs as ccrs from cartopy.mpl.geoaxes import GeoAxes -from cartopy.mpl.ticker import (LatitudeFormatter, LongitudeFormatter, - LatitudeLocator, LongitudeLocator) +from cartopy.mpl.ticker import (LatitudeFormatter, LatitudeLocator, + LongitudeFormatter, LongitudeLocator) ONE_MIN = 1 / 60. ONE_SEC = 1 / 3600. diff --git a/lib/cartopy/tests/mpl/test_ticks.py b/lib/cartopy/tests/mpl/test_ticks.py index d629ccd7f..bb54b6314 100644 --- a/lib/cartopy/tests/mpl/test_ticks.py +++ b/lib/cartopy/tests/mpl/test_ticks.py @@ -7,7 +7,7 @@ import pytest import cartopy.crs as ccrs -from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter +from cartopy.mpl.ticker import LatitudeFormatter, LongitudeFormatter @pytest.mark.natural_earth diff --git a/lib/cartopy/tests/test_coding_standards.py b/lib/cartopy/tests/test_coding_standards.py index 3eb22da3e..ac44fb140 100644 --- a/lib/cartopy/tests/test_coding_standards.py +++ b/lib/cartopy/tests/test_coding_standards.py @@ -5,8 +5,8 @@ # licensing details. from fnmatch import fnmatch -from pathlib import Path import os +from pathlib import Path import re import subprocess @@ -14,7 +14,6 @@ import cartopy - # Add shebang possibility or C comment starter to the LICENSE_RE_PATTERN SHEBANG_PATTERN = r'((\#\!.*|\/\*)\n)?' diff --git a/lib/cartopy/tests/test_crs.py b/lib/cartopy/tests/test_crs.py index eb26fb0e9..c1a5d11da 100644 --- a/lib/cartopy/tests/test_crs.py +++ b/lib/cartopy/tests/test_crs.py @@ -11,8 +11,9 @@ import pickle import numpy as np -from numpy.testing import assert_almost_equal, assert_array_equal +from numpy.testing import assert_almost_equal from numpy.testing import assert_array_almost_equal as assert_arr_almost_eq +from numpy.testing import assert_array_equal import pyproj import pytest import shapely.geometry as sgeom diff --git a/lib/cartopy/tests/test_features.py b/lib/cartopy/tests/test_features.py index 3109abe1f..9c34b8f1b 100644 --- a/lib/cartopy/tests/test_features.py +++ b/lib/cartopy/tests/test_features.py @@ -4,9 +4,10 @@ # See COPYING and COPYING.LESSER in the root of the repository for full # licensing details. -import cartopy.feature as cfeature import pytest +import cartopy.feature as cfeature + small_extent = (-6, -8, 56, 59) medium_extent = (-20, 20, 20, 60) large_extent = (-40, 40, 0, 80) diff --git a/lib/cartopy/tests/test_img_nest.py b/lib/cartopy/tests/test_img_nest.py index 685c2cb5c..07b6cb304 100644 --- a/lib/cartopy/tests/test_img_nest.py +++ b/lib/cartopy/tests/test_img_nest.py @@ -11,16 +11,15 @@ import sys import warnings -import numpy as np -from numpy.testing import assert_array_equal, assert_array_almost_equal from PIL import Image +import numpy as np +from numpy.testing import assert_array_almost_equal, assert_array_equal import pytest import shapely.geometry as sgeom from cartopy import config -import cartopy.io.img_tiles as cimgt import cartopy.io.img_nest as cimg_nest - +import cartopy.io.img_tiles as cimgt #: An integer version which should be increased if the test data needs #: to change in some way. diff --git a/lib/cartopy/tests/test_img_transform.py b/lib/cartopy/tests/test_img_transform.py index 4ddc0804c..b738f3083 100644 --- a/lib/cartopy/tests/test_img_transform.py +++ b/lib/cartopy/tests/test_img_transform.py @@ -8,8 +8,8 @@ from numpy.testing import assert_array_equal import pytest -import cartopy.img_transform as img_trans import cartopy.crs as ccrs +import cartopy.img_transform as img_trans @pytest.mark.parametrize('xmin, xmax', [ diff --git a/lib/cartopy/tests/test_util.py b/lib/cartopy/tests/test_util.py index c6a807f89..b675ba84b 100644 --- a/lib/cartopy/tests/test_util.py +++ b/lib/cartopy/tests/test_util.py @@ -9,7 +9,7 @@ from numpy.testing import assert_array_equal import pytest -from cartopy.util import add_cyclic_point, add_cyclic, has_cyclic +from cartopy.util import add_cyclic, add_cyclic_point, has_cyclic class Test_add_cyclic_point: diff --git a/lib/cartopy/tests/test_vector_transform.py b/lib/cartopy/tests/test_vector_transform.py index 7de000cfc..8a790a4c4 100644 --- a/lib/cartopy/tests/test_vector_transform.py +++ b/lib/cartopy/tests/test_vector_transform.py @@ -5,10 +5,10 @@ # licensing details. import numpy as np -from numpy.testing import assert_array_equal, assert_array_almost_equal +from numpy.testing import assert_array_almost_equal, assert_array_equal -import cartopy.vector_transform as vec_trans import cartopy.crs as ccrs +import cartopy.vector_transform as vec_trans def _sample_plate_carree_coordinates(): diff --git a/lib/cartopy/trace.pyx b/lib/cartopy/trace.pyx index 68b679488..f33dbd55b 100644 --- a/lib/cartopy/trace.pyx +++ b/lib/cartopy/trace.pyx @@ -13,15 +13,17 @@ In general, this should never be called manually, instead leaving the processing to be done by the :class:`cartopy.crs.Projection` subclasses. """ from __future__ import print_function + from functools import lru_cache cimport cython from libc.math cimport HUGE_VAL, sqrt -from numpy.math cimport isfinite, isnan from libc.stdint cimport uintptr_t as ptr from libcpp cimport bool from libcpp.list cimport list from libcpp.vector cimport vector +from numpy.math cimport isfinite, isnan + cdef bool DEBUG = False @@ -53,9 +55,9 @@ cdef extern from "geos_c.h": import re import warnings -import shapely.geometry as sgeom from pyproj import Geod, Transformer from pyproj.exceptions import ProjError +import shapely.geometry as sgeom cdef GEOSContextHandle_t get_geos_context_handle(): @@ -109,6 +111,7 @@ cdef class LineAccumulator: cdef GEOSGeometry *as_geom(self, GEOSContextHandle_t handle): from cython.operator cimport dereference, preincrement + # self.lines.remove_if(degenerate_line) is not available in Cython. cdef list[Line].iterator it = self.lines.begin() while it != self.lines.end(): diff --git a/lib/cartopy/vector_transform.py b/lib/cartopy/vector_transform.py index f2f04b359..fe3f89cc5 100644 --- a/lib/cartopy/vector_transform.py +++ b/lib/cartopy/vector_transform.py @@ -10,6 +10,7 @@ """ import numpy as np + try: from scipy.interpolate import griddata except ImportError as e: diff --git a/pyproject.toml b/pyproject.toml index 71e009031..7db7afc17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,3 +11,11 @@ build-backend = "setuptools.build_meta" [tool.codespell] ignore-words-list = "damon,koordinates,linz,slippy,subtiles,tring" skip = "./.git,./docs/build,./docs/source/gallery,./docs/source/reference,*.cpp,*.css,*.examples,*.js,*.html,*.ipynb,*.pdf,*.rst.txt" + +[tool.isort] +force_sort_within_sections = "True" +known_first_party = "cartopy" +# line_length = 88 +# profile = "black" +skip_gitignore = "True" +verbose = "False" diff --git a/setup.py b/setup.py index 54da9f03a..9e4373225 100644 --- a/setup.py +++ b/setup.py @@ -24,16 +24,15 @@ sys.exit(error) -from pathlib import Path +from collections import defaultdict import os +from pathlib import Path import subprocess -import warnings -from collections import defaultdict from sysconfig import get_config_var +import warnings from setuptools import Extension, find_packages, setup - # The existence of a PKG-INFO directory is enough to tell us whether this is a # source installation or not (sdist). HERE = Path(__file__).parent diff --git a/tools/cartopy_feature_download.py b/tools/cartopy_feature_download.py index ffa8f702a..239bcba7b 100755 --- a/tools/cartopy_feature_download.py +++ b/tools/cartopy_feature_download.py @@ -21,7 +21,6 @@ from cartopy.feature import Feature, GSHHSFeature, NaturalEarthFeature from cartopy.io import Downloader, DownloadWarning - ALL_SCALES = ('110m', '50m', '10m') # See https://github.com/SciTools/cartopy/pull/1833