-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
eye see deprecated methods #24438
eye see deprecated methods #24438
Conversation
8af3e9a
to
02d2d38
Compare
@@ -1788,7 +1788,53 @@ end | |||
@deprecate get_creds!(cache::CachedCredentials, credid, default) get!(cache, credid, default) | |||
end | |||
|
|||
@deprecate eye(::Type{Diagonal{T}}, n::Int) where {T} Diagonal{T}(I, n) | |||
## goodbeye, eye! | |||
export eye |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, I guess we also need
@eval Base.LinAlg import Base.eye
@eval Base.SparseArrays import Base.eye
if someone uses LinAlg.eye(...)
or SparseArrays.eye()
in their codes. I don't think we have done that before, but perhaps we should, since changes like this should not break code :)
base/linalg/dense.jl
Outdated
@@ -614,7 +614,7 @@ triangular factor. | |||
|
|||
# Examples | |||
```jldoctest | |||
julia> A = 2.7182818 * eye(2) | |||
julia> A = Matrix(2.7182818I, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The I
looked like a 1
at first sight and I was confused... Perhaps add an explicit *
? Matrix(2.7182818*I, 2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revised accordingly on push. Thanks!
@@ -27,7 +27,7 @@ The object has two fields: | |||
triu(F.factors)` for a `QR` object `F`. | |||
|
|||
- The subdiagonal part contains the reflectors ``v_i`` stored in a packed format where | |||
``v_i`` is the ``i``th column of the matrix `V = eye(m,n) + tril(F.factors,-1)`. | |||
``v_i`` is the ``i``th column of the matrix `V = I + tril(F.factors, -1)`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sizes m
and n
not needed? Same on the changes below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omitting the explicit m
and n
in this documentation seems preferable on this end, particularly if we relax addition with UniformScaling
s to behave generally as it does with sparse matrices (as discussed on triage).
test/sparse/cholmod.jl
Outdated
@@ -436,7 +436,7 @@ for elty in (Float64, Complex{Float64}) | |||
|
|||
## Low level interface | |||
@test CHOLMOD.nnz(A1Sparse) == nnz(A1) | |||
@test CHOLMOD.speye(5, 5, elty) == eye(elty, 5, 5) | |||
@test CHOLMOD.speye(5, 5, elty) == Matrix(I, 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably does not matter, but perhaps Matrix{elty}(I, 5)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In ==
, the Matrix(I, ...)
on the right-hand-side lifts to the eltype of the left-hand-side, making the eltype specification on the right unnecessary :).
base/linalg/dense.jl
Outdated
@@ -508,7 +508,7 @@ function exp!(A::StridedMatrix{T}) where T<:BlasFloat | |||
end | |||
ilo, ihi, scale = LAPACK.gebal!('B', A) # modifies A | |||
nA = norm(A, 1) | |||
I = eye(T,n) | |||
Inn = Matrix{T}(I, n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great example why exporting single-character names is a bad idea :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, in all recent work related to I
I have found only two such collisions IIRC, indicating that in practice this issue is not so great :).
base/deprecated.jl
Outdated
"constructors. For a direct replacement, consider `Matrix(1.0I, m)` or ", | ||
"`Matrix{Float64}(I, m)`. If `Float64` element type is not necessary, ", | ||
"consider the shorter `Matrix(I, m)` (with default `eltype(I)` `Bool`)."), :eye) | ||
return Matrix{Float64}(I, m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be Matrix{Float64}(I, m, m)
.
Plan per triage: Remove the single-integer |
c6e46ad
to
f48bf94
Compare
Rebased and revised per triage, removing all single-integer Removing those calls strongly reaffirmed what I conveyed weakly in triage: Constructing a non-square identity matrix is the rare exception; |
6fe1522
to
a36c13d
Compare
Why is this not titled "eye speye deprecated methods"? Anyway looks great but could you rebase? |
That's brilliant! #24356 now has a vastly superior title. (Also https://media.giphy.com/media/DvtsYOKrqPZg4/giphy.gif :).) |
7d86a5b
to
220061d
Compare
Rebased and (hopefully) fixed the |
Thanks all! :) |
This pull request deprecates
eye
in favor ofI
andMatrix
constructors (e.g.... == I
rather than... == eye(...)
andMatrix{T}(I, n)
rather thaneye(T, n)
). Regarding theeye
call rewrites intest/
, the rewrites are for the most part conservative rather than potentially ideal (e.g.... == eye(T, 3, 4)
->... == Matrix(I, 3, 4)
rather than... == I
); see #23156 (comment). Addresses #23156 (comment). Best!(I expect a cascade of CI failures and subsequent iteration on this pull request, hence the WIP.)