#16269: Cartesian Products of additive groups
-------------------------------------+-------------------------------------
       Reporter:  ncohen             |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.2
      Component:  categories         |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Nathann Cohen,     |    Reviewers:
  Nicolas M. ThiƩry                  |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:  u/ncohen/16269     |  d22e245049e26dd10522d3514603868701a286fb
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by ncohen):

 Yo !

 > - CartesianProduct.__iter__ should be in
 EnumeratedSets.CartesianProducts.ParentMethods

 Done

 > - In ``_add_``, ``self.parent(right)`` looks suspicious. Does it even
 work?
 >   If the purpose is to convert ``right`` into the same parent as
 >   ``self``, then no need to worry about this: ``_add_`` may assume
 >   that its two arguments belong to the same parent.

 That was the reason. Done.

 > - I am uncomfortable with using ``__iter__`` and ``__getitem__`` for
 >   accessing the components of an element. For certain cartesian
 >   products (e.g. cartesian products of modules), ``__iter__`` may have
 >   a different meaning. Please use ``summand_split`` and
 >   ``summand_projection`` instead.

 Here I do not agree. This is the most natural definition of an "iter" for
 a cartesian product. Your application will overrule this anyway, so how
 can that be a problem ?

 > - In ``_element_constructor_``: given the catch, if we feed completely
 >   unrelated crap to the constructor, is there an exception raised as
 >   one could desire?
 > {{{
 >     sage: GF(3)("a")
 >     Traceback (most recent call last)
 >     ...
 >     TypeError: unable to convert x (=a) to an integer
 >
 >     sage: C = cartesian_product([GF(3), GF(3)])
 >     sage: C(["a","b"])
 >     ???
 > }}}

 Okay, so here I am stuck and I can't sort this out. Here is the problem :

 {{{
 sage: FiniteEnumeratedSet(["a","b","c"])("a")
 TypeError: Cannot convert str to sage.structure.element.Element
 sage: FiniteEnumeratedSet(["a","b","c"])("d")
 ValueError: d not in {'a', 'b', 'c'}
 }}}

 Because you cannot trust `FiniteEnumeratedSet` to have a sound `__call__`
 method, I need this try/catch.

 On the other hand, if I have this try/catch, then I cannot detect
 `GF(3)("e")` anymore. So what do we do ?

 I personally see no problem in removing this catch, knowing that cartesian
 products of `FiniteEnumeratedSet` will fail. For me it is because of a bug
 in `FiniteEnumeratedSet`, not of what I implement.

 Nathann

--
Ticket URL: <http://trac.sagemath.org/ticket/16269#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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to