Questions tagged [assertion]
The assertion tag has no usage guidance.
8
questions
0
votes
0
answers
29
views
Can I avoid FindMinimum ruining my Asserts with symbolic stuff?
I am new with Mathematica, so forgive me if I completely misunderstood the nature of the problem...
Problem description
I want to optimize a fairly complex function bypassing explicit derivative ...
1
vote
0
answers
141
views
How to print local variable when assertion failed
Given the following code:
func[i_] := Module[{k}, k = i; Assert[k > 0, k]];
func[-1]
The output is:
...
20
votes
1
answer
315
views
Confirm vs Throw
Version 12.2 brought us Confirm and Enclose. What's the point? Is it just that it's a slightly more convenient syntax than ...
2
votes
2
answers
213
views
Assert that prints message and aborts computation?
I'd like to add asserts which check for condition, print useful message and abort computation on failure.
IE,
...
3
votes
1
answer
85
views
Improving `$AssertFunction` to always tell what the assertion test resulted in
I really like this form of assertion failure:
On[Assert];
Assert[1 + 1 == True];
Assert::asrttf: Assertion test 1+1==True evaluated to 2==True that is neither ...
17
votes
4
answers
1k
views
stop notebook evaluation when Assert fails
I would like a notebook evaluation to entirely stop when an Assert fails, without quitting the kernel. Is this possible (e.g., by setting ...
4
votes
1
answer
432
views
How to get Mathematica to abort the current evaluation if an assertion fails?
I can turn on assertions, but they don't terminate the current evaluation. For example:
...
34
votes
1
answer
1k
views
which is better, using Assert[] or manual checks on arguments and other computations?
I never used Asserts in Mathematica, but trying to see what advantage they have over just argument check and additional definitions of the function to capture unwanted input.
For example, which one ...