[Piglit] [PATCH 1/4] arb_shader_precision: support scalar values in shader_runner_format

Dylan Baker baker.dylan.c at gmail.com
Wed Feb 18 22:50:14 PST 2015


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
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150218/babb9f43/attachment-0001.sig>


More information about the Piglit mailing list