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

1.5 beta allunique errors with Unitful #36080

Closed
Tokazama opened this issue May 30, 2020 · 2 comments · Fixed by #36113
Closed

1.5 beta allunique errors with Unitful #36080

Tokazama opened this issue May 30, 2020 · 2 comments · Fixed by #36113
Milestone

Comments

@Tokazama
Copy link
Contributor

On the most recent 1.5 beta release I get the following error.

julia> using Unitful

julia> using Unitful: s

julia> allunique((1.0:1.0:10.0)s)
ERROR: DimensionError: s and 0 are not dimensionally compatible.
Stacktrace:
 [1] convert(::Type{Quantity{Float64,𝐓,Unitful.FreeUnits{(s,),𝐓,nothing}}}, ::Int64) at /Users/zchristensen/.julia/packages/Unitfu
l/KE9TK/src/conversion.jl:111
 [2] Base.TwicePrecision{Quantity{Float64,𝐓,Unitful.FreeUnits{(s,),𝐓,nothing}}}(::Int64, ::Int64) at ./twiceprecision.jl:185
 [3] zero(::Type{Base.TwicePrecision{Quantity{Float64,𝐓,Unitful.FreeUnits{(s,),𝐓,nothing}}}}) at ./twiceprecision.jl:260
 [4] allunique(::StepRangeLen{Quantity{Float64,𝐓,Unitful.FreeUnits{(s,),𝐓,nothing}},Base.TwicePrecision{Quantity{Float64,𝐓,Unitful
.FreeUnits{(s,),𝐓,nothing}}},Base.TwicePrecision{Quantity{Float64,𝐓,Unitful.FreeUnits{(s,),𝐓,nothing}}}}) at ./set.jl:390
 [5] top-level scope at REPL[3]:1

This does raise some things that could probably be addressed in Unitful.jl but I wonder if it would make more sense to just have allunique(::AbstractRange) = true.

@sostock
Copy link
Contributor

sostock commented May 30, 2020

I wonder if it would make more sense to just have allunique(::AbstractRange) = true

One can actually create ranges that are not allunique:

julia> LinRange(1.0, 1.0, 5)
5-element LinRange{Float64}:
 1.0,1.0,1.0,1.0,1.0

@simeonschaub
Copy link
Member

I think this should just be a matter of replacing step(r) != zero(T) with !iszero(step(r)) in the lines 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

Successfully merging a pull request may close this issue.

4 participants