Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 04586cd

Browse filesBrowse files
authored
Merge pull request #25843 from anntzer/rv
Fix invalid range validators.
2 parents 0172ec3 + 12533d8 commit 04586cd
Copy full SHA for 04586cd

File tree

Expand file treeCollapse file tree

4 files changed

+28
-30
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+28
-30
lines changed

‎lib/matplotlib/_constrained_layout.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_constrained_layout.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ def reposition_colorbar(layoutgrids, cbax, renderer, *, offset=None):
678678
width and height padding (in fraction of figure)
679679
hspace, wspace : float
680680
width and height padding as fraction of figure size divided by
681-
number of columns or rows
681+
number of columns or rows
682682
margin : array-like
683683
offset the colorbar needs to be pushed to in order to
684684
account for multiple colorbars

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,10 +2665,10 @@ def margins(self, *margins, x=None, y=None, tight=True):
26652665
26662666
The padding added to each limit of the Axes is the *margin*
26672667
times the data interval. All input parameters must be floats
2668-
within the range [0, 1]. Passing both positional and keyword
2668+
greater than -0.5. Passing both positional and keyword
26692669
arguments is invalid and will raise a TypeError. If no
26702670
arguments (positional or otherwise) are provided, the current
2671-
margins will remain in place and simply be returned.
2671+
margins will remain unchanged and simply be returned.
26722672
26732673
Specifying any margin changes only the autoscaling; for example,
26742674
if *xmargin* is not None, then *xmargin* times the X data

‎lib/matplotlib/mpl-data/matplotlibrc

Copy file name to clipboardExpand all lines: lib/matplotlib/mpl-data/matplotlibrc
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,10 +585,14 @@
585585
#figure.constrained_layout.use: False # When True, automatically make plot
586586
# elements fit on the figure. (Not
587587
# compatible with `autolayout`, above).
588-
#figure.constrained_layout.h_pad: 0.04167 # Padding around axes objects. Float representing
589-
#figure.constrained_layout.w_pad: 0.04167 # inches. Default is 3/72 inches (3 points)
590-
#figure.constrained_layout.hspace: 0.02 # Space between subplot groups. Float representing
591-
#figure.constrained_layout.wspace: 0.02 # a fraction of the subplot widths being separated.
588+
## Padding (in inches) around axes; defaults to 3/72 inches, i.e. 3 points.
589+
#figure.constrained_layout.h_pad: 0.04167
590+
#figure.constrained_layout.w_pad: 0.04167
591+
## Spacing between subplots, relative to the subplot sizes. Much smaller than for
592+
## tight_layout (figure.subplot.hspace, figure.subplot.wspace) as constrained_layout
593+
## already takes surrounding texts (titles, labels, # ticklabels) into account.
594+
#figure.constrained_layout.hspace: 0.02
595+
#figure.constrained_layout.wspace: 0.02
592596

593597

594598
## ***************************************************************************

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+17-23Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -552,12 +552,12 @@ def validate_sketch(s):
552552
raise ValueError("Expected a (scale, length, randomness) triplet")
553553

554554

555-
def _validate_greaterequal0_lessthan1(s):
555+
def _validate_greaterthan_minushalf(s):
556556
s = validate_float(s)
557-
if 0 <= s < 1:
557+
if s > -0.5:
558558
return s
559559
else:
560-
raise RuntimeError(f'Value must be >=0 and <1; got {s}')
560+
raise RuntimeError(f'Value must be >-0.5; got {s}')
561561

562562

563563
def _validate_greaterequal0_lessequal1(s):
@@ -568,12 +568,6 @@ def _validate_greaterequal0_lessequal1(s):
568568
raise RuntimeError(f'Value must be >=0 and <=1; got {s}')
569569

570570

571-
_range_validators = { # Slightly nicer (internal) API.
572-
"0 <= x < 1": _validate_greaterequal0_lessthan1,
573-
"0 <= x <= 1": _validate_greaterequal0_lessequal1,
574-
}
575-
576-
577571
def validate_hatch(s):
578572
r"""
579573
Validate a hatch pattern.
@@ -1012,9 +1006,9 @@ def _convert_validator_spec(key, conv):
10121006
# If "data", axes limits are set close to the data.
10131007
# If "round_numbers" axes limits are set to the nearest round numbers.
10141008
"axes.autolimit_mode": ["data", "round_numbers"],
1015-
"axes.xmargin": _range_validators["0 <= x <= 1"], # margin added to xaxis
1016-
"axes.ymargin": _range_validators["0 <= x <= 1"], # margin added to yaxis
1017-
'axes.zmargin': _range_validators["0 <= x <= 1"], # margin added to zaxis
1009+
"axes.xmargin": _validate_greaterthan_minushalf, # margin added to xaxis
1010+
"axes.ymargin": _validate_greaterthan_minushalf, # margin added to yaxis
1011+
"axes.zmargin": _validate_greaterthan_minushalf, # margin added to zaxis
10181012

10191013
"polaraxes.grid": validate_bool, # display polar grid or not
10201014
"axes3d.grid": validate_bool, # display 3d grid
@@ -1149,21 +1143,21 @@ def _convert_validator_spec(key, conv):
11491143
"figure.max_open_warning": validate_int,
11501144
"figure.raise_window": validate_bool,
11511145

1152-
"figure.subplot.left": _range_validators["0 <= x <= 1"],
1153-
"figure.subplot.right": _range_validators["0 <= x <= 1"],
1154-
"figure.subplot.bottom": _range_validators["0 <= x <= 1"],
1155-
"figure.subplot.top": _range_validators["0 <= x <= 1"],
1156-
"figure.subplot.wspace": _range_validators["0 <= x < 1"],
1157-
"figure.subplot.hspace": _range_validators["0 <= x < 1"],
1146+
"figure.subplot.left": validate_float,
1147+
"figure.subplot.right": validate_float,
1148+
"figure.subplot.bottom": validate_float,
1149+
"figure.subplot.top": validate_float,
1150+
"figure.subplot.wspace": validate_float,
1151+
"figure.subplot.hspace": validate_float,
11581152

11591153
"figure.constrained_layout.use": validate_bool, # run constrained_layout?
11601154
# wspace and hspace are fraction of adjacent subplots to use for space.
11611155
# Much smaller than above because we don't need room for the text.
1162-
"figure.constrained_layout.hspace": _range_validators["0 <= x < 1"],
1163-
"figure.constrained_layout.wspace": _range_validators["0 <= x < 1"],
1156+
"figure.constrained_layout.hspace": validate_float,
1157+
"figure.constrained_layout.wspace": validate_float,
11641158
# buffer around the axes, in inches.
1165-
'figure.constrained_layout.h_pad': validate_float,
1166-
'figure.constrained_layout.w_pad': validate_float,
1159+
"figure.constrained_layout.h_pad": validate_float,
1160+
"figure.constrained_layout.w_pad": validate_float,
11671161

11681162
## Saving figure's properties
11691163
'savefig.dpi': validate_dpi,
@@ -1207,7 +1201,7 @@ def _convert_validator_spec(key, conv):
12071201
"docstring.hardcopy": validate_bool,
12081202

12091203
"path.simplify": validate_bool,
1210-
"path.simplify_threshold": _range_validators["0 <= x <= 1"],
1204+
"path.simplify_threshold": _validate_greaterequal0_lessequal1,
12111205
"path.snap": validate_bool,
12121206
"path.sketch": validate_sketch,
12131207
"path.effects": validate_anylist,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.