Skip to content

Commit ee20e19

Browse files
committed
Fix type conversion for weird orders
1 parent 2ab1c47 commit ee20e19

3 files changed

Lines changed: 24 additions & 22 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseMatrixColorings"
22
uuid = "0a514795-09f3-496d-8182-132a7b665d35"
33
authors = ["Guillaume Dalle", "Alexis Montoison"]
4-
version = "0.4.15"
4+
version = "0.4.16"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/order.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function DegreeBuckets(::Type{T}, degrees::Vector{<:Integer}, dmax::Integer) whe
144144
deg_count[d + 1] += 1
145145
end
146146
# bucket limits
147-
bucket_high = cumsum(deg_count)
147+
bucket_high = convert(Vector{T}, cumsum(deg_count))
148148
bucket_low = vcat(zero(T), @view(bucket_high[1:(end - 1)]))
149149
bucket_low .+= 1
150150
# assign each vertex to the correct position inside its degree class
@@ -253,7 +253,7 @@ function vertices(
253253
if degree_increasing(; degtype, direction)
254254
degrees = zeros(T, nb_vertices(g))
255255
else
256-
degrees = [degree(g, v) for v in vertices(g)]
256+
degrees = T[degree(g, v) for v in vertices(g)]
257257
end
258258
db = DegreeBuckets(T, degrees, maximum_degree(g))
259259
π = T[]

test/type_stability.jl

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -178,25 +178,27 @@ end;
178178
(:nonsymmetric, :bidirectional, :direct),
179179
(:nonsymmetric, :bidirectional, :substitution),
180180
]
181-
result = coloring(
182-
A,
183-
ColoringProblem(; structure, partition),
184-
GreedyColoringAlgorithm(; decompression);
185-
)
186-
if partition in (:column, :bidirectional)
187-
@test eltype(column_colors(result)) == Int32
188-
@test eltype(column_groups(result)[1]) == Int32
189-
end
190-
if partition in (:row, :bidirectional)
191-
@test eltype(row_colors(result)) == Int32
192-
@test eltype(row_groups(result)[1]) == Int32
193-
end
194-
if partition == :bidirectional
195-
Br, Bc = compress(A, result)
196-
@test decompress(Br, Bc, result) isa SparseMatrixCSC{Float32,Int32}
197-
else
198-
B = compress(A, result)
199-
@test decompress(B, result) isa SparseMatrixCSC{Float32,Int32}
181+
for order in (NaturalOrder(), RandomOrder(), LargestFirst(), DynamicLargestFirst())
182+
result = coloring(
183+
A,
184+
ColoringProblem(; structure, partition),
185+
GreedyColoringAlgorithm(order; decompression);
186+
)
187+
if partition in (:column, :bidirectional)
188+
@test eltype(column_colors(result)) == Int32
189+
@test eltype(column_groups(result)[1]) == Int32
190+
end
191+
if partition in (:row, :bidirectional)
192+
@test eltype(row_colors(result)) == Int32
193+
@test eltype(row_groups(result)[1]) == Int32
194+
end
195+
if partition == :bidirectional
196+
Br, Bc = compress(A, result)
197+
@test decompress(Br, Bc, result) isa SparseMatrixCSC{Float32,Int32}
198+
else
199+
B = compress(A, result)
200+
@test decompress(B, result) isa SparseMatrixCSC{Float32,Int32}
201+
end
200202
end
201203
end
202204
end

0 commit comments

Comments
 (0)