Skip to content

Commit

Permalink
Prep for v1.0 release and drop support for pre Julia 1.6 versions (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Feb 15, 2022
1 parent 549f25b commit bcafec7
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 91 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
# MutableArithmetics doesn't have any binary dependencies, so just test
# on Linux, LTS and current release, 64-bit and 32-bit.
include:
- version: '1.0'
- version: '1.6'
os: ubuntu-latest
arch: x86
- version: '1.0'
- version: '1.6'
os: ubuntu-latest
arch: x64
- version: '1'
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
# Build documentation on Julia 1.0
version: '1.0'
version: '1.6'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MutableArithmetics"
uuid = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
authors = ["Gilles Peiffer", "Benoît Legat", "Sascha Timme"]
version = "0.3.3"
version = "1.0.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -10,7 +10,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
OffsetArrays = "1"
julia = "1"
julia = "1.6"

[extras]
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Expand Down
10 changes: 3 additions & 7 deletions src/Test/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ function non_array_test(x, x2)
@test_throws AssertionError diagm(x2)
else
@test MA.isequal_canonical(diagm(0 => x), diagm(0 => x2))
if VERSION >= v"1.2"
@test MA.isequal_canonical(diagm(x), diagm(x2))
end
@test MA.isequal_canonical(diagm(x), diagm(x2))
end
end
end
Expand All @@ -295,10 +293,8 @@ function dot_test(x)
@test_rewrite dot(A, x)
@test_rewrite dot(x, A)

if VERSION >= v"1.1"
y = repeat(x, outer = (one.(size(x))..., size(x, 1)))
@test_rewrite dot(x, _constant(x)) - dot(y, _constant(y))
end
y = repeat(x, outer = (one.(size(x))..., size(x, 1)))
@test_rewrite dot(x, _constant(x)) - dot(y, _constant(y))
end

function sum_test(matrix)
Expand Down
61 changes: 24 additions & 37 deletions src/dispatch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,23 @@ end

# TODO: LinearAlgebra should have a documented function so that we don't have to
# overload an internal function
if VERSION >= v"1.5.0-rc1.23"
function LinearAlgebra._dot_nonrecursive(
lhs::AbstractArray{<:AbstractMutable},
rhs::AbstractArray,
)
return fused_map_reduce(add_mul, lhs, rhs)
end
function LinearAlgebra._dot_nonrecursive(
lhs::AbstractArray,
rhs::AbstractArray{<:AbstractMutable},
)
return fused_map_reduce(add_mul, lhs, rhs)
end
function LinearAlgebra._dot_nonrecursive(
lhs::AbstractArray{<:AbstractMutable},
rhs::AbstractArray{<:AbstractMutable},
)
return fused_map_reduce(add_mul, lhs, rhs)
end
function LinearAlgebra._dot_nonrecursive(
lhs::AbstractArray{<:AbstractMutable},
rhs::AbstractArray,
)
return fused_map_reduce(add_mul, lhs, rhs)
end
function LinearAlgebra._dot_nonrecursive(
lhs::AbstractArray,
rhs::AbstractArray{<:AbstractMutable},
)
return fused_map_reduce(add_mul, lhs, rhs)
end
function LinearAlgebra._dot_nonrecursive(
lhs::AbstractArray{<:AbstractMutable},
rhs::AbstractArray{<:AbstractMutable},
)
return fused_map_reduce(add_mul, lhs, rhs)
end

function LinearAlgebra.dot(
Expand Down Expand Up @@ -72,24 +70,13 @@ end
# fill!(::Array{AbstractVariableRef}, zero(GenericAffExpr{Float64,eltype(x)}))
_one_indexed(A) = all(x -> isa(x, Base.OneTo), axes(A))

if VERSION <= v"1.2"
function LinearAlgebra.diagm_container(
kv::Pair{<:Integer,<:AbstractVector{<:AbstractMutable}}...,
)
T = promote_type(map(x -> eltype(x.second), kv)...)
U = promote_type(T, promote_operation(zero, T))
n = mapreduce(x -> length(x.second) + abs(x.first), max, kv)
return zeros(U, n, n)
end
else
function LinearAlgebra.diagm_container(
size,
kv::Pair{<:Integer,<:AbstractVector{<:AbstractMutable}}...,
)
T = promote_type(map(x -> promote_type(eltype(x.second)), kv)...)
U = promote_type(T, promote_operation(zero, T))
return zeros(U, LinearAlgebra.diagm_size(size, kv...)...)
end
function LinearAlgebra.diagm_container(
size,
kv::Pair{<:Integer,<:AbstractVector{<:AbstractMutable}}...,
)
T = promote_type(map(x -> promote_type(eltype(x.second)), kv)...)
U = promote_type(T, promote_operation(zero, T))
return zeros(U, LinearAlgebra.diagm_size(size, kv...)...)
end

function LinearAlgebra.diagm(x::AbstractVector{<:AbstractMutable})
Expand Down
6 changes: 1 addition & 5 deletions src/implementations/BigFloat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ function mutable_copy(x::BigFloat)
return Base.MPFR._BigFloat(x.prec, x.sign, x.exp, d′)
end

@static if VERSION >= v"1.1.0-DEV.683"
const _MPFRRoundingMode = Base.MPFR.MPFRRoundingMode
else
const _MPFRRoundingMode = Int32
end
const _MPFRRoundingMode = Base.MPFR.MPFRRoundingMode

# zero

Expand Down
2 changes: 1 addition & 1 deletion test/big.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end
allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 240 : 0)
# Requires https://github.com/JuliaLang/julia/commit/3f92832df042198b2daefc1f7ca609db38cb8173
# for `gcd` to be defined on `Rational`.
if T == BigInt || (T == Rational{BigInt} && VERSION >= v"1.4.0-DEV.606")
if T == BigInt || T == Rational{BigInt}
allocation_test(gcd, T, MA.gcd!!, MA.gcd_to!!, 0)
allocation_test(lcm, T, MA.lcm!!, MA.lcm_to!!, 0)
end
Expand Down
16 changes: 6 additions & 10 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ const MA = MutableArithmetics
@test a == [4, 5]
# Need to have immutable structs that contain references to be allocated on
# the stack: https://github.com/JuliaLang/julia/pull/33886
if VERSION >= v"1.5"
alloc_test(() -> MA.broadcast!!(+, a, b), 0)
alloc_test(() -> MA.broadcast!!(+, a, c), 0)
end
alloc_test(() -> MA.broadcast!!(+, a, b), 0)
alloc_test(() -> MA.broadcast!!(+, a, c), 0)
end
@testset "BigInt" begin
x = BigInt(1)
Expand All @@ -25,10 +23,8 @@ end
@test a == [4, 5]
@test x == 4
@test y == 5
if VERSION >= v"1.5"
# FIXME This should not allocate but I couldn't figure out where these
# 240 come from.
alloc_test(() -> MA.broadcast!!(+, a, b), 240)
alloc_test(() -> MA.broadcast!!(+, a, c), 0)
end
# FIXME This should not allocate but I couldn't figure out where these
# 240 come from.
alloc_test(() -> MA.broadcast!!(+, a, b), 30 * sizeof(Int))
alloc_test(() -> MA.broadcast!!(+, a, c), 0)
end
8 changes: 3 additions & 5 deletions test/dispatch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ end

@testset "Dispatch tests" begin
dispatch_tests(BigInt)
if VERSION >= v"1.5"
# On `DummyBigInt` allocates more on previous releases of Julia
# as it's dynamically allocated
dispatch_tests(DummyBigInt)
end
# On `DummyBigInt` allocates more on previous releases of Julia
# as it's dynamically allocated
dispatch_tests(DummyBigInt)
end
30 changes: 10 additions & 20 deletions test/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,16 @@ const EXPECTED_ERROR = string(
"`Matrix{NoProdMutable}` because the sum of the product of a ",
"`NoProdMutable` and a `NoProdMutable` could not be inferred so a ",
"`Matrix{Union{}}` allocated to store the output of the ",
"multiplication instead of a `Matrix{Int64}`.",
"multiplication instead of a `Matrix{$(Int)}`.",
)

struct NoProdMutable <: MA.AbstractMutable end
@static if VERSION < v"1.6"
# Hack for making the test work on old Julia versions
Base.:*(::NoProdMutable, ::NoProdMutable) = error(EXPECTED_ERROR)
else
function MA.promote_operation(
::typeof(*),
::Type{NoProdMutable},
::Type{NoProdMutable},
)
return Int # Dummy result just to test error message
end
function MA.promote_operation(
::typeof(*),
::Type{NoProdMutable},
::Type{NoProdMutable},
)
return Int # Dummy result just to test error message
end

function unsupported_product()
Expand All @@ -99,14 +94,9 @@ end
@testset "Dimension mismatch" begin
A = zeros(1, 1)
B = zeros(2, 2)
# Changed by https://github.com/JuliaLang/julia/pull/33567
if VERSION >= v"1.4.0-DEV.307"
err = DimensionMismatch(
"dimensions must match: a has dims (Base.OneTo(1), Base.OneTo(1)), b has dims (Base.OneTo(2), Base.OneTo(2)), mismatch at 1",
)
else
err = DimensionMismatch("dimensions must match")
end
err = DimensionMismatch(
"dimensions must match: a has dims (Base.OneTo(1), Base.OneTo(1)), b has dims (Base.OneTo(2), Base.OneTo(2)), mismatch at 1",
)
@test_throws err MA.@rewrite A + B
x = ones(1)
y = ones(2)
Expand Down

2 comments on commit bcafec7

@odow
Copy link
Member Author

@odow odow commented on bcafec7 Feb 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/54726

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.0 -m "<description of version>" bcafec7bc6ff0079fa26e9f9bed34590859ae94f
git push origin v1.0.0

Please sign in to comment.