mirror of
https://github.com/wassname/catalyst.git
synced 2026-09-12 12:12:04 +08:00
ENH: Improve error message on bad return.
This commit is contained in:
@@ -153,7 +153,7 @@ class LabelArrayTestCase(ZiplineTestCase):
|
|||||||
lambda s: object(),
|
lambda s: object(),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_map_requires_f_to_return_a_string(self, f):
|
def test_map_requires_f_to_return_a_string_or_none(self, f):
|
||||||
la = LabelArray(self.strs, missing_value=None)
|
la = LabelArray(self.strs, missing_value=None)
|
||||||
|
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
|
|||||||
@@ -591,8 +591,12 @@ class LabelArray(ndarray):
|
|||||||
|
|
||||||
if not isinstance(ret, otypes):
|
if not isinstance(ret, otypes):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
"Expected f() to return a string. Got %s." % (
|
"LabelArray.map expected function {f} to return a string"
|
||||||
type(ret).__name__
|
" or None, but got {type} instead.\n"
|
||||||
|
"Value was {value}.".format(
|
||||||
|
f=f.__name__,
|
||||||
|
type=type(ret).__name__,
|
||||||
|
value=ret,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user