Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

np.linalg.norm doesn't work, when performed along an axis #588

Open
Baekalfen opened this issue Jan 27, 2019 · 2 comments
Open

np.linalg.norm doesn't work, when performed along an axis #588

Baekalfen opened this issue Jan 27, 2019 · 2 comments

Comments

@Baekalfen
Copy link
Contributor

Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bohrium as np
>>> np.linalg.norm(np.ones((2,2,2)),axis=0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "bohrium/bhary.pyx", line 95, in bohrium.bhary.fix_biclass_wrapper.inner
  File "/home/mads/.bin/bohrium/lib/python2.7/site-packages/bohrium/linalg.py", line 291, in norm
    raise NotImplementedError("Unsupported value of param ord=%s" % axis)
NotImplementedError: Unsupported value of param ord=0

Calling it without an axis works, but gives of course a different result:

>>> np.linalg.norm(np.ones((2,2,2)))
2.82843
@dionhaefner
Copy link
Collaborator

In case it's not already obvious, a workaround is

np.sqrt(np.sum(arr**2, axis=0))

(at least for real numbers)

@Baekalfen
Copy link
Contributor Author

I hadn't thought of that. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants