Skip to content

Commit 8c2c275

Browse files
committed
Relax empty
1 parent e192c11 commit 8c2c275

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/Utilities/matrix_of_constraints.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ mutable struct MatrixOfConstraints{T,AT,BT,ST} <: MOI.ModelLike
101101
BitSet[],
102102
false,
103103
)
104-
MOI.empty!(model)
104+
_reset_caches!(model)
105105
return model
106106
end
107107
end
@@ -303,13 +303,17 @@ function rows end
303303

304304
MOI.is_empty(v::MatrixOfConstraints) = MOI.is_empty(v.sets)
305305

306-
function MOI.empty!(v::MatrixOfConstraints{T}) where {T}
307-
MOI.empty!(v.coefficients)
308-
empty!(v.constants)
309-
MOI.empty!(v.sets)
306+
function _reset_caches!(v::MatrixOfConstraints{T}) where {T}
310307
v.caches =
311308
[Tuple{_affine_function_type(T, S),S}[] for S in set_types(v.sets)]
312309
v.are_indices_mapped = [BitSet() for _ in eachindex(v.caches)]
310+
end
311+
312+
function MOI.empty!(v::MatrixOfConstraints)
313+
MOI.empty!(v.coefficients)
314+
empty!(v.constants)
315+
MOI.empty!(v.sets)
316+
_reset_caches!(v)
313317
v.final_touch = false
314318
return
315319
end

src/Utilities/sparse_matrix.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ function Base.convert(
184184
end
185185

186186
function _first_in_column(
187-
A::MutableSparseMatrixCSC{Tv,Ti},
187+
A::MutableSparseMatrixCSC,
188188
row::Integer,
189189
col::Integer,
190-
) where {Tv,Ti}
190+
)
191191
range = SparseArrays.nzrange(A, col)
192192
row = _shift(row, OneBasedIndexing(), A.indexing)
193193
idx = searchsortedfirst(view(A.rowval, range), row)

0 commit comments

Comments
 (0)