Skip to content

Commit ab89df5

Browse files
committed
Convert iter_*_spaces methods to properties on LayoutTree
1 parent a5dc95a commit ab89df5

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

plotnine/_mpl/layout_manager/_layout_tree.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ def right_spaces_in_col(self, c: int) -> list[right_space]:
460460
spaces.extend(node.right_most_spaces)
461461
return spaces
462462

463-
def iter_left_spaces(self) -> Iterator[list[left_space]]:
463+
@property
464+
def left_spaces(self) -> Iterator[list[left_space]]:
464465
"""
465466
Left spaces for each non-empty column
466467
@@ -471,7 +472,8 @@ def iter_left_spaces(self) -> Iterator[list[left_space]]:
471472
if spaces:
472473
yield spaces
473474

474-
def iter_right_spaces(self) -> Iterator[list[right_space]]:
475+
@property
476+
def right_spaces(self) -> Iterator[list[right_space]]:
475477
"""
476478
Right spaces for each non-empty column
477479
@@ -482,7 +484,8 @@ def iter_right_spaces(self) -> Iterator[list[right_space]]:
482484
if spaces:
483485
yield spaces
484486

485-
def iter_bottom_spaces(self) -> Iterator[list[bottom_space]]:
487+
@property
488+
def bottom_spaces(self) -> Iterator[list[bottom_space]]:
486489
"""
487490
Bottom spaces for each non-empty row
488491
@@ -493,7 +496,8 @@ def iter_bottom_spaces(self) -> Iterator[list[bottom_space]]:
493496
if spaces:
494497
yield spaces
495498

496-
def iter_top_spaces(self) -> Iterator[list[top_space]]:
499+
@property
500+
def top_spaces(self) -> Iterator[list[top_space]]:
497501
"""
498502
Top spaces for each non-empty row
499503
@@ -509,23 +513,23 @@ def align_panels(self):
509513
Align the edges of the panels in the composition
510514
"""
511515
_equalize(
512-
self.iter_bottom_spaces(),
516+
self.bottom_spaces,
513517
lambda s: s.panel_bottom,
514518
"margin_alignment",
515519
)
516520
_equalize(
517-
self.iter_top_spaces(),
521+
self.top_spaces,
518522
lambda s: s.panel_top,
519523
"margin_alignment",
520524
how="min",
521525
)
522526
_equalize(
523-
self.iter_left_spaces(),
527+
self.left_spaces,
524528
lambda s: s.panel_left,
525529
"margin_alignment",
526530
)
527531
_equalize(
528-
self.iter_right_spaces(),
532+
self.right_spaces,
529533
lambda s: s.panel_right,
530534
"margin_alignment",
531535
how="min",
@@ -536,22 +540,22 @@ def align_tags(self):
536540
Align the tags in the composition
537541
"""
538542
_equalize(
539-
self.iter_bottom_spaces(),
543+
self.bottom_spaces,
540544
lambda s: s.tag_height + s.tag_alignment,
541545
"tag_alignment",
542546
)
543547
_equalize(
544-
self.iter_top_spaces(),
548+
self.top_spaces,
545549
lambda s: s.tag_height + s.tag_alignment,
546550
"tag_alignment",
547551
)
548552
_equalize(
549-
self.iter_left_spaces(),
553+
self.left_spaces,
550554
lambda s: s.tag_width + s.tag_alignment,
551555
"tag_alignment",
552556
)
553557
_equalize(
554-
self.iter_right_spaces(),
558+
self.right_spaces,
555559
lambda s: s.tag_width + s.tag_alignment,
556560
"tag_alignment",
557561
)
@@ -569,12 +573,12 @@ def align_axis_titles(self):
569573
setting the position of the texts!
570574
"""
571575
_equalize(
572-
self.iter_bottom_spaces(),
576+
self.bottom_spaces,
573577
lambda s: s.axis_title_clearance,
574578
"axis_title_alignment",
575579
)
576580
_equalize(
577-
self.iter_left_spaces(),
581+
self.left_spaces,
578582
lambda s: s.axis_title_clearance,
579583
"axis_title_alignment",
580584
)

0 commit comments

Comments
 (0)