Thank you for looking into it! There is still something I do not understand (despite different numerics on different machines, etc.) On my system plain "p == p" (where p's are from runif()) gives all TRUE values, but with q (gset) which memberships values are set to p "q == q" generates FALSE
Apparently memberships values are identical, tags of set members are identical (letters), but "q == q" still generates FALSE... Best regards, Ryszard p <- runif(length(letters)) q <- gset(letters, p) summary(p == p) # gives all TRUE values, but q == q # gives FALSE summary(p == gset_memberships(q)) # and this gives all TRUE values > p <- runif(length(letters)) > q <- gset(letters, p) > summary(p == p) # gives all TRUE values, but Mode TRUE logical 26 > q == q # gives FALSE [1] FALSE > summary(p == gset_memberships(q)) # and this gives all TRUE values Mode TRUE logical 26 > -------------------------------------------------------------------------- Confidentiality Notice: This message is private and may contain confidential and proprietary information. If you have received this message in error, please notify us and remove it from your system and note that you must not copy, distribute or take any action in reliance on it. Any unauthorized use or disclosure of the contents of this message is not permitted and may be unlawful. -----Original Message----- From: David Meyer [mailto:david.me...@wu.ac.at] Sent: Wednesday, April 07, 2010 8:25 AM To: Czerminski, Ryszard Cc: Peter Ehlers; R-help@R-project.org; David Meyer Subject: Re: [R] library sets: A & EMPTY does not work; gset_intersection(A,EMPTY) works >> This is rather by chance due to numeric instabilities, I think: > It looks like something else is going on in addition to potential problem > with numerical instabilities: > > p <- runif(length(letters)) > q <- gset(letters, p) > all.equal(p,p) > all.equal(q,q) > q == q > >> p <- runif(length(letters)) >> q <- gset(letters, p) >> all.equal(p,p) > [1] TRUE >> all.equal(q,q) > [1] "target and current have different memberships" >> q == q > [1] FALSE On my system: > p <- runif(length(letters)) > q <- gset(letters, p) > all.equal(p,p) [1] TRUE > all.equal(q,q) [1] TRUE > q == q [1] TRUE This is the same problem, since the all.equal-method for gsets does not use all.equal internally (which *is* a bug, of course!). Will be fixed ASAP ... Thanks David > > > -------------------------------------------------------------------------- > Confidentiality Notice: This message is private and may contain confidential > and proprietary information. If you have received this message in error, > please notify us and remove it from your system and note that you must not > copy, distribute or take any action in reliance on it. Any unauthorized use > or disclosure of the contents of this message is not permitted and may be > unlawful. > > -----Original Message----- > From: David Meyer [mailto:david.me...@wu.ac.at] > Sent: Tuesday, April 06, 2010 6:03 PM > To: Czerminski, Ryszard > Cc: Peter Ehlers; R-help@R-project.org; David Meyer > Subject: Re: [R] library sets: A & EMPTY does not work; > gset_intersection(A,EMPTY) works > > This is rather by chance due to numeric instabilities, I think: > > > uv <- c('a', 'b', 'c'); s <- gset(uv, runif(length(uv))) > > s > {"a" [0.7533966], "b" [0.968067], "c" [0.2494876]} > > s == s > [1] TRUE > > gset_is_equal(s,s) > [1] TRUE > > But using all.equal instead of `==` for the memberships might by a good > idea, I will have a look at it. > > Thanks > David > > Czerminski, Ryszard wrote: >> Hi Peter, >> >> This looks like another one: "gset_is_equal(X,X)" and "X == X" evaluate to >> FALSE ? >> >>> uv <- c('a', 'b', 'c'); s <- gset(uv, runif(length(uv))) >>> s >> {"a" [0.0811552], "b" [0.3552998], "c" [0.996772]} >>> gset_is_equal(s, s) >> [1] FALSE >>> s == s >> [1] FALSE >>> class(s) >> [1] "gset" "cset" >> >> Best regards, >> Ryszard >> >> >> -------------------------------------------------------------------------- >> Confidentiality Notice: This message is private and may contain confidential >> and proprietary information. If you have received this message in error, >> please notify us and remove it from your system and note that you must not >> copy, distribute or take any action in reliance on it. Any unauthorized use >> or disclosure of the contents of this message is not permitted and may be >> unlawful. >> >> -----Original Message----- >> From: Peter Ehlers [mailto:ehl...@ucalgary.ca] >> Sent: Wednesday, March 31, 2010 2:03 PM >> To: Czerminski, Ryszard >> Cc: R-help@r-project.org; David Meyer >> Subject: Re: [R] library sets: A & EMPTY does not work; >> gset_intersection(A,EMPTY) works >> >> Ryszard, >> >> You've made me take a closer look and now I do think that >> you've found a bug. >> >> After a quick look at the package vignette, I see that the >> authors have indeed overloaded "&" and so it should work for >> your example. The problem seems to be the order of the class >> attribute which is used to call the relevant 'Ops' function: >> >> class(A) >> #[1] "gset" "cset" >> >> class(B) >> #[1] "gset" "cset" >> >> class(E <- A - A) >> #[1] "set" "gset" "cset" >> >> If you re-order the class vector, function Ops.gset will be called >> to handle A and E: >> >> class(E) <- class(E)[c(2,3,1)] >> A & E >> #{} >> >> I've cc'd David Meyer. >> >> -Peter Ehlers >> >> On 2010-03-31 10:11, Czerminski, Ryszard wrote: >>> It seems that "A& B" works the same way as "gset_intersection(A,B)" >>> as long as A and B are not empty... >>> see below: >>> >>> fuzzy_logic("Yager", p=2) >>> support<- universe<- c('a','b','c','d') >>> A<- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0), >>> universe=universe) >>> B<- gset(support=support, memberships=c(0.211, 0.222, 0.999, 0), >>> universe=universe) >>> A >>> B >>> A& B >>> gset_intersection(A,B) >>> E<- A - A >>> A& E >>> gset_intersection(A,E) >>> >>>> fuzzy_logic("Yager", p=2) >>>> support<- universe<- c('a','b','c','d') >>>> A<- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0), >>> universe=universe) >>>> B<- gset(support=support, memberships=c(0.211, 0.222, 0.999, 0), >>> universe=universe) >>>> A >>> {"a" [0.2], "b" [0.2], "c" [0.9]} >>>> B >>> {"a" [0.211], "b" [0.222], "c" [0.999]} >>>> A& B >>> {"c" [0.899995]} >>>> gset_intersection(A,B) >>> {"c" [0.899995]} >>>> E<- A - A >>>> A& E >>> Error in A& E : >>> operations are possible only for numeric or logical types >>> In addition: Warning message: >>> Incompatible methods ("Ops.gset", "Ops.set") for "&" >>>> gset_intersection(A,E) >>> {} >>> >>> >>> -------------------------------------------------------------------------- >>> Confidentiality Notice: This message is private and may contain >>> confidential and proprietary information. If you have received this message >>> in error, please notify us and remove it from your system and note that you >>> must not copy, distribute or take any action in reliance on it. Any >>> unauthorized use or disclosure of the contents of this message is not >>> permitted and may be unlawful. >>> >>> -----Original Message----- >>> From: Peter Ehlers [mailto:ehl...@ucalgary.ca] >>> Sent: Wednesday, March 31, 2010 11:43 AM >>> To: Czerminski, Ryszard >>> Cc: R-help@r-project.org >>> Subject: Re: [R] library sets: A& EMPTY does not work; >>> gset_intersection(A,EMPTY) works >>> >>> On 2010-03-31 9:30, Peter Ehlers wrote: >>>> Unless I'm missing something, I don't see any method >>>> in pkg:sets for intersection other than gset_intersection. >>> Whoops, a bit quick on the draw. >>> There are of course also set_intersection and cset_intersection, >>> but not AFAICS any method for `&`. >>> >>> -Peter Ehlers >>> >>>> So you're using the base R function `&` whose help page >>>> tells you that its arguments should be vectors. Yours >>>> aren't. >>>> >>>> -Peter Ehlers >>>> >>>> On 2010-03-31 8:50, Czerminski, Ryszard wrote: >>>>> When using generalized sets from "sets" library >>>>> >>>>> A& EMPTY does not work, but gset_intersection(A,EMPTY) works: example >>>>> code below >>>>> >>>>> Is it a bug? >>>>> >>>>> Best regards, >>>>> Ryszard >>>>> >>>>> library(sets) >>>>> support<- universe<- c('a','b','c','d') >>>>> A<- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0), >>>>> universe=universe) >>>>> class(A) >>>>> A >>>>> E<- A - A # create empty set >>>>> I<- gset_intersection(A, E) #<<< this WORKS >>>>> class(I); I >>>>> I<- A& E #<<< this DOES NOT WORK >>>>> >>>>> # --- >>>>> >>>>>> support<- universe<- c('a','b','c','d') >>>>>> A<- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0), >>>>> universe=universe) >>>>>> class(A) >>>>> [1] "gset" "cset" >>>>>> A >>>>> {"a" [0.2], "b" [0.2], "c" [0.9]} >>>>>> E<- A - A >>>>>> I<- gset_intersection(A, E) #<<< this WORKS >>>>>> class(I); I >>>>> [1] "set" "gset" "cset" >>>>> {} >>>>>> I<- A& E #<<< this DOES NOT WORK >>>>> Error in A& E : >>>>> operations are possible only for numeric or logical types >>>>> In addition: Warning message: >>>>> Incompatible methods ("Ops.gset", "Ops.set") for "&" >>>>> >>>>> >>>>> >>> ------------------------------------------------------------------------ >>> -- >>>>> Confidentiality Notice: This message is private and may >>> ...{{dropped:8}} >>>>> ______________________________________________ >>>>> R-help@r-project.org mailing list >>>>> https://stat.ethz.ch/mailman/listinfo/r-help >>>>> PLEASE do read the posting guide >>>>> http://www.R-project.org/posting-guide.html >>>>> and provide commented, minimal, self-contained, reproducible code. >>>>> >>>>> > -- Priv.-Doz. Dr. David Meyer Department of Information Systems and Operations WU Wirtschaftsuniversität Wien Vienna University of Economics and Business Augasse 2-6, 1090 Vienna, Austria Tel: +43-1-313-36-4393 Fax: +43-1-313-36-90-4393 HP: http://ec.wu.ac.at/~meyer ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.