[Piglit] [PATCH 04/24] gen_shader_bit_encoding_tests.py: use builtin operators

Dylan Baker baker.dylan.c at gmail.com
Mon Nov 24 09:58:04 PST 2014


This module implements a neg function, which is available in the math
module. Use that to save a whole line of code!

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 generated_tests/gen_shader_bit_encoding_tests.py | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/generated_tests/gen_shader_bit_encoding_tests.py b/generated_tests/gen_shader_bit_encoding_tests.py
index f72c465..add3368 100644
--- a/generated_tests/gen_shader_bit_encoding_tests.py
+++ b/generated_tests/gen_shader_bit_encoding_tests.py
@@ -23,6 +23,7 @@
 
 import struct
 import os
+from operator import neg
 
 from templates import template_file
 
@@ -42,14 +43,8 @@ def intBitsToFloat(i):
 def uintBitsToFloat(u):
     return struct.unpack('f', struct.pack('I', u))[0]
 
-def passthrough(f):
-    return f
-
-def neg(num):
-    return -num
-
 def neg_abs(num):
-    return -abs(num)
+    return neg(abs(num))
 
 def vec4(f):
     return [f, f, f, f]
@@ -79,13 +74,13 @@ test_data = {
 
 funcs = {
     'floatBitsToInt': {
-        'in_func':  passthrough,
+        'in_func':  lambda x: x,
         'out_func': floatBitsToInt,
         'input':    'vec4',
         'output':   'ivec4'
     },
     'floatBitsToUint': {
-        'in_func':  passthrough,
+        'in_func':  lambda x: x,
         'out_func': floatBitsToUint,
         'input':    'vec4',
         'output':   'uvec4'
@@ -105,10 +100,10 @@ funcs = {
 }
 
 modifier_funcs = {
-    '':            passthrough,
+    '':            lambda x: x,
     'abs':         abs,
     'neg':         neg,
-    'neg_abs':     neg_abs
+    'neg_abs':     neg_abs,
 }
 
 requirements = {
-- 
2.1.3



More information about the Piglit mailing list