Skip to content

Commit

Permalink
Run rewrite tests for Float64
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Nov 19, 2019
1 parent af65f13 commit 514a724
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ os:
- linux
- osx
julia:
- 1.0
- 1.1
- 1.2
- 1.3
- nightly
matrix:
allow_failures:
Expand Down
2 changes: 2 additions & 0 deletions src/MutableArithmetics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

module MutableArithmetics

import LinearAlgebra

# Performance note:
# We use `Vararg` instead of splatting `...` as using `where N` forces Julia to
# specialize in the number of arguments `N`. Otherwise, we get allocations and
Expand Down
3 changes: 3 additions & 0 deletions src/bigint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ promote_operation(::typeof(+), ::Vararg{Type{BigInt}, N}) where {N} = BigInt
function mutable_operate_to!(output::BigInt, ::typeof(+), a::BigInt, b::BigInt)
return Base.GMP.MPZ.add!(output, a, b)
end
function mutable_operate_to!(output::BigInt, op::typeof(+), a::BigInt, b::LinearAlgebra.UniformScaling)
return mutable_operate_to!(output, op, a, b.λ)
end

# *
promote_operation(::typeof(*), ::Vararg{Type{BigInt}, N}) where {N} = BigInt
Expand Down
2 changes: 0 additions & 2 deletions src/linear_algebra.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import LinearAlgebra

mutability(::Type{<:Array}) = IsMutable()

# Sum
Expand Down
48 changes: 29 additions & 19 deletions test/rewrite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,14 @@ function non_array_test(x, x2)
if !MA._one_indexed(x2)
@test_throws DimensionMismatch x + x2
end
@testset "diagm" begin
if !MA._one_indexed(x2) && eltype(x2) isa MA.AbstractMutable
@test_throws AssertionError diagm(x2)
else
@test diagm(x) == diagm(x2)
# `diagm` not defined for Int before Julia v1.2
if !(eltype(x2) <: Integer) || VERSION >= v"1.2"
@testset "diagm" begin
if !MA._one_indexed(x2) && eltype(x2) isa MA.AbstractMutable
@test_throws AssertionError diagm(x2)
else
@test diagm(x) == diagm(x2)
end
end
end
end
Expand Down Expand Up @@ -484,22 +487,29 @@ end
using LinearAlgebra
using OffsetArrays

@testset "@rewrite with Int" begin
basic_operators_test(1, 2, 3, 4)
sum_test(rand(Int, 3, 3))
dot_test(rand(Int, 3), rand(Int, 2, 2), rand(Int, 2, 2, 2))
issue_656(3)
transpose_test(rand(Int, 3), rand(Int, 2, 3), rand(Int, 5))
vectorized_test([3, 2, 6], 4, 5, [8 1 9; 4 3 1; 2 0 8])
broadcast_test([2 4; 1 3])
x = [2, 4, 3]
@testset "@rewrite with $T" for T in [
Int,
Float64
#, BigInt
]
basic_operators_test(T(1), T(2), T(3), T(4))
sum_test(T[5 1 9; -7 2 4; -2 -7 5])
S = zeros(T, 2, 2, 2)
S[1, :, :] = T[5 -8; 3 -7]
S[2, :, :] = T[-2 8; 8 -1]
dot_test(T[-7, 1, 4], T[0 -4; 6 -5], S)
issue_656(T(3))
transpose_test(T[9, -3, 8], T[-4 4 1; 4 -8 -6], T[6, 9, 2, 4, -3])
vectorized_test(T[3, 2, 6], T(4), T(5), T[8 1 9; 4 3 1; 2 0 8])
broadcast_test(T[2 4; 1 3])
x = T[2, 4, 3]
non_array_test(x, x)
non_array_test(x, OffsetArray(x, -length(x)))
non_array_test(x, view(x, :))
non_array_test(x, sparse(x))
unary_matrix([1 2; 3 4])
unary_matrix(Symmetric([1 2; 2 4]))
scalar_uniform_scaling(3)
matrix_uniform_scaling([1 2; 3 4])
matrix_uniform_scaling(Symmetric([1 2; 2 4]))
unary_matrix(T[1 2; 3 4])
unary_matrix(Symmetric(T[1 2; 2 4]))
scalar_uniform_scaling(T(3))
matrix_uniform_scaling(T[1 2; 3 4])
matrix_uniform_scaling(Symmetric(T[1 2; 2 4]))
end

0 comments on commit 514a724

Please sign in to comment.