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 50cfd7e

Browse filesBrowse files
committed
Rename some variables for clarity or pep8.
1 parent c739a08 commit 50cfd7e
Copy full SHA for 50cfd7e

File tree

Expand file treeCollapse file tree

1 file changed

+37
-37
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+37
-37
lines changed

‎lib/mpl_toolkits/axes_grid1/axes_divider.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/axes_divider.py
+37-37Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -584,48 +584,48 @@ def get_subplotspec(self):
584584

585585

586586
# Helper for HBoxDivider/VBoxDivider.
587-
def _determine_karray(equivalent_sizes, appended_sizes,
588-
max_equivalent_size, total_appended_size):
589-
n = len(equivalent_sizes)
590-
eq_rs, eq_as = np.asarray(equivalent_sizes).T
591-
ap_rs, ap_as = np.asarray(appended_sizes).T
587+
# The variable names are written for a horizontal layout, but the calculations
588+
# work identically for vertical layouts (and likewise for the helpers below).
589+
def _determine_karray(equal_heights, summed_widths, max_height, total_width):
590+
n = len(equal_heights)
591+
eq_rs, eq_as = np.asarray(equal_heights).T
592+
sm_rs, sm_as = np.asarray(summed_widths).T
592593
A = np.zeros((n + 1, n + 1))
593594
B = np.zeros(n + 1)
594595
np.fill_diagonal(A[:n, :n], eq_rs)
595596
A[:n, -1] = -1
596-
A[-1, :-1] = ap_rs
597+
A[-1, :-1] = sm_rs
597598
B[:n] = -eq_as
598-
B[-1] = total_appended_size - sum(ap_as)
599+
B[-1] = total_width - sum(sm_as)
599600
# A @ K = B: This solves for {k_0, ..., k_{N-1}, H} so that
600601
# eq_r_i * k_i + eq_a_i = H for all i: all axes have the same height
601-
# sum(ap_r_i * k_i + ap_a_i) = total_summed_width: fixed total width
602+
# sum(sm_r_i * k_i + sm_a_i) = total_summed_width: fixed total width
602603
# (foo_r_i * k_i + foo_a_i will end up being the size of foo.)
603-
karray_H = np.linalg.solve(A, B)
604-
karray = karray_H[:-1]
605-
H = karray_H[-1]
606-
if H > max_equivalent_size: # Additionally, upper-bound the height.
607-
karray = (max_equivalent_size - eq_as) / eq_rs
604+
karray_and_height = np.linalg.solve(A, B)
605+
karray = karray_and_height[:-1]
606+
height = karray_and_height[-1]
607+
if height > max_height: # Additionally, upper-bound the height.
608+
karray = (max_height - eq_as) / eq_rs
608609
return karray
609610

610611

611-
# Helper for HBoxDivider/VBoxDivider.
612-
def _calc_offsets(appended_sizes, karray):
612+
# Helper for HBoxDivider/VBoxDivider (see above re: variable naming).
613+
def _calc_offsets(summed_sizes, karray):
613614
offsets = [0.]
614-
for (r, a), k in zip(appended_sizes, karray):
615+
for (r, a), k in zip(summed_sizes, karray):
615616
offsets.append(offsets[-1] + r*k + a)
616617
return offsets
617618

618619

619-
# Helper for HBoxDivider/VBoxDivider.
620-
def _locate(
621-
x, y, w, h, equivalent_sizes, appended_sizes, fig_w, fig_h, anchor):
620+
# Helper for HBoxDivider/VBoxDivider (see above re: variable naming).
621+
def _locate(x, y, w, h, equal_heights, summed_widths, fig_w, fig_h, anchor):
622622
karray = _determine_karray(
623-
equivalent_sizes, appended_sizes,
624-
max_equivalent_size=fig_h * h, total_appended_size=fig_w * w)
625-
ox = _calc_offsets(appended_sizes, karray)
623+
equal_heights, summed_widths,
624+
max_height=fig_h * h, total_width=fig_w * w)
625+
ox = _calc_offsets(summed_widths, karray)
626626

627627
ww = (ox[-1] - ox[0]) / fig_w
628-
h0_r, h0_a = equivalent_sizes[0]
628+
h0_r, h0_a = equal_heights[0]
629629
hh = (karray[0]*h0_r + h0_a) / fig_h
630630
pb = mtransforms.Bbox.from_bounds(x, y, w, h)
631631
pb1 = mtransforms.Bbox.from_bounds(x, y, ww, hh)
@@ -661,16 +661,16 @@ def new_locator(self, nx, nx1=None):
661661

662662
def locate(self, nx, ny, nx1=None, ny1=None, axes=None, renderer=None):
663663
# docstring inherited
664-
figW, figH = self._fig.get_size_inches()
664+
fig_w, fig_h = self._fig.get_size_inches()
665665
x, y, w, h = self.get_position_runtime(axes, renderer)
666-
y_equivalent_sizes = self.get_vertical_sizes(renderer)
667-
x_appended_sizes = self.get_horizontal_sizes(renderer)
668-
x0, y0, ox, hh = _locate(x, y, w, h,
669-
y_equivalent_sizes, x_appended_sizes,
670-
figW, figH, self.get_anchor())
666+
y_equal_sizes = self.get_vertical_sizes(renderer)
667+
x_summed_sizes = self.get_horizontal_sizes(renderer)
668+
x0, y0, ox, hh = _locate(
669+
x, y, w, h, y_equal_sizes, x_summed_sizes, fig_w, fig_h,
670+
self.get_anchor())
671671
if nx1 is None:
672672
nx1 = nx + 1
673-
x1, w1 = x0 + ox[nx] / figW, (ox[nx1] - ox[nx]) / figW
673+
x1, w1 = x0 + ox[nx] / fig_w, (ox[nx1] - ox[nx]) / fig_w
674674
y1, h1 = y0, hh
675675
return mtransforms.Bbox.from_bounds(x1, y1, w1, h1)
676676

@@ -697,17 +697,17 @@ def new_locator(self, ny, ny1=None):
697697

698698
def locate(self, nx, ny, nx1=None, ny1=None, axes=None, renderer=None):
699699
# docstring inherited
700-
figW, figH = self._fig.get_size_inches()
700+
fig_w, fig_h = self._fig.get_size_inches()
701701
x, y, w, h = self.get_position_runtime(axes, renderer)
702-
x_equivalent_sizes = self.get_horizontal_sizes(renderer)
703-
y_appended_sizes = self.get_vertical_sizes(renderer)
704-
y0, x0, oy, ww = _locate(y, x, h, w,
705-
x_equivalent_sizes, y_appended_sizes,
706-
figH, figW, self.get_anchor())
702+
x_equal_sizes = self.get_horizontal_sizes(renderer)
703+
y_summed_sizes = self.get_vertical_sizes(renderer)
704+
y0, x0, oy, ww = _locate(
705+
y, x, h, w, x_equal_sizes, y_summed_sizes, fig_h, fig_w,
706+
self.get_anchor())
707707
if ny1 is None:
708708
ny1 = ny + 1
709709
x1, w1 = x0, ww
710-
y1, h1 = y0 + oy[ny] / figH, (oy[ny1] - oy[ny]) / figH
710+
y1, h1 = y0 + oy[ny] / fig_h, (oy[ny1] - oy[ny]) / fig_h
711711
return mtransforms.Bbox.from_bounds(x1, y1, w1, h1)
712712

713713

0 commit comments

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