Changes between Version 3 and Version 4 of Ticket #18305


Ignore:
Timestamp:
Apr 29, 2015, 4:13:44 PM (8 years ago)
Author:
Vincent Delecroix
Comment:

I was able to modify six Python elements to use coercion for their comparisons. The code is simplified.

In order to do that, I had to modify slightly the implementation of _richcmp to not catch a TypeError when it calls _richcmp_. We should precise what elements should do when == and != makes sense but not <, <=, >=, >. Is TypeError appropriate?

Vincent


Last 10 new commits:

04570b3Fix bad doctest in etaproducts
3976f2cAdd pointers for special uses of __richcmp__
ce7e4f1merge u/jdemeyer/ticket/17890 in Sage-6.7.beta3
203820bTrac 18305: py_rich_to_bool(_sgn) and operators
c6d3e23Trac 18305: use `_cmp_` for alternating sign matrices
f3e46e3Trac 18305: use _cmp_ for ideals of finite dimensional algebras
b0c39b0Trac 18305: _richcmp_ for indexed monoids and groups
220a140Trac 18305: _richcmp_ for Newton polygons
042b6feTrac 18305: modify Element._richcmp so that _richcmp_ can raise errors
7749fe8Trac 18305: _richcmp_ for `finite dimensional algebra elements

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #18305

    • Property Commit changed from to 7749fe882a88d0978413e9c58b9d2660e0de23a6
    • Property Dependencies changed from #17890, #18303 to #17890
    • Property Branch changed from to u/vdelecroix/18305
    • Property Authors changed from to Vincent Delecroix
  • Ticket #18305 – Description

    v3 v4  
    1010 - comparison is possible via `__cmp__`
    1111
    12 In this ticket:
    13  - make everything needed for rich comparisons available from Python (i.e. `Py_EQ`, `Py_NE`, etc as well as `rich_to_bool/rich_to_bool_sgn`)
    14  - check the sage libraries for occurrences of `__eq__`/`__ne__`/`__cmp__` in elements and see whether these can be simplified
    15      - #18303 takes care of `sage.rings.qqbar`
     12With the current branch:
     13 - make everything needed for rich comparisons available from Python: the branch adds `py_rich_to_bool` and `py_rich_to_bool_sgn` and `op_EQ`, `op_NE`, `op_LT`, `op_LE`, `op_GE` and `op_GT` in `sage.structure.sage_object`
     14 - six elements are modified to use either `_richcmp_` or `_cmp_` instead of `__eq__`/`__ne__`/`__lt__`, etc (and #18303 takes care of `sage.rings.qqbar`)
     15
     16Still to do or discuss:
    1617 - update the documentation in `sage.structure.Element`
    17  - remove the test in the default `Element._cmp_` since an element implementing `__cmp__` wants to avoid coercion
     18 - decide what should we do with respect to `x < y` when this makes no sense (some elements do raise a `TypeError`)
     19 - remove the test in the default `Element._cmp_` since an element implementing `__cmp__` wants to avoid coercion (?)