Difference between revisions of "IgnoreWarnings"
m |
|||
Line 4: | Line 4: | ||
== IgnoreWarnings(e) == | == IgnoreWarnings(e) == | ||
− | Evaluates the expression, | + | Evaluates the expression, «e», while suppressing any warnings that might otherwise be generated during the evaluation of «e». For example, |
− | + | :<code>IgnoreWarnings(Emissions[@Time = @Time + 1])</code> | |
− | We strongly recommend that you keep | + | We strongly recommend that you keep ''Show Result Warnings'' checked in the [[Preferences]] Dialog, since warnings can help you find many modeling errors. But, sometimes you really do want to do something that generates a warning. For example, you may intentionally want to allow an out-of-range subscript, which returns [[Null]] when warnings are ignored. Then you can wrap the expression inside '''IgnoreWarnings''' to suppress the warnings, while leaving ''Show Result Warnings'' checked. |
Line 13: | Line 13: | ||
Judicious use of '''IgnoreWarnings''' can speed up calculation where inner expressions encounter many warning conditions that do not propagate to the final result. Consider: | Judicious use of '''IgnoreWarnings''' can speed up calculation where inner expressions encounter many warning conditions that do not propagate to the final result. Consider: | ||
− | + | :<code>IF X > 0 THEN Sqrt(X) ELSE Sqrt(-X)</code> | |
− | If X is an array, this expression generates a warning condition for every non-zero element of X, since either Sqrt(X) or Sqrt(-X) requires a warning. You won't see these warnings, since none of them make it to the top level. But Analytica must do extra bookkeeping to track the warnings and decide whether it needs to display them. So, it will evaluate more quickly (especially if X large) if you embed the expression inside IgnoreWarnings, i.e.: | + | If <code>X</code> is an array, this expression generates a warning condition for every non-zero element of <code>X</code>, since either [[Sqrt]](X) or [[Sqrt]](-X) requires a warning. You won't see these warnings, since none of them make it to the top level. But Analytica must do extra bookkeeping to track the warnings and decide whether it needs to display them. So, it will evaluate more quickly (especially if <code>X</code> is large) if you embed the expression inside [[IgnoreWarnings]], i.e.: |
− | + | :<code>IgnoreWarnings(IF X > 0 THEN Sqrt(X) ELSE Sqrt(-X))</code> | |
This example is only for illustration -- it would be simpler and faster still to use the equivalent: | This example is only for illustration -- it would be simpler and faster still to use the equivalent: | ||
− | + | :<code>Sqrt(Abs(X))</code> | |
+ | |||
+ | ==See Also== | ||
+ | * [[Warnings]] | ||
+ | * [[Error_Messages|Error messages]] |
Revision as of 01:20, 9 January 2016
IgnoreWarnings(e)
Evaluates the expression, «e», while suppressing any warnings that might otherwise be generated during the evaluation of «e». For example,
IgnoreWarnings(Emissions[@Time = @Time + 1])
We strongly recommend that you keep Show Result Warnings checked in the Preferences Dialog, since warnings can help you find many modeling errors. But, sometimes you really do want to do something that generates a warning. For example, you may intentionally want to allow an out-of-range subscript, which returns Null when warnings are ignored. Then you can wrap the expression inside IgnoreWarnings to suppress the warnings, while leaving Show Result Warnings checked.
Speeding calculations with IgnoreWarnings
Judicious use of IgnoreWarnings can speed up calculation where inner expressions encounter many warning conditions that do not propagate to the final result. Consider:
IF X > 0 THEN Sqrt(X) ELSE Sqrt(-X)
If X
is an array, this expression generates a warning condition for every non-zero element of X
, since either Sqrt(X) or Sqrt(-X) requires a warning. You won't see these warnings, since none of them make it to the top level. But Analytica must do extra bookkeeping to track the warnings and decide whether it needs to display them. So, it will evaluate more quickly (especially if X
is large) if you embed the expression inside IgnoreWarnings, i.e.:
IgnoreWarnings(IF X > 0 THEN Sqrt(X) ELSE Sqrt(-X))
This example is only for illustration -- it would be simpler and faster still to use the equivalent:
Sqrt(Abs(X))
Enable comment auto-refresher