From eb29e2911c7c846fd9e1610df80d49459d91ea01 Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni <kaushikcfd@gmail.com> Date: Thu, 20 May 2021 16:29:34 -0500 Subject: [PATCH] [minor]: avoid call to all(...) - probably cleaner to read - probably better performance (?) --- pyopencl/array.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyopencl/array.py b/pyopencl/array.py index 4c987864..e563ccdf 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -2707,9 +2707,9 @@ def if_positive(criterion, then_, else_, out=None, queue=None): contains *then_[i]* if *criterion[i]>0*, else *else_[i]*. """ - if all(isinstance(k, SCALAR_CLASSES) for k in [criterion, - then_, - else_]): + if (isinstance(criterion, SCALAR_CLASSES) + and isinstance(then_, SCALAR_CLASSES) + and isinstance(else_, SCALAR_CLASSES)): result = np.where(criterion, then_, else_) if out is not None: @@ -2733,7 +2733,7 @@ def if_positive(criterion, then_, else_, out=None, queue=None): def maximum(a, b, out=None, queue=None): """Return the elementwise maximum of *a* and *b*.""" - if all(isinstance(k, SCALAR_CLASSES) for k in [a, b]): + if isinstance(a, SCALAR_CLASSES) and isinstance(b, SCALAR_CLASSES): result = np.maximum(a, b) if out is not None: out[...] = result @@ -2748,7 +2748,7 @@ def maximum(a, b, out=None, queue=None): def minimum(a, b, out=None, queue=None): """Return the elementwise minimum of *a* and *b*.""" - if all(isinstance(k, SCALAR_CLASSES) for k in [a, b]): + if isinstance(a, SCALAR_CLASSES) and isinstance(b, SCALAR_CLASSES): result = np.minimum(a, b) if out is not None: out[...] = result -- GitLab