Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-commit: adopt isort hook #2150

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ eb1dd508e087396948de5a3d20c5791500743ddf

# style: sort __all__ statements (#2151)
c00e0adae1b1e8695e173f4482369face82206ee

# style: adopt isort to enforce import ordering (#2150)
030a78b0f5cd6a88b04dd2fbe78f12b4b3e5e60d
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
6 changes: 4 additions & 2 deletions benchmarks/cases/mpl_redraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
# 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.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/cases/project_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 7 additions & 9 deletions docs/make_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
import inspect
from pathlib import Path
import textwrap

import matplotlib.pyplot as plt
import numpy as np

import cartopy.crs as ccrs


#: A dictionary to allow examples to use non-default parameters to the CRS
#: constructor.
SPECIFIC_PROJECTION_KWARGS = {
Expand All @@ -25,9 +29,6 @@


def plate_carree_plot():
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

nplots = 2

fig = plt.figure(figsize=(6, 6))
Expand All @@ -42,9 +43,6 @@ def plate_carree_plot():


def igh_plot():
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

fig = plt.figure(figsize=(6.9228, 6))

ax1 = fig.add_subplot(2, 1, 1,
Expand All @@ -61,9 +59,6 @@ def igh_plot():


def utm_plot():
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

nplots = 60

fig = plt.figure(figsize=(10, 3))
Expand Down Expand Up @@ -201,6 +196,9 @@ def prj_class_sorter(cls):
code = textwrap.dedent("""
.. plot::

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

{func_code}

""").format(func_code=func_code)
Expand Down
4 changes: 3 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
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()))
Expand Down
4 changes: 2 additions & 2 deletions examples/gridlines_and_labels/gridliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():

Expand Down
5 changes: 3 additions & 2 deletions examples/gridlines_and_labels/tick_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
9 changes: 5 additions & 4 deletions examples/lines_and_polygons/effects_of_the_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
3 changes: 2 additions & 1 deletion examples/lines_and_polygons/feature_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 2 additions & 1 deletion examples/lines_and_polygons/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 2 additions & 0 deletions examples/lines_and_polygons/nightshade.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

"""
import datetime

import matplotlib.pyplot as plt

import cartopy.crs as ccrs
from cartopy.feature.nightshade import Nightshade

Expand Down
4 changes: 3 additions & 1 deletion examples/miscellanea/animate_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
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))
ax = plt.axes(projection=ccrs.Robinson())
ax.set_global()
Expand Down
7 changes: 4 additions & 3 deletions examples/miscellanea/axes_grid_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`"""
Expand Down
5 changes: 3 additions & 2 deletions examples/miscellanea/eccentric_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
7 changes: 4 additions & 3 deletions examples/miscellanea/favicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
7 changes: 4 additions & 3 deletions examples/miscellanea/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
9 changes: 5 additions & 4 deletions examples/miscellanea/un_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
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.
Expand Down
3 changes: 2 additions & 1 deletion examples/miscellanea/utm_all_zones.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions examples/scalar_data/aurora_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 2 additions & 1 deletion examples/scalar_data/contour_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
3 changes: 2 additions & 1 deletion examples/scalar_data/contour_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
3 changes: 2 additions & 1 deletion examples/scalar_data/geostationary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
"""
Expand Down
3 changes: 2 additions & 1 deletion examples/scalar_data/wrapping_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/web_services/image_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions examples/web_services/reprojected_wmts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

"""
import matplotlib.pyplot as plt

import cartopy.crs as ccrs


Expand Down
3 changes: 2 additions & 1 deletion examples/web_services/wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading