[Piglit] [PATCH v2 19/29] builtin_functions.py: Finish PEP8 comliance

Dylan Baker baker.dylan.c at gmail.com
Tue Jul 23 09:39:10 PDT 2013


This patch finishes bringing builtin_functions into compliance with
python's PEP8 standard with a a few exceptions, as marked below with
line number and explanation:

141-153: Leave a table in tabluar spacing per Chad
1077-1110: lists with either positive or negative numbers, use a blank
	   space on for positive numbers so that they line up nicely
	   with the negative numbers

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 generated_tests/builtin_function.py | 274 +++++++++++++++++++++++-------------
 1 file changed, 175 insertions(+), 99 deletions(-)

diff --git a/generated_tests/builtin_function.py b/generated_tests/builtin_function.py
index 7963a63..9512bce 100644
--- a/generated_tests/builtin_function.py
+++ b/generated_tests/builtin_function.py
@@ -448,7 +448,7 @@ def _clamp(x, minVal, maxVal):
 def _smoothstep(edge0, edge1, x):
     if edge0 >= edge1:
         return None
-    t = _clamp((x-edge0)/(edge1-edge0),0.0,1.0)
+    t = _clamp((x-edge0)/(edge1-edge0), 0.0, 1.0)
     return t*t*(3.0-2.0*t)
 
 
@@ -464,15 +464,15 @@ def _faceforward(N, I, Nref):
 
 
 def _reflect(I, N):
-    return I-2*np.dot(N,I)*N
+    return I-2*np.dot(N, I)*N
 
 
 def _refract(I, N, eta):
-    k = 1.0-eta*eta*(1.0-np.dot(N,I)*np.dot(N,I))
+    k = 1.0-eta*eta*(1.0-np.dot(N, I)*np.dot(N, I))
     if k < 0.0:
         return I*0.0
     else:
-        return eta*I-(eta*np.dot(N,I)+np.sqrt(k))*N
+        return eta*I-(eta*np.dot(N, I)+np.sqrt(k))*N
 
 
 def _change_signedness(x):
@@ -675,7 +675,7 @@ def _vectorize_test_vectors(test_vectors, scalar_arg_indices, vector_length):
 
 
 def _store_test_vector(test_suite_dict, name, glsl_version, test_vector,
-                       template = None):
+                       template=None):
     """Store a test vector in the appropriate place in
     test_suite_dict.  The dictionary key (which is a Signature tuple)
     is generated by consulting the argument and return types of the
@@ -704,7 +704,7 @@ def _store_test_vector(test_suite_dict, name, glsl_version, test_vector,
 
 
 def _store_test_vectors(test_suite_dict, name, glsl_version, test_vectors,
-                        template = None):
+                        template=None):
     """Store multiple test vectors in the appropriate places in
     test_suite_dict.
 
@@ -713,7 +713,7 @@ def _store_test_vectors(test_suite_dict, name, glsl_version, test_vectors,
     """
     for test_vector in test_vectors:
         _store_test_vector(test_suite_dict, name, glsl_version, test_vector,
-                           template = template)
+                           template=template)
 
 
 def make_arguments(input_generators):
@@ -756,7 +756,7 @@ def _make_componentwise_test_vectors(test_suite_dict):
 
     def f(name, arity, glsl_version, python_equivalent,
           alternate_scalar_arg_indices, test_inputs,
-          tolerance_function = _strict_tolerance):
+          tolerance_function=_strict_tolerance):
         """Create test vectors for the function with the given name
         and arity, which was introduced in the given glsl_version.
 
@@ -793,28 +793,41 @@ def _make_componentwise_test_vectors(test_suite_dict):
                     _vectorize_test_vectors(
                         scalar_test_vectors, scalar_arg_indices,
                         vector_length))
+
     f('radians', 1, 110, np.radians, None, [np.linspace(-180.0, 180.0, 4)])
     f('degrees', 1, 110, np.degrees, None, [np.linspace(-np.pi, np.pi, 4)])
