Opened 7 years ago

Last modified 6 years ago

#18251 new defect

CombinatorialFreeModule should use coercion for comparisons — at Version 9

Reported by: tscrim Owned by: tscrim
Priority: critical Milestone: sage-7.4
Component: coercion Keywords: zero
Cc: nthiery, darij, nbruin, robertwb, chapoton, vdelecroix Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #21128 Stopgaps:

Status badges

Description (last modified by jdemeyer)

Currently we have the following in Sage:

sage: C = CombinatorialFreeModule(QQ, ['a','b'])
sage: C.zero() == ZZ(0)
True
sage: C.zero() == QQ(0)
False

This should be fixed by using coercing comparison (_cmp_ or _richcmp_).

Change History (9)

comment:1 Changed 6 years ago by jdemeyer

  • Description modified (diff)
  • Summary changed from Equality comparison with 0 is not consistant to CombinatorialFreeModule should use coercion for comparisons

comment:2 Changed 6 years ago by jdemeyer

  • Cc chapoton added
  • Description modified (diff)

comment:3 Changed 6 years ago by jdemeyer

  • Description modified (diff)
  • Milestone changed from sage-6.7 to sage-7.4

comment:4 Changed 6 years ago by jdemeyer

  • Cc vdelecroix added

comment:5 Changed 6 years ago by jdemeyer

  • Description modified (diff)

comment:6 Changed 6 years ago by jdemeyer

Part of the problem is that there is no coercion defined anyway:

sage: C = CombinatorialFreeModule(QQ, ['a','b'])
sage: C.coerce(QQ(0))
TypeError: no canonical coercion from Rational Field to Free module generated by {'a', 'b'} over Rational Field

This makes sense, but it means that the problem is different from what I originally thought.

comment:7 Changed 6 years ago by jdemeyer

  • Description modified (diff)

comment:8 Changed 6 years ago by jdemeyer

And the coercion model has an explicit special case for ZZ(0).

comment:9 Changed 6 years ago by jdemeyer

  • Dependencies set to #21128
  • Description modified (diff)
Note: See TracTickets for help on using tickets.