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

Newly defined units unavailable to u_str #61

Closed
ggggggggg opened this issue Mar 9, 2017 · 1 comment
Closed

Newly defined units unavailable to u_str #61

ggggggggg opened this issue Mar 9, 2017 · 1 comment

Comments

@ggggggggg
Copy link
Contributor

ggggggggg commented Mar 9, 2017

Following the docs I tried:

julia> using Unitful

julia> @unit M "M" Molar 1u"mol/L" true
M

julia> 1M
1 M

julia> 1u"M"
ERROR: Symbol M could not be found in registered unit modules.

edit: Expected behavior is that 1M==1u"M"

@ajkeller34
Copy link
Collaborator

I wouldn't expect this to work, since Main isn't a registered unit module by default. On the other hand, it appears like it was not possible before to even register Main as a unit module. I've patched master, it should work for you now provided you do Unitful.register(Main) before using @u_str, like:

julia> using Unitful
INFO: Recompiling stale cache file /Users/ajkeller/.julia/lib/v0.6/Unitful.ji for module Unitful.

julia> Unitful.register(Main)
2-element Array{Module,1}:
 Unitful
 Main   

julia> @unit M "M" Molar 1u"mol/L" true
M

julia> 1M
1 M

julia> 1u"M"
1 M

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