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

Promotion error on latest 0.5 master #84

Open
ssfrr opened this issue Jul 15, 2016 · 1 comment
Open

Promotion error on latest 0.5 master #84

ssfrr opened this issue Jul 15, 2016 · 1 comment

Comments

@ssfrr
Copy link
Contributor

ssfrr commented Jul 15, 2016

Seems that something has changed with the way values are promoted during array/scalar multiplication:

julia> collect(1:5) * Hz
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type SIUnits.SIUnit{0,0,-1,0,0,0,0,0,0}
This may have arisen from a call to the constructor SIUnits.SIUnit{0,0,-1,0,0,0,0,0,0}(...),
since type constructors fall back to convert methods.
 in promote_op(::Base.#.*, ::Type{Int64}, ::Type{SIUnits.SIUnit{0,0,-1,0,0,0,0,0,0}}) at ./number.jl:73
 in .*(::Array{Int64,1}, ::SIUnits.SIUnit{0,0,-1,0,0,0,0,0,0}) at ./arraymath.jl:78
 in *(::Array{Int64,1}, ::SIUnits.SIUnit{0,0,-1,0,0,0,0,0,0}) at ./abstractarraymath.jl:55
 in eval(::Module, ::Any) at ./boot.jl:234
 in macro expansion at ./REPL.jl:92 [inlined]
 in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46
julia> versioninfo()
Julia Version 0.5.0-dev+5440
Commit edb112a* (2016-07-14 21:40 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)
@pabloferz
Copy link

If you need this to work before there is a fix of the issue in base you can define the following before trying to call anything like collect(1:5) * Hz for the first time

Base.promote_op{T<:Number,m,kg,s,A,K,mol,cd,rad,sr}(op, ::Type{SIUnits.SIUnit{m,kg,s,A,K,mol,cd,rad,sr}}, ::Type{T}) =
    SIUnits.SIQuantity{T,m,kg,s,A,K,mol,cd,rad,sr}
Base.promote_op{T<:Number,m,kg,s,A,K,mol,cd,rad,sr}(op, ::Type{T}, ::Type{SIUnits.SIUnit{m,kg,s,A,K,mol,cd,rad,sr}}) =
    SIUnits.SIQuantity{T,m,kg,s,A,K,mol,cd,rad,sr}

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