@@ -481,7 +481,6 @@ def test_subplots_pixelsnap_aligns_axes_bounds():
481481 assert np .allclose (coords , np .round (coords ), atol = 1e-8 )
482482
483483
484-
485484def test_figure_repr ():
486485 fig , axs = uplt .subplots (ncols = 2 , nrows = 3 )
487486 r = repr (fig )
@@ -491,15 +490,12 @@ def test_figure_repr():
491490 uplt .close (fig )
492491
493492
494-
495493class TestShareLabelGroups :
496494 def test_register_share_label_group_basic (self ):
497495 fig , axs = uplt .subplots (ncols = 3 )
498496 axs [0 ].set_xlabel ("shared x" )
499497 axs [1 ].set_xlabel ("also x" )
500- fig ._register_share_label_group (
501- [axs [0 ], axs [1 ]], target = "x" , source = axs [0 ]
502- )
498+ fig ._register_share_label_group ([axs [0 ], axs [1 ]], target = "x" , source = axs [0 ])
503499 assert fig ._has_share_label_groups ("x" )
504500 assert fig ._is_share_label_group_member (axs [0 ], "x" )
505501 assert fig ._is_share_label_group_member (axs [1 ], "x" )
@@ -510,9 +506,7 @@ def test_register_share_label_group_y(self):
510506 fig , axs = uplt .subplots (nrows = 3 )
511507 axs [0 ].set_ylabel ("shared y" )
512508 axs [1 ].set_ylabel ("also y" )
513- fig ._register_share_label_group (
514- [axs [0 ], axs [1 ]], target = "y" , source = axs [0 ]
515- )
509+ fig ._register_share_label_group ([axs [0 ], axs [1 ]], target = "y" , source = axs [0 ])
516510 assert fig ._has_share_label_groups ("y" )
517511 assert fig ._is_share_label_group_member (axs [0 ], "y" )
518512 uplt .close (fig )
@@ -528,9 +522,7 @@ def test_register_empty_and_single_axes(self):
528522 def test_register_deduplicates (self ):
529523 fig , axs = uplt .subplots (ncols = 2 )
530524 axs [0 ].set_xlabel ("x" )
531- fig ._register_share_label_group (
532- [axs [0 ], axs [0 ], axs [1 ]], target = "x"
533- )
525+ fig ._register_share_label_group ([axs [0 ], axs [0 ], axs [1 ]], target = "x" )
534526 assert fig ._has_share_label_groups ("x" )
535527 uplt .close (fig )
536528
@@ -558,9 +550,7 @@ def test_clear_share_label_groups_with_spanning_labels(self):
558550 fig , axs = uplt .subplots (ncols = 3 )
559551 axs [0 ].set_xlabel ("shared x" )
560552 axs [1 ].set_xlabel ("shared x" )
561- fig ._register_share_label_group (
562- [axs [0 ], axs [1 ]], target = "x" , source = axs [0 ]
563- )
553+ fig ._register_share_label_group ([axs [0 ], axs [1 ]], target = "x" , source = axs [0 ])
564554 fig .canvas .draw ()
565555 fig ._clear_share_label_groups (axes = [axs [0 ], axs [1 ]], target = "x" )
566556 assert not fig ._has_share_label_groups ("x" )
@@ -570,32 +560,24 @@ def test_apply_share_label_groups(self):
570560 fig , axs = uplt .subplots (ncols = 3 , share = False )
571561 axs [0 ].set_xlabel ("shared label" )
572562 axs [1 ].set_xlabel ("" )
573- fig ._register_share_label_group (
574- [axs [0 ], axs [1 ]], target = "x" , source = axs [0 ]
575- )
563+ fig ._register_share_label_group ([axs [0 ], axs [1 ]], target = "x" , source = axs [0 ])
576564 fig .canvas .draw ()
577565 uplt .close (fig )
578566
579567 def test_apply_share_label_groups_y (self ):
580568 fig , axs = uplt .subplots (nrows = 3 , share = False )
581569 axs [0 ].set_ylabel ("shared label" )
582570 axs [1 ].set_ylabel ("" )
583- fig ._register_share_label_group (
584- [axs [0 ], axs [1 ]], target = "y" , source = axs [0 ]
585- )
571+ fig ._register_share_label_group ([axs [0 ], axs [1 ]], target = "y" , source = axs [0 ])
586572 fig .canvas .draw ()
587573 uplt .close (fig )
588574
589575 def test_register_for_side_updates_existing_group (self ):
590576 fig , axs = uplt .subplots (ncols = 3 )
591577 axs [0 ].set_xlabel ("original" )
592- fig ._register_share_label_group (
593- [axs [0 ], axs [1 ]], target = "x" , source = axs [0 ]
594- )
578+ fig ._register_share_label_group ([axs [0 ], axs [1 ]], target = "x" , source = axs [0 ])
595579 axs [0 ].set_xlabel ("updated" )
596- fig ._register_share_label_group (
597- [axs [0 ], axs [1 ]], target = "x" , source = axs [0 ]
598- )
580+ fig ._register_share_label_group ([axs [0 ], axs [1 ]], target = "x" , source = axs [0 ])
599581 fig .canvas .draw ()
600582 uplt .close (fig )
601583
@@ -605,14 +587,11 @@ def test_mixed_label_position_splits(self):
605587 axs [1 ].xaxis .set_label_position ("top" )
606588 axs [1 ].set_xlabel ("top" )
607589 axs [2 ].set_xlabel ("bottom" )
608- fig ._register_share_label_group (
609- [axs [0 ], axs [1 ], axs [2 ]], target = "x"
610- )
590+ fig ._register_share_label_group ([axs [0 ], axs [1 ], axs [2 ]], target = "x" )
611591 fig .canvas .draw ()
612592 uplt .close (fig )
613593
614594
615-
616595class TestSubsetTitleHelpers :
617596 def test_deduplicate_axes (self ):
618597 fig , axs = uplt .subplots (ncols = 3 )
@@ -675,9 +654,7 @@ def test_update_subset_title_empty_raises(self):
675654
676655 def test_update_subset_title_creates_group (self ):
677656 fig , axs = uplt .subplots (ncols = 3 )
678- artist = fig ._update_subset_title (
679- [axs [0 ], axs [1 ]], "Two-panel title"
680- )
657+ artist = fig ._update_subset_title ([axs [0 ], axs [1 ]], "Two-panel title" )
681658 assert artist .get_text () == "Two-panel title"
682659 assert len (fig ._subset_title_dict ) == 1
683660 uplt .close (fig )
@@ -721,9 +698,7 @@ def test_align_subset_titles_removes_orphaned(self):
721698
722699 def test_align_subset_titles_with_manual_y (self ):
723700 fig , axs = uplt .subplots (ncols = 3 )
724- fig ._update_subset_title (
725- [axs [0 ], axs [1 ]], "Manual Y" , y = 0.95
726- )
701+ fig ._update_subset_title ([axs [0 ], axs [1 ]], "Manual Y" , y = 0.95 )
727702 fig .canvas .draw ()
728703 key = next (iter (fig ._subset_title_dict ))
729704 artist = fig ._subset_title_dict [key ]["artist" ]
@@ -732,26 +707,21 @@ def test_align_subset_titles_with_manual_y(self):
732707
733708 def test_subset_title_left_alignment (self ):
734709 fig , axs = uplt .subplots (ncols = 3 )
735- fig ._update_subset_title (
736- [axs [0 ], axs [1 ]], "Left title" , loc = "left"
737- )
710+ fig ._update_subset_title ([axs [0 ], axs [1 ]], "Left title" , loc = "left" )
738711 key = next (iter (fig ._subset_title_dict ))
739712 artist = fig ._subset_title_dict [key ]["artist" ]
740713 assert artist .get_ha () == "left"
741714 uplt .close (fig )
742715
743716 def test_subset_title_right_alignment (self ):
744717 fig , axs = uplt .subplots (ncols = 3 )
745- fig ._update_subset_title (
746- [axs [0 ], axs [1 ]], "Right title" , loc = "right"
747- )
718+ fig ._update_subset_title ([axs [0 ], axs [1 ]], "Right title" , loc = "right" )
748719 key = next (iter (fig ._subset_title_dict ))
749720 artist = fig ._subset_title_dict [key ]["artist" ]
750721 assert artist .get_ha () == "right"
751722 uplt .close (fig )
752723
753724
754-
755725class TestAspectConstrainedHelpers :
756726 def test_find_spans_empty (self ):
757727 fig , axs = uplt .subplots (ncols = 2 )
@@ -817,7 +787,6 @@ def test_full_align_aspect_row_spanning(self):
817787 uplt .close (fig )
818788
819789
820-
821790def test_add_subplot_three_integer_args ():
822791 fig = uplt .figure ()
823792 ax = fig .add_subplot (2 , 2 , 1 )
@@ -827,7 +796,6 @@ def test_add_subplot_three_integer_args():
827796 uplt .close (fig )
828797
829798
830-
831799def test_explicit_figwidth_figheight ():
832800 fig , axs = uplt .subplots (figwidth = 6 , figheight = 4 )
833801 w , h = fig .get_size_inches ()
@@ -840,9 +808,7 @@ def test_figwidth_overrides_refwidth():
840808 with warnings .catch_warnings (record = True ) as record :
841809 warnings .simplefilter ("always" )
842810 fig , axs = uplt .subplots (figwidth = 6 , refwidth = 3 )
843- conflict_warnings = [
844- w for w in record if "conflicting" in str (w .message ).lower ()
845- ]
811+ conflict_warnings = [w for w in record if "conflicting" in str (w .message ).lower ()]
846812 assert len (conflict_warnings ) >= 1
847813 uplt .close (fig )
848814
@@ -851,9 +817,7 @@ def test_figheight_overrides_refheight():
851817 with warnings .catch_warnings (record = True ) as record :
852818 warnings .simplefilter ("always" )
853819 fig , axs = uplt .subplots (figheight = 4 , refheight = 2 )
854- conflict_warnings = [
855- w for w in record if "conflicting" in str (w .message ).lower ()
856- ]
820+ conflict_warnings = [w for w in record if "conflicting" in str (w .message ).lower ()]
857821 assert len (conflict_warnings ) >= 1
858822 uplt .close (fig )
859823
@@ -867,12 +831,8 @@ def test_journal_size():
867831def test_subplots_with_gridspec_kw_warns ():
868832 with warnings .catch_warnings (record = True ) as record :
869833 warnings .simplefilter ("always" )
870- fig , axs = uplt .subplots (
871- [[1 , 2 ], [3 , 4 ]], gridspec_kw = {"hspace" : 0.5 }
872- )
873- kw_warnings = [
874- w for w in record if "not necessary" in str (w .message ).lower ()
875- ]
834+ fig , axs = uplt .subplots ([[1 , 2 ], [3 , 4 ]], gridspec_kw = {"hspace" : 0.5 })
835+ kw_warnings = [w for w in record if "not necessary" in str (w .message ).lower ()]
876836 assert len (kw_warnings ) >= 1
877837 uplt .close (fig )
878838
0 commit comments