Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0d47f0

Browse files
committed
Remove unused Variables from LayoutGrid
While the above comment claims that these variables are useful, they are not added to the solver nor added to any constraints, so they cannot contain any useful information. They are only really used for the `__repr__`, which can be changed to the actually-used Variables instead.
1 parent 04586cd commit b0d47f0

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

lib/matplotlib/_layoutgrid.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,8 @@ def __init__(self, parent=None, parent_pos=(0, 0),
7777

7878
sol = self.solver
7979

80-
# These are redundant, but make life easier if
81-
# we define them all. All that is really
82-
# needed is left/right, margin['left'], and margin['right']
83-
self.widths = [Variable(f'{sn}widths[{i}]') for i in range(ncols)]
8480
self.lefts = [Variable(f'{sn}lefts[{i}]') for i in range(ncols)]
8581
self.rights = [Variable(f'{sn}rights[{i}]') for i in range(ncols)]
86-
self.inner_widths = [Variable(f'{sn}inner_widths[{i}]')
87-
for i in range(ncols)]
8882
for todo in ['left', 'right', 'leftcb', 'rightcb']:
8983
self.margins[todo] = [Variable(f'{sn}margins[{todo}][{i}]')
9084
for i in range(ncols)]
@@ -95,9 +89,6 @@ def __init__(self, parent=None, parent_pos=(0, 0),
9589
self.margins[todo] = np.empty((nrows), dtype=object)
9690
self.margin_vals[todo] = np.zeros(nrows)
9791

98-
self.heights = [Variable(f'{sn}heights[{i}]') for i in range(nrows)]
99-
self.inner_heights = [Variable(f'{sn}inner_heights[{i}]')
100-
for i in range(nrows)]
10192
self.bottoms = [Variable(f'{sn}bottoms[{i}]') for i in range(nrows)]
10293
self.tops = [Variable(f'{sn}tops[{i}]') for i in range(nrows)]
10394
for todo in ['bottom', 'top', 'bottomcb', 'topcb']:
@@ -119,14 +110,14 @@ def __repr__(self):
119110
for i in range(self.nrows):
120111
for j in range(self.ncols):
121112
str += f'{i}, {j}: '\
122-
f'L({self.lefts[j].value():1.3f}, ' \
113+
f'L{self.lefts[j].value():1.3f}, ' \
123114
f'B{self.bottoms[i].value():1.3f}, ' \
124-
f'W{self.widths[j].value():1.3f}, ' \
125-
f'H{self.heights[i].value():1.3f}, ' \
126-
f'innerW{self.inner_widths[j].value():1.3f}, ' \
127-
f'innerH{self.inner_heights[i].value():1.3f}, ' \
115+
f'R{self.rights[j].value():1.3f}, ' \
116+
f'T{self.tops[i].value():1.3f}, ' \
128117
f'ML{self.margins["left"][j].value():1.3f}, ' \
129-
f'MR{self.margins["right"][j].value():1.3f}, \n'
118+
f'MR{self.margins["right"][j].value():1.3f}, ' \
119+
f'MB{self.margins["bottom"][i].value():1.3f}, ' \
120+
f'MT{self.margins["top"][i].value():1.3f}, \n'
130121
return str
131122

132123
def reset_margins(self):

0 commit comments

Comments
 (0)