File tree Expand file tree Collapse file tree 4 files changed +58
-0
lines changed Expand file tree Collapse file tree 4 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -264,6 +264,29 @@ function test_convert()
264
264
return
265
265
end
266
266
267
+ function test_inverse_hash ()
268
+ d = CleverDicts. CleverDict {Int,String} (identity, identity)
269
+ key = CleverDicts. add_item (d, " a" )
270
+ @test d[key] == " a"
271
+ return
272
+ end
273
+
274
+ function test_resize ()
275
+ d = CleverDicts. CleverDict {MOI.VariableIndex,String} ()
276
+ resize! (d, 1 )
277
+ @test length (d. vector) == 1
278
+ x = CleverDicts. add_item (d, " a" )
279
+ @test_throws (
280
+ ErrorException (
281
+ " CleverDict cannot be resized to a size smaller than the current" ,
282
+ ),
283
+ resize! (d, 0 ),
284
+ )
285
+ delete! (d, x)
286
+ resize! (d, 0 )
287
+ return
288
+ end
289
+
267
290
end # module
268
291
269
292
TestCleverDicts. runtests ()
Original file line number Diff line number Diff line change @@ -1093,6 +1093,19 @@ function test_deprecated_copy_free_variables()
1093
1093
return
1094
1094
end
1095
1095
1096
+ function test_index_map ()
1097
+ src = MOI. Utilities. Model {Float64} ()
1098
+ x, c_z = MOI. add_constrained_variable (src, MOI. ZeroOne ())
1099
+ dest = MOI. Utilities. Model {Float64} ()
1100
+ index_map = MOI. copy_to (dest, src)
1101
+ @test collect (keys (index_map)) == Any[x, c_z]
1102
+ delete! (index_map, x)
1103
+ @test collect (keys (index_map)) == Any[c_z]
1104
+ delete! (index_map, c_z)
1105
+ @test collect (keys (index_map)) == Any[]
1106
+ return
1107
+ end
1108
+
1096
1109
end # module
1097
1110
1098
1111
TestCopy. runtests ()
Original file line number Diff line number Diff line change @@ -2179,6 +2179,27 @@ function test_deprecated_eval_term()
2179
2179
return
2180
2180
end
2181
2181
2182
+ function test_cannonicalize_Variable ()
2183
+ x = MOI. VariableIndex .(1 : 2 )
2184
+ f = MOI. VectorOfVariables (x)
2185
+ @test MOI. Utilities. canonicalize! (x[1 ]) === x[1 ]
2186
+ @test MOI. Utilities. canonicalize! (f) === f
2187
+ return
2188
+ end
2189
+
2190
+ function test_filter_variables_variable_index ()
2191
+ f = MOI. VariableIndex (1 )
2192
+ @test MOI. Utilities. filter_variables (x -> x. value == 1 , f) === f
2193
+ @test_throws (
2194
+ ErrorException (
2195
+ " Cannot remove variable from a `VariableIndex` function of the " *
2196
+ " same variable." ,
2197
+ ),
2198
+ MOI. Utilities. filter_variables (x -> x. value == 0 , f),
2199
+ )
2200
+ return
2201
+ end
2202
+
2182
2203
end # module
2183
2204
2184
2205
TestUtilitiesFunctions. runtests ()
Original file line number Diff line number Diff line change @@ -222,6 +222,7 @@ function test_set_dot_scaling(n = 10)
222
222
N = div (n * (n + 1 ), 2 )
223
223
M = N + div (n * (n - 1 ), 2 )
224
224
v = MOI. Utilities. SymmetricMatrixScalingVector {Float64} (1.5 , 0.5 , N)
225
+ @test size (v) == (N,)
225
226
w = MOI. Utilities. SymmetricMatrixScalingVector {Float64} (1.5 , N)
226
227
s = MOI. Utilities. symmetric_matrix_scaling_vector (Float64, N)
227
228
s32 = MOI. Utilities. symmetric_matrix_scaling_vector (Float32, N)
You can’t perform that action at this time.
0 commit comments