On Thu, Feb 19, 2015 at 12:06:15AM -0600, Micah Fedke wrote:
> Prep work for using arrays of tolerances in the shader_test files.
> 
> ---
>   generated_tests/gen_shader_precision_tests.py | 34 
> +++++++++++++++++----------
>   1 file changed, 22 insertions(+), 12 deletions(-)
> 
> diff --git a/generated_tests/gen_shader_precision_tests.py 
> b/generated_tests/gen_shader_precision_tests.py
> index 0d24a80..cfa5065 100644
> --- a/generated_tests/gen_shader_precision_tests.py
> +++ b/generated_tests/gen_shader_precision_tests.py
> @@ -68,6 +68,10 @@ trig_builtins = ('sin', 'cos', 'tan',
>                    'sinh', 'cosh', 'tanh',                   'asinh', 
> 'acosh', 'atanh')
>   +def _is_sequence(arg):
> +    return (not hasattr(arg, "strip") and
> +            hasattr(arg, "__iter__"))
> +

All of the built-in sequence types (list, set, frozenset, tuple) inherit
from one of the ABC's in collections, collections.Sequence is probably
the right one. Would using isinstance(arg, collections.Sequence) work?
This just feels...  abusive, definitely not idiomatic.

>   def make_indexers(signature):
>      """Build a list of strings which index into every possible
>      value of the result.  For example, if the result is a vec2,
> @@ -105,20 +109,26 @@ def shader_runner_format(values):
>       "probe rgba" command.  Bools are converted to 0's and 1's, and
>       values are separated by spaces.
>       """
> -    transformed_values = []
> -    retval = ''
> -    for value in values:
> -        if isinstance(value, (bool, np.bool_)):
> -            transformed_values.append(int(value))
> -        else:
> -            transformed_values.append(value)
> -    for x in transformed_values:
> -        if isinstance(x,np.float32):
> -            retval+=' {0}'.format('{0:1.8e}'.format(x))
> -        else:
> -            retval+=' {0}'.format(repr(x))
> +
> +    if _is_sequence(values):
> +        transformed_values = []
> +        retval = ''
> +        for value in values:
> +            if isinstance(value, (bool, np.bool_)):
> +                transformed_values.append(int(value))
> +            else:
> +                transformed_values.append(value)
> +        for x in transformed_values:
> +            if isinstance(x,np.float32):
> +                retval+=' {0}'.format('{0:1.8e}'.format(x))
> +            else:
> +                retval+=' {0}'.format(repr(x))
> +    else:
> +        retval = '{}'.format(values)

What is values? I assume in this else block it's a string? If it is a
string then just setting retval = values should be sufficient.

> +
>       return retval
>   +
>   def main():
>       """ Main function """
>   -- 2.2.2
> _______________________________________________
> Piglit mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/piglit

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to