Skip to content

Commit 76577d7

Browse files
committed
expand reduce to vector properly
1 parent 16819ef commit 76577d7

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

src/operations/reduce.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ function Base.reduce(
2929
typeout = eltype(A)
3030
end
3131

32-
if dims == 2 && !(A isa GBVectorOrTranspose)
32+
if dims == 2
3333
w = similar(A, typeout, size(A, 1))
3434
reduce!(op, w, A; desc, accum, mask)
3535
return w
36-
elseif dims == 1 && !(A isa GBVectorOrTranspose)
36+
elseif dims == 1
3737
desc.transpose_input1 = true
3838
w = similar(A, typeout, size(A, 2))
3939
reduce!(op, w, A; desc, accum, mask)
4040
return w
4141
elseif dims == (1,2) || dims == Colon() || A isa GBVectorOrTranspose
42-
mask !== nothing && throw(
42+
mask != C_NULL && throw(
4343
ArgumentError("Reduction to a scalar does not support masking."))
4444
if init === nothing
4545
c = GBScalar{typeout}()

test/operations/reduce.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
@testset "reduce" begin
22
@testset "Reduction of Vec -> Scalar" begin
3-
v = GBVector(1:10)
3+
v = GBVector(Int128.(1:10))
44
@test reduce(+, v) == 55
55
@test reduce(*, v) == 3628800
6+
@test reduce(+, v, dims=1) == 55
7+
@test reduce(+, v, dims=2) == v
68
end
79
end

test/runtests.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,25 @@ SuiteSparseGraphBLAS.@unop foo F=>F
7070
println("Testing SuiteSparseGraphBLAS.jl")
7171
println("$(SuiteSparseGraphBLAS.get_lib())")
7272
@testset "SuiteSparseGraphBLAS" begin
73-
# include_test("libutils.jl")
74-
# include_test("operatorutils.jl")
75-
# include_test("ops.jl")
76-
# include_test("gbarray.jl")
77-
# include_test("issues.jl")
78-
# include_test("operations/ewise.jl")
79-
# include_test("operations/kron.jl")
80-
# include_test("operations/map.jl")
81-
# include_test("operations/mul.jl")
73+
include_test("libutils.jl")
74+
include_test("operatorutils.jl")
75+
include_test("ops.jl")
76+
include_test("gbarray.jl")
77+
include_test("issues.jl")
78+
include_test("operations/ewise.jl")
79+
include_test("operations/kron.jl")
80+
include_test("operations/map.jl")
81+
include_test("operations/mul.jl")
8282
include_test("operations/reduce.jl")
83-
# include_test("operations/select.jl")
84-
# include_test("operations/transpose.jl")
85-
# include_test("operations/broadcasting.jl")
86-
# include_test("operations/concat.jl")
87-
# include_test("chainrules/chainrulesutils.jl")
88-
# include_test("chainrules/mulrules.jl")
89-
# include_test("chainrules/ewiserules.jl")
90-
# include_test("chainrules/selectrules.jl")
91-
# include_test("chainrules/constructorrules.jl")
92-
# include_test("chainrules/maprules.jl")
83+
include_test("operations/select.jl")
84+
include_test("operations/transpose.jl")
85+
include_test("operations/broadcasting.jl")
86+
include_test("operations/concat.jl")
87+
include_test("chainrules/chainrulesutils.jl")
88+
include_test("chainrules/mulrules.jl")
89+
include_test("chainrules/ewiserules.jl")
90+
include_test("chainrules/selectrules.jl")
91+
include_test("chainrules/constructorrules.jl")
92+
include_test("chainrules/maprules.jl")
9393

9494
end

0 commit comments

Comments
 (0)