@@ -1585,8 +1585,8 @@ def param(func):
1585
1585
# remove the first "ax" / self arg
1586
1586
arg_names = _arg_names [1 :]
1587
1587
else :
1588
- # in this case we need a supplied list of arguments or we need to replace all variables
1589
- # -> compile time check
1588
+ # in this case we need a supplied list of arguments or we need to
1589
+ # replace all variables -> compile time check
1590
1590
if replace_names is None :
1591
1591
# all argnames should be replaced
1592
1592
arg_names = None
@@ -1599,8 +1599,9 @@ def param(func):
1599
1599
# all to be replaced arguments are in the list
1600
1600
arg_names = _arg_names [1 :]
1601
1601
else :
1602
- msg = "Got unknown 'replace_names' and wrapped function '%s' uses '*args', " \
1603
- "need 'positional_parameter_names'!"
1602
+ msg = ("Got unknown 'replace_names' and wrapped function "
1603
+ "'%s' uses '*args', need "
1604
+ "'positional_parameter_names'!" )
1604
1605
raise AssertionError (msg % func .__name__ )
1605
1606
else :
1606
1607
if positional_parameter_names is not None :
@@ -1609,11 +1610,14 @@ def param(func):
1609
1610
if replace_all_args :
1610
1611
arg_names = []
1611
1612
else :
1612
- msg = "Got 'replace_names' and wrapped function '%s' uses *args, " \
1613
- "need 'positional_parameter_names' or 'replace_all_args'!"
1613
+ msg = ("Got 'replace_names' and wrapped function "
1614
+ "'%s' uses *args, need "
1615
+ "'positional_parameter_names' or "
1616
+ "'replace_all_args'!" )
1614
1617
raise AssertionError (msg % func .__name__ )
1615
1618
1616
- # compute the possible label_namer and label position in positional arguments
1619
+ # compute the possible label_namer and label position in positional
1620
+ # arguments
1617
1621
label_pos = 9999 # bigger than all "possible" argument lists
1618
1622
label_namer_pos = 9999 # bigger than all "possible" argument lists
1619
1623
if label_namer and arg_names and (label_namer in arg_names ):
@@ -1627,12 +1631,12 @@ def param(func):
1627
1631
# which might surprise the user :-(
1628
1632
if label_namer and not _has_varkwargs :
1629
1633
if not arg_names :
1630
- msg = "label_namer '%s' can't be found as the parameter without " \
1631
- " 'positional_parameter_names'."
1634
+ msg = ( "label_namer '%s' can't be found as the parameter "
1635
+ "without 'positional_parameter_names'.")
1632
1636
raise AssertionError (msg % label_namer )
1633
1637
elif label_namer not in arg_names :
1634
- msg = "label_namer '%s' can't be found in the parameter names " \
1635
- " (known argnames: %s)."
1638
+ msg = ( "label_namer '%s' can't be found in the parameter "
1639
+ "names (known argnames: %s).")
1636
1640
raise AssertionError (msg % (label_namer , arg_names ))
1637
1641
else :
1638
1642
# this is the case when the name is in arg_names
@@ -1643,7 +1647,8 @@ def inner(ax, *args, **kwargs):
1643
1647
data = kwargs .pop ('data' , None )
1644
1648
label = None
1645
1649
if data is not None :
1646
- # save the current label_namer value so that it can be used as a label
1650
+ # save the current label_namer value so that it can be used as
1651
+ # a label
1647
1652
if label_namer_pos < len (args ):
1648
1653
label = args [label_namer_pos ]
1649
1654
else :
@@ -1654,23 +1659,30 @@ def inner(ax, *args, **kwargs):
1654
1659
1655
1660
if (replace_names is None ) or replace_all_args :
1656
1661
# all should be replaced
1657
- args = tuple (_replacer (data , a ) for j , a in enumerate (args ))
1662
+ args = tuple (_replacer (data , a ) for
1663
+ j , a in enumerate (args ))
1658
1664
else :
1659
- # An arg is replaced if the arg_name of that position is in replace_names ...
1665
+ # An arg is replaced if the arg_name of that position is in
1666
+ # replace_names ...
1660
1667
if len (arg_names ) < len (args ):
1661
- raise RuntimeError ("Got more args than function expects" )
1662
- args = tuple (_replacer (data , a ) if arg_names [j ] in replace_names else a
1668
+ raise RuntimeError (
1669
+ "Got more args than function expects" )
1670
+ args = tuple (_replacer (data , a )
1671
+ if arg_names [j ] in replace_names else a
1663
1672
for j , a in enumerate (args ))
1664
1673
1665
1674
if replace_names is None :
1666
- kwargs = dict ((k , _replacer (data , v )) for k , v in six .iteritems (kwargs ))
1675
+ kwargs = dict ((k , _replacer (data , v ))
1676
+ for k , v in six .iteritems (kwargs ))
1667
1677
else :
1668
1678
# ... or a kwarg of that name in replace_names
1669
- kwargs = dict ((k , _replacer (data , v ) if k in replace_names else v )
1670
- for k , v in six .iteritems (kwargs ))
1679
+ kwargs = dict ((k , _replacer (data , v )
1680
+ if k in replace_names else v )
1681
+ for k , v in six .iteritems (kwargs ))
1671
1682
1672
- # replace the label if this func "wants" a label arg and the user didn't set one
1673
- # Note: if the usere puts in "label=None", it does *NOT* get replaced!
1683
+ # replace the label if this func "wants" a label arg and the user
1684
+ # didn't set one Note: if the usere puts in "label=None", it does
1685
+ # *NOT* get replaced!
1674
1686
user_supplied_label = (
1675
1687
(len (args ) >= label_pos ) or # label is included in args
1676
1688
('label' in kwargs ) # ... or in kwargs
@@ -1688,10 +1700,10 @@ def inner(ax, *args, **kwargs):
1688
1700
kwargs ['label' ] = label
1689
1701
else :
1690
1702
import warnings
1691
- msg = "Tried to set a label via parameter '%s' in " \
1692
- "func '%s' but couldn't find such an argument. \n " \
1693
- "(This is a programming error, please report to the " \
1694
- " matplotlib list!)"
1703
+ msg = ( "Tried to set a label via parameter '%s' in "
1704
+ "func '%s' but couldn't find such an argument. \n "
1705
+ "(This is a programming error, please report to "
1706
+ "the matplotlib list!)")
1695
1707
warnings .warn (msg % (label_namer , func .__name__ ),
1696
1708
RuntimeWarning , stacklevel = 2 )
1697
1709
# raise Exception()
0 commit comments