Skip to content
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

Allow disabling DCP warnings #372

Merged
merged 4 commits into from
Mar 5, 2020
Merged

Allow disabling DCP warnings #372

merged 4 commits into from
Mar 5, 2020

Conversation

ericphanson
Copy link
Collaborator

@ericphanson ericphanson commented Mar 5, 2020

Fixes #362

I'm not a big fan of globals (and I spent some time getting rid of them in #322), but since we emit this warning even on things like x = Variable; y = Variable(); x*y, there doesn't seem like a good place to pass in an argument warn=false. Arguably we could only do the check when calculating the vexity of a Problem, and then pass warning info through the problem constructor. (We would need to also make sure you can see the check before starting a solve, etc..)

However, (1) the way the vexity of a Problem is written currently is a little strange and I'd prefer not to mess with it yet, and (2) it might be helpful that we are very eager to warn on non-DCPness (i.e., on x*y instead of waiting for the user to put that inside a Problem or call a solve!), because it can help formulate a DCP problem easily, checking along the way, especially when you are first learning the rules.

So for these reasons, I think a simple fix to the current way of emitting the warnings is best, namely to just check if warnings are enabled from a global before issuing one. In the interests of thread safety (since that appears to be a useful thing to do with Convex: #370), I followed the pattern of https://discourse.julialang.org/t/attempting-to-make-my-module-code-threadsafe/30434/2 of making a vector of parameters indexed by threadid(). I think the same pattern is also used for Julia's RNG. I used atomics, and added some for the other globals (for printing width and depth).

@ericphanson ericphanson merged commit 6a5ffd8 into master Mar 5, 2020
@ericphanson ericphanson deleted the DCP_warnings branch March 5, 2020 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[Request] Ability to suppress "vexity check" warnings
1 participant