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
Frobenius Norm defined for vectors? #15533
Comments
This looks like a bug in the handling of the >>> print(np.linalg.norm(b))
1.7547099704258247 Note that the Frobenius norm is the default when the |
As Ross pointed out to me, the issue/PR I linked are only tangentially related and this is quite clearly a bug in the |
A PR to address the bug in the kwarg handling (and accompanying tests) is welcome! Nice catch @TNonet |
Since this is my first issue, Are there any resources for making proper tests and a pull request? (Also, if I was to clone the numpy repo and run setup.py, how would I make sure which numpy version I use when I import numpy?) I would argue if ord is 'fro', then lines 2512-14 below. Lines 2510 to 2524 in dae4f67
Would need to be changed to: if ((ord is None) or
(ord in ('f', 'fro')) or
(ord == 2 and ndim == 1)): Assuming everyone agrees that an nth order array has a Forbenious Norm that is naturally summing up squares of each element. |
The problem is actually a bit further down in the code - if you follow the traceback from the error you received originally, you should be able to find the offending bit. As mentioned in the discussions in #14719 and #14215, the behavior for >2 dimensions is a separate issue - it would be best if you could limit this PR to the bug in kwarg handling. Re: resources for testing/contributing: take a look at NumPy's contribution guidelines. You can also take a look at linalg tests in |
Default parameters for norms implements the Frobenious Norm. See numpy#15533 When using ord='fro' should work for both vectors and arrays, as defined.
This might be less of an implementation question, and more of a "philosophy" question, but shouldn't the Frobenius Norm work on Vectors? Source: Wolfram
Currently, the Frobenius Norm in numpy does not accept vectors:
Which results in:
The text was updated successfully, but these errors were encountered: