Skip to content
Snippets Groups Projects
Commit 4a08cada authored by Matthias Diener's avatar Matthias Diener
Browse files

fix norm()

parent 980715cb
No related branches found
No related tags found
No related merge requests found
......@@ -179,19 +179,6 @@ class BaseFakeNumpyLinalgNamespace:
if isinstance(ary, Number):
return abs(ary)
if is_array_container(ary):
import numpy.linalg as la
return la.norm(
[self.norm(subary, ord=ord)
for _, subary in serialize_container(ary)],
ord=ord)
if len(ary.shape) != 1:
raise NotImplementedError("only vector norms are implemented")
if ary.size == 0:
return 0
if ord is None:
ord = 2
......@@ -213,6 +200,19 @@ class BaseFakeNumpyLinalgNamespace:
for _, subary in serialize_container(ary)],
ord=ord)
if is_array_container(ary):
import numpy.linalg as la
return la.norm(
[self.norm(subary, ord=ord)
for _, subary in serialize_container(ary)],
ord=ord)
if len(ary.shape) != 1:
raise NotImplementedError("only vector norms are implemented")
if ary.size == 0:
return 0
if ord == np.inf:
return self._array_context.np.max(abs(ary))
elif isinstance(ord, Number) and ord > 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment