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

Add pre-commit hooks and fixes #1934

Merged
merged 2 commits into from
Mar 12, 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
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[run]
branch = True
omit =
omit =
lib/cartopy/examples/*
lib/cartopy/sphinxext/*
lib/cartopy/tests/*
Expand Down
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# style: start of pre-commit and whitespace fixes
16aba40dd09fb95c85fac1a0bee0f795b9f8b5fe
3 changes: 1 addition & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Getting started
1. Fork the Cartopy repository, create your new fix/feature branch, and
start committing code. We broadly follow the [gitwash guidelines](https://matthew-brett.github.io/pydagogue/gitwash/git_development.html).
1. Remember to add appropriate documentation and tests to supplement any new or changed functionality.
1. If you're not already on it (and would like to be), please add yourself to the
1. If you're not already on it (and would like to be), please add yourself to the
contributors list (docs/source/contributors.rst)


Expand All @@ -29,4 +29,3 @@ Submitting changes
1. Push your branch to your fork of cartopy.
1. Submit your pull request.
1. Sit back and wait for the core Cartopy development team to review your code.

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ questions on StackOverflow can be found at https://stackoverflow.com/questions/t

```

#### Traceback
#### Traceback

```

Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ request could be broken into smaller parts before submitting.
* If this is a new feature, please provide an example of its use in the description. We may want to make a
follow-on pull request to put the example in the gallery!

* Ensure there is a suitable item in the cartopy test suite for the change you are proposing.
* Ensure there is a suitable item in the cartopy test suite for the change you are proposing.

-->
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ci:
autofix_prs: false
autoupdate_schedule: 'quarterly'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-added-large-files
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
2 changes: 1 addition & 1 deletion docs/doc-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sphinx<6
sphinx-gallery
beautifulsoup4
pydata-sphinx-theme
pydata-sphinx-theme
2 changes: 1 addition & 1 deletion docs/source/_static/version_switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
var select = build_select(version, release);

var index_li = $('li.right:contains("index")');
index_li.append('|&nbsp;');
index_li.append('|&nbsp;');
index_li.before('<li class="version_switcher right">' + select + '</li>');
$('.version_switcher select').bind('change', on_switch);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

.. autoclass:: {{ objname }}
:members:
:no-inherited-members:
:no-inherited-members:
4 changes: 2 additions & 2 deletions docs/source/citation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Latest release DOI through Zenodo


************
BibTeX entry
BibTeX entry
************

For example::
Expand All @@ -26,7 +26,7 @@ For example::
year = {2010 - 2015},
address = {Exeter, Devon },
url = {https://scitools.org.uk/cartopy}
}
}


*******************
Expand Down
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,3 @@
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = False

1 change: 0 additions & 1 deletion docs/source/copyright.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,3 @@ repository are licensed under the UK's Open Government Licence:

Any email enquiries regarding the use and re-use of this information
resource should be sent to: [email protected].

1 change: 0 additions & 1 deletion docs/source/developer_interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ interactive visualisation. Generally the SlippyImageArtist is a developer's
interface, with users often creating a
:class:`SlippyImageArtist` instance through
the GeoAxes' :meth:`~cartopy.mpl.geoaxes.GeoAxes.add_raster` method.

2 changes: 1 addition & 1 deletion docs/source/matplotlib/advanced_plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Images
ax = plt.axes(projection=ccrs.PlateCarree())
plt.title('Hurricane Miriam from the Aqua/MODIS satellite\n'
'2012 09/26/2012 20:50 UTC')

ax.use_sticky_edges = False
# set a margin around the data
ax.set_xmargin(0.05)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/matplotlib/feature_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Name Description
United States at this scale).
Natural Earth have first-order admin boundaries for most
countries at the 1:10,000,000 scale; these may be
accessed with ``cartopy.feature.STATES.with_scale('10m')``
accessed with ``cartopy.feature.STATES.with_scale('10m')``
======================= ================================================================

.. note::
Expand Down
10 changes: 5 additions & 5 deletions docs/source/matplotlib/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ and then adding some coastlines to the axes:
A list of the available projections to be used with Matplotlib can be
found on the :ref:`cartopy_projections` page.

The line ``plt.axes(projection=ccrs.PlateCarree())`` sets up a
The line ``plt.axes(projection=ccrs.PlateCarree())`` sets up a
:class:`~cartopy.mpl.geoaxes.GeoAxes` instance
which exposes a variety of other map related methods, in the case of the
previous example, we used the
which exposes a variety of other map related methods, in the case of the
previous example, we used the
:meth:`~cartopy.mpl.geoaxes.GeoAxes.coastlines` method
to add coastlines to the map.

Expand Down Expand Up @@ -68,8 +68,8 @@ Adding data to the map

Once you have the map just the way you want it, data can be added to it in exactly the same way as
with normal Matplotlib axes. By default, the coordinate system of any data added to a GeoAxes is
the same as the coordinate system of the GeoAxes itself, to control which coordinate system
that the given data is in, you can add the ``transform`` keyword with an appropriate
the same as the coordinate system of the GeoAxes itself, to control which coordinate system
that the given data is in, you can add the ``transform`` keyword with an appropriate
:class:`cartopy.crs.CRS` instance:


Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ The top level cartopy module contains the :attr:`~cartopy.config` dictionary whi
``downloaders``
A dictionary mapping standard "specifications" to the appropriate
:class:`~cartopy.io.Downloader`. For further documentation and an
example see :func:`cartopy.io.Downloader.from_config`.
example see :func:`cartopy.io.Downloader.from_config`.
2 changes: 1 addition & 1 deletion docs/source/reference/crs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ List of projections
.. toctree::
:maxdepth: 2

projections
projections
2 changes: 1 addition & 1 deletion docs/source/reference/feature.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Feature classes
Scaler
ShapelyFeature
WFSFeature
nightshade.Nightshade
nightshade.Nightshade
2 changes: 1 addition & 1 deletion docs/source/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ see the :ref:`getting started guide <getting_started>`.
matplotlib
feature
transformations
config
config
4 changes: 2 additions & 2 deletions docs/source/reference/matplotlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ location information to the plots.
.. autosummary::
:toctree: generated/
:template: autosummary/class_without_inherited.rst

gridliner.Gridliner
ticker.LongitudeFormatter
ticker.LatitudeFormatter
Expand Down Expand Up @@ -72,4 +72,4 @@ between GEOS, Shapely, and Matplotlib paths.

patch.geos_to_path
patch.path_segments
patch.path_to_geos
patch.path_to_geos
2 changes: 1 addition & 1 deletion docs/source/reference/transformations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ LinearRing/LineString projection
trace.Interpolator
trace.CartesianInterpolator
trace.SphericalInterpolator
trace.LineAccumulator
trace.LineAccumulator
5 changes: 2 additions & 3 deletions docs/source/tutorials/using_the_shapereader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Using the cartopy shapereader
=============================

Cartopy provides an object oriented shapefile reader based on top of the
Cartopy provides an object oriented shapefile reader based on top of the
`pyshp`_ module to provide easy, programmatic, access to standard vector datasets.

Cartopy's wrapping of pyshp has the benefit of being pure python, and is therefore
Expand Down Expand Up @@ -120,7 +120,7 @@ Which we can print with

Democratic Republic of the Congo, Egypt, Ethiopia, Nigeria

* **SHP.2**: Using the countries shapefile, find the most populated country grouped
* **SHP.2**: Using the countries shapefile, find the most populated country grouped
by the first letter of the "name_long".

Hint: :func:`itertools.groupby` can help with the grouping.
Expand Down Expand Up @@ -174,4 +174,3 @@ Which we can print with
W Western Sahara
Y Yemen
Z Zimbabwe

2 changes: 1 addition & 1 deletion docs/source/whatsnew/v0.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ capabilities, including:
.. figure:: ../gallery/vector_data/images/sphx_glr_barbs_001.png
:target: ../gallery/vector_data/barbs.html
:align: center
:scale: 70
:scale: 70
2 changes: 1 addition & 1 deletion docs/source/whatsnew/v0.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ Version 0.11 (June 19, 2014)
.. figure:: ../gallery/gridlines_and_labels/images/sphx_glr_tick_labels_001.png
:target: ../gallery/gridlines_and_labels/tick_labels.html
:align: center
:scale: 70
:scale: 70
2 changes: 1 addition & 1 deletion docs/source/whatsnew/v0.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ Deprecations
returned, rather than a single image and its associated extent.

* The ``secant_latitudes`` keyword in :class:`cartopy.crs.LambertConformal` has
been deprecated in favour of ``standard_parallels``.
been deprecated in favour of ``standard_parallels``.
2 changes: 1 addition & 1 deletion docs/source/whatsnew/v0.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ Features
.. figure:: ../gallery/web_services/images/sphx_glr_wmts_time_001.png
:target: ../gallery/web_services/wmts_time.html
:align: center
:scale: 70
:scale: 70
2 changes: 1 addition & 1 deletion docs/source/whatsnew/v0.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ Features
time. (:pull:`990`)

* Mahé Perrette and Ryan May collaborated to improve the
:class:`~cartopy.crs.Stereographic` projection. (:pull:`929`)
:class:`~cartopy.crs.Stereographic` projection. (:pull:`929`)
2 changes: 1 addition & 1 deletion docs/source/whatsnew/v0.17.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@ Deprecations

Incompatible Changes
--------------------
* Support for Matplotlib < 1.5.1 and NumPy < 1.10 has been removed.
* Support for Matplotlib < 1.5.1 and NumPy < 1.10 has been removed.
2 changes: 1 addition & 1 deletion docs/source/whatsnew/v0.18.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ Deprecations
Instead, use :attr:`cartopy.mpl.gridliner.Gridliner.top_labels`,
:attr:`cartopy.mpl.gridliner.Gridliner.bottom_labels`,
:attr:`cartopy.mpl.gridliner.Gridliner.left_labels`, or
:attr:`cartopy.mpl.gridliner.Gridliner.right_labels`.
:attr:`cartopy.mpl.gridliner.Gridliner.right_labels`.
4 changes: 2 additions & 2 deletions docs/source/whatsnew/v0.19.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Features
* Luke Davis fixed the label padding for gridliners to use points which makes
the rendered screen image appear the same as the printed image now.
(:pull:`1556`)

* Daryl Herzmann added the ability to make Hexbin plots. (:pull:`1542`)

.. plot::
Expand All @@ -75,4 +75,4 @@ Features
* Kyle Penner fixed image plotting when a 2D alpha array is input. (:pull:`1543`)

* Elliott Sales de Andrade and Hugo van Kemenade removed Python 2 support.
(:pull:`1516`, :pull:`1517`, :pull:`1540`, :pull:`1544`, and :pull:`1547`)
(:pull:`1516`, :pull:`1517`, :pull:`1540`, :pull:`1544`, and :pull:`1547`)
2 changes: 1 addition & 1 deletion docs/source/whatsnew/v0.21.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Removals

The following functions and classes have been removed after being deprecated
multiple versions prior. See the previous What's New notes for replacements.

* ``geoaxes.outline_patch()``
* ``geoaxes.background_patch()``
* ``geoaxes.natural_earth_shp()``
Expand Down
1 change: 0 additions & 1 deletion docs/source/whatsnew/v0.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ Version 0.7 (March 21, 2013)

This is a quick release which targets two very specific requirements. The goals outlined in the development plan at
``v0.6`` still remain the primary target for ``v0.8`` and beyond.

1 change: 0 additions & 1 deletion examples/gridlines_and_labels/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

Gridlines and labels
====================

1 change: 0 additions & 1 deletion examples/lines_and_polygons/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

Lines and polygons
==================

1 change: 0 additions & 1 deletion examples/miscellanea/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

Miscellanea
===========

1 change: 0 additions & 1 deletion examples/scalar_data/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

Scalar data
===========

1 change: 0 additions & 1 deletion examples/vector_data/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

Vector data
===========

1 change: 0 additions & 1 deletion examples/web_services/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

Web services
============

4 changes: 2 additions & 2 deletions lib/cartopy/data/shapefiles/gshhs/README.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ data as shapefiles.
--------------------------------------------------------------------
Global Self-consistent Hierarchical High-resolution Shorelines
version 2.0 July 15, 2009

Distributed under the Gnu Public License

This is the README file for the GSHHS Data distribution. To read
the data you should get the gshhs supplement to GMT, the Generic
Mapping Tools (gmt.soest.hawaii.edu). GSHHS appear in GMT in a
Expand Down
27 changes: 9 additions & 18 deletions lib/cartopy/mpl/geoaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,20 @@
assert mpl.__version__ >= '3.1', \
'Cartopy is only supported with Matplotlib 3.1 or greater.'

# A nested mapping from path, source CRS, and target projection to the
# resulting transformed paths:
# {path: {(source_crs, target_projection): list_of_paths}}
# Provides a significant performance boost for contours which, at
# matplotlib 1.2.0 called transform_path_non_affine twice unnecessarily.
_PATH_TRANSFORM_CACHE = weakref.WeakKeyDictionary()
"""
A nested mapping from path, source CRS, and target projection to the
resulting transformed paths::

{path: {(source_crs, target_projection): list_of_paths}}

Provides a significant performance boost for contours which, at
matplotlib 1.2.0 called transform_path_non_affine twice unnecessarily.

"""

# A dictionary of pre-loaded images for large background images, kept as a
# dictionary so that large images are loaded only once.
_BACKG_IMG_CACHE = {}
"""
A dictionary of pre-loaded images for large background images, kept as a
dictionary so that large images are loaded only once.
"""

# A dictionary of background images in the directory specified by the
# CARTOPY_USER_BACKGROUNDS environment variable.
_USER_BG_IMGS = {}
"""
A dictionary of background images in the directory specified by the
CARTOPY_USER_BACKGROUNDS environment variable.
"""


# XXX call this InterCRSTransform
Expand Down
Loading