diff options
Diffstat (limited to 'numpy/lib/shape_base.py')
| -rw-r--r-- | numpy/lib/shape_base.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index de8606167..5357c62df 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -643,10 +643,9 @@ def get_array_prepare(*args): In case of ties, leftmost wins. If no wrapper is found, return None """ - wrappers = [(getattr(x, '__array_priority__', 0), -i, + wrappers = sorted((getattr(x, '__array_priority__', 0), -i, x.__array_prepare__) for i, x in enumerate(args) - if hasattr(x, '__array_prepare__')] - wrappers.sort() + if hasattr(x, '__array_prepare__')) if wrappers: return wrappers[-1][-1] return None @@ -656,10 +655,9 @@ def get_array_wrap(*args): In case of ties, leftmost wins. If no wrapper is found, return None """ - wrappers = [(getattr(x, '__array_priority__', 0), -i, + wrappers = sorted((getattr(x, '__array_priority__', 0), -i, x.__array_wrap__) for i, x in enumerate(args) - if hasattr(x, '__array_wrap__')] - wrappers.sort() + if hasattr(x, '__array_wrap__')) if wrappers: return wrappers[-1][-1] return None |