-    f('sin', 1, 110, np.sin, None, [np.linspace(-np.pi, np.pi, 4)], _trig_tolerance)
-    f('cos', 1, 110, np.cos, None, [np.linspace(-np.pi, np.pi, 4)], _trig_tolerance)
-    f('tan', 1, 110, np.tan, None, [np.linspace(-np.pi, np.pi, 4)], _trig_tolerance)
-    f('asin', 1, 110, np.arcsin, None, [np.linspace(-1.0, 1.0, 4)], _trig_tolerance)
-    f('acos', 1, 110, np.arccos, None, [np.linspace(-1.0, 1.0, 4)], _trig_tolerance)
+    f('sin', 1, 110, np.sin, None, [np.linspace(-np.pi, np.pi, 4)],
+      _trig_tolerance)
+    f('cos', 1, 110, np.cos, None, [np.linspace(-np.pi, np.pi, 4)],
+      _trig_tolerance)
+    f('tan', 1, 110, np.tan, None, [np.linspace(-np.pi, np.pi, 4)],
+      _trig_tolerance)
+    f('asin', 1, 110, np.arcsin, None, [np.linspace(-1.0, 1.0, 4)],
+      _trig_tolerance)
+    f('acos', 1, 110, np.arccos, None, [np.linspace(-1.0, 1.0, 4)],
+      _trig_tolerance)
     f('atan', 1, 110, np.arctan, None, [atan_inputs], _trig_tolerance)
-    f('atan', 2, 110, _arctan2, None, [atan_inputs, atan_inputs], _trig_tolerance)
-    f('sinh', 1, 130, np.sinh, None, [np.linspace(-2.0, 2.0, 4)], _trig_tolerance)
-    f('cosh', 1, 130, np.cosh, None, [np.linspace(-2.0, 2.0, 4)], _trig_tolerance)
-    f('tanh', 1, 130, np.tanh, None, [np.linspace(-2.0, 2.0, 4)], _trig_tolerance)
+    f('atan', 2, 110, _arctan2, None, [atan_inputs, atan_inputs],
+      _trig_tolerance)
+    f('sinh', 1, 130, np.sinh, None, [np.linspace(-2.0, 2.0, 4)],
+      _trig_tolerance)
+    f('cosh', 1, 130, np.cosh, None, [np.linspace(-2.0, 2.0, 4)],
+      _trig_tolerance)
+    f('tanh', 1, 130, np.tanh, None, [np.linspace(-2.0, 2.0, 4)],
+      _trig_tolerance)
     f('asinh', 1, 130, np.arcsinh, None, [atan_inputs], _trig_tolerance)
     f('acosh', 1, 130, np.arccosh, None, [acosh_inputs], _trig_tolerance)
-    f('atanh', 1, 130, np.arctanh, None, [np.linspace(-0.99, 0.99, 4)], _trig_tolerance)
-    f('pow', 2, 110, _pow, None, [np.linspace(0.0, 2.0, 4), np.linspace(-2.0, 2.0, 4)])
+    f('atanh', 1, 130, np.arctanh, None, [np.linspace(-0.99, 0.99, 4)],
+      _trig_tolerance)
+    f('pow', 2, 110, _pow, None, [np.linspace(0.0, 2.0, 4),
+      np.linspace(-2.0, 2.0, 4)])
     f('exp', 1, 110, np.exp, None, [np.linspace(-2.0, 2.0, 4)])
     f('log', 1, 110, np.log, None, [np.linspace(0.01, 2.0, 4)])
     f('exp2', 1, 110, _exp2, None, [np.linspace(-2.0, 2.0, 4)])
     f('log2', 1, 110, np.log2, None, [np.linspace(0.01, 2.0, 4)])
     f('sqrt', 1, 110, np.sqrt, None, [np.linspace(0.0, 2.0, 4)])
-    f('inversesqrt', 1, 110, lambda x: 1.0/np.sqrt(x), None, [np.linspace(0.1, 2.0, 4)])
+    f('inversesqrt', 1, 110, lambda x: 1.0/np.sqrt(x), None,
+      [np.linspace(0.1, 2.0, 4)])
     f('abs', 1, 110, np.abs, None, [np.linspace(-1.5, 1.5, 5)])
     f('abs', 1, 130, np.abs, None, [ints])
     f('sign', 1, 110, np.sign, None, [np.linspace(-1.5, 1.5, 5)])
@@ -834,21 +847,32 @@ def _make_componentwise_test_vectors(test_suite_dict):
     f('roundEven', 1, 130, np.round, None, [np.linspace(-2.0, 2.0, 25)])
 
     f('ceil', 1, 110, np.ceil, None, [np.linspace(-2.0, 2.0, 4)])
-    f('fract', 1, 110, lambda x: x-np.floor(x), None, [np.linspace(-2.0, 2.0, 4)])
-    f('mod', 2, 110, lambda x, y: x-y*np.floor(x/y), [1], [np.linspace(-1.9, 1.9, 4), np.linspace(-2.0, 2.0, 4)])
-    f('min', 2, 110, min, [1], [np.linspace(-2.0, 2.0, 4), np.linspace(-2.0, 2.0, 4)])
+    f('fract', 1, 110, lambda x: x-np.floor(x), None,
+      [np.linspace(-2.0, 2.0, 4)])
+    f('mod', 2, 110, lambda x, y: x-y*np.floor(x/y), [1],
+      [np.linspace(-1.9, 1.9, 4), np.linspace(-2.0, 2.0, 4)])
+    f('min', 2, 110, min, [1],
+      [np.linspace(-2.0, 2.0, 4), np.linspace(-2.0, 2.0, 4)])
     f('min', 2, 130, min, [1], [ints, ints])
     f('min', 2, 130, min, [1], [uints, uints])
-    f('max', 2, 110, max, [1], [np.linspace(-2.0, 2.0, 4), np.linspace(-2.0, 2.0, 4)])
+    f('max', 2, 110, max, [1],
+      [np.linspace(-2.0, 2.0, 4), np.linspace(-2.0, 2.0, 4)])
     f('max', 2, 130, max, [1], [ints, ints])
     f('max', 2, 130, max, [1], [uints, uints])
-    f('clamp', 3, 110, _clamp, [1, 2], [np.linspace(-2.0, 2.0, 4), np.linspace(-1.5, 1.5, 3), np.linspace(-1.5, 1.5, 3)])
+    f('clamp', 3, 110, _clamp, [1, 2], [np.linspace(-2.0, 2.0, 4),
+      np.linspace(-1.5, 1.5, 3), np.linspace(-1.5, 1.5, 3)])
     f('clamp', 3, 130, _clamp, [1, 2], [ints, ints, ints])
     f('clamp', 3, 130, _clamp, [1, 2], [uints, uints, uints])
-    f('mix', 3, 110, lambda x, y, a: x*(1-a)+y*a, [2], [np.linspace(-2.0, 2.0, 2), np.linspace(-3.0, 3.0, 2), np.linspace(0.0, 1.0, 4)])
-    f('mix', 3, 130, lambda x, y, a: y if a else x, None, [np.linspace(-2.0, 2.0, 2), np.linspace(-3.0, 3.0, 2), bools])
-    f('step', 2, 110, lambda edge, x: 0.0 if x < edge else 1.0, [0], [np.linspace(-2.0, 2.0, 4), np.linspace(-2.0, 2.0, 4)])
-    f('smoothstep', 3, 110, _smoothstep, [0, 1], [np.linspace(-1.9, 1.9, 4), np.linspace(-1.9, 1.9, 4), np.linspace(-2.0, 2.0, 4)])
+    f('mix', 3, 110, lambda x, y, a: x*(1-a)+y*a, [2],
+      [np.linspace(-2.0, 2.0, 2), np.linspace(-3.0, 3.0, 2),
+       np.linspace(0.0, 1.0, 4)])
+    f('mix', 3, 130, lambda x, y, a: y if a else x, None,
+      [np.linspace(-2.0, 2.0, 2), np.linspace(-3.0, 3.0, 2), bools])
+    f('step', 2, 110, lambda edge, x: 0.0 if x < edge else 1.0, [0],
+      [np.linspace(-2.0, 2.0, 4), np.linspace(-2.0, 2.0, 4)])
+    f('smoothstep', 3, 110, _smoothstep, [0, 1],
+      [np.linspace(-1.9, 1.9, 4), np.linspace(-1.9, 1.9, 4),
+       np.linspace(-2.0, 2.0, 4)])
 _make_componentwise_test_vectors(test_suite)
 
 
