Skip to content

Commit

Permalink
Merge pull request #29 from mdavezac/array_times_units
Browse files Browse the repository at this point in the history
Simplify creation of typed arrays: `[1, 2]u"km"`
  • Loading branch information
ajkeller34 authored Sep 30, 2016
2 parents e2c7179 + 8388fe4 commit 8040760
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Unitful.jl
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ end
.\(X::AbstractArray, y::Units) =
reshape([ x .\ y for x in X ], size(X))

for f in (:.*,) # looked in arraymath.jl for similar code
for f in (:.*, :*) # looked in arraymath.jl for similar code
@eval begin
function ($f){T}(A::Units, B::AbstractArray{T})
F = similar(B, promote_op($f,typeof(A),T))
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ end
@test @inferred([1V, 2V] .* [true, false]) == [1V, 0V]
@test @inferred([1.0m, 2.0m] ./ 3) == [1m/3, 2m/3]
@test @inferred([1V, 2.0V] ./ [3m, 4m]) == [1V/(3m), 0.5V/m]

@test @inferred([1, 2]kg) == [1, 2] * kg
@test @inferred([1, 2]kg .* [2, 3]kg^-1) == [2, 6]
end

@testset ">> Array addition" begin
Expand Down

0 comments on commit 8040760

Please sign in to comment.