[Thread Prev][Thread Next][Index]

Re: [ferret_users] Masking in list command works for floats, not strings



Hi,

This is definitely a bug. We have a fix for it which will be included in the next release.


On 7/3/2017 2:13 PM, Riede, Hella wrote:
Thanks, Ansley.

Usually, I first define a variable, then list it in a simple way, so that's OK as a workaround for me.

However, there doesn't seem to be a workaround for this one as all variables are defined before listing already:

can var/all
let test = {1,1,0}
let strings = {"a","b","c"}
let masked = if (test) then strings
let masked2 = xsequence(masked)
list masked2
              VARIABLE : XSEQUENCE(MASKED)
              SUBSET   : 3 points (X)
  1   / 1:  1.859-316
  2   / 2:  1.877-316
  3   / 3:  1.877-316

(Last example in mask_string.jnl, see attachment. An extra 'faulty' listing is too big / takes too long for my real dataset.)


Thanks in advance for a hint on this one.


Best wishes,
Hella






On 06/27/2017 11:35 PM, Ansley C. Manke wrote:
Hi Hella,

Thank you for the example.  In principle, specifying an expression as
the argument to a command:

    yes? list if (test) then strings

should be equivalent to defining a variable with that same expression
and sending that to the command:

     yes? let masked = if (test) then strings
     yes? list masked

However there winds up being a slight variation in how the computation
is done with occasionally different and incorrect results. (Here we're
seeing pointers to the strings which should be returned!)  We had a
similar bug report a year or two back which I think has been fixed; I'll
check into this.

Ansley

On 6/27/2017 9:38 AM, Riede, Hella wrote:
Dear ferreters,

I discovered listing while masking seems to work. But not in all cases (see also attached script file with more examples and comments):


yes? let test = {1,1,0}

!! problem with masked strings -> unexpected values
yes? let strings = {"a","b","c"}
yes? list if (test) then strings
               VARIABLE : IF (TEST) THEN STRINGS
               SUBSET   : 3 points (X)
   1   / 1:  2.109-316
   2   / 2:  2.109-316
   3   / 3:  2.109-316
!! repeat the listing, and the values change every time

!! define a masked variable instead, then list - works
yes? let masked = if (test) then strings
yes? list masked
               VARIABLE : IF (TEST) THEN STRINGS
               SUBSET   : 3 points (X)
   1   / 1:"a"
   2   / 2:"b"
   3   / 3:""

!! OR do the same listing for a float first
yes? let floats = {2,3,4}
yes? list if (test) then floats
               VARIABLE : IF (TEST) THEN FLOATS
               SUBSET   : 3 points (X)
   1   / 1:  2.000
   2   / 2:  3.000
   3   / 3:   ....

!! now, also for strings listing while masking works
yes? list if (test) then strings
               VARIABLE : IF (TEST) THEN STRINGS
               SUBSET   : 3 points (X)
   1   / 1:"a"
   2   / 2:"b"
   3   / 3:""


In an interactive ferret session, I first had defined a masked variable for strings (in this example 'masked'), and had also listed it for testing. After that I discovered that listing while masking works too (of course I didn't know it only worked because I had defined and listed the 'masked' variable before, in the same session). So later in my ferret script I omitted defining the 'masked' variable, and used the listing while masking. The script did not crash, but gave me unexpected values like the ones above, instead of proper strings.

Would be good to fix this, or - if the syntax of listing while masking is not supported - to catch these cases and throw an error.

The story goes on, however, see attached script as it seems not possible to mask a string variable and then make an xsequence out of it - unless you do for instance the "faulty listing while masking" from above before the "right" listing.



Best wishes,
Hella

PyFerret v7.11 (beta/optim), Linux 4.4.0-72-generic - 04/19/17



[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement