internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: instadeepai/Mava

Issue:
[BUG][Jax] Default executor flattens observations
### Describe the bug
The default executor flattens observations which is undesirable for environments which can benefit from spatial knowledge.

### To Reproduce
`observation = executor.store.observation.observation.reshape((1, -1))` <- inside `action_selection.py`

### Expected behavior
It was expected that observations would be fed to neural networks unedited.

### Possible Solution
`observation = utils.add_batch_dim(executor.store.observation.observation)`



Discussion:

Resolving patch:
diff --git a/mava/components/jax/executing/action_selection.py b/mava/components/jax/executing/action_selection.py
--- a/mava/components/jax/executing/action_selection.py
+++ b/mava/components/jax/executing/action_selection.py
@@ -18,6 +18,7 @@
 from dataclasses import dataclass
 
 import jax
+from acme.jax import utils
 
 from mava.components.jax import Component
 from mava.core_jax import SystemExecutor
@@ -59,7 +60,7 @@ def on_execution_select_action_compute(self, executor: SystemExecutor) -> None:
             executor.store.agent_net_keys[agent]
         ]
 
-        observation = executor.store.observation.observation.reshape((1, -1))
+        observation = utils.add_batch_dim(executor.store.observation.observation)
         rng_key, executor.store.key = jax.random.split(executor.store.key)
 
         # TODO (dries): We are currently using jit in the networks per agent.


Test patch:
Repository: instadeepai/Mava

Issue:
[BUG] SMAC legal action masking 
### Describe the bug
There is a bug with legal action masking on the SMAC tasks leading to runs failing. This is happening on big run sweeps for both recurrent and feedforward systems on the `25m` and `bane_vs_bane` tasks so far. 

### To Reproduce
A note. I was not able to reproduce this locally due to these tasks being to demanding for my machine to run effectively.

Steps to reproduce the behavior:
1. Run smac on `25m` or `bane_vs_bane` with either recurrent or feedforward policies. 

### Expected behavior
The following error occurs 
```
2022/10/12 11:37:24 | Traceback:
-- | --
2022/10/12 11:37:24 | File "/mava/lib/python3.8/site-packages/launchpad/nodes/python/process_entry.py", line 126, in <module> app.run(main)
2022/10/12 11:37:24 | File "/mava/lib/python3.8/site-packages/absl/app.py", line 308, in run _run_main(main, args)
2022/10/12 11:37:24 | File "/mava/lib/python3.8/site-packages/absl/app.py", line 254, in _run_main sys.exit(main(argv))
2022/10/12 11:37:24 | File "/mava/lib/python3.8/site-packages/launchpad/nodes/python/process_entry.py", line 121, in main functions[task_id]()
2022/10/12 11:37:24 | File "/mava/lib/python3.8/site-packages/launchpad/nodes/python/node.py", line 75, in _construct_function return functools.partial(self._function, *args, **kwargs)()
2022/10/12 11:37:24 | File "/mava/lib/python3.8/site-packages/launchpad/nodes/courier/node.py", line 130, in run instance.run()
2022/10/12 11:37:24 | File "/mava/lib/python3.8/site-packages/mava/environment_loop.py", line 686, in run result = self.run_episode()
2022/10/12 11:37:24 | File "/mava/lib/python3.8/site-packages/mava/environment_loop.py", line 511, in run_episode timestep = self._environment.step(env_actions)
2022/10/12 11:37:24 | File "/mava/lib/python3.8/site-packages/mava/wrappers/smac.py", line 120, in step reward, self._done, self._info = self._environment.step(smac_actions)
2022/10/12 11:37:24 | File "/mava/lib/python3.8/site-packages/smac/env/starcraft2/starcraft2.py", line 465, in step sc_action = self.get_agent_action(a_id, action)
2022/10/12 11:37:24 | File "/mava/lib/python3.8/site-packages/smac/env/starcraft2/starcraft2.py", line 551, in get_agent_action assert (
2022/10/12 11:37:24 | Agent 15 cannot perform action 18
```

### Context (Environment)
 - Occurring when using the `sc2-latest` Docker image. 

### Possible Solution
Not obligatory, but suggest a fix/reason for the bug.



Discussion:

Resolving patch:
diff --git a/mava/wrappers/smac.py b/mava/wrappers/smac.py
--- a/mava/wrappers/smac.py
+++ b/mava/wrappers/smac.py
@@ -114,7 +114,7 @@ def step(self, actions: Dict[str, np.ndarray]) -> dm_env.TimeStep:
             return self.reset()
 
         # Convert dict of actions to list for SMAC
-        smac_actions = list(actions.values())
+        smac_actions = [actions[agent] for agent in self._agents]
 
         # Step the SMAC environment
         reward, self._done, self._info = self._environment.step(smac_actions)


Test patch:
Repository: instadeepai/Mava

Issue:
[MAINTAIN] Set environment factory function based on executor or evaluator.
### Please describe what needs to be maintained?
Set `evaluation` variable in environment factory based on if an executor or evaluator is in use.

### Describe the outcome you'd like
Set `evaluation` variable in environment factory based on `store.executor_environment`. 

### How do we know when maintenance is complete?
`evaluation` variable in environment factory will be set based on if an executor or evaluator is us use.



Discussion:

Resolving patch:
diff --git a/mava/components/building/environments.py b/mava/components/building/environments.py
--- a/mava/components/building/environments.py
+++ b/mava/components/building/environments.py
@@ -115,7 +115,9 @@ def on_building_executor_environment(self, builder: SystemBuilder) -> None:
         """
         # Global config set by EnvironmentSpec component
         builder.store.executor_environment = (
-            builder.store.global_config.environment_factory(evaluation=False)
+            builder.store.global_config.environment_factory(
+                evaluation=builder.store.is_evaluator
+            )
         )  # type: ignore
 
     @abc.abstractmethod


Test patch:
diff --git a/tests/components/building/environments_test.py b/tests/components/building/environments_test.py
--- a/tests/components/building/environments_test.py
+++ b/tests/components/building/environments_test.py
@@ -98,6 +98,7 @@ def environment_factory(evaluation: bool) -> str:
     system_builder.store.executor_environment = "environment"
     system_builder.store.executor = "executor"
     system_builder.store.executor_logger = "executor_logger"
+    system_builder.store.is_evaluator = True
 
     return system_builder
 
@@ -179,7 +180,7 @@ def test_on_building_executor_environment(
     ) -> None:
         """Test by manually calling the hook and checking the store"""
         test_executor_environment_loop.on_building_executor_environment(test_builder)
-        assert test_builder.store.executor_environment == "environment_eval_false"
+        assert test_builder.store.executor_environment == "environment_eval_true"
 
 
 class TestParallelExecutorEnvironmentLoop:
Repository: instadeepai/Mava

Issue:
[BUG]: Flasbax bug on LBF (type issue)
### Describe the bug
In the AgentID wrapper, the new_agents_view type is not enforced to be consistent, so for LBF with flashbax a dtype error emerges.

### To Reproduce
Steps to reproduce the behavior:
1. Run LBF with flashbax.

### Expected behavior
Expected the observation to be added easily to the buffer.

### Context (Environment)
 - Updated jumanji

### Additional context
This is somewhat an exercise in opening an issue!

### Possible Solution
Will make a PR soon! Basically a cast to the agents_view type.



Discussion:
Thank you @lbeyers for catching this! 
A question here, did you test this with Rware? And can you please test this with Matrax as well 🙏 

Extra: This [commit](https://github.com/instadeepai/Mava/commit/4aad61dba580ab6a33ccfe17716fa5dbe6d892ab) would help for understanding the issue at the moment 😄 

Resolving patch:
diff --git a/mava/wrappers/observation.py b/mava/wrappers/observation.py
--- a/mava/wrappers/observation.py
+++ b/mava/wrappers/observation.py
@@ -38,7 +38,11 @@ def _add_agent_ids(
         """Adds agent IDs to the observation."""
         obs = timestep.observation
         agent_ids = jnp.eye(num_agents)
-        agents_view = jnp.concatenate([agent_ids, obs.agents_view], axis=-1)
+        agents_view = jnp.concatenate(
+            [agent_ids, obs.agents_view],
+            axis=-1,
+            dtype=obs.agents_view.dtype,
+        )
 
         return obs._replace(agents_view=agents_view)  # type: ignore
 


Test patch:
Repository: SciTools/cartopy

Issue:
axes range bug
The code below sets the dataLim as expected.
However, when using the _PlateCarree_ object instead (commented out here),
the upper limits remain at _1,1_.

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

#ax = plt.axes(projection=ccrs.PlateCarree())
ax = plt.axes()

print ax.dataLim

ax.update_datalim([(-0.42041015714311403, -0.12780000269415132), (-0.33129882901803986, -0.0386999994516301)])

print ax.dataLim
```



Discussion:

Resolving patch:
diff --git a/lib/cartopy/mpl_integration/geoaxes.py b/lib/cartopy/mpl_integration/geoaxes.py
--- a/lib/cartopy/mpl_integration/geoaxes.py
+++ b/lib/cartopy/mpl_integration/geoaxes.py
@@ -128,8 +128,10 @@ def cla(self):
         self.yaxis.set_visible(False)
         self.autoscale_view(tight=True)
         self.set_aspect('equal')
-#        self.patch.set_transform(self.transData)
+
+        pre_bounary = self.ignore_existing_data_limits
         self._boundary()
+        self.ignore_existing_data_limits = pre_bounary
 
         # gives a better display of data. However, does need to be made clear in the docs.
         self._xmargin = 0.15


Test patch:
diff --git a/lib/cartopy/tests/mpl/baseline_images/mpl/test_mpl_integration/global_map.png b/lib/cartopy/tests/mpl/baseline_images/mpl/test_mpl_integration/global_map.png
Binary files a/lib/cartopy/tests/mpl/baseline_images/mpl/test_mpl_integration/global_map.png and b/lib/cartopy/tests/mpl/baseline_images/mpl/test_mpl_integration/global_map.png differ
diff --git a/lib/cartopy/tests/mpl/test_set_extent.py b/lib/cartopy/tests/mpl/test_set_extent.py
--- a/lib/cartopy/tests/mpl/test_set_extent.py
+++ b/lib/cartopy/tests/mpl/test_set_extent.py
@@ -55,7 +55,13 @@ def test_extents():
                               )
     
 
+def test_update_lim():
+    # check that the standard data lim setting works
+    ax = plt.axes(projection=ccrs.PlateCarree())
+    ax.update_datalim([(-10, -10), (-5, -5)])
+    assert_array_almost_equal(ax.dataLim.get_points(), np.array([[-10., -10.], [ -5.,  -5.]]))
+    
+
 if __name__=='__main__':
     import nose
-    nose.runmodule(argv=['-s','--with-doctest'], exit=False)
-    
\ No newline at end of file
+    nose.runmodule(argv=['-s','--with-doctest'], exit=False)
\ No newline at end of file
Repository: SciTools/cartopy

Issue:
Cursor is not displaying the correct coordinate values
The `GenericProjectionAxes.format_coord` method is not producing the correct results. To reproduce:

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

rob = ccrs.Robinson()
ax = plt.axes(projection=rob)
ax.coastlines()
ax.set_global()
plt.show()
```

Placing the mouse on the map should show the correct coordinates in the status bar.



Discussion:

Resolving patch:
diff --git a/lib/cartopy/mpl_integration/geoaxes.py b/lib/cartopy/mpl_integration/geoaxes.py
--- a/lib/cartopy/mpl_integration/geoaxes.py
+++ b/lib/cartopy/mpl_integration/geoaxes.py
@@ -138,7 +138,7 @@ def cla(self):
 
     def format_coord(self, x, y):
         """Return a format string formatting the coordinate value for GUI purposes only."""
-        lon, lat = self.projection.transform_point(x, y, ccrs.Geodetic())
+        lon, lat = ccrs.Geodetic().transform_point(x, y, self.projection)
 
         ns = 'N' if lat >= 0.0 else 'S'
         ew = 'E' if lon >= 0.0 else 'W'


Test patch:
diff --git a/lib/cartopy/tests/mpl/test_mpl_integration.py b/lib/cartopy/tests/mpl/test_mpl_integration.py
--- a/lib/cartopy/tests/mpl/test_mpl_integration.py
+++ b/lib/cartopy/tests/mpl/test_mpl_integration.py
@@ -15,6 +15,7 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with cartopy.  If not, see <http://www.gnu.org/licenses/>.
 
+from nose.tools import assert_equal
 import numpy as np
 from matplotlib.testing.decorators import image_comparison as mpl_image_comparison
 import matplotlib.pyplot as plt
@@ -77,6 +78,23 @@ def test_multiple_projections():
         plt.plot([-0.08, 132], [51.53, 43.17], color='blue',
                  transform=ccrs.Geodetic())
 
+
+def test_cursor_values():
+    ax = plt.axes(projection=ccrs.NorthPolarStereo())
+    x, y = np.array([-969100.]), np.array([-4457000.])
+    r = ax.format_coord(x, y)
+    assert_equal(r.encode('ascii', 'ignore'), '-9.691e+05, -4.457e+06 (50.716617N, 12.267069W)')
+    
+    ax = plt.axes(projection=ccrs.PlateCarree())
+    x, y = np.array([-181.5]), np.array([50.])
+    r = ax.format_coord(x, y)
+    assert_equal(r.encode('ascii', 'ignore'), '-181.5, 50 (50.000000N, 178.500000E)')
+
+    ax = plt.axes(projection=ccrs.Robinson())
+    x, y = np.array([16060595.2]), np.array([2363093.4])
+    r = ax.format_coord(x, y)
+    assert_equal(r.encode('ascii', 'ignore'), '1.606e+07, 2.363e+06 (22.095524N, 173.709136E)')
+
 #
 #@image_comparison(baseline_images=['image_transform'])
 #def test_image_transforms():
@@ -85,4 +103,4 @@ def test_multiple_projections():
 
 if __name__=='__main__':
     import nose
-    nose.runmodule(argv=['-s','--with-doctest'], exit=False)
+    nose.runmodule(argv=['-s','--with-doctest'], exit=False)
\ No newline at end of file
Repository: SciTools/cartopy

Issue:
Path <-> LineString vs Polygon conversion
Consider the following:

```
p = Path([[0, 0], [0, 2], [0, 0]])
print cpatch.path_to_geos(p)
```

In this case, the result should be a LineString, but the following should be a polygon:

```
p = Path([[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]])
print cpatch.path_to_geos(p)
```

Update `cartopy.mpl_integration.patch` (possibly renaming it) to handle these cases in the best possible way (which way is, as yet, unclear). 

Add tests for these cases.



Discussion:
MPL's `contour()` method (no "f") can generate paths such as:

```
Path([[ 357.20001221   59.        ]
 [ 357.20001221   59.        ]
 [ 357.20001221   59.        ]], None)
```

The current heuristics in cartopy.mpl_integration.patch.path_to_geos attempt to convert this into a Polygon, which creates a null geometry, and then it falls over itself.

Ultimately it'd be nicer to remove the heuristic guesswork from `path_to_geos` by modifying MPL to actually use the CLOSE_POLY vertex code when a path describes a polygon. In the meantime, we can get a chunk of that benefit by removing the heuristics and making `GeoAxes.contourf()` ensure the resulting paths use CLOSE_POLY.


Resolving patch:
diff --git a/lib/cartopy/mpl_integration/patch.py b/lib/cartopy/mpl_integration/patch.py
--- a/lib/cartopy/mpl_integration/patch.py
+++ b/lib/cartopy/mpl_integration/patch.py
@@ -202,7 +202,9 @@ def path_to_geos(path):
         geom_collection = [MultiLineString(geom_collection)]
 
     # Remove any zero area Polygons
-    result = filter(lambda geom: (isinstance(geom, Polygon) and geom.area != 0) or
-                    not isinstance(geom, Polygon), geom_collection)
-    
+    not_zero_poly = lambda geom: ((isinstance(geom, Polygon) and
+                                   not geom._is_empty and geom.area != 0) or
+                                  not isinstance(geom, Polygon))
+    result = filter(not_zero_poly, geom_collection)
+
     return result


Test patch:
diff --git a/lib/cartopy/tests/mpl/test_shapely_to_mpl.py b/lib/cartopy/tests/mpl/test_shapely_to_mpl.py
--- a/lib/cartopy/tests/mpl/test_shapely_to_mpl.py
+++ b/lib/cartopy/tests/mpl/test_shapely_to_mpl.py
@@ -81,6 +81,15 @@ def test_polygon_interiors():
     ax.add_collection(collection)
     
 
+def test_null_geometry():
+    pth = Path([[358.27203369, 3.56399965],
+                [358.27203369, 3.56399965],
+                [358.27203369, 3.56399965]])
+    geoms = cpatch.path_to_geos(pth)
+
+    assert len(geoms) == 0
+
+
 @ImageTesting(['contour_with_interiors'])
 def test_contour_interiors():
 #    ############## produces a polygon with multiple holes:
Repository: SciTools/cartopy

Issue:
Remove ```GenericProjectionAxes``` ```from cartopy.mpl.geoaxes```



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
@@ -1293,11 +1293,6 @@ def _pcolor_patched(self, *args, **kwargs):
         return collection
 
 
-# alias GeoAxes - NOTE: THIS WAS NOT IN v0.4.0rc1
-GenericProjectionAxes = GeoAxes
-"""(To be removed in v0.5) An alias to the :class:`GeoAxes` class."""
-
-
 class SimpleClippedTransform(mtransforms.Transform):
     """
     Transforms the values using a pre transform, clips them, then post


