-
-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add better tests for shapes #3808
Comments
@blegat: could you sketch what you had in mind here? Adding some default tests for the shapes doesn't help us show that we use the appropriate shape for a constraint? (Which was the issue here.) |
I think it can just be something like function test_shape(primal, dual, shape)
vec_primal = vectorize(primal, shape)
vec_dual = vectorize(dual, dual_shape(shape))
@test primal = reshape(vec_primal, shape)
@test dual == reshape(vec_dual, dual_shape(shape))
@test dot(primal, dual) == dot(vec_primal, vec_dual)
end |
Sure. But this doesn't really help us catch the fact that the solver might return a "different" value to the one we expected (if we didn't think clearly) for the dual. That would just tell us that Symmetric works. But it would't help tell us we needed the adjoint? (Unless we know good values for primal and dual to test?) |
You're right, then we can do something like: function test_shape(primal, dual, con::VectorConstraint)
vec_primal = vectorize(primal, con.shape)
vec_dual = vectorize(dual, dual_shape(con.shape))
@test primal = reshape(vec_primal, con.shape)
@test dual == reshape(vec_dual, dual_shape(con.shape))
@test dot(primal, dual) == MOI.Utilities.set_dot(vec_primal, vec_dual, con.set)
end |
We could test that the dot product before and after reshaping is the same.
This would catch issues like #3797
The text was updated successfully, but these errors were encountered: