Skip to content

Commit

Permalink
fix allocation tests on julia-1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
kalmarek committed Dec 9, 2024
1 parent 0ea0688 commit 5ca08fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions test/caching_allocations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ end

@test Y isa AlgebraElement

@static if v"1.10" VERSION < v"1.11"
@static if v"1.10" VERSION
star(Y)
star(Y)
@test (@allocations star(Y)) 4
@test (@allocations star(Y)) 6
end

@test SA.supp(Y) == basis(fRG)[1:k]
Expand All @@ -48,7 +48,7 @@ end
@test all(!iszero(mstr.table))
@test_throws SA.UndefRefError all(!iszero, SA.mstructure(fRG).table)

@static if v"1.10" VERSION < v"1.11"
@static if v"1.10" VERSION
@test (@allocations Y * Y) > k^2 - 2 * k
@test Y * Y isa AlgebraElement
@test (@allocations Y * Y) 26
Expand All @@ -63,15 +63,15 @@ end
@test all(!iszero, SA.mstructure(fRG).table)


@static if v"1.10" VERSION < v"1.11"
@static if v"1.10" VERSION
YY = deepcopy(Y)
_alloc_test(YY, *, Y, Y, 25)
_alloc_test(YY, +, Y, Y, 0)
_alloc_test(YY, -, Y, Y, 0)

# SparseArrays calls `Base.unalias` which allocates:
_alloc_test(YY, +, YY, Y, 2)
_alloc_test(YY, +, Y, YY, 2)
_alloc_test(YY, +, YY, Y, 4)
_alloc_test(YY, +, Y, YY, 4)
end
end

Expand Down
7 changes: 4 additions & 3 deletions test/monoid_algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@
@test_throws ArgumentError MA.operate_to!(d, *, d, b)

d = deepcopy(a)
@test @allocated(MA.operate_to!(d, *, 2, d)) == 0
@test d == 2a

MA.operate_to!(d, *, 2, a) # preallocates memory in coefficients
@test @allocated(MA.operate_to!(d, *, 2, a)) == 0
@test d == 2a

@test @allocated(MA.operate_to!(d, *, 2, d)) == 0
@test d == 4a

MA.operate_to!(d, *, a, b, 2)
@test d == 2 * a * b
end
Expand Down

0 comments on commit 5ca08fb

Please sign in to comment.