FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Backport PR #24229 on branch v3.6.x (FIX: do not mutate dictionaries passed in by user) by meeseeksmachine · Pull Request #24230 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 2 additions & 3 deletions lib/matplotlib/figure.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,7 @@ def subplots(self, nrows=1, ncols=1, *, sharex=False, sharey=False,
# Note that this is the same as
fig.subplots(2, 2, sharex=True, sharey=True)
"""
if gridspec_kw is None:
gridspec_kw = {}
gridspec_kw = dict(gridspec_kw or {})
if height_ratios is not None:
if 'height_ratios' in gridspec_kw:
raise ValueError("'height_ratios' must not be defined both as "
Expand Down Expand Up @@ -1869,7 +1868,7 @@ def subplot_mosaic(self, mosaic, *, sharex=False, sharey=False,

"""
subplot_kw = subplot_kw or {}
gridspec_kw = gridspec_kw or {}
gridspec_kw = dict(gridspec_kw or {})
if height_ratios is not None:
if 'height_ratios' in gridspec_kw:
raise ValueError("'height_ratios' must not be defined both as "
Expand Down
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_figure.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1412,3 +1412,11 @@ def test_unpickle_with_device_pixel_ratio():
assert fig.dpi == 42*7
fig2 = pickle.loads(pickle.dumps(fig))
assert fig2.dpi == 42


def test_gridspec_no_mutate_input():
gs = {'left': .1}
gs_orig = dict(gs)
plt.subplots(1, 2, width_ratios=[1, 2], gridspec_kw=gs)
assert gs == gs_orig
plt.subplot_mosaic('AB', width_ratios=[1, 2], gridspec_kw=gs)

Back | FazBrowse Home | New Git URL