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

numeric type not preserved in uconvert #25

Closed
elehcim opened this issue Nov 29, 2021 · 2 comments
Closed

numeric type not preserved in uconvert #25

elehcim opened this issue Nov 29, 2021 · 2 comments

Comments

@elehcim
Copy link

elehcim commented Nov 29, 2021

As pointed out by @islent in JuliaAstroSim/PhysicalParticles.jl#27 (comment)

julia> using Unitful, UnitfulAstro

julia> a = 1.0f0u"kpc/Gyr"
┌ Warning: Symbol Gyr was found in multiple registered unit modules.
│ We will use the one from UnitfulAstro.
└ @ Unitful E:\.julia\packages\Unitful\9janP\src\user.jl:589
1.0f0 kpc Gyr^-1

julia> b = uconvert(u"km/s", a)
0.9777922216807892 km s^-1

julia> typeof(a)
Quantity{Float32, 𝐋 𝐓^-1, Unitful.FreeUnits{(Gyr^-1, kpc), 𝐋 𝐓^-1, nothing}}

julia> typeof(b)
Quantity{Float64, 𝐋  𝐓 ^-1, Unitful.FreeUnits{(km, s^-1), 𝐋  𝐓 ^-1, nothing}

I'd like b to stay Float32

@islent
Copy link

islent commented Nov 29, 2021

That comes from Unitful. 🤣
PainterQubits/Unitful.jl#502

@mileslucas
Copy link
Member

I'm going to close this since it is a Unitful issue, not specific to this repo. Feel free to open it again or move to a discussion for further discourse.

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

No branches or pull requests

3 participants