| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| (symmetric if real-valued) and positive-definite. No checking is performed | ||
| to verify whether `a` is Hermitian or not. In addition, only the lower or | ||
| upper-triangular and diagonal elements of `a` are used. Only `L` or `U` | ||
| is actually returned. |
There was a problem hiding this comment.
I think all of these should be double backtick quotes, since they're not cross-references to numpy types.
Sorry, something went wrong.
There was a problem hiding this comment.
Right, I formatted them.
Sorry, something went wrong.
| -------------------------------------------------------------- | ||
|
|
||
| ``upper`` keyword parameter was added to `numpy.linalg.cholesky` and | ||
| ``rtol`` keyword parameter to `numpy.linalg.pinv` for Array API compatibility. |
There was a problem hiding this comment.
Weren't both added for array API compat?
I'd also mention that rtol doesn't have the array API default.
Sorry, something went wrong.
There was a problem hiding this comment.
That's correct, both of these were added to array-api-compat.
rtol doesn't have the default value because default for pinv is always taken from rcond (for backward compatibility) - I added a note about it.
Sorry, something went wrong.
There was a problem hiding this comment.
I'm trying to say it reads like only rtol was added for compat now. Maybe something like:
The ``upper`` and ``rtol`` keyword parameters were added to `numpy.linalg.colesky` and `numpy.lingalg.ping`, respectively, to improve array API compatibility.
Sorry, something went wrong.
There was a problem hiding this comment.
Ah, now I got it - I updated it.
Sorry, something went wrong.
| a, wrap = _makearray(a) | ||
| if rtol is not None: | ||
| if rcond != 1e-15: | ||
| raise ValueError("`rtol` and `rcond` can't be both set.") |
There was a problem hiding this comment.
What if someone sets rcond=1e-15 and rtol != None. In that case rtol would be ignored. Of course that's a pretty unusual thing to happen.
Still, it might be better to change the default value of rcond to None, and if both are unset, assume the user meant rcond=1e-15 to preserve backward compatibility. Also document that behavior.
Sorry, something went wrong.
There was a problem hiding this comment.
Or error if both are set to non-default values and leave the default alone.
Sorry, something went wrong.
There was a problem hiding this comment.
Sure! Changed to rcond=None.
Sorry, something went wrong.
There was a problem hiding this comment.
One little buglet and a comment.
Bit more generally, might it make sense to move towards the array API and deprecate rcond? (maybe just a FutureDeprecationWarning or so).
Also, might it be an idea to use rtol=np._NoValue as the default for now, to allow passing in rtol=None to opt in to the array API default?
Not sure about either, to be honest.
Sorry, something went wrong.
| over='ignore', divide='ignore', under='ignore'): | ||
| r = gufunc(a, signature=signature) | ||
| if upper: | ||
| r = r.T.conj() |
There was a problem hiding this comment.
This is only correct for 2-d arrays, while I think the input can be a stack of matrices. Replace with
r = matrix_transpose(r).conj()
Sorry, something went wrong.
There was a problem hiding this comment.
Ah, right - fixed!
Sorry, something went wrong.
| rtol : (...) array_like of float, optional | ||
| Same as `rcond`, but it's an Array API compatible parameter name. | ||
| Only `rcond` or `rtol` can be set at a time. If none of them are | ||
| provided then ``1e-15`` default is used. |
There was a problem hiding this comment.
Needs a .. versionadded:: 2.0.0
Sorry, something went wrong.
There was a problem hiding this comment.
Done!
Sorry, something went wrong.
There was a problem hiding this comment.
Should note here that if None is passed in, the API standard default is used.
Sorry, something went wrong.
There was a problem hiding this comment.
Done!
Sorry, something went wrong.
@mhvk In my opinion it's a good idea - I added a PendingDeprecationWarning when rcond is set explicitly and made it possible to use rtol default value with rtol=None. |
Sorry, something went wrong.
| over='ignore', divide='ignore', under='ignore'): | ||
| r = gufunc(a, signature=signature) | ||
| if upper: | ||
| r = matrix_transpose(r).conj() |
There was a problem hiding this comment.
Now wondering about this, since this makes a copy of a potentially large matrix: an alternative would be to actually define cholesky_up (like done for eigenvalues, etc.), i.e., creating a new gufunc by adding to
numpy/numpy/linalg/umath_linalg.cpp
Lines 1988 to 1993 in 0032ede
numpy/numpy/linalg/umath_linalg.cpp
Line 4178 in 0032ede
numpy/numpy/linalg/umath_linalg.cpp
Lines 4390 to 4399 in 0032ede
Sorry, something went wrong.
There was a problem hiding this comment.
If it's Ok, let me create later a separate issue/PR that introduces a new ufunc.
Sorry, something went wrong.
There was a problem hiding this comment.
Sure, it is fine to have the support now and improve it later!
Sorry, something went wrong.
There was a problem hiding this comment.
Beyond the larger separate comment about maybe creating the appropriate gufunc to avoid copies, a few nits in-line.
Sorry, something went wrong.
| rtol : (...) array_like of float, optional | ||
| Same as `rcond`, but it's an Array API compatible parameter name. | ||
| Only `rcond` or `rtol` can be set at a time. If none of them are | ||
| provided then ``1e-15`` default is used. |
There was a problem hiding this comment.
Should note here that if None is passed in, the API standard default is used.
Sorry, something went wrong.
| improve array API compatibility. | ||
|
|
||
| For `numpy.linalg.pinv` if neither ``rcond`` nor ``rtol`` is specified, | ||
| the ``rcond``'s default is used. |
There was a problem hiding this comment.
Maybe worth stating that eventually we hope to deprecate rcond?
Sorry, something went wrong.
There was a problem hiding this comment.
Sure! Added.
Sorry, something went wrong.
| def test_pinv_rtol_arg(): | ||
| a = np.array([[1, 2, 3], [4, 1, 1], [2, 3, 1]]) | ||
|
|
||
| with suppress_warnings() as sup: |
There was a problem hiding this comment.
Since the warning is intensional, I'd do
with pytest.warns(PendingDeprecationWarning, match="In the future `rcond`"):
Sorry, something went wrong.
There was a problem hiding this comment.
As the warning got removed it's not needed.
Sorry, something went wrong.
There was a problem hiding this comment.
All looks good to me!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Hi @rgommers @ngoldbaum,
This PR is (one of) the last Array API compatibility changes: