From a6d0029803dcbd74ad46f38f8520bc08db5d05d4 Mon Sep 17 00:00:00 2001 From: Ananya Devarakonda <57040724+ananya314@users.noreply.github.com> Date: Fri, 22 Sep 2023 18:36:11 -0400 Subject: [PATCH] removed deprecated code from gridspec.py Co-Authored-By: Elliott Sales de Andrade --- ci/mypy-stubtest-allowlist.txt | 1 - .../next_api_changes/removals/26885-AD.rst | 4 +++ lib/matplotlib/gridspec.py | 31 +++++-------------- lib/matplotlib/gridspec.pyi | 2 +- 4 files changed, 13 insertions(+), 25 deletions(-) create mode 100644 doc/api/next_api_changes/removals/26885-AD.rst diff --git a/ci/mypy-stubtest-allowlist.txt b/ci/mypy-stubtest-allowlist.txt index 64fae8d44562..e0890b3f7117 100644 --- a/ci/mypy-stubtest-allowlist.txt +++ b/ci/mypy-stubtest-allowlist.txt @@ -53,7 +53,6 @@ matplotlib.figure.Figure.set_tight_layout matplotlib.cm.register_cmap matplotlib.cm.unregister_cmap matplotlib.collections.PolyCollection.span_where -matplotlib.gridspec.GridSpecBase.get_grid_positions # 3.8 deprecations matplotlib.cbook.get_sample_data diff --git a/doc/api/next_api_changes/removals/26885-AD.rst b/doc/api/next_api_changes/removals/26885-AD.rst new file mode 100644 index 000000000000..c617f10d07ed --- /dev/null +++ b/doc/api/next_api_changes/removals/26885-AD.rst @@ -0,0 +1,4 @@ +``raw`` parameter +~~~~~~~~~~~~~~~~~ + +... of `.GridSpecBase.get_grid_positions` is removed without replacements. diff --git a/lib/matplotlib/gridspec.py b/lib/matplotlib/gridspec.py index 13a7d29ca563..0b93ea93dd3d 100644 --- a/lib/matplotlib/gridspec.py +++ b/lib/matplotlib/gridspec.py @@ -141,8 +141,7 @@ def get_height_ratios(self): """ return self._row_height_ratios - @_api.delete_parameter("3.7", "raw") - def get_grid_positions(self, fig, raw=False): + def get_grid_positions(self, fig): """ Return the positions of the grid cells in figure coordinates. @@ -151,11 +150,6 @@ def get_grid_positions(self, fig, raw=False): fig : `~matplotlib.figure.Figure` The figure the grid should be applied to. The subplot parameters (margins and spacing between subplots) are taken from *fig*. - raw : bool, default: False - If *True*, the subplot parameters of the figure are not taken - into account. The grid spans the range [0, 1] in both directions - without margins and there is no space between grid cells. This is - used for constrained_layout. Returns ------- @@ -164,22 +158,13 @@ def get_grid_positions(self, fig, raw=False): figure coordinates. """ nrows, ncols = self.get_geometry() - - if raw: - left = 0. - right = 1. - bottom = 0. - top = 1. - wspace = 0. - hspace = 0. - else: - subplot_params = self.get_subplot_params(fig) - left = subplot_params.left - right = subplot_params.right - bottom = subplot_params.bottom - top = subplot_params.top - wspace = subplot_params.wspace - hspace = subplot_params.hspace + subplot_params = self.get_subplot_params(fig) + left = subplot_params.left + right = subplot_params.right + bottom = subplot_params.bottom + top = subplot_params.top + wspace = subplot_params.wspace + hspace = subplot_params.hspace tot_width = right - left tot_height = top - bottom diff --git a/lib/matplotlib/gridspec.pyi b/lib/matplotlib/gridspec.pyi index 6f314054a9ee..1ac1bb0b40e7 100644 --- a/lib/matplotlib/gridspec.pyi +++ b/lib/matplotlib/gridspec.pyi @@ -30,7 +30,7 @@ class GridSpecBase: def set_height_ratios(self, height_ratios: ArrayLike | None) -> None: ... def get_height_ratios(self) -> ArrayLike: ... def get_grid_positions( - self, fig: Figure, raw: bool = ... + self, fig: Figure ) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: ... @staticmethod def _check_gridspec_exists(figure: Figure, nrows: int, ncols: int) -> GridSpec: ...