Opened 13 years ago

Closed 11 years ago

#3638 closed defect (fixed)

Vector equality coercion problems

Reported by: jbmohler Owned by: malb
Priority: major Milestone: sage-4.3.1
Component: algebra Keywords:
Cc: Merged in: sage-4.3.1.rc1
Authors: Robert Bradshaw Reviewers: Mike Hansen
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


I think this bit of code should not produce an exception. The vectors should both be coerced to belong to Z8^3 and compared.

sage: Z8=IntegerModRing(8)
sage: vector(ZZ,[1,2,11])==vector(Z8,[1,2,3])
AttributeError                            Traceback (most recent call last)
AttributeError: 'FreeModule_ambient' object has no attribute 'ambient_vector_space'

Note that a similar thing seems to work in other cases (because 7 is prime and Z7 is a field?).

sage: Z7=IntegerModRing(7)
sage: vector(ZZ,[1,2,10])==vector(Z7,[1,2,3])

This may or may not be related, but combining QQ and Z7 produces some wrong results:

sage: Z7=IntegerModRing(7)
sage: vector(Z7,[1,2,3])==vector(QQ,[1,2,3])

That those vectors are not equal is truly disturbing. This should either raise an exception about not having compatible parents or should be True. I'll let the coercion guru's argue about that. :)

Attachments (1)

3638-free-module-coerce.patch (1.4 KB) - added by robertwb 11 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 12 years ago by malb

  • Owner changed from tbd to malb
  • Status changed from new to assigned

Changed 11 years ago by robertwb

comment:2 Changed 11 years ago by robertwb

  • Report Upstream set to N/A
  • Status changed from new to needs_review

Fixed the Z/8Z case. As for Z/7Z and Q, they are incomparable, which by convention means == returns False. (If it gave an error,we would have to re-think nonsense like "some string" != random_matrix(ZZ, 3) returning False).

comment:3 Changed 11 years ago by mhansen

  • Authors set to Robert Bradshaw
  • Reviewers set to Mike Hansen
  • Status changed from needs_review to positive_review

Looks good to me.

comment:4 Changed 11 years ago by rlm

  • Merged in set to sage-4.3.1.rc1
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.