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

Use tfill instead of fill in testvalue #360

Merged
merged 2 commits into from Aug 13, 2020
Merged

Conversation

mohamed82008
Copy link
Contributor

This PR makes testvalue type stable.

@fverdugo fverdugo self-requested a review August 13, 2020 05:47
@@ -123,11 +123,11 @@ testvalue(::Type{T}) where T = zero(T)
testvalue(v) = testvalue(typeof(v))

function testvalue(::Type{T}) where T<:AbstractArray{E,N} where {E,N}
similar(T,fill(0,N)...)
similar(T,tfill(0,Val(N))...)
Copy link
Member

Choose a reason for hiding this comment

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

Val(N) is still type-unstable (unless the compiler is able to leverage that N is a compiler constant here).
Use Val{N}() instead.

Copy link
Member

Choose a reason for hiding this comment

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

It is the same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since JuliaLang/julia#24362 and Julia 1.0, we don't need to be so careful.

end

function testvalue(::Type{T}) where T<:Fill{E,N} where {E,N}
Fill(zero(E),fill(0,N)...)
Fill(zero(E),tfill(0,Val(N))...)
Copy link
Member

Choose a reason for hiding this comment

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

Idem

@fverdugo
Copy link
Member

Let's wait to some clarifying answer in
https://discourse.julialang.org/t/should-i-use-val-n-or-val-n/44862

@fverdugo fverdugo merged commit 839ae09 into gridap:master Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants