diff options
| author | hippo91 <guillaume.peillex@gmail.com> | 2019-12-08 20:43:38 +0100 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-12-09 08:42:00 +0100 |
| commit | 441979fe07662714e2f0b7166d97f12353865c86 (patch) | |
| tree | 20e4b4e638402faa14b0f447f5ce3abe5ccb8a96 /tests | |
| parent | f233e599f603ffb26eb8f39d547142bcd58b29df (diff) | |
| download | astroid-git-441979fe07662714e2f0b7166d97f12353865c86.tar.gz | |
Adds unittest for ufunc objects returning pair of ndarray
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unittest_brain_numpy_core_umath.py | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/tests/unittest_brain_numpy_core_umath.py b/tests/unittest_brain_numpy_core_umath.py index b81baa04..40e478b5 100644 --- a/tests/unittest_brain_numpy_core_umath.py +++ b/tests/unittest_brain_numpy_core_umath.py @@ -37,14 +37,14 @@ class NumpyBrainCoreUmathTest(unittest.TestCase): #"exp2", "expm1", "fabs", - #"frexp", + "frexp", #"isfinite", #"isinf", "log", "log1p", "log2", "logical_not", - # "modf", + "modf", "negative", "rad2deg", "reciprocal", @@ -212,6 +212,37 @@ class NumpyBrainCoreUmathTest(unittest.TestCase): ), ) + def test_numpy_core_umath_functions_return_type_tuple(self): + """ + Test that functions which should return a pair of ndarray do return it + """ + ndarray_returning_func = ("frexp", "modf") + + for func_ in ndarray_returning_func: + with self.subTest(typ=func_): + inferred_values = list(self._inferred_numpy_func_call(func_)) + self.assertTrue( + len(inferred_values) == 1, + msg="Too much inferred values ({}) for {:s}".format(inferred_values, func_), + ) + self.assertTrue( + inferred_values[-1].pytype() == "builtins.tuple", + msg="Illicit type for {:s} ({})".format( + func_, inferred_values[-1].pytype() + ), + ) + self.assertTrue( + len(inferred_values[0].elts) == 2, + msg="{} should return a pair of values. That's not the case.".format(func_) + ) + for array in inferred_values[-1].elts: + effective_infer = [m.pytype() for m in array.inferred()] + self.assertTrue( + ".ndarray" in effective_infer, + msg = ('Each item in the return of {} ' + 'should be inferred as a ndarray and not as {}'.format(func_, effective_infer)) + ) + if __name__ == "__main__": unittest.main() |
