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

Adding Type argument to sprandn #29074

Closed
wants to merge 5 commits into from
Closed

Conversation

lostella
Copy link
Contributor

@lostella lostella commented Sep 6, 2018

This is a shot at solving #29018. I added tests for the Vector cases, but not for the Matrix case: these are nowhere to be found for sprand and sprandn. Or am I missing something?

In addition to this, I did minor rephrasing to the docstring, in particular to how optional arguments are listed: it makes more sense to me like this.

First PR, go easy on me :-)

@@ -1488,6 +1489,8 @@ julia> sprandn(2, 2, 0.75)
"""
sprandn(r::AbstractRNG, m::Integer, n::Integer, density::AbstractFloat) = sprand(r,m,n,density,randn,Float64)
sprandn(m::Integer, n::Integer, density::AbstractFloat) = sprandn(GLOBAL_RNG,m,n,density)
sprandn(r::AbstractRNG, ::Type{T}, m::Integer, n::Integer, density::AbstractFloat) where {T} = sprand(r, T, m, n, density)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might this definition end up drawing from a uniform rather than normal distribution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! I’ll add tests for the matrix case and fix this

@Sacha0
Copy link
Member

Sacha0 commented Sep 10, 2018

First PR

Welcome @lostella! :D

@@ -1488,6 +1489,8 @@ julia> sprandn(2, 2, 0.75)
"""
sprandn(r::AbstractRNG, m::Integer, n::Integer, density::AbstractFloat) = sprand(r,m,n,density,randn,Float64)
sprandn(m::Integer, n::Integer, density::AbstractFloat) = sprandn(GLOBAL_RNG,m,n,density)
sprandn(r::AbstractRNG, ::Type{T}, m::Integer, n::Integer, density::AbstractFloat) where {T} = sprand(r,m,n,density,randn,T)
sprandn(::Type{T}, m::Integer, n::Integer, density::AbstractFloat) where {T} = sprandn(GLOBAL_RNG,T,m,n,density)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine that tests for these signatures are inbound per your preceding comment; commenting in case that idea got lost :).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, they’re coming probably later today.

@lostella
Copy link
Contributor Author

I added tests, CI is running.

I'm sorry for the multiple commits, is there a way to stop the builds (in travis, circleci) for all but the latest commit? It seems like a waste otherwise.

@Sacha0
Copy link
Member

Sacha0 commented Sep 11, 2018

I'm sorry for the multiple commits, is there a way to stop the builds (in travis, circleci) for all but the latest commit? It seems like a waste otherwise.

No worries! CI should cancel the outdated builds automagically :).

@lostella
Copy link
Contributor Author

Sure. One note: i limited tests for the SparseMatrixCSC case to the signatures I added + the sprand ones (simply because it was very easy to copy-paste and modify the entire @testset from the sparse vector tests). Maybe an issue should be opened regarding missing tests for the all other sparse matrices signatures? They are probably covered elsewhere, but proper unit tests seem to be missing.

@Sacha0
Copy link
Member

Sacha0 commented Sep 20, 2018

They are probably covered elsewhere

Most sparse matrix functionality is covered in stdlib/SparseArrays/test/sparse.jl; chances are the tests in the file you add here (sparsematrix.jl) belong somewhere in there :). Best!

@lostella
Copy link
Contributor Author

@Sacha0 @KristofferC – Do you think anything is missing here? Any idea whether this feature will make it to 1.1?

@kshyatt kshyatt added the sparse Sparse arrays label Dec 12, 2018
@kshyatt
Copy link
Contributor

kshyatt commented Dec 12, 2018

Any chance we can shepherd this first-time pr over the finish line by the time the release drops, @Sacha0 and @KristofferC? Sorry this fell off the radar, @lostella.

@fredrikekre
Copy link
Member

#30090

@lostella
Copy link
Contributor Author

Oh no! My beautiful PR... Well, at least it’s reassuring that I didn’t fall too far from the one that got merged. Or maybe it was exactly identical.

Next time!

@StefanKarpinski
Copy link
Member

Sorry about that! Your PR is still greatly appreciated ❤️

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

Successfully merging this pull request may close these issues.

5 participants