-
-
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
deprecate sprandbool + add new syntax for creating random sparse matrix #16098
Conversation
Probably makes sense to deprecate sprandbool here too since now it is just: julia> sprand(Bool, 3, 3, 0.5)
3×3 sparse matrix with 5 Bool nonzero entries:
[2, 1] = false
[1, 2] = false
[2, 2] = false
[3, 2] = true
[3, 3] = true |
Actually the above is wrong since |
@@ -356,17 +356,17 @@ function sprand(r::AbstractRNG, n::Integer, p::AbstractFloat, rfn::Function) | |||
SparseVector(n, I, V) | |||
end | |||
|
|||
sprand{T}(::Type{T}, n::Integer, p::AbstractFloat) = sprand(GLOBAL_RNG, n, p, rand, T) | |||
sprand{T}(n::Integer, p::AbstractFloat, ::Type{T}) = sprand(GLOBAL_RNG, n, p, rand, T) |
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.
Should this one be deprecated as well? It doesn't correspond to the dense case.
Needs a doc update for the new |
Yes, I will make stuff more consistent between |
0b5e0c7
to
21b3b2a
Compare
Updated. Some usage examples: julia> sprand(Bool, 3, 3, 0.3)
3×3 sparse matrix with 2 Bool nonzero entries:
[3, 1] = true
[1, 3] = true
julia> sprand(Base.GLOBAL_RNG, Bool, 3, 3, 0.3)
3×3 sparse matrix with 4 Bool nonzero entries:
[1, 1] = true
[3, 1] = true
[1, 3] = true
[2, 3] = true
julia> sprand(Base.GLOBAL_RNG, Float32, 3, 3, 0.3)
3×3 sparse matrix with 2 Float32 nonzero entries:
[3, 2] = 0.954499
[2, 3] = 0.00251913
julia> sprand(Float64, 3, 3, 0.3)
3×3 sparse matrix with 3 Float64 nonzero entries:
[2, 1] = 0.960525
[3, 1] = 0.990573
[1, 3] = 0.475681
julia> sprand(Float64, 2, 0.3)
Sparse vector of length 2 with 1 Float64 nonzero entries:
[1] = 0.446653
julia> sprand(Bool, 5, 0.3)
Sparse vector of length 5 with 2 Bool nonzero entries:
[2] = true
[5] = true |
|
||
Create a random length `m` sparse vector or `m` by `n` sparse matrix, in | ||
which the probability of any element being nonzero is independently given by | ||
`p` (and hence the mean density of nonzeros is also exactly `p`). Nonzero | ||
values are sampled from the distribution specified by `rfn`. The uniform | ||
values are sampled from the distribution specified by `rfn` and have the type `type`. The uniform |
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.
run genstdlib
looks really good, thanks for getting to this before I did
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.
wow, you are fast.. just ran it.
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.
think I need to rerun make for the actual docstring to get updated though..
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.
yeah make docs
is the more precise way that will also rerun bootstrap to get the updated docstring into the system image
21b3b2a
to
7d65f74
Compare
What is the policy regarding documentation? Should documentation for deprecated methods be removed? |
I think that's what we've been doing. The deprecation warning will point to the new syntax and the new syntax should be as well or better documented than the old syntax. |
077afc3
to
9e53eda
Compare
I built up a bit of unnecessary CI queue which could possibly be killed. |
I've cancelled the duplicate builds. |
there are hooks that fail fast on redundant builds automatically, so not a big deal. manually cancelling saves maybe a minute or two tops. edit: unless they builds have already started, in which case manually cancelling is worthwhile |
@tkelman The issue is that the obsolete builds had already started, and AFAIK they aren't cancelled automatically in that case. |
Error is OSX timeout. |
Last few places it should be cleaned up, from
then we're good to merge |
Doesn't it still need to be exported? Or does the deprecated macro export? |
the deprecate macro should be handling the exporting, I believe |
That's right (as documented in the comment at the top of deprecated.jl). |
9e53eda
to
8044d1d
Compare
I accidentally amended the latest changes to the "remove documentation" commit. However, if things are fine now then it will be squashed by the one who merges anyway so it shouldn't matter much. |
Anyway this is ready from my pov. |
@@ -152,7 +152,7 @@ end | |||
let r1 = MersenneTwister(), r2 = MersenneTwister() | |||
@test sprand(r1, 100, .9) == sprand(r2, 100, .9) | |||
@test sprandn(r1, 100, .9) == sprandn(r2, 100, .9) | |||
@test sprandbool(r1, 100, .9) == sprandbool(r2, 100, .9) | |||
@test sprand(r1, Bool, 100, .9, ) == sprand(r2, Bool, 100, .9) |
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.
any recollection why there's an extra comma here?
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.
Accident probably.
This mimics the one already existing for
rand
.Now:
[edit by tkelman: closes #11688]