internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: SciTools/cartopy

Issue:
scatter plot with Spherical transform not supported since v0.18
Hey, thanks for the great cartopy project!

I just wanted to drop a note that `ax.scatter(..., transform=Geodetic)` used to work in cartopy 0.17, but does not work any more in cartopy 0.18.

No big deal, from #1431 I understand that this is intended behaviour and maybe was also the desired behaviour in 0.17.

obspy/obspy#2624



Discussion:

Resolving patch:
diff --git a/lib/cartopy/mpl/geoaxes.py b/lib/cartopy/mpl/geoaxes.py
--- a/lib/cartopy/mpl/geoaxes.py
+++ b/lib/cartopy/mpl/geoaxes.py
@@ -300,7 +300,12 @@ def wrapper(self, *args, **kwargs):
         transform = kwargs.get('transform', None)
         if transform is None:
             transform = self.projection
-        if (isinstance(transform, ccrs.CRS) and
+        # Raise an error if any of these functions try to use
+        # a spherical source CRS.
+        non_spherical_funcs = ['contour', 'contourf', 'pcolormesh', 'pcolor',
+                               'quiver', 'barbs', 'streamplot']
+        if (func.__name__ in non_spherical_funcs and
+                isinstance(transform, ccrs.CRS) and
                 not isinstance(transform, ccrs.Projection)):
             raise ValueError('Invalid transform: Spherical {} '
                              'is not supported - consider using '


Test patch:
Repository: SciTools/cartopy

Issue:
Missing .prj for NaturalEarth data
### Description

With the current default downloader from ``cartopy``, not all elements from the NaturalEarth zip container are extracted.
Currently, [only shp, dbf, and shx](https://github.com/SciTools/cartopy/blob/8b106fec9511911eb49a7f78b65407895c37bfc3/lib/cartopy/io/shapereader.py#L319) are present.

This means that when loading the file (e.g. in my case with ``geopandas.read_file``) leads to a ``GeoDataFrame`` that has its ``crs`` element set to ``None`` instead of ``"epsg:4326"``.

### Feature request

Unless there is a good reason not to include the .prj file (that has already been downloaded anyways), I'd suggest to include it in the list of extensions [there](https://github.com/SciTools/cartopy/blob/8b106fec9511911eb49a7f78b65407895c37bfc3/lib/cartopy/io/shapereader.py#L319).
Given that it takes virtually no space, I'd also suggest to include the .cpg in case it might also be of use to somebody somewhere.

I can provide a PR if necessary.


Discussion:
That sounds reasonable—a PR implementing it would be welcome.

Resolving patch:
diff --git a/lib/cartopy/io/shapereader.py b/lib/cartopy/io/shapereader.py
--- a/lib/cartopy/io/shapereader.py
+++ b/lib/cartopy/io/shapereader.py
@@ -316,7 +316,7 @@ def zip_file_contents(self, format_dict):
         natural earth zip file.
 
         """
-        for ext in ['.shp', '.dbf', '.shx']:
+        for ext in ['.shp', '.dbf', '.shx', '.prj', '.cpg']:
             yield ('ne_{resolution}_{name}'
                    '{extension}'.format(extension=ext, **format_dict))
 


Test patch:
Repository: SciTools/cartopy

Issue:
Backport NaturalEarth url change in release 0.18 and 0.19 ?
It should be great, if possible, to backport the change of NaturalEarth url (done in this [commit](https://github.com/SciTools/cartopy/commit/af814c31829002acd7c1c49ba52cee530c6ac19a) ) in at least releases 0.18 (==> 0.18.1) and 0.19 (==> 0.19.1), and of course to release a new version with this change.


Discussion:

Resolving patch:
diff --git a/tools/cartopy_feature_download.py b/tools/cartopy_feature_download.py
--- a/tools/cartopy_feature_download.py
+++ b/tools/cartopy_feature_download.py
@@ -10,19 +10,24 @@
 
 For detail on how to use this tool, execute it with the `-h` option:
 
-    python download.py -h
+    python cartopy_feature_download.py -h
 
 """
 
 import argparse
+import pathlib
 
 from cartopy import config
 from cartopy.feature import Feature, GSHHSFeature, NaturalEarthFeature
-from cartopy.io import Downloader
+from cartopy.io import Downloader, DownloadWarning
 
 
 ALL_SCALES = ('110m', '50m', '10m')
 
+# See https://github.com/SciTools/cartopy/pull/1833
+URL_TEMPLATE = ('https://naturalearth.s3.amazonaws.com/{resolution}_'
+                '{category}/ne_{resolution}_{name}.zip')
+SHP_NE_SPEC = ('shapefiles', 'natural_earth')
 
 FEATURE_DEFN_GROUPS = {
     # Only need one GSHHS resolution because they *all* get downloaded
@@ -114,11 +119,28 @@ def download_features(group_names, dry_run=True):
                         action='store_true')
     parser.add_argument('--ignore-repo-data', action='store_true',
                         help='ignore existing repo data when downloading')
+    parser.add_argument('--no-warn',
+                        action='store_true',
+                        help='ignore cartopy "DownloadWarning" warnings')
     args = parser.parse_args()
 
     if args.output:
-        config['pre_existing_data_dir'] = args.output
-        config['data_dir'] = args.output
+        target_dir = pathlib.Path(args.output).expanduser().resolve()
+        target_dir.mkdir(parents=True, exist_ok=True)
+        config['pre_existing_data_dir'] = target_dir
+        config['data_dir'] = target_dir
     if args.ignore_repo_data:
         config['repo_data_dir'] = config['data_dir']
+    if args.no_warn:
+        import warnings
+        warnings.filterwarnings('ignore', category=DownloadWarning)
+
+    # Enforce use of stable AWS endpoint, regardless of cartopy version.
+    # In doing so, this allows users to download this script and execute it
+    # with any version of cartopy, thus taking advantage of the stable AWS
+    # endpoint.
+    # This removes the need to backport the associated fix
+    # https://github.com/SciTools/cartopy/pull/1833.
+    config['downloaders'][SHP_NE_SPEC].url_template = URL_TEMPLATE
+
     download_features(args.group_names, dry_run=args.dry_run)


Test patch:
Repository: SciTools/cartopy

Issue:
Add better title for projections.rst?
The title of [projections.rst](https://github.com/SciTools/cartopy/blob/main/docs/source/reference/projections.rst) is currently "PlateCarree" - I think this is sub-optimal (I had trouble finding the overview...). I think the title should be Projections and all other titles moved one level down.

https://github.com/SciTools/cartopy/blob/main/docs/source/reference/projections.rst

![image](https://user-images.githubusercontent.com/10194086/149549647-690248ff-3d01-4858-a3a6-f1cd9759e71d.png)


Discussion:

Resolving patch:
diff --git a/docs/make_projection.py b/docs/make_projection.py
--- a/docs/make_projection.py
+++ b/docs/make_projection.py
@@ -134,7 +134,7 @@ def create_instance(prj_cls, instance_args):
                          'reference', 'projections.rst')
     table = open(fname, 'w')
 
-    notes = """
+    header = """
         .. (comment): DO NOT EDIT this file.
         .. It is auto-generated by running : cartopy/docs/make_projection.py
         .. Please adjust by making changes there.
@@ -142,8 +142,13 @@ def create_instance(prj_cls, instance_args):
 
         .. _cartopy_projections:
 
+        Cartopy projection list
+        =======================
+
+
         """
-    table.write(textwrap.dedent(notes))
+
+    table.write(textwrap.dedent(header))
 
     def prj_class_sorter(cls):
         return (PRJ_SORT_ORDER.get(cls.__name__, 100),


Test patch:
Repository: SciTools/cartopy

Issue:
Plea for a stock_img() alpha
### Description
I am delighted that `.add_feature()` now allows for transparency via an `alpha` parameter; this goes a long way to decluttering busy maps. Unfortunately, the same feature is not available for `stock_img()`, and I was wondering why. I am admittedly ignorant of the way the background is implemented in Cartopy, but given that a lot of matplotlib objects have an alpha parameter, I was hoping this would be a matter of exposing it at the API level. Is this thinking too simplistic?

### Proposal
`ax.stock_img(alpha=0.5)` reduces background opacity by 50%, for instance. 


Discussion:
`stock_img` passes the image to `imshow`, and `imshow` handles _alpha_.  So it looks to me that it might indeed just be a case of exposing the keyword, though I am certainly no expert here.
https://github.com/SciTools/cartopy/blob/7f132a580c36027ddc4ef70aa70f4a2c0a878a67/lib/cartopy/mpl/geoaxes.py#L1012-L1014
@rcomer That looks correct to me.

Resolving patch:
diff --git a/lib/cartopy/mpl/geoaxes.py b/lib/cartopy/mpl/geoaxes.py
--- a/lib/cartopy/mpl/geoaxes.py
+++ b/lib/cartopy/mpl/geoaxes.py
@@ -999,12 +999,13 @@ def set_yticks(self, ticks, minor=False, crs=None):
 
         return super().set_yticks(yticks, minor=minor)
 
-    def stock_img(self, name='ne_shaded'):
+    def stock_img(self, name='ne_shaded', **kwargs):
         """
         Add a standard image to the map.
 
-        Currently, the only (and default) option is a downsampled version of
-        the Natural Earth shaded relief raster.
+        Currently, the only (and default) option for image is a downsampled
+        version of the Natural Earth shaded relief raster. Other options
+        (e.g., alpha) will be passed to :func:`GeoAxes.imshow`.
 
         """
         if name == 'ne_shaded':
@@ -1014,7 +1015,8 @@ def stock_img(self, name='ne_shaded'):
 
             return self.imshow(imread(fname), origin='upper',
                                transform=source_proj,
-                               extent=[-180, 180, -90, 90])
+                               extent=[-180, 180, -90, 90],
+                               **kwargs)
         else:
             raise ValueError('Unknown stock image %r.' % name)
 


Test patch:
Repository: SciTools/cartopy

Issue:
flake8: increase max line length?
### Description
<!-- Please provide a general introduction to the issue/proposal. -->
Would Cartopy consider increasing its maximum line length to 88 characters, like Matplotlib did at https://github.com/matplotlib/matplotlib/pull/24893?  I keep finding myself needing to rearrange lines because they are just a few characters over the limit.



Discussion:
I didn't even realize that would be an increase for us. That sounds fine.
Agreed, should be fine especially if you don't wholesale change the current code with black which did have some pushback: https://github.com/SciTools/cartopy/pull/2152

Resolving patch:
diff --git a/lib/cartopy/mpl/gridliner.py b/lib/cartopy/mpl/gridliner.py
--- a/lib/cartopy/mpl/gridliner.py
+++ b/lib/cartopy/mpl/gridliner.py
@@ -19,8 +19,8 @@
 
 import cartopy
 from cartopy.crs import PlateCarree, Projection, _RectangularProjection
-from cartopy.mpl.ticker import (LatitudeFormatter, LatitudeLocator,
-                                LongitudeFormatter, LongitudeLocator)
+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])


Test patch:
diff --git a/lib/cartopy/tests/mpl/test_axes.py b/lib/cartopy/tests/mpl/test_axes.py
--- a/lib/cartopy/tests/mpl/test_axes.py
+++ b/lib/cartopy/tests/mpl/test_axes.py
@@ -13,8 +13,7 @@
 
 import cartopy.crs as ccrs
 import cartopy.feature as cfeature
-from cartopy.mpl.geoaxes import (GeoAxes, GeoAxesSubplot,
-                                 InterProjectionTransform)
+from cartopy.mpl.geoaxes import GeoAxes, GeoAxesSubplot, InterProjectionTransform
 
 
 class TestNoSpherical:
diff --git a/lib/cartopy/tests/mpl/test_gridliner.py b/lib/cartopy/tests/mpl/test_gridliner.py
--- a/lib/cartopy/tests/mpl/test_gridliner.py
+++ b/lib/cartopy/tests/mpl/test_gridliner.py
@@ -16,9 +16,8 @@
 import cartopy.crs as ccrs
 from cartopy.mpl import _MPL_36
 from cartopy.mpl.geoaxes import GeoAxes
-from cartopy.mpl.gridliner import (LATITUDE_FORMATTER, LONGITUDE_FORMATTER,
-                                   Gridliner, classic_formatter,
-                                   classic_locator)
+from cartopy.mpl.gridliner import (LATITUDE_FORMATTER, LONGITUDE_FORMATTER, Gridliner,
+                                   classic_formatter, classic_locator)
 from cartopy.mpl.ticker import LongitudeFormatter, LongitudeLocator
 
 
diff --git a/lib/cartopy/tests/mpl/test_ticker.py b/lib/cartopy/tests/mpl/test_ticker.py
--- a/lib/cartopy/tests/mpl/test_ticker.py
+++ b/lib/cartopy/tests/mpl/test_ticker.py
@@ -12,8 +12,8 @@
 
 import cartopy.crs as ccrs
 from cartopy.mpl.geoaxes import GeoAxes
-from cartopy.mpl.ticker import (LatitudeFormatter, LatitudeLocator,
-                                LongitudeFormatter, LongitudeLocator)
+from cartopy.mpl.ticker import (LatitudeFormatter, LatitudeLocator, LongitudeFormatter,
+                                LongitudeLocator)
 
 
 ONE_MIN = 1 / 60.
Repository: SciTools/cartopy

Issue:
Remove "cfeature.LAND" from "Feature Creation" example ?
In the nice example provided on the [Feature Creation page](https://scitools.org.uk/cartopy/docs/latest/gallery/feature_creation.html), you could probably remove the useless line:
B) `ax.add_feature(cfeature.LAND)`
because you have already called
A) `ax.stock_img()`

As a matter of fact, B) being called after A), it should theoretically be plotted above A). I see you are using a default `zorder=-1` for LAND, so it is probably below everything else (did not know you could use negative zorder values)
```
>>> cfeature.LAND.kwargs
{'edgecolor': 'face', 'zorder': -1, 'facecolor': array([0.9375  , 0.9375  , 0.859375])}
```
If I use `ax.add_feature(cfeature.LAND, zorder=10)`, I do get land with a uniform color above the stock image on land (and the stock ocean elsewhere)


Discussion:
Hmmm, on the other hand, there is the following comment
```
    # Put a background image on for nice sea rendering.
    ax.stock_img()
```
The **comment does not mention using the stock image for land**! Is the fact that we see the stock image rather than a flat color on land in this example a bug or a feature?

Resolving patch:
diff --git a/examples/lines_and_polygons/feature_creation.py b/examples/lines_and_polygons/feature_creation.py
--- a/examples/lines_and_polygons/feature_creation.py
+++ b/examples/lines_and_polygons/feature_creation.py
@@ -28,7 +28,7 @@ def main():
     # Put a background image on for nice sea rendering.
     ax.stock_img()
 
-    # Create a feature for States/Admin 1 regions at 1:50m from Natural Earth
+    # Create a feature for States/Admin 1 regions at 1:50m from Natural Earth.
     states_provinces = cfeature.NaturalEarthFeature(
         category='cultural',
         name='admin_1_states_provinces_lines',
@@ -38,9 +38,11 @@ def main():
     SOURCE = 'Natural Earth'
     LICENSE = 'public domain'
 
-    ax.add_feature(cfeature.LAND)
-    ax.add_feature(cfeature.COASTLINE)
+    # Add our states feature.
     ax.add_feature(states_provinces, edgecolor='gray')
+    # Add land feature, overriding the default negative zorder so it shows
+    # above the background image.
+    ax.add_feature(cfeature.LAND, zorder=1, edgecolor='k')
 
     # Add a text annotation for the license information to the
     # the bottom right corner.


Test patch:
Repository: facebookresearch/nevergrad

Issue:
Documentation is out of date for 0.2.0
Trying to run examples like:

https://github.com/facebookresearch/nevergrad/blob/master/docs/machinelearning.md

gives errors.


Discussion:
Thank you for pointing out, I indeed forgot to update this document. I'll take care of it asap ;)

Resolving patch:
diff --git a/nevergrad/instrumentation/variables.py b/nevergrad/instrumentation/variables.py
--- a/nevergrad/instrumentation/variables.py
+++ b/nevergrad/instrumentation/variables.py
@@ -58,7 +58,7 @@ def _short_repr(self) -> str:
         return "SC({}|{})".format(",".join([str(x) for x in self.possibilities]), int(self.deterministic))
 
 
-class OrderedDiscrete(SoftmaxCategorical[X]):
+class OrderedDiscrete(utils.Variable[X]):
     """Discrete list of n values transformed to a 1-dim discontinuous variable.
     A gaussian input yields a uniform distribution on the list of variables.
 
@@ -72,6 +72,9 @@ class OrderedDiscrete(SoftmaxCategorical[X]):
     The variables are assumed to be ordered.
     """
 
+    def __init__(self, possibilities: List[X]) -> None:
+        self.possibilities = list(possibilities)
+
     @property
     def dimension(self) -> int:
         return 1
@@ -108,7 +111,7 @@ def __init__(self, mean: float, std: float, shape: Optional[Sequence[int]] = Non
     def dimension(self) -> int:
         return 1 if self.shape is None else int(np.prod(self.shape))
 
-    def data_to_argument(self, data: ArrayLike, deterministic: bool = True) -> Y:
+    def data_to_argument(self, data: ArrayLike, deterministic: bool = True) -> Y:  # pylint: disable=unused-argument
         assert len(data) == self.dimension
         x = data[0] if self.shape is None else np.reshape(data, self.shape)
         return self.std * x + self.mean


Test patch:
Repository: facebookresearch/nevergrad

Issue:
pytest should be a installed as a dependency
in instrumentation/instantiate.py testing is imported .. which depends on pytest but it's not installed with nevergrad as a dependency with pip


Discussion:

Resolving patch:
diff --git a/nevergrad/optimization/requirements_check.py b/nevergrad/optimization/requirements_check.py
new file mode 100644
--- /dev/null
+++ b/nevergrad/optimization/requirements_check.py
@@ -0,0 +1,13 @@
+from pathlib import Path
+from nevergrad import optimization
+from nevergrad import instrumentation as inst
+
+
+if __name__ == "__main__":
+    folder = Path(__file__).parents[1] / "instrumentation" / "examples"
+    func = inst.FolderFunction(folder, ["python", "examples/script.py"], clean_copy=True)
+    instrumentation = inst.Instrumentation(value1=inst.var.Array(1).asfloat(),
+                                           value2=12,
+                                           string=inst.var.SoftmaxCategorical(["plop", "blublu", "plouf"]))
+    opt = optimization.registry["OnePlusOne"](instrumentation, budget=4)
+    opt.optimize(func)


Test patch:
diff --git a/nevergrad/common/testing.py b/nevergrad/common/testing.py
--- a/nevergrad/common/testing.py
+++ b/nevergrad/common/testing.py
@@ -7,7 +7,10 @@
 import inspect
 from pathlib import Path
 from typing import Iterable, Any, Union, List, Tuple, Callable
-import pytest
+try:
+    import pytest
+except ImportError:
+    pass  # makes most of this module usable without pytest
 import numpy as np
Repository: facebookresearch/nevergrad

Issue:
Bounded variable with clipping can lead to early converging for PSO and DE
With small population, clipped variables (eg. `Scalar(lower=0, upper=1)`) can lead to early convergence of PSO and DE. Indeed, if for some reasons all of the individuals reach the same bound, they will not be able to move away from it anymore.

Currently, we do not have any idea of how to fix this. Using other methods than clipping for bounds can help, but will lead to other issues (inefficiency, transformed space etc)


Discussion:

Resolving patch:
diff --git a/nevergrad/parametrization/data.py b/nevergrad/parametrization/data.py
--- a/nevergrad/parametrization/data.py
+++ b/nevergrad/parametrization/data.py
@@ -204,7 +204,7 @@ def set_bounds(
         self: A,
         lower: BoundValue = None,
         upper: BoundValue = None,
-        method: str = "clipping",
+        method: str = "bouncing",
         full_range_sampling: tp.Optional[bool] = None,
         a_min: BoundValue = None,
         a_max: BoundValue = None,
@@ -220,10 +220,10 @@ def set_bounds(
         method: str
             One of the following choices:
 
+            - "bouncing": bounce on border (at most once). This is a variant of clipping,
+               avoiding bounds over-samping (default).
             - "clipping": clips the values inside the bounds. This is efficient but leads
               to over-sampling on the bounds.
-            - "bouncing": bounce on border (at most once). This is an experimental variant of clipping,
-               avoiding bounds over-samping.
             - "constraint": adds a constraint (see register_cheap_constraint) which leads to rejecting mutations
               reaching beyond the bounds. This avoids oversampling the boundaries, but can be inefficient in large
               dimension.


Test patch:
Repository: facebookresearch/nevergrad

Issue:
Wrong dates in changelog
All the dates at https://github.com/facebookresearch/nevergrad/blob/master/CHANGELOG.md shows 2019, but seems it should be 2020.


Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -70,4 +70,5 @@
 html_static_path = []
 
 # -- Other --
-linkcheck_ignore = [r'https://gecco-2020.sigevo.org/*']
+linkcheck_ignore = [r'https://gecco-2020.sigevo.org/*',
+                    r'https://arxiv.org/abs/*']  # Transient certificate error :(


Test patch:
Repository: facebookresearch/nevergrad

Issue:
Importing nevergrad raises UserWarning
## Steps to reproduce
```
pip install nevergrad

```
then import nevergrad in python interpreter
```
>>> import nevergrad as ng
/Users/jieru/opt/anaconda3/envs/testnv/lib/python3.8/site-packages/cma/s.py:13: UserWarning: Could not import matplotlib.pyplot, therefore ``cma.plot()`` etc. is not available
  _warnings.warn('Could not import matplotlib.pyplot, therefore'

```
## Observed Results

Warning raised

## Expected Results

  * Ideally no warnings raised when importing nevergrad
## Relevant Code
This is a new behavior introduced by the [latest release of `cma`](https://github.com/CMA-ES/pycma/releases) - if I pin `cma==3.0.3`, no warnings raised during importing.




<!--- In any case, don't hesitate to join and ask questions if you need on Nevergrad users Facebook group https://www.facebook.com/groups/nevergradusers/ -->



Discussion:

Resolving patch:
diff --git a/nevergrad/optimization/optimizerlib.py b/nevergrad/optimization/optimizerlib.py
--- a/nevergrad/optimization/optimizerlib.py
+++ b/nevergrad/optimization/optimizerlib.py
@@ -8,7 +8,6 @@
 import itertools
 from collections import deque
 import warnings
-import cma
 import numpy as np
 from bayes_opt import UtilityFunction
 from bayes_opt import BayesianOptimization
@@ -380,6 +379,8 @@ def __init__(
 ).set_name("RecombiningPortfolioDiscreteOnePlusOne", register=True)
 
 # pylint: too-many-arguments,too-many-instance-attributes
+
+
 class _CMA(base.Optimizer):
     def __init__(
         self,
@@ -404,6 +405,8 @@ def __init__(
     def es(self) -> tp.Any:  # typing not possible since cmaes not imported :(
         if self._es is None:
             if not self._config.fcmaes:
+                import cma  # import inline in order to avoid matplotlib initialization warning
+
                 inopts = dict(
                     popsize=self._popsize,
                     randn=self._rng.randn,
@@ -412,6 +415,7 @@ def es(self) -> tp.Any:  # typing not possible since cmaes not imported :(
                     seed=np.nan,
                     CMA_elitist=self._config.elitist,
                 )
+
                 inopts.update(self._config.inopts if self._config.inopts is not None else {})
                 self._es = cma.CMAEvolutionStrategy(
                     x0=self.parametrization.sample().get_standardized_data(reference=self.parametrization)
@@ -422,7 +426,7 @@ def es(self) -> tp.Any:  # typing not possible since cmaes not imported :(
                 )
             else:
                 try:
-                    from fcmaes import cmaes  # pylint: disable=import-outside-toplevel
+                    from fcmaes import cmaes
                 except ImportError as e:
                     raise ImportError(
                         "Please install fcmaes (pip install fcmaes) to use FCMA optimizers"


Test patch: