#16836: __neg__ fails in CartesianProduct of CombinatorialFreeModule
------------------------------+------------------------
       Reporter:  cnassau     |        Owner:
           Type:  defect      |       Status:  new
       Priority:  major       |    Milestone:  sage-6.4
      Component:  categories  |   Resolution:
       Keywords:              |    Merged in:
        Authors:              |    Reviewers:
Report Upstream:  N/A         |  Work issues:
         Branch:              |       Commit:
   Dependencies:              |     Stopgaps:
------------------------------+------------------------

Comment (by cnassau):

 The fix appears to be quite simple:

 {{{#!diff
 --- a/src/sage/categories/additive_magmas.py
 +++ b/src/sage/categories/additive_magmas.py
 @@ -918,8 +918,8 @@ class AdditiveMagmas(Category_singleton):
                              ...
                              AssertionError
                      """
 -                    return self.parent()(
 -                        -x for x in self.cartesian_factors())
 +                    return self.parent()._cartesian_product_of_elements(
 +                       [-x for x in self.cartesian_factors()])
 }}}

 This breaks a doctest, however:
 {{{
 File "src/sage/categories/additive_magmas.py", line 903, in
 
sage.categories.additive_magmas.AdditiveMagmas.AdditiveUnital.CartesianProducts.ElementMethods.__neg__
 Failed example:
     -c
 Expected:
     Traceback (most recent call last):
     ...
     ValueError: Value -42 in not in Non negative integers.
 Got:
     (-1, -42, -1.00000000000000)
 }}}

 The fix for that doctest would be to move a sanity check from `_neg_` to
 `CartesianProduct._cartesian_product_of_elements`. That then breaks a
 design-comment in the latter routine about being optimized for speed.

 Alternatively, the doctest could be removed (my choice). We don't want an
 implicit sanity-check whenever we negate an element of a cartesian
 product.

 This is therefore the sort of code/bug that only the original author can
 fix.

--
Ticket URL: <http://trac.sagemath.org/ticket/16836#comment:1>
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