@@ -866,7 +890,7 @@ def _make_vector_relational_test_vectors(test_suite_dict):
     }
 
     def f(name, arity, glsl_version, python_equivalent, arg_types,
-          tolerance_function = _strict_tolerance):
+          tolerance_function=_strict_tolerance):
         """Make test vectors for the function with the given name and
         arity, which was introduced in the given glsl_version.
 
@@ -892,6 +916,7 @@ def _make_vector_relational_test_vectors(test_suite_dict):
                     test_suite_dict, name, glsl_version,
                     _vectorize_test_vectors(
                         scalar_test_vectors, (), vector_length))
+
     f('lessThan', 2, 110, lambda x, y: x < y, 'viu')
     f('lessThanEqual', 2, 110, lambda x, y: x <= y, 'viu')
     f('greaterThan', 2, 110, lambda x, y: x > y, 'viu')
@@ -993,7 +1018,8 @@ def _make_vector_or_matrix_test_vectors(test_suite_dict):
         [np.array(bs) for bs in itertools.product(bools, bools, bools)] + \
         [np.array(bs) for bs in itertools.product(bools, bools, bools, bools)]
     ints = [np.int32(x) for x in [12, -6, 74, -32, 0]]
-    small_ints = [np.int32(x) for x in [-31, -25, -5, -2, -1, 0, 1, 2, 5, 25, 31]]
+    small_ints = \
+        [np.int32(x) for x in [-31, -25, -5, -2, -1, 0, 1, 2, 5, 25, 31]]
     ivecs = [
         np.array([38, 35], dtype=np.int32),
         np.array([64, -9], dtype=np.int32),
@@ -1005,7 +1031,7 @@ def _make_vector_or_matrix_test_vectors(test_suite_dict):
         np.array([66, 72, 87, 75], dtype=np.int32),
         np.array([-24, 40, -23, 74], dtype=np.int32),
         np.array([24, 40, 23, 74], dtype=np.int32),
-        ]
+    ]
     small_ivecs = [
         np.array([13, 26], dtype=np.int32),
         np.array([-2, 26], dtype=np.int32),
@@ -1018,7 +1044,7 @@ def _make_vector_or_matrix_test_vectors(test_suite_dict):
         np.array([16, 24, 23, 25], dtype=np.int32),
         np.array([-23, -12, 14, 19], dtype=np.int32),
         np.array([23, 12, 14, 19], dtype=np.int32),
-        ]
+    ]
     uints = [np.uint32(x) for x in [0, 6, 12, 32, 74]]
     small_uints = [np.uint32(x) for x in [0, 1, 2, 5, 25, 31]]
     large_uints = [np.uint32(x) for x in [0xdeadbeef, 0xaffeaffe, 0xbadbad]]
@@ -1029,7 +1055,7 @@ def _make_vector_or_matrix_test_vectors(test_suite_dict):
         np.array([59, 77, 68], dtype=np.uint32),
         np.array([66, 72, 87, 75], dtype=np.uint32),
         np.array([24, 40, 23, 74], dtype=np.uint32)
-        ]
+    ]
     small_uvecs = [
         np.array([13, 26], dtype=np.uint32),
         np.array([2, 26], dtype=np.uint32),
@@ -1037,76 +1063,76 @@ def _make_vector_or_matrix_test_vectors(test_suite_dict):
         np.array([19, 1, 13], dtype=np.uint32),
         np.array([16, 24, 23, 25], dtype=np.uint32),
         np.array([23, 12, 14, 19], dtype=np.uint32),
-        ]
+    ]
     nz_floats = [-1.33, 0.85]
     floats = [0.0] + nz_floats
     vecs = [
-         np.array([-0.10, -1.20]),
-         np.array([-0.42, 0.48]),
-         np.array([-0.03, -0.85, -0.94]),
-         np.array([1.67, 0.66, 1.87]),
-         np.array([-1.65, 1.33, 1.93, 0.76]),
-         np.array([0.80, -0.15, -0.51, 0.0])
-         ]
+        np.array([-0.10, -1.20]),
+        np.array([-0.42, 0.48]),
+        np.array([-0.03, -0.85, -0.94]),
+        np.array([1.67, 0.66, 1.87]),
+        np.array([-1.65, 1.33, 1.93, 0.76]),
+        np.array([0.80, -0.15, -0.51, 0.0])
+    ]
     nz_floats_vecs = nz_floats + vecs
     vec3s = [
         np.array([-0.03, -0.85, -0.94]),
         np.array([1.67, 0.66, 1.87]),
-        ]
+    ]
     norm_floats_vecs = [_normalize(x) for x in nz_floats_vecs]
     squaremats = [
         np.array([[ 1.60,  0.76],
-                  [ 1.53, -1.00]]), # mat2
+                  [ 1.53, -1.00]]),  # mat2
         np.array([[-0.13, -0.87],
-                  [-1.40,  1.40]]), # mat2
+                  [-1.40,  1.40]]),  # mat2
         np.array([[-1.11,  1.67, -0.41],
                   [ 0.13,  1.09, -0.02],
-                  [ 0.56,  0.95,  0.24]]), # mat3
+                  [ 0.56,  0.95,  0.24]]),  # mat3
         np.array([[-1.69, -0.46, -0.18],
                   [-1.09,  1.75,  2.00],
-                  [-1.53, -0.70, -1.47]]), # mat3
+                  [-1.53, -0.70, -1.47]]),  # mat3
         np.array([[-1.00, -0.55, -1.08,  1.79],
                   [ 1.77,  0.62,  0.48, -1.35],
                   [ 0.09, -0.71, -1.39, -1.21],
-                  [-0.91, -1.82, -1.43,  0.72]]), # mat4
+                  [-0.91, -1.82, -1.43,  0.72]]),  # mat4
         np.array([[ 0.06,  1.31,  1.52, -1.96],
                   [ 1.60, -0.32,  0.51, -1.84],
                   [ 1.25,  0.45,  1.90, -0.72],
-                  [-0.16,  0.45, -0.88,  0.39]]), # mat4
-        ]
+                  [-0.16,  0.45, -0.88,  0.39]]),  # mat4
+    ]
     mats = squaremats + [
         np.array([[ 0.09,  1.30,  1.25],
-                  [-1.19,  0.08,  1.08]]), # mat3x2
+                  [-1.19,  0.08,  1.08]]),  # mat3x2
         np.array([[-0.36, -1.08, -0.60],
-                  [-0.53,  0.88, -1.79]]), # mat3x2
+                  [-0.53,  0.88, -1.79]]),  # mat3x2
         np.array([[-0.46,  1.94],
                   [-0.45, -0.75],
-                  [ 1.03, -0.50]]), # mat2x3
+                  [ 1.03, -0.50]]),  # mat2x3
         np.array([[ 1.38, -1.08],
                   [-1.27,  1.83],
-                  [ 1.00, -0.74]]), # mat2x3
+                  [ 1.00, -0.74]]),  # mat2x3
         np.array([[ 1.81, -0.87,  0.81,  0.65],
-                  [-1.16, -1.52,  0.25, -1.51]]), # mat4x2
+                  [-1.16, -1.52,  0.25, -1.51]]),  # mat4x2
         np.array([[ 1.93, -1.63,  0.29,  1.60],
-                  [ 0.49,  0.27,  0.14,  0.94]]), # mat4x2
+                  [ 0.49,  0.27,  0.14,  0.94]]),  # mat4x2
         np.array([[ 0.16, -1.69],
                   [-0.80,  0.59],
                   [-1.74, -1.43],
-                  [-0.02, -1.21]]), # mat2x4
+                  [-0.02, -1.21]]),  # mat2x4
         np.array([[-1.02,  0.74],
                   [-1.64, -0.13],
                   [-1.59,  0.47],
-                  [ 0.30,  1.13]]), # mat2x4
+                  [ 0.30,  1.13]]),  # mat2x4
         np.array([[-0.27, -1.38, -1.41, -0.12],
                   [-0.17, -0.56,  1.47,  1.86],
-                  [-1.85, -1.29,  1.77,  0.01]]), # mat4x3
+                  [-1.85, -1.29,  1.77,  0.01]]),  # mat4x3
         np.array([[-0.47, -0.15,  1.97, -1.05],
                   [-0.20,  0.53, -1.82, -1.41],
-                  [-1.39, -0.19,  1.62,  1.58]]), # mat4x3
+                  [-1.39, -0.19,  1.62,  1.58]]),  # mat4x3
         np.array([[ 1.42, -0.86,  0.27],
                   [ 1.80, -1.74,  0.04],
                   [-1.88, -0.37,  0.43],
-                  [ 1.37,  1.90,  0.71]]), # mat3x4
+                  [ 1.37,  1.90,  0.71]]),  # mat3x4
         np.array([[-1.72,  0.09,  0.45],
                   [-0.31, -1.58,  1.92],
                   [ 0.14,  0.18, -0.56],
@@ -1114,8 +1140,8 @@ def _make_vector_or_matrix_test_vectors(test_suite_dict):
     ]
 
     def f(name, arity, glsl_version, python_equivalent,
-          filter, test_inputs, tolerance_function = _strict_tolerance,
-          template = None):
+          filter, test_inputs, tolerance_function=_strict_tolerance,
+          template=None):
         """Make test vectors for the function with the given name and
         arity, which was introduced in the given glsl_version.
 
