#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):
Replying to [comment:9 nthiery]:
> Replying to [comment:7 cnassau]:
> > I think this is also how my patch implements this (which does not
quite follow the description in my original submission).
> >
> > In my patch function equality is tested like this:
> >
> > * finite family: brute force check of all values
> > * infinite family: check if function objects are identical
>
> There is a slight difference: I prefer the distinction to be based on
> the class, namely whether we are manipulating two FiniteFamily's or
> not.
This has some really bad consequences if (as I believe) we're __not__ able
to reliably test functions for equality. We would then have to live with
{{{
sage: LazyFamily([1,2,3], lambda i:i) == LazyFamily([1,2,3], lambda
i:i)
False
}}}
I would find it better to use a brute force check for those finite index
sets that implement a `list()` method:
{{{
try:
for i in self.set.list():
if self.function(i) != other.function(i):
return False
return True
except NotImplementedError:
pass
}}}
As noted in `src/categories/enumerated_sets.py` a set can choose to not
implement `list` if it is probably too large to be useful.
> By the way, please use:
> {{{
> for i in self.set:
> }}}
>
> rather than:
> {{{
> lst = list(self.set)
> for i in lst
> }}}
The idea was to use `self.set.list()` as explained above, because then the
exhaustive check would be skipped for sets that are too big and know about
it.
> > It occured to me that we should also try this:
> >
> > * comparison of the pickle-string of the function objects
>
> This sounds reasonable, but needs to be heavily tested for all sorts
> of function objects.
I've changed my mind: this is not at all a good idea: in my tests an
`unpickle_function(lambda i:i)` includes a reference to the doctest where
it was defined. That's not good at all if we want to test for function
equality... for similar reasons it seems bad to use the bytecode
disassembly from the dis module...
Could you live with the `self.set.list()` suggestion?
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13814#comment:10>
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.