summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorhippo91 <guillaume.peillex@gmail.com>2019-12-09 07:46:29 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2019-12-09 08:42:00 +0100
commit18c99c4e5538ee07d932cf6b25b5ede140f73535 (patch)
tree1fc68c91a47c5591cdc76b67b963ebab6b5f09a2 /tests
parent2c51b6e4d3674efe852c87549014c79efc1d6fc3 (diff)
downloadastroid-git-18c99c4e5538ee07d932cf6b25b5ede140f73535.tar.gz
Reformatting according to black
Diffstat (limited to 'tests')
-rw-r--r--tests/unittest_brain_numpy_core_umath.py54
1 files changed, 39 insertions, 15 deletions
diff --git a/tests/unittest_brain_numpy_core_umath.py b/tests/unittest_brain_numpy_core_umath.py
index 19c8fa8c..51b696f6 100644
--- a/tests/unittest_brain_numpy_core_umath.py
+++ b/tests/unittest_brain_numpy_core_umath.py
@@ -138,11 +138,22 @@ class NumpyBrainCoreUmathTest(unittest.TestCase):
"""
Test the arguments names of functions.
"""
- exact_arg_names = ["self", "x", "out", "where", "casting", "order", "dtype", "subok"]
+ exact_arg_names = [
+ "self",
+ "x",
+ "out",
+ "where",
+ "casting",
+ "order",
+ "dtype",
+ "subok",
+ ]
for func in self.one_arg_ufunc:
with self.subTest(func=func):
inferred = self._inferred_numpy_attribute(func)
- self.assertEqual(inferred.getattr('__call__')[0].argnames(), exact_arg_names)
+ self.assertEqual(
+ inferred.getattr("__call__")[0].argnames(), exact_arg_names
+ )
def test_numpy_core_umath_functions_two_args(self):
"""
@@ -162,7 +173,9 @@ class NumpyBrainCoreUmathTest(unittest.TestCase):
for func in self.two_args_ufunc:
with self.subTest(func=func):
inferred = self._inferred_numpy_attribute(func)
- self.assertEqual(inferred.getattr('__call__')[0].argnames(), exact_arg_names)
+ self.assertEqual(
+ inferred.getattr("__call__")[0].argnames(), exact_arg_names
+ )
def test_numpy_core_umath_functions_kwargs_default_values(self):
"""
@@ -173,7 +186,8 @@ class NumpyBrainCoreUmathTest(unittest.TestCase):
with self.subTest(func=func):
inferred = self._inferred_numpy_attribute(func)
default_args_values = [
- default.value for default in inferred.getattr('__call__')[0].args.defaults
+ default.value
+ for default in inferred.getattr("__call__")[0].args.defaults
]
self.assertEqual(default_args_values, exact_kwargs_default_values)
@@ -194,19 +208,21 @@ class NumpyBrainCoreUmathTest(unittest.TestCase):
Test that functions which should return a ndarray do return it
"""
ndarray_returning_func = [
- f
- for f in self.all_ufunc
- if f not in ("frexp", "modf")
+ f for f in self.all_ufunc if f not in ("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 or len(inferred_values) == 2 and inferred_values[-1].pytype() is util.Uninferable,
- msg="Too much inferred values ({}) for {:s}".format(inferred_values[-1].pytype(), func_),
+ len(inferred_values) == 1
+ or len(inferred_values) == 2
+ and inferred_values[-1].pytype() is util.Uninferable,
+ msg="Too much inferred values ({}) for {:s}".format(
+ inferred_values[-1].pytype(), func_
+ ),
)
self.assertTrue(
- inferred_values[0].pytype() == '.ndarray',
+ inferred_values[0].pytype() == ".ndarray",
msg="Illicit type for {:s} ({})".format(
func_, inferred_values[-1].pytype()
),
@@ -217,13 +233,15 @@ class NumpyBrainCoreUmathTest(unittest.TestCase):
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_),
+ msg="Too much inferred values ({}) for {:s}".format(
+ inferred_values, func_
+ ),
)
self.assertTrue(
inferred_values[-1].pytype() == "builtins.tuple",
@@ -233,14 +251,20 @@ class NumpyBrainCoreUmathTest(unittest.TestCase):
)
self.assertTrue(
len(inferred_values[0].elts) == 2,
- msg="{} should return a pair of values. That's not the case.".format(func_)
+ 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))
+ msg=(
+ "Each item in the return of {} "
+ "should be inferred as a ndarray and not as {}".format(
+ func_, effective_infer
+ )
+ ),
)