[kepler-dev] [Bug 2240] - add support for null values to data passing among ports

bugzilla-daemon@ecoinformatics.org bugzilla-daemon at ecoinformatics.org
Thu Feb 9 10:31:41 PST 2006


------- Additional Comments From cxh at eecs.berkeley.edu  2006-02-09 10:31 -------
[I'm going to try to keep most of the email in the null value bug so 
that I don't lose track while I'm on vacation 2/15-2/28]

Hi Dan,
Yep, Token.toString() returns "nil"
cxh at carson 46% $PTII/bin/ptjacl
% set token [java::new ptolemy.data.Token]
% $token nil
% $token toString

One big problem is that Tokens are supposed to be immutable, so we need
a constructor that will set the Token to nil.  We need constructors for
all the Tokens that will set them to nil.  I'm a little unclear on the type
of a nil Token.  In many ways it is of type "General", where it can be 
used anywhere.

I need to set up a way to create nil tokens of a particular type using
the expression actor.  I'm thinking that a function call nil() that takes
a type would be the way to go.  Thus nil("double") would create a nil
DoubleToken.  I've not thought about this much though.

Once we have that, we can create ArraysTokens that have nil elements.

The notion of logical arrays sounds like it could be implemented without
much effort.


Dan writes:
> Hi Christopher,
>     I don't know if you guys discussed this or not, but in looking at
> the RExpression actor I noted that I use the the Token 'toString()'
> method. Thus, if 'at' is an arrayToken containing the 3 integers 1,2,3,
> then at.toString() is used to create the string "{1,2,3}".
>     So the question is, if one of the tokens in an array is 'nil', then
> what is the result of the 'toString()' method?
>     The R system just returns the string 'NA'. If Ptolemy returned 'NA'
> or maybe 'nil' that would make it easy to convert the RExpression actor.
> In any case, it seems to me that it would be useful to have Kepler/PT
> return some string value for 'toString' when a token has the nil
> property rather than throw an exception.
>     On a slightly different topic, we talked about an actor that would
> take an array with nils and produce a smaller array without nils. A
> somewhat more general approach used in R that might be very useful is
> the idea of of a 'logical array'. We can certainly have an array of
> boolean values, but R uses a logical array to select parts of another
> array of the same dimensions. In other words, one could use an actor
> that has two array inputs, one a logical array and the other any other
> kind of array with the same dimension. The resulting output is a smaller
> array where only those values corresponding to true values in the
> logical array are retained. Thus, one would remove nils by creating a
> logical array from some arrays where nil values are 'false' and then
> combining that logical array with the original.
> Dan

More information about the Kepler-dev mailing list