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

something wrong with the length of ranges build from Quantitys #45

Closed
ggggggggg opened this issue Nov 4, 2016 · 2 comments
Closed

something wrong with the length of ranges build from Quantitys #45

ggggggggg opened this issue Nov 4, 2016 · 2 comments

Comments

@ggggggggg
Copy link
Contributor

ggggggggg commented Nov 4, 2016

I remember that you had requested change to Base to allow ranges to work correctly, I don't remember if those happened or not. But I think these are unrelated. Here is an example where collect(range) is not even monotonic. The result is not always the same, suggesting this value is initialized. Also the behavior is different when the range is used in a comprehenision vs when used with the new vectorizing dot syntax.

julia> range = 0u"mm":0.001u"mm":5.4167u"mm"
0.0 mm:0.001 mm:5.416 mm
julia> collect(range)[end]
NaN mm #expected 5.416mm
julia> [r.val for r in range][end]
6.934269676051e-310 #expected 5.416
julia> getval(q)=q.val
julia> getval.(range)[end]
5.416 #expected 5.416

Here is an example where the range appears to end two value too soon.

julia> collect(0u"mm":0.001u"mm":5u"mm")[end]
4.998000000000004 mm #expected 5.0 mm
julia> length(0:0.001:5)-length(0u"mm":0.001u"mm":5u"mm")
2
@ChrisRackauckas
Copy link
Contributor

Use Ranges.jl for units-compatible ranges/linspace.

@ajkeller34
Copy link
Collaborator

This has been fixed on master. It will work exactly as you expect on Julia 0.6 when that comes out, and it will use Ranges.jl automatically on Julia 0.5, which does a pretty good job given the constraints of 0.5. I'll keep the issue open until I tag a new release—I've been slow to do that since Julia 0.6 development seems to break Unitful with some regularity.

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