Difference between revisions of "Warnings"
DKontotasiou (talk | contribs) (Created page with "Category:Analytica User Guide <languages /> <translate> Analytica User Guide > Using Expressions > Warnings Warnings can occur during evaluation, for example...") |
m (→See Also) |
||
(11 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | [[Category:Analytica User Guide]] | + | [[Category: Analytica User Guide]] |
− | + | [[Category: Error messages]] | |
− | < | + | |
− | + | <breadcrumbs>Analytica User Guide > Expressions > {{PAGENAME}}</breadcrumbs> | |
+ | |||
Warnings can occur during evaluation, for example when trying to take the square root of a negative number, for example: | Warnings can occur during evaluation, for example when trying to take the square root of a negative number, for example: | ||
− | :<code>Variable X := Sequence(-2, 2) </code> | + | :<code>Variable X := [[Sequence]](-2, 2) </code> |
− | :<code>Variable Y := Sqrt(X) </code> | + | :<code>Variable Y := [[Sqrt]](X) </code> |
− | [[File:Chapter10 6.png]] | + | :[[File:Chapter10 6.png]] |
This '''Warning '''dialog gives you the option to ignore this and future warnings. If you select '''Ignore Warnings''', '''Y '''yields: | This '''Warning '''dialog gives you the option to ignore this and future warnings. If you select '''Ignore Warnings''', '''Y '''yields: | ||
:<code>Y → [NAN, NAN, 0, 1, 1.414]</code> | :<code>Y → [NAN, NAN, 0, 1, 1.414]</code> | ||
− | The | + | The [[NaN]] values can be propagated further into a model. |
− | <tip title="Tip">If you click the '''Ignore warnings '''button, it will ignore all warnings from this variable and all other variables in this and future sessions with this model. Ignoring warnings could lead to you getting | + | <tip title="Tip">If you click the '''Ignore warnings '''button, it will ignore all warnings from this variable and all other variables in this and future sessions with this model. Ignoring warnings could lead to you getting [[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.</tip> |
− | 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 | + | 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 [[Sqrt]](X) for negative <code>X</code> does not appear in the result, so it does not display a warning: |
− | :<code>Variable Z := | + | :<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> | ||
− | Because (<code>X<0</code>) evaluates to an array containing both <code>True</code> (1) and <code>False</code> (0) values, the expression evaluates <code>Sqrt(X)</code>, and generates <code>NAN</code> as for <code>Y</code> above. But, the conditional means that resulting value for <code>Z</code> contains no <code> | + | Because (<code>X < 0</code>) evaluates to an array containing both <code>True</code> (1) and <code>False</code> (0) values, the expression evaluates <code>Sqrt(X)</code>, and generates <code>NAN</code> as for <code>Y</code> above. But, the conditional means that resulting value for <code>Z</code> contains no <code>NAN</code>s, and so Analytica generates no warning when <code>Z</code> is evaluated. |
You can also make use of the return value, even if it might be errant, as in the following example: | You can also make use of the return value, even if it might be errant, as in the following example: | ||
− | :<code>VAR x := Sqrt(y);</code> | + | :<code>VAR x := [[Sqrt]](y);</code> |
− | :<code> | + | :<code>[[If]] [[IsNaN]](x) [[Then]] 0 [[Else]] x</code> |
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 | + | If you want to ignore warnings for a single variable, you can use the [[IgnoreWarnings]]() function around the definition. |
==See Also== | ==See Also== | ||
− | + | * [[IgnoreWarnings]] | |
− | + | * [[Error Message Types]] | |
− | + | * [[Help menu and documentation]] | |
− | + | * [[Expression Assist]] | |
− | </ | + | * [[The Expression popup menu]] |
+ | * [[Sys_WarningsToIgnore]] (should rarely use) | ||
+ | |||
+ | <footer>INF, NAN, and NULL - Exception values / {{PAGENAME}} / Datatype functions</footer> |
Latest revision as of 21:25, 7 July 2021
Warnings can occur during evaluation, for example when trying to take the square root of a negative number, for example:
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.
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:
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 NAN
s, 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:
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