@@ -616,3 +616,46 @@ def test_alt_axes_x_shared():
616616 assert alt .get_ylabel () == ""
617617 axi .set_xlabel ("X" )
618618 return fig
619+
620+
621+ def test_inset_format_scope ():
622+ """
623+ Test that calling format() on an inset axes does not affect the
624+ parent figure's properties like suptitle or super labels.
625+ """
626+ fig , axs = uplt .subplots ()
627+ ax = axs [0 ]
628+ # Inset axes are instances of the same class as the parent
629+ ix = ax .inset_axes ([0.5 , 0.5 , 0.4 , 0.4 ])
630+ assert ix ._inset_parent is ax , "Inset parent should be the main axes"
631+
632+ # Test that suptitle is not set
633+ ix .format (suptitle = "This should not appear" )
634+ assert (
635+ fig ._suptitle is None or fig ._suptitle .get_text () == ""
636+ ), "Inset format should not set the figure's suptitle."
637+
638+ # Test that leftlabels are not set
639+ # Create a copy to ensure we're not comparing against a modified list
640+ original_left_labels = list (fig ._suplabel_dict ["left" ])
641+ ix .format (leftlabels = ["a" , "b" ])
642+ assert (
643+ list (fig ._suplabel_dict ["left" ]) == original_left_labels
644+ ), "Inset format should not set the figure's leftlabels."
645+
646+
647+ def test_panel_format_scope ():
648+ """
649+ Test that calling format() on a panel axes does not affect the
650+ parent figure's properties like suptitle.
651+ """
652+ fig , axs = uplt .subplots ()
653+ ax = axs [0 ]
654+ pax = ax .panel_axes ("right" )
655+ assert pax ._panel_parent is ax , "Panel parent should be the main axes"
656+
657+ # Test that suptitle is not set
658+ pax .format (suptitle = "This should not appear" )
659+ assert (
660+ fig ._suptitle is None or fig ._suptitle .get_text () == ""
661+ ), "Panel format should not set the figure's suptitle."
0 commit comments