@@ -1141,54 +1167,104 @@ def _make_vector_or_matrix_test_vectors(test_suite_dict):
         """
         test_inputs = make_arguments(test_inputs)
         if filter is not None:
-            test_inputs = [
-                arguments
-                for arguments in test_inputs
-                if filter(*arguments)]
+            test_inputs = \
+                [arguments for arguments in test_inputs if filter(*arguments)]
         _store_test_vectors(
             test_suite_dict, name, glsl_version,
             _simulate_function(
                 test_inputs, python_equivalent, tolerance_function),
-            template = template)
-    f('op-add', 2, 110, lambda x, y: x + y, match_simple_binop, [floats+vecs+mats+ints+ivecs+uints+uvecs, floats+vecs+mats+ints+ivecs+uints+uvecs], template = '({0} + {1})')
-    f('op-sub', 2, 110, lambda x, y: x - y, match_simple_binop, [floats+vecs+mats+ints+ivecs+uints+uvecs, floats+vecs+mats+ints+ivecs+uints+uvecs], template = '({0} - {1})')
-    f('op-mult', 2, 110, _multiply, match_multiply, [floats+vecs+mats+ints+ivecs+uints+uvecs, floats+vecs+mats+ints+ivecs+uints+uvecs], template = '({0} * {1})')
-    f('op-div', 2, 110, _divide, match_simple_binop, [floats+vecs+mats+ints+ivecs+uints+uvecs, floats+vecs+mats+ints+ivecs+uints+uvecs], template = '({0} / {1})')
-    f('op-div-large', 2, 130, _divide, match_simple_binop, [large_uints, large_uints+small_uints], template = '({0} / {1})')
-    f('op-mod', 2, 130, _modulus, match_simple_binop, [ints+ivecs+uints+uvecs, ints+ivecs+uints+uvecs], template = '({0} % {1})')
-    f('op-uplus', 1, 110, lambda x: +x, None, [floats+vecs+mats+ints+ivecs+uints+uvecs], template = '(+ {0})')
-    f('op-neg', 1, 110, lambda x: -x, None, [floats+vecs+mats+ints+ivecs+uints+uvecs], template = '(- {0})')
-    f('op-gt', 2, 110, lambda x, y: x > y, match_args(0, 1), [ints+uints+floats, ints+uints+floats], template = '({0} > {1})')
-    f('op-lt', 2, 110, lambda x, y: x < y, match_args(0, 1), [ints+uints+floats, ints+uints+floats], template = '({0} < {1})')
-    f('op-ge', 2, 110, lambda x, y: x >= y, match_args(0, 1), [ints+uints+floats, ints+uints+floats], template = '({0} >= {1})')
-    f('op-le', 2, 110, lambda x, y: x <= y, match_args(0, 1), [ints+uints+floats, ints+uints+floats], template = '({0} <= {1})')
-    f('op-eq', 2, 110, _equal, match_args(0, 1), [floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs, floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs], template = '({0} == {1})')
-    f('op-ne', 2, 110, _not_equal, match_args(0, 1), [floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs, floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs], template = '({0} != {1})')
-    f('op-and', 2, 110, lambda x, y: x and y, None, [bools, bools], template = '({0} && {1})')
-    f('op-or', 2, 110, lambda x, y: x or y, None, [bools, bools], template = '({0} || {1})')
-    f('op-xor', 2, 110, lambda x, y: x != y, None, [bools, bools], template = '({0} ^^ {1})')
-    f('op-not', 1, 110, lambda x: not x, None, [bools], template = '(! {0})')
-    f('op-selection', 3, 110, lambda x, y, z: y if x else z, match_args(1, 2), [bools, floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs, floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs], template = '({0} ? {1} : {2})')
-    f('op-complement', 1, 130, lambda x: ~x, None, [ints+ivecs+uints+uvecs], template = '(~ {0})')
-    f('op-lshift', 2, 130, _lshift, match_shift, [small_ints+small_ivecs+small_uints+small_uvecs, small_ints+small_ivecs+small_uints+small_uvecs], template = '({0} << {1})')
-    f('op-rshift', 2, 130, _rshift, match_shift, [small_ints+small_ivecs+small_uints+small_uvecs, small_ints+small_ivecs+small_uints+small_uvecs], template = '({0} >> {1})')
-    f('op-bitand', 2, 130, lambda x, y: x & y, match_simple_binop, [ints+ivecs+uints+uvecs, ints+ivecs+uints+uvecs], template = '({0} & {1})')
-    f('op-bitor', 2, 130, lambda x, y: x | y, match_simple_binop, [ints+ivecs+uints+uvecs, ints+ivecs+uints+uvecs], template = '({0} | {1})')
-    f('op-bitxor', 2, 130, lambda x, y: x ^ y, match_simple_binop, [ints+ivecs+uints+uvecs, ints+ivecs+uints+uvecs], template = '({0} ^ {1})')
+            template=template)
+
+    f('op-add', 2, 110, lambda x, y: x + y, match_simple_binop,
+      [floats+vecs+mats+ints+ivecs+uints+uvecs,
+       floats+vecs+mats+ints+ivecs+uints+uvecs],
+      template='({0} + {1})')
+    f('op-sub', 2, 110, lambda x, y: x - y, match_simple_binop,
+      [floats+vecs+mats+ints+ivecs+uints+uvecs,
+       floats+vecs+mats+ints+ivecs+uints+uvecs],
+      template='({0} - {1})')
+    f('op-mult', 2, 110, _multiply, match_multiply,
+      [floats+vecs+mats+ints+ivecs+uints+uvecs,
+       floats+vecs+mats+ints+ivecs+uints+uvecs],
+      template='({0} * {1})')
+    f('op-div', 2, 110, _divide, match_simple_binop,
+      [floats+vecs+mats+ints+ivecs+uints+uvecs,
+       floats+vecs+mats+ints+ivecs+uints+uvecs],
+      template='({0} / {1})')
+    f('op-div-large', 2, 130, _divide, match_simple_binop,
+      [large_uints, large_uints+small_uints], template='({0} / {1})')
+    f('op-mod', 2, 130, _modulus, match_simple_binop,
+      [ints+ivecs+uints+uvecs, ints+ivecs+uints+uvecs], template='({0} % {1})')
+    f('op-uplus', 1, 110, lambda x: +x, None,
+      [floats+vecs+mats+ints+ivecs+uints+uvecs], template='(+ {0})')
+    f('op-neg', 1, 110, lambda x: -x, None,
+      [floats+vecs+mats+ints+ivecs+uints+uvecs], template='(- {0})')
+    f('op-gt', 2, 110, lambda x, y: x > y, match_args(0, 1),
+      [ints+uints+floats, ints+uints+floats], template='({0} > {1})')
+    f('op-lt', 2, 110, lambda x, y: x < y, match_args(0, 1),
+      [ints+uints+floats, ints+uints+floats], template='({0} < {1})')
+    f('op-ge', 2, 110, lambda x, y: x >= y, match_args(0, 1),
+      [ints+uints+floats, ints+uints+floats], template='({0} >= {1})')
+    f('op-le', 2, 110, lambda x, y: x <= y, match_args(0, 1),
+      [ints+uints+floats, ints+uints+floats], template='({0} <= {1})')
+    f('op-eq', 2, 110, _equal, match_args(0, 1),
+      [floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs,
+       floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs],
+      template='({0} == {1})')
+    f('op-ne', 2, 110, _not_equal, match_args(0, 1),
+      [floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs,
+       floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs],
+      template='({0} != {1})')
+    f('op-and', 2, 110, lambda x, y: x and y, None, [bools, bools],
+      template='({0} && {1})')
+    f('op-or', 2, 110, lambda x, y: x or y, None, [bools, bools],
+      template='({0} || {1})')
+    f('op-xor', 2, 110, lambda x, y: x != y, None, [bools, bools],
+      template='({0} ^^ {1})')
+    f('op-not', 1, 110, lambda x: not x, None, [bools], template='(! {0})')
+    f('op-selection', 3, 110, lambda x, y, z: y if x else z, match_args(1, 2),
+      [bools, floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs,
+       floats+vecs+mats+ints+ivecs+uints+uvecs+bools+bvecs],
+      template='({0} ? {1} : {2})')
+    f('op-complement', 1, 130, lambda x: ~x, None, [ints+ivecs+uints+uvecs],
+      template='(~ {0})')
+    f('op-lshift', 2, 130, _lshift, match_shift,
+      [small_ints+small_ivecs+small_uints+small_uvecs,
+       small_ints+small_ivecs+small_uints+small_uvecs],
+      template='({0} << {1})')
+    f('op-rshift', 2, 130, _rshift, match_shift,
+      [small_ints+small_ivecs+small_uints+small_uvecs,
+       small_ints+small_ivecs+small_uints+small_uvecs],
+      template='({0} >> {1})')
+    f('op-bitand', 2, 130, lambda x, y: x & y, match_simple_binop,
+      [ints+ivecs+uints+uvecs, ints+ivecs+uints+uvecs],
+      template='({0} & {1})')
+    f('op-bitor', 2, 130, lambda x, y: x | y, match_simple_binop,
+      [ints+ivecs+uints+uvecs, ints+ivecs+uints+uvecs],
+      template='({0} | {1})')
+    f('op-bitxor', 2, 130, lambda x, y: x ^ y, match_simple_binop,
+      [ints+ivecs+uints+uvecs, ints+ivecs+uints+uvecs],
+      template='({0} ^ {1})')
     f('length', 1, 110, np.linalg.norm, None, [floats+vecs])
-    f('distance', 2, 110, lambda x, y: np.linalg.norm(x-y), match_args(0, 1), [floats+vecs, floats+vecs])
+    f('distance', 2, 110, lambda x, y: np.linalg.norm(x-y), match_args(0, 1),
+      [floats+vecs, floats+vecs])
     f('dot', 2, 110, np.dot, match_args(0, 1), [floats+vecs, floats+vecs])
-    f('cross', 2, 110, np.cross, match_args(0, 1), [vec3s, vec3s], _cross_product_tolerance)
+    f('cross', 2, 110, np.cross, match_args(0, 1), [vec3s, vec3s],
+      _cross_product_tolerance)
     f('normalize', 1, 110, _normalize, None, [nz_floats_vecs])
-    f('faceforward', 3, 110, _faceforward, match_args(0, 1, 2), [floats+vecs, floats+vecs, floats+vecs])
-    f('reflect', 2, 110, _reflect, match_args(0, 1), [floats+vecs, norm_floats_vecs])
-    f('refract', 3, 110, _refract, match_args(0, 1), [norm_floats_vecs, norm_floats_vecs, [0.5, 2.0]])
+    f('faceforward', 3, 110, _faceforward, match_args(0, 1, 2),
+      [floats+vecs, floats+vecs, floats+vecs])
+    f('reflect', 2, 110, _reflect, match_args(0, 1),
+      [floats+vecs, norm_floats_vecs])
+    f('refract', 3, 110, _refract, match_args(0, 1),
+      [norm_floats_vecs, norm_floats_vecs, [0.5, 2.0]])
 
     # Note: technically matrixCompMult operates componentwise.
     # However, since it is the only componentwise function to operate
     # on matrices, it is easier to generate test cases for it here
     # than to add matrix support to _make_componentwise_test_vectors.
-    f('matrixCompMult', 2, 110, lambda x, y: x*y, match_args(0, 1), [mats, mats])
+    f('matrixCompMult', 2, 110, lambda x, y: x*y, match_args(0, 1),
+      [mats, mats])
 
     f('outerProduct', 2, 120, np.outer, None, [vecs, vecs])
     f('transpose', 1, 120, np.transpose, None, [mats])
-- 
1.8.3.1



More information about the Piglit mailing list