File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -949,13 +949,16 @@ def clear(self, keep_observers=False):
949
949
950
950
self .stale = True
951
951
952
- # synonym for `clear`.
953
- clf = clear
952
+ # synonym for `clear`. We do this with a property to make sure that we get
953
+ # a literal alias that correctly behaves for sub-classes (without resorting
954
+ # to __subclass_init__ or other meta-programming tools.
955
+ @property
956
+ def clf (self ):
957
+ return self .clear
954
958
955
959
# Note: in the docstring below, the newlines in the examples after the
956
960
# calls to legend() allow replacing it with figlegend() to generate the
957
961
# docstring of pyplot.figlegend.
958
-
959
962
@_docstring .dedent_interpd
960
963
def legend (self , * args , ** kwargs ):
961
964
"""
@@ -2848,9 +2851,6 @@ def clear(self, keep_observers=False):
2848
2851
if toolbar is not None :
2849
2852
toolbar .update ()
2850
2853
2851
- # synonym for `clear`.
2852
- clf = clear
2853
-
2854
2854
@_finalize_rasterization
2855
2855
@allow_rasterization
2856
2856
def draw (self , renderer ):
Original file line number Diff line number Diff line change @@ -791,10 +791,12 @@ def test_figure_clear():
791
791
792
792
793
793
def test_clf_is_clear ():
794
- for cls in [FigureBase ] + FigureBase .__subclasses__ ():
795
- assert cls .clf is cls .clear
796
- assert cls .clear .__name__ == 'clear'
794
+ fig = Figure ()
795
+ subfig = fig .subfigures ()
797
796
797
+ for f in [fig , subfig ]:
798
+ assert f .clear .__func__ is f .clf .__func__
799
+ assert f .clear .__func__ .__name__ == 'clear'
798
800
799
801
@mpl .style .context ('mpl20' )
800
802
def test_picking_does_not_stale ():
You can’t perform that action at this time.
0 commit comments