Test patch:
Repository: SciTools/cartopy

Issue:
Remove standard out from web tiles
`cartopy.tests.mpl.test_images.test_web_tiles` produces debug standard out. 
Ideally, consider tidying this up before we release 0.5.



Discussion:

Resolving patch:
diff --git a/lib/cartopy/io/img_tiles.py b/lib/cartopy/io/img_tiles.py
--- a/lib/cartopy/io/img_tiles.py
+++ b/lib/cartopy/io/img_tiles.py
@@ -50,7 +50,6 @@ def image_for_domain(self, target_domain, target_z):
                 img, extent, origin = self.get_image(tile)
             except IOError:
                 continue
-            print tile, extent
             img = np.array(img)
             x = np.linspace(extent[0], extent[1], img.shape[1])
             y = np.linspace(extent[2], extent[3], img.shape[0])


Test patch:
Repository: SciTools/cartopy

Issue:
BUG: Geostationary example bug
```
python cartopy/docs/source/examples/geostationary.py
Traceback (most recent call last):
  File "/net/home/h05/cpelley/git/cartopy/docs/source/examples/geostationary.py", line 60, in <module>
    main()
  File "/net/home/h05/cpelley/git/cartopy/docs/source/examples/geostationary.py", line 54, in main
    img, crs, extent, origin = geos_image()
  File "/net/home/h05/cpelley/git/cartopy/docs/source/examples/geostationary.py", line 43, in geos_image
    img_handle = BytesIO(urllib2.urlopen(url).read())
NameError: global name 'urllib2' is not defined
```



