Difference between revisions of "Warnings"
Line 17: | Line 17: | ||
Analytica displays warning conditions detected while evaluating an expression ''only if ''the resulting value assigned to a variable contains an explicit error. In the following example, the <code>NAN</code> resulting from evaluating <code>Sqrt(X)</code> for negative <code>X</code> does not appear in the result, so it does not display a warning: | Analytica displays warning conditions detected while evaluating an expression ''only if ''the resulting value assigned to a variable contains an explicit error. In the following example, the <code>NAN</code> resulting from evaluating <code>Sqrt(X)</code> for negative <code>X</code> does not appear in the result, so it does not display a warning: | ||
− | :<code>Variable Z := IF X<0 THEN 0 ELSE Sqrt(X) </code> | + | :<code>Variable Z := IF X < 0 THEN 0 ELSE Sqrt(X) </code> |
:<code>Z → [0, 0, 0, 1, 1.414]</code> | :<code>Z → [0, 0, 0, 1, 1.414]</code> | ||
Line 28: | Line 28: | ||
The common warning “subscript or slice value out of range” returns <code>Null</code>, for example: | The common warning “subscript or slice value out of range” returns <code>Null</code>, for example: | ||
:<code>Index I := 1..5 </code> | :<code>Index I := 1..5 </code> | ||
− | :<code>X[I=6] → Null</code> | + | :<code>X[I = 6] → Null</code> |
If you want to ignore warnings for a single variable, you can use the '''IgnoreWarnings()''' function around the definition. | If you want to ignore warnings for a single variable, you can use the '''IgnoreWarnings()''' function around the definition. |
Revision as of 03:57, 7 December 2015
Warnings can occur during evaluation, for example when trying to take the square root of a negative number, for example:
Variable X := Sequence(-2, 2)
Variable Y := Sqrt(X)
This Warning dialog gives you the option to ignore this and future warnings. If you select Ignore Warnings, Y yields:
Y → [NAN, NAN, 0, 1, 1.414]
The NAN
values can be propagated further into a model.
NAN
or NULL
results for unknown reasons. If this happens, you can switch warnings back on by checking Show result warnings in the Preferences dialog.Analytica displays warning conditions detected while evaluating an expression only if the resulting value assigned to a variable contains an explicit error. In the following example, the NAN
resulting from evaluating Sqrt(X)
for negative X
does not appear in the result, so it does not display a warning:
Variable Z := IF X < 0 THEN 0 ELSE Sqrt(X)
Z → [0, 0, 0, 1, 1.414]
Because (X<0
) evaluates to an array containing both True
(1) and False
(0) values, the expression evaluates Sqrt(X)
, and generates NAN
as for Y
above. But, the conditional means that resulting value for Z
contains no NANs
, and so Analytica generates no warning when Z
is evaluated.
You can also make use of the return value, even if it might be errant, as in the following example:
VAR x := Sqrt(y);
IF IsNaN(x) THEN 0 ELSE x
The common warning “subscript or slice value out of range” returns Null
, for example:
Index I := 1..5
X[I = 6] → Null
If you want to ignore warnings for a single variable, you can use the IgnoreWarnings() function around the definition.
Enable comment auto-refresher