From c8efdbb72eab78ed2fc735d3078ef8534dcc6ef7 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Mon, 11 Jan 2021 17:26:04 -0700 Subject: Fix different behavior of norm() with axis=None in the array API namespace --- numpy/_array_api/linear_algebra_functions.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'numpy/_array_api/linear_algebra_functions.py') diff --git a/numpy/_array_api/linear_algebra_functions.py b/numpy/_array_api/linear_algebra_functions.py index 9995e6b98..820dfffba 100644 --- a/numpy/_array_api/linear_algebra_functions.py +++ b/numpy/_array_api/linear_algebra_functions.py @@ -55,6 +55,9 @@ def inv(x): def norm(x, /, *, axis=None, keepdims=False, ord=None): # Note: this function is being imported from a nondefault namespace from ..linalg import norm + # Note: this is different from the default behavior + if axis == None and x.ndim > 2: + x = x.flatten() return norm(x, axis=axis, keepdims=keepdims, ord=ord) def outer(x1, x2, /): -- cgit v1.2.1