Hi!

sage: G = CombinatorialFreeModule(ZZ, [1,2,3,4], prefix="G")
sage: y = CombinatorialFreeModule(ZZ, [1,2,3,4], prefix='y')
sage: G is y
False
sage: G == y
True

This is inspite of the fact that CombinatorialFreeModule inherits from
UniqueRepresentation. Namely, it overloads __eq__ and __ne__.

At #14054, I try to make hash and equality test of UniqueRepresentation
faster (using cython) and at the same time I separate two features:
There is a weak instance cache obtained from a new class
CachedRepresentation, and UniqueRepresentation only adds equality test
and hash by identity.

The failure in being a unique parent results in a doctest error in
sage/combinat/free_module.py. It is mere coincidance that the error
occurs with my patch from #14054---the error only occurs if the tests
are executed in a particular order, and can be reproduced as follows:

  sage: F = CombinatorialFreeModule(ZZ, [1,2,3], prefix="F")
  sage: G = CombinatorialFreeModule(ZZ, [1,2,3,4], prefix="G")
  sage: f =   F.monomial(1) + 2 * F.monomial(2)
  sage: g = 2*G.monomial(3) +     G.monomial(4)
  sage: tensor([f, g]) # indirect doctest
  2*F[1] # G[3] + F[1] # G[4] + 4*F[2] # G[3] + 2*F[2] # G[4]
  sage: F = CombinatorialFreeModule(ZZ, [1,2,3], prefix='x')
  sage: G = CombinatorialFreeModule(ZZ, [1,2,3,4], prefix='y')
  sage: f =   F.monomial(1) + 2 * F.monomial(2)
  sage: g = 2*G.monomial(3) +     G.monomial(4)
  sage: latex(tensor([f, g])) # indirect doctest
  Traceback (most recent call last):
  ...
  
/home/simon/SAGE/prerelease/sage-5.6.rc0/local/lib/python2.7/site-packages/sage/categories/modules_with_basis.pyc
  in __call__(self, *args)
     1385         after = args[self._position+1:len(args)]
     1386         x = args[self._position]
  -> 1387         assert(x.parent() is self.domain())
     1388 
     1389         if self._is_module_with_basis_over_same_base_ring:
  AssertionError: 

Problem: The tensor construction relies on a cached method. Cached
methods compare by equality. That's why two tensor constructions
involving equal distinct parents are problematic: The assertion in
modules_with_basis.py asks for identity, but the cache only cares about
equality.

Do you have an idea how to solve this problem?

When I tried to make CombinatorialFreeModule truly unique, other tests
broke badly. But perhaps it would work to replace cached_method by a
different way of caching tensor products, using identity and not
equality on the arguments, such that "A is not A'" and
"A==A'" would imply "tensor(A,B) is not tensor(A',B)" and
"tensor(A,B)==tensor(A',B)".

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-combinat-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to