Re: cmset_op question (Craig) [message #38320] |
Thu, 04 March 2004 01:57  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
jbattat@cfa.harvard.edu (James) writes:
> IDL> print, cmset_op(b, 'and' b)
> 1 1
>
> cmset_op returns unique values in the case of an integer array but not
> in the case of a string array.
James, this is a bug. But it's only tickled when you use AND, and
each set has only one unique value, and when those values are equal
between sets. (I complain about RSI, but this is my own dog food
problem). And yes, some integer cases do not tickle the bug.
The fix is to find the following line:
if NOT keyword_set(not1) AND NOT keyword_set(not2) then begin
and add the following code just after it:
;; Special case: if there are one in each set, and
;; they are equal, then the SHIFT() technique below
;; fails. Do this one by hand.
if na EQ 1 AND nb EQ 1 AND uu(0) EQ uu(1) then begin
count = 1L
if kind then return, 0L
return, [uu(0)]
endif
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: cmset_op question (Craig) [message #38403 is a reply to message #38320] |
Thu, 04 March 2004 11:06  |
jbattat
Messages: 8 Registered: November 2003
|
Junior Member |
|
|
Craig,
Thank you for the reply. I will update my code with your fix.
The reason I noticed this problem is that I was using cmset_op to
return the unique values from a list by and-ing the list with itself.
I did notice that if the list had more than one unique value I did not
get the problem, but with only one unique entry (which is the usual
case in my application), the duplicated value was returned (I always
used string arrays).
Take care,
James
Craig Markwardt <craigmnet@REMOVEcow.physics.wisc.edu> wrote in message news:<onvfllgciz.fsf@cow.physics.wisc.edu>...
> jbattat@cfa.harvard.edu (James) writes:
>> IDL> print, cmset_op(b, 'and' b)
>> 1 1
>>
>> cmset_op returns unique values in the case of an integer array but not
>> in the case of a string array.
>
> James, this is a bug. But it's only tickled when you use AND, and
> each set has only one unique value, and when those values are equal
> between sets. (I complain about RSI, but this is my own dog food
> problem). And yes, some integer cases do not tickle the bug.
>
> The fix is to find the following line:
> if NOT keyword_set(not1) AND NOT keyword_set(not2) then begin
>
> and add the following code just after it:
> ;; Special case: if there are one in each set, and
> ;; they are equal, then the SHIFT() technique below
> ;; fails. Do this one by hand.
> if na EQ 1 AND nb EQ 1 AND uu(0) EQ uu(1) then begin
> count = 1L
> if kind then return, 0L
> return, [uu(0)]
> endif
>
> Craig
|
|
|