Difference between revisions of "Error Messages/40512"

 
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
= Examples of Message =
+
[[Category: Error messages]]
  
In call to function [[Bernoulli]], the first parameter, p, should be greater than or equal to zero, but the array passed for this parameter contains a value that is not numeric and non-negative at coordinate:
+
== Examples of message ==
  Time=2012
 
  Plant='N337'
 
  
== General form of message ==
+
<pre style="background:white; border:white; margin-left: 1em; font-style:italic">
 +
In the call to function Bernoulli, the first parameter, «p», should be greater than
 +
or equal to zero, but the array passed for this parameter contains a value that is either
 +
negative or non-numeric at coordinate:
 +
  Time = 2012
 +
  Plant = 'N337'
 +
</pre>
  
In call to function «fn», the «nth» parameter, «name», should be greater than or equal to zero, but the array passed for this parameter contains a value that is not numeric and non-negative at coordinate:
+
General form of the message:
  «coord»
 
  
= Why this occurs =
+
<pre style="background:white; border:white; margin-left: 1em; font-style:italic">
 +
In the call to function «fn», the «nth» parameter, «name», should be greater than
 +
or equal to zero, but the array passed for this parameter contains a value that is either
 +
negative or non-negative at coordinate:
 +
«coord»
 +
</pre>
  
You are calling a function, where the «nth» parameter is declared as NonNegative.  You are passing an array of values to this parameter, and at least one of those values, the one at the indicated coordinate of the array, contains a value that is either non-numeric (e.g., textual, [[Null]], etc), or is negative.
+
== Cause ==
 +
You are calling a function, where the ''n''<sup>th</sup> parameter is declared as NonNegative.  You are passing an array of values to this parameter, and at least one of those values, the one at the indicated coordinate of the array, contains a value that is either non-numeric (e.g., textual, [[Null]], etc), or is negative.
  
= Tricks for debugging =
+
Alternatively, this error may also occur when an index (which was intended to have numeric values) is defined as a list-of-labels, rather than as a list -- looking like numeric values, but in fact text values like: <code>['0%', '10%', ...]</code>.
  
Try copying and pasting the expression for the «nth» parameter into a different variable, say Va1.  Then view its result table and find the coordinate that was listed in the error message.  This will help you determine what the value is, and from there you can trace back to figure out why.
+
==Remedies==
  
= Work Arounds =
+
Try copying and pasting the expression for the ''n''th parameter into a different variable, say <code>Va1</code>.  Then view its result table and find the coordinate that was listed in the error message.  This will help you determine what the value is, and from there you can trace back to figure out why.
  
 
Suppose you'd like to call the function for all the non-negative numeric cases, and just return [[Null]] for those cases that violate the parameter declaration.
 
Suppose you'd like to call the function for all the non-negative numeric cases, and just return [[Null]] for those cases that violate the parameter declaration.
  
 
If there is only one parameter at fault, and if that parameter expects a scalar, you could replace the original call:
 
If there is only one parameter at fault, and if that parameter expects a scalar, you could replace the original call:
  F(...,someExpr,...)
+
:<code>F(..., someExpr,...)</code>
 +
 
 
with
 
with
  [[Var..Do|Var]] tmp[]:=someExpr Do [[If]] [[IsNumber]](tmp) and tmp>=0 then F(...,tmp,...) else [[Null]]
+
:<code>Var tmp[] := someExpr Do If IsNumber(tmp) and tmp >= 0 then F(..., tmp,...) else Null</code>
  
If the parameter at fault expects an array indexed by I,J, the same trick can be adapted like this:
+
If the parameter at fault expects an array indexed by <code>I, J</code>, the same trick can be adapted like this:
  [[Var..Do|Var]] tmp[I,J]:=someExpr Do [[If]] Min([[IsNumber]](tmp) and tmp>=0,I,J) then F(...,tmp,...) else [[Null]]
+
:<code>Var tmp[I, J]:=someExpr Do If Min(IsNumber(tmp) and tmp >= 0, I, J) then F(...,tmp,...) else Null</code>
  
Notice that F gets called only if every element in the I,J slice is non-negative and numeric.
+
Notice that <code>F</code> gets called only if every element in the <code>I, J</code> [[slice]] is non-negative and numeric.
  
 
If more than one parameter is bad, rather than extend the above trick with several [[Var..Do]] declarations, for each parameter, it is slightly more efficient to create a user-defined wrapper function, having the same parameter declaration as the original, but with the non-negative qualifier removed.  For the example of [[Binomial]], this would be:
 
If more than one parameter is bad, rather than extend the above trick with several [[Var..Do]] declarations, for each parameter, it is slightly more efficient to create a user-defined wrapper function, having the same parameter declaration as the original, but with the non-negative qualifier removed.  For the example of [[Binomial]], this would be:
  
  Function MyBinomial(n,p : atomic ; over:...optional atomic)  
+
:<code>Function MyBinomial(n, p: atomic; over:...optional atomic)</code>
  Definition: If [[IsNumber]](p) and [[IsNumber]](n) and and p>=0 and n>=0 then [[Binomial]](n,p) else [[Null]]
+
:<code>Definition: If IsNumber(p) and IsNumber(n) and and p >= 0 and n >= 0 then Binomial(n, p) else Null</code>
 
 
This is slightly more efficient than multiple [[Var..Do]] declarations because the function call can coordinate the iteration over any indexes shared between n and p.  In the original [[Binomial]], both n and p are declared as NonNegative.
 
  
= User Experiences =
+
This is slightly more efficient than multiple [[Var..Do]] declarations because the function call can coordinate the iteration over any indexes shared between <code>n</code> and <code>p</code>.  In the original [[Binomial]], both <code>n</code> and <code>p</code> are declared as NonNegative.
  
== Please contribute ==
+
If the index was defined as a list-of-labels, rather than as a list, select the definition and change the definition type pulldown from "list of labels" to just "list".  Then remove the quotes.
  
If you encountered this error and had trouble finding the root cause, or learned something new from the experience that might help in understanding the problem if it ever occurs again, please document it on this page for others.
+
==See Also==
 +
* [[Arrays and Indexes]]
 +
* [[Slice]]
 +
* [[Function calls and parameters]]
 +
* [[Function parameter qualifiers]]
 +
* [[Numbers]]
 +
* [[IsNumber]]
 +
* [[If]]
 +
* [[Var..Do]]
 +
* [[Binomial]]

Latest revision as of 20:19, 29 March 2016


Examples of message

 In the call to function Bernoulli, the first parameter, «p», should be greater than 
 or equal to zero, but the array passed for this parameter contains a value that is either
 negative or non-numeric at coordinate:
   Time = 2012
   Plant = 'N337'

General form of the message:

In the call to function «fn», the «nth» parameter, «name», should be greater than 
or equal to zero, but the array passed for this parameter contains a value that is either 
negative or non-negative at coordinate:
«coord»

Cause

You are calling a function, where the nth parameter is declared as NonNegative. You are passing an array of values to this parameter, and at least one of those values, the one at the indicated coordinate of the array, contains a value that is either non-numeric (e.g., textual, Null, etc), or is negative.

Alternatively, this error may also occur when an index (which was intended to have numeric values) is defined as a list-of-labels, rather than as a list -- looking like numeric values, but in fact text values like: ['0%', '10%', ...].

Remedies

Try copying and pasting the expression for the nth parameter into a different variable, say Va1. Then view its result table and find the coordinate that was listed in the error message. This will help you determine what the value is, and from there you can trace back to figure out why.

Suppose you'd like to call the function for all the non-negative numeric cases, and just return Null for those cases that violate the parameter declaration.

If there is only one parameter at fault, and if that parameter expects a scalar, you could replace the original call:

F(..., someExpr,...)

with

Var tmp[] := someExpr Do If IsNumber(tmp) and tmp >= 0 then F(..., tmp,...) else Null

If the parameter at fault expects an array indexed by I, J, the same trick can be adapted like this:

Var tmp[I, J]:=someExpr Do If Min(IsNumber(tmp) and tmp >= 0, I, J) then F(...,tmp,...) else Null

Notice that F gets called only if every element in the I, J slice is non-negative and numeric.

If more than one parameter is bad, rather than extend the above trick with several Var..Do declarations, for each parameter, it is slightly more efficient to create a user-defined wrapper function, having the same parameter declaration as the original, but with the non-negative qualifier removed. For the example of Binomial, this would be:

Function MyBinomial(n, p: atomic; over:...optional atomic)
Definition: If IsNumber(p) and IsNumber(n) and and p >= 0 and n >= 0 then Binomial(n, p) else Null

This is slightly more efficient than multiple Var..Do declarations because the function call can coordinate the iteration over any indexes shared between n and p. In the original Binomial, both n and p are declared as NonNegative.

If the index was defined as a list-of-labels, rather than as a list, select the definition and change the definition type pulldown from "list of labels" to just "list". Then remove the quotes.

See Also

Comments


You are not allowed to post comments.