File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -860,14 +860,18 @@ def set_weight(self, weight):
860
860
"""
861
861
if weight is None :
862
862
weight = rcParams ['font.weight' ]
863
+ if weight in weight_dict :
864
+ self ._weight = weight
865
+ return
863
866
try :
864
867
weight = int (weight )
865
- if weight < 0 or weight > 1000 :
866
- raise ValueError ()
867
868
except ValueError :
868
- if weight not in weight_dict :
869
- raise ValueError ("weight is invalid" )
870
- self ._weight = weight
869
+ pass
870
+ else :
871
+ if 0 <= weight <= 1000 :
872
+ self ._weight = weight
873
+ return
874
+ raise ValueError (f"{ weight = } is invalid" )
871
875
872
876
def set_stretch (self , stretch ):
873
877
"""
@@ -882,14 +886,18 @@ def set_stretch(self, stretch):
882
886
"""
883
887
if stretch is None :
884
888
stretch = rcParams ['font.stretch' ]
889
+ if stretch in stretch_dict :
890
+ self ._stretch = stretch
891
+ return
885
892
try :
886
893
stretch = int (stretch )
887
- if stretch < 0 or stretch > 1000 :
888
- raise ValueError ()
889
894
except ValueError as err :
890
- if stretch not in stretch_dict :
891
- raise ValueError ("stretch is invalid" ) from err
892
- self ._stretch = stretch
895
+ pass
896
+ else :
897
+ if 0 <= stretch <= 1000 :
898
+ self ._stretch = stretch
899
+ return
900
+ raise ValueError (f"{ stretch = } is invalid" )
893
901
894
902
def set_size (self , size ):
895
903
"""
You can’t perform that action at this time.
0 commit comments