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

Converting inverse units fails #720

Open
jariji opened this issue May 13, 2024 · 2 comments
Open

Converting inverse units fails #720

jariji opened this issue May 13, 2024 · 2 comments

Comments

@jariji
Copy link

jariji commented May 13, 2024

julia> uconvert(u"1/km", 3.0u"1/m")
ERROR: MethodError: no method matching uconvert(::Quantity{Int64, 𝐋^-1, Unitful.FreeUnits{(km^-1,), 𝐋^-1, nothing}}, ::Quantity{Float64, 𝐋^-1, Unitful.FreeUnits{(m^-1,), 𝐋^-1, nothing}})

Is this supposed to work? Why not?

@sostock
Copy link
Collaborator

sostock commented May 13, 2024

This doesn’t work because u"1/km" is a quantity, not a unit. You can use u"km^-1" instead.

@jariji
Copy link
Author

jariji commented May 13, 2024

Thanks.

An error-message hint (Base.Experimental.register_error_hint) might be helpful here.

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

2 participants