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

Allow passing a type as first argument to similar #17201

Closed
wants to merge 1 commit into from

Conversation

eschnett
Copy link
Contributor

Closes #17124.

@andreasnoack
Copy link
Member

For an array type T, why not use the constructor T(something) instead of similar(T, something)?

@timholy
Copy link
Member

timholy commented Jun 29, 2016

A perhaps-more-general version is in #17137. That's currently held up due to a weird compile-time performance regression.

@@ -315,6 +315,7 @@ checkbounds(A::AbstractArray) = checkbounds(A, 1) # 0-d case
typealias SimIdx Union{Integer,UnitRangeInteger}
"""
similar(array, [element_type=eltype(array)], [dims=size(array)])
similar(array_type, [element_type=eltype(array)], [dims=size(array)])
Copy link
Contributor

Choose a reason for hiding this comment

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

should match in the rst

@eschnett
Copy link
Contributor Author

@andreasnoack The use case is similar(Vector{Int}, Float64): all you have is the type Vector{Int}, and you want to change the element type to Float64.

@timholy Yes, the allocate_for there should to do the trick. Let's close this PR here, then.

@eschnett eschnett closed this Jun 29, 2016
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.

4 participants