Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ed733c

Browse files
committed
added @timhoffm's suggestion about changing wrap to lambda and implicit concat on message
1 parent 14f0106 commit 0ed733c

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ def test_arguments(self, func, args, expected):
10601060
("{}+{}+{}".format)],
10611061
ids=["function", "format"])
10621062
def test_typerror(self, func):
1063-
with pytest.raises(TypeError, match=r'function: 3'):
1063+
with pytest.raises(TypeError, match=r'3 arguments'):
10641064
mticker.FuncFormatter(func)
10651065

10661066
def test_other_builtins(self):

lib/matplotlib/ticker.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,18 +396,17 @@ def __init__(self, func):
396396
else:
397397
#finding argcount for other builtins is a mess
398398
nargs = 2
399-
raise warnings.warn(f"""{func.__name__} is not supported
400-
and may not work as expected""")
401-
if nargs == 2:
399+
raise warnings.warn(f"{func.__name__} is not supported "
400+
"and may not work as expected")
401+
402+
if nargs == 1:
403+
self.func = lambda x, pos: func(x)
404+
elif nargs == 2:
402405
self.func = func
403-
elif nargs == 1:
404-
def func_pos(x, pos):
405-
return func(x)
406-
self.func = func_pos
407406
else:
408-
raise TypeError(f"""Number of parameters in function: {nargs}.
409-
FuncFormatter functions take at most 2:
410-
x (required), pos (optional).""")
407+
raise TypeError(f"{func.__name__} takes {nargs} arguments. "
408+
"FuncFormatter functions take at most 2: "
409+
"x (required), pos (optional).")
411410

412411
def __call__(self, x, pos=None):
413412
"""

0 commit comments

Comments
 (0)