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

float(SVector) gives an MVector #247

Closed
stevengj opened this issue Jul 20, 2017 · 2 comments
Closed

float(SVector) gives an MVector #247

stevengj opened this issue Jul 20, 2017 · 2 comments
Labels
feature features and feature requests good first issue Issue which is likely easy to solve up for grabs Implement me, I'm yours!

Comments

@stevengj
Copy link
Contributor

julia> float(SVector(0))
1-element MVector{1,Float64}:
 0.0

This is because it is calling base/float.jl, which calls convert(AbstractArray, ...) which calls similar, I think(?), but in this case it seems more useful to return an SVector?

Or is there a better way to promote an SVector to a float-based type, e.g. from Complex{Int} to Complex{Float}?

@c42f
Copy link
Member

c42f commented Jul 21, 2017

How about

float.(SVector(0))

I guess we should just add the following as a general solution:

float(a::StaticArray) = map(float,a)

Perhaps this would also be a better solution for Base for AbstractArrays of non-floats.

@c42f c42f added feature features and feature requests up for grabs Implement me, I'm yours! good first issue Issue which is likely easy to solve labels Jul 31, 2019
@daanhb
Copy link

daanhb commented Nov 1, 2020

I think this one is fixed, perhaps by #747?

julia> float(SVector(0))
1-element SArray{Tuple{1},Float64,1,1} with indices SOneTo(1):
 0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature features and feature requests good first issue Issue which is likely easy to solve up for grabs Implement me, I'm yours!
Projects
None yet
Development

No branches or pull requests

4 participants