Ticket #3103 (closed defect: fixed)
Coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2
| Reported by: | ncalexan | Owned by: | was |
|---|---|---|---|
| Priority: | major | Milestone: | sage-5.7 |
| Component: | linear algebra | Keywords: | vector CDF coerce |
| Cc: | ncalexan, rbradshaw, jason | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Robert Bradshaw |
| Authors: | Charles Bouillaguet | Merged in: | sage-5.7.beta1 |
| Dependencies: | Stopgaps: |
Description
With
sage: version() 'SAGE Version 3.0.1.alpha0, Release Date: 2008-04-26'
I get the following coercion errors:
sage: vector(CDF, [2, 2]) * vector(ZZ, [1, 3]) --------------------------------------------------------------------------- <type 'exceptions.TypeError'> Traceback (most recent call last) /Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/<ipython console> in <module>() /Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/element.pyx in sage.structure.element.Vector.__mul__ (sage/structure/element.c:10413)() /Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/coerce.pyx in sage.structure.coerce.CoercionModel_cache_maps.bin_op_c (sage/structure/coerce.c:5292)() <type 'exceptions.TypeError'>: unsupported operand parent(s) for '*': 'Vector space of dimension 2 over Complex Double Field' and 'Ambient free module of rank 2 over the principal ideal domain Integer Ring' sage: vector(CDF, [2, 2]) * vector(QQ, [1, 3]) --------------------------------------------------------------------------- <type 'exceptions.TypeError'> Traceback (most recent call last) /Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/<ipython console> in <module>() /Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/element.pyx in sage.structure.element.Vector.__mul__ (sage/structure/element.c:10413)() /Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/coerce.pyx in sage.structure.coerce.CoercionModel_cache_maps.bin_op_c (sage/structure/coerce.c:5292)() <type 'exceptions.TypeError'>: unsupported operand parent(s) for '*': 'Vector space of dimension 2 over Complex Double Field' and 'Vector space of dimension 2 over Rational Field'
Attachments
Change History
comment:2 Changed 5 years ago by robertwb
This is not due to coercion, but rather that dot product is not implemented for CDFn.
sage: (CDF^2)([1,2]) * (CDF^2)([2,3]) ------------------------------------------------------------ Traceback (most recent call last): File "<ipython console>", line 1, in <module> File "element.pyx", line 1884, in sage.structure.element.Vector.__mul__ (sage/structure/element.c:10398) File "element.pyx", line 1898, in sage.structure.element.Vector._dot_product_c (sage/structure/element.c:10564) File "element.pyx", line 1904, in sage.structure.element.Vector._dot_product_c_impl (sage/structure/element.c:10649) <type 'exceptions.TypeError'>: unsupported operand parent(s) for '*': 'Vector space of dimension 2 over Complex Double Field' and 'Vector space of dimension 2 over Complex Double Field'
Which, looking at element.pyx line 1904 shows that _dot_product_c_impl was never implemented for CDF. This should almost certainly be a NotImplementedError?, or something like that, not a TypeError?. In fact, there should just be a generic implementation.
comment:3 Changed 5 years ago by ncalexan
- Cc rbradshaw added
- Summary changed from coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 to [with patch, needs review] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2
The attached patch fixes the errors (they were in fact dot_product errors and not coercion) and adds doctests and functionality for preserving inner product matrices.
comment:4 Changed 5 years ago by robertwb
- Summary changed from [with patch, needs review] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 to [with patch, positive review] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2
The patch solves the problem and cleans up a lot of old code.
comment:5 Changed 5 years ago by mabshoff
- Summary changed from [with patch, positive review] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 to [with patch, positive review, needs works] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2
This patch causes a number of doctest failures:
sage -t -long devel/sage/sage/modular/modsym/space.py # 5 doctests failed
sage -t -long devel/sage/sage/modular/modform/constructor.py # 3 doctests failed
sage -t -long devel/sage/sage/modular/hecke/module.py # 12 doctests failed
sage -t -long devel/sage/sage/modular/abvar/abvar_newform.py # 19 doctests failed
sage -t -long devel/sage/sage/modular/abvar/abvar_ambient_jacobian.py # 2 doctests failed
sage -t -long devel/sage/sage/modular/abvar/abvar.py # 3 doctests failed
sage -t -long devel/sage/sage/modular/abvar/homspace.py # 2 doctests failed
Cheers,
Michael
comment:6 Changed 5 years ago by mabshoff
- Summary changed from [with patch, positive review, needs works] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 to [with patch, needs works] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2
comment:8 Changed 4 years ago by AlexGhitza
- Summary changed from [with patch, needs works] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 to [with patch, needs work] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2
comment:9 Changed 4 years ago by jason
In Sage 3.4.1.rc2, this works:
---------------------------------------------------------------------- | Sage Version 3.4.1.rc2, Release Date: 2009-04-10 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: vector(CDF, [2, 2]) * vector(ZZ, [1, 3]) 8.0
So this sounds like it is fixed. However, are there nice doctests from the above patch that could be added to the current code? Nick?
comment:10 Changed 4 years ago by mabshoff
Yes, I agree with Jason. Once we add a patch that adds a doctest this ticket can be merged and closed. By maybe someone ought to check out if Nick's patch contains anything else.
Cheers,
Michael
comment:11 Changed 4 months ago by Bouillaguet
- Status changed from needs_work to needs_review
- Report Upstream set to N/A
- Authors set to Charles Bouillaguet
Since the problem has been fixed, here is a very simple doctest that enforces it won't happen again.
Patchbot !
apply trac_3103_add_doctest.patch
comment:12 Changed 4 months ago by Bouillaguet
took care of stupid TAB in the patch
comment:13 Changed 4 months ago by robertwb
Apply only trac_3103_add_doctest.patch
comment:15 Changed 4 months ago by jdemeyer
- Reviewers set to Robert Bradshaw
- Summary changed from [with patch, needs work] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 to Coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2
- Milestone changed from sage-5.6 to sage-5.7
comment:16 Changed 4 months ago by jdemeyer
- Status changed from positive_review to closed
- Resolution set to fixed
- Merged in set to sage-5.7.beta1

