Skip to content

Commit 8cf1c26

Browse files
authored
Remove the temporary skip. (#74)
1 parent 8d397cc commit 8cf1c26

File tree

2 files changed

+20
-34
lines changed

2 files changed

+20
-34
lines changed

src/sparsematrix.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,10 +1921,8 @@ _mapreducezeros(f, op::Union{typeof(Base.mul_prod),typeof(*)},::Type{T}, nzeros:
19211921
nzeros == 0 ? op(one(v0), v0) : op(f(zero(T))^nzeros, v0)
19221922
_mapreducezeros(f, op::Union{typeof(min),typeof(max)}, ::Type{T}, nzeros::Integer, v0) where {T} =
19231923
nzeros == 0 ? v0 : op(v0, f(zero(T)))
1924-
if isdefined(Base, :_extrema_rf)
1925-
_mapreducezeros(f::Base.ExtremaMap, op::typeof(Base._extrema_rf), ::Type{T}, nzeros::Integer, v0) where {T} =
1926-
nzeros == 0 ? v0 : op(v0, f(zero(T)))
1927-
end
1924+
_mapreducezeros(f::Base.ExtremaMap, op::typeof(Base._extrema_rf), ::Type{T}, nzeros::Integer, v0) where {T} =
1925+
nzeros == 0 ? v0 : op(v0, f(zero(T)))
19281926

19291927
function Base._mapreduce(f, op::typeof(*), ::Base.IndexCartesian, A::AbstractSparseMatrixCSC{T}) where T
19301928
nzeros = widelength(A)-nnz(A)

test/higherorderfns.jl

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -709,51 +709,39 @@ end
709709
@test extrema(f, x) == extrema(f, y)
710710
@test extrema(spzeros(n, n)) == (0.0, 0.0)
711711
@test extrema(spzeros(n)) == (0.0, 0.0)
712-
# TODO: Remove the temporary skip once https://github.com/JuliaLang/julia/pull/43604 is merged
713-
if isdefined(Base, :_extrema_rf)
714-
@test_throws "reducing over an empty" extrema(spzeros(0, 0))
715-
@test_throws "reducing over an empty" extrema(spzeros(0))
716-
end
712+
@test_throws "reducing over an empty" extrema(spzeros(0, 0))
713+
@test_throws "reducing over an empty" extrema(spzeros(0))
717714
@test extrema(sparse(ones(n, n))) == (1.0, 1.0)
718715
@test extrema(sparse(ones(n))) == (1.0, 1.0)
719716
@test extrema(A; dims=:) == extrema(B; dims=:)
720717
@test extrema(A; dims=1) == extrema(B; dims=1)
721718
@test extrema(A; dims=2) == extrema(B; dims=2)
722719
@test extrema(A; dims=(1,2)) == extrema(B; dims=(1,2))
723720
@test extrema(f, A; dims=1) == extrema(f, B; dims=1)
724-
# TODO: Remove the temporary skip once https://github.com/JuliaLang/julia/pull/43604 is merged
725-
if isdefined(Base, :_extrema_rf)
726-
@test_throws "reducing over an empty" extrema(sparse(C); dims=1) == extrema(C; dims=1)
727-
end
721+
@test_throws "reducing over an empty" extrema(sparse(C); dims=1) == extrema(C; dims=1)
728722
@test extrema(A; dims=[]) == extrema(B; dims=[])
729723
@test extrema(x; dims=:) == extrema(y; dims=:)
730724
@test extrema(x; dims=1) == extrema(y; dims=1)
731725
@test extrema(f, x; dims=1) == extrema(f, y; dims=1)
732-
# TODO: Remove the temporary skip once https://github.com/JuliaLang/julia/pull/43604 is merged
733-
if isdefined(Base, :_extrema_rf)
734-
@test_throws "reducing over an empty" extrema(sparse(z); dims=1)
735-
end
726+
@test_throws "reducing over an empty" extrema(sparse(z); dims=1)
736727
@test extrema(x; dims=[]) == extrema(y; dims=[])
737728
end
738729

739-
# TODO: Remove the temporary skip once https://github.com/JuliaLang/julia/pull/43604 is merged
740-
if isdefined(Base, :_extrema_rf)
741-
function test_extrema(a; dims_test = ((), 1, 2, (1,2), 3))
742-
for dims in dims_test
743-
vext = extrema(a; dims)
744-
vmin, vmax = minimum(a; dims), maximum(a; dims)
745-
@test all(x -> isequal(x[1], x[2:3]), zip(vext,vmin,vmax))
746-
end
730+
function test_extrema(a; dims_test = ((), 1, 2, (1,2), 3))
731+
for dims in dims_test
732+
vext = extrema(a; dims)
733+
vmin, vmax = minimum(a; dims), maximum(a; dims)
734+
@test all(x -> isequal(x[1], x[2:3]), zip(vext,vmin,vmax))
747735
end
748-
@testset "NaN test for sparse extrema" begin
749-
for sz = (3, 10, 100)
750-
A = sprand(sz, sz, 0.3)
751-
A[rand(1:sz^2,sz)] .= NaN
752-
test_extrema(A)
753-
A = sprand(sz*sz, 0.3)
754-
A[rand(1:sz^2,sz)] .= NaN
755-
test_extrema(A; dims_test = ((), 1, 2))
756-
end
736+
end
737+
@testset "NaN test for sparse extrema" begin
738+
for sz = (3, 10, 100)
739+
A = sprand(sz, sz, 0.3)
740+
A[rand(1:sz^2,sz)] .= NaN
741+
test_extrema(A)
742+
A = sprand(sz*sz, 0.3)
743+
A[rand(1:sz^2,sz)] .= NaN
744+
test_extrema(A; dims_test = ((), 1, 2))
757745
end
758746
end
759747

0 commit comments

Comments
 (0)