Discussion:
No need to make the issue - just submit a PR if you have a fix already... ?


Resolving patch:
diff --git a/lib/cartopy/examples/geostationary.py b/lib/cartopy/examples/geostationary.py
--- a/lib/cartopy/examples/geostationary.py
+++ b/lib/cartopy/examples/geostationary.py
@@ -41,7 +41,7 @@ def geos_image():
     """
     url = ('https://gist.github.com/pelson/5871263/raw/'
            'EIDA50_201211061300_clip2.png')
-    img_handle = BytesIO(urllib2.urlopen(url).read())
+    img_handle = BytesIO(urlopen(url).read())
     img = plt.imread(img_handle)
     img_proj = ccrs.Geostationary(satellite_height=35786000)
     img_extent = (-5500000, 5500000, -5500000, 5500000)


Test patch:
Repository: SciTools/cartopy

Issue:
Update srtm.py
prevent from bug when nx,ny fall on the sea



Discussion:

Resolving patch:
diff --git a/lib/cartopy/io/srtm.py b/lib/cartopy/io/srtm.py
--- a/lib/cartopy/io/srtm.py
+++ b/lib/cartopy/io/srtm.py
@@ -119,14 +119,18 @@ def srtm_composite(lon_min, lat_min, nx, ny):
             x_img_slice = slice(i * shape[0], (i + 1) * shape[0])
             y_img_slice = slice(j * shape[1], (j + 1) * shape[1])
 
-            tile_img, crs, extent = srtm(bottom_left_ll[0] + j,
-                                         bottom_left_ll[1] + i)
-            img[x_img_slice, y_img_slice] = tile_img
+            try:
+                tile_img, _, _ = srtm(bottom_left_ll[0] + j,
+                                      bottom_left_ll[1] + i)
+            except ValueError:
+                img[x_img_slice, y_img_slice] = 0
+            else:
+                img[x_img_slice, y_img_slice] = tile_img
 
     extent = (bottom_left_ll[0], bottom_left_ll[0] + ny,
               bottom_left_ll[1], bottom_left_ll[1] + nx)
 
-    return img, crs, extent
+    return img, ccrs.PlateCarree(), extent
 
 
 def read_SRTM3(fh):
@@ -153,11 +157,22 @@ def read_SRTM3(fh):
 
 
 def SRTM3_retrieve(lon, lat):
+    """
+    Return the path of a .hgt file for the given SRTM location.
+
+    If no such .hgt file exists (because it is over the ocean)
+    None will be returned.
+
+    """
     x = '%s%03d' % ('E' if lon > 0 else 'W', abs(int(lon)))
     y = '%s%02d' % ('N' if lat > 0 else 'S', abs(int(lat)))
 
     srtm_downloader = Downloader.from_config(('SRTM', 'SRTM3'))
-    return srtm_downloader.path({'config': config, 'x': x, 'y': y})
+    params = {'config': config, 'x': x, 'y': y}
+    if srtm_downloader.url(params) is None:
+        return None
+    else:
+        return srtm_downloader.path({'config': config, 'x': x, 'y': y})
 
 
 class SRTM3Downloader(Downloader):


Test patch:
diff --git a/lib/cartopy/tests/io/test_srtm.py b/lib/cartopy/tests/io/test_srtm.py
--- a/lib/cartopy/tests/io/test_srtm.py
+++ b/lib/cartopy/tests/io/test_srtm.py
@@ -18,6 +18,9 @@
 
 import warnings
 
+import numpy as np
+from numpy.testing import assert_array_equal
+
 import cartopy.io.srtm
 from cartopy.tests.io.test_downloaders import download_to_temp
 
@@ -41,6 +44,12 @@ def test_srtm3_retrieve():
         assert img[-10, 12] == 78, msg + 'Got {}'.format(img[-10, 12])
 
 
+def test_srtm3_out_of_range():
+    # Somewhere over the pacific the elevation should be 0.
+    img, _, _ = cartopy.io.srtm.srtm_composite(120, 2, 2, 2)
+    assert_array_equal(img, np.zeros(np.array((1201, 1201)) * 2))
+
+
 if __name__ == '__main__':
     import nose
     nose.runmodule(argv=['-sv', '--with-doctest'], exit=False)