#13814: LazyFamily.__eq__ gives false positives.
------------------------------------+---------------------------------------
       Reporter:  cnassau           |         Owner:  sage-combinat
           Type:  defect            |        Status:  needs_review 
       Priority:  major             |     Milestone:  sage-5.6     
      Component:  combinatorics     |    Resolution:               
       Keywords:                    |   Work issues:               
Report Upstream:  N/A               |     Reviewers:               
        Authors:  Christian Nassau  |     Merged in:               
   Dependencies:                    |      Stopgaps:               
------------------------------------+---------------------------------------

Comment (by cnassau):

 > Should I remove the previous patch? Then we won't have to specify
 > which patch to apply.

 Yes, please! I would do it myself if I knew how to do it ;-)

 > A couple questions:
 >
 > Would there be a problem to just compare the functions with:
 > {{{
 >    self.function == other.function
 > }}}
 > Rather than doing the check for is and then for eq?

 No problem, that's definitly better.

 > I am surprised about your comment about Permutations not being
 > picklable. This works for me:
 > {{{
 >   sage: P = Permutations(3)
 >   sage: P == Permutations(3)
 >   True
 >   sage: P == loads(dumps(P))
 >   True
 > }}}

 This is really an issue with {{{sage.misc.fpickle}}}: the function "``n ->
 Permutations(n)``" can be pickled, but the unpickled version has forgotten
 the default value of the second argument of {{{Permutations(n,k)}}}:
 {{{#!python
    sage: f = Permutations
    sage: from sage.misc.fpickle import pickle_function, unpickle_function
    sage: g = unpickle_function(pickle_function(f))
    sage: print f(5)
    Standard permutations of 5
    sage: print g(5)
    Traceback (most recent call last):
    ...
    TypeError: Permutations() takes exactly 2 arguments (1 given)
 }}}

 > Could the hash be calculated using both the hash of the indexing set
 > and the function?

 I'm now using the sum of both hashes.

 > Please take the occasion to rewrite {{{WARNING}}} into
 > {{{.. WARNING::}}} (see the developers manual for the exact syntax).

 Fixed.

 > Where is ``!=`` implemented?

 That's a good question: ``grep`` could find a handful of {{{__ne__}}} in
 the Sage code base, but none that would be a candidate for
 {{{LazyFamily.__ne__}}}. The python manual clearly says that one should
 define {{{__ne__}}} if {{{__eq__}}} is defined; that appears not to be the
 case in class {{{SageObject}}}, so my guess is that Python is using a
 default implementation.

 By the way, both {{{Parent}}} and {{{SageObject}}} seem to test the
 consistency of {{{__eq__}}} and {{{__ne__}}} in the test suite.

 Cheers,\\
 Christian

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13814#comment:18>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to