#5598: [with patch, needs work] allow post-creation (pre-use) declaration of
coercions
----------------------+-----------------------------------------------------
 Reporter:  robertwb  |       Owner:  robertwb  
     Type:  defect    |      Status:  new       
 Priority:  major     |   Milestone:  sage-4.0.1
Component:  coercion  |    Keywords:            
----------------------+-----------------------------------------------------

Comment(by mhansen):

 I merged

 {{{
 5598-coerce-declare.patch
 5598-ncalexan-fixes-and-tests.3.patch
 5598-test-coercion.patch
 }}}

 and got the following failures:

 {{{
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 863:
     sage: K.unset_coercions_used()
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_21[5]>", line 1, in <module>
         K.unset_coercions_used()###line 863:
     sage: K.unset_coercions_used()
     AttributeError: 'PolynomialRing_integral_domain' object has no
 attribute 'unset_coercions_used'
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 864:
     sage: K.register_coercion(L_into_K)
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_21[6]>", line 1, in <module>
         K.register_coercion(L_into_K)###line 864:
     sage: K.register_coercion(L_into_K)
       File "parent.pyx", line 853, in
 sage.structure.parent.Parent.register_coercion
 (sage/structure/parent.c:7450)
         cpdef register_coercion(self, mor):
       File "parent.pyx", line 878, in
 sage.structure.parent.Parent.register_coercion
 (sage/structure/parent.c:7239)
         assert not self._coercions_used, "coercions must all be registered
 up before use"
     AssertionError: coercions must all be registered up before use
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 866:
     sage: K(0) + b
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_21[7]>", line 1, in <module>
         K(Integer(0)) + b###line 866:
     sage: K(0) + b
       File "element.pyx", line 729, in
 sage.structure.element.ModuleElement.__add__
 (sage/structure/element.c:6533)
         return coercion_model.bin_op(left, right, add)
       File "coerce.pyx", line 740, in
 sage.structure.coerce.CoercionModel_cache_maps.bin_op
 (sage/structure/coerce.c:6589)
         raise TypeError, arith_error_message(x,y,op)
     TypeError: unsupported operand parent(s) for '+': 'Univariate
 Polynomial Ring in a over Integer Ring' and 'Univariate Polynomial Ring in
 b over Integer Ring'
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 868:
     sage: a + b
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_21[8]>", line 1, in <module>
         a + b###line 868:
     sage: a + b
       File "element.pyx", line 729, in
 sage.structure.element.ModuleElement.__add__
 (sage/structure/element.c:6533)
         return coercion_model.bin_op(left, right, add)
       File "coerce.pyx", line 740, in
 sage.structure.coerce.CoercionModel_cache_maps.bin_op
 (sage/structure/coerce.c:6589)
         raise TypeError, arith_error_message(x,y,op)
     TypeError: unsupported operand parent(s) for '+': 'Univariate
 Polynomial Ring in a over Integer Ring' and 'Univariate Polynomial Ring in
 b over Integer Ring'
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 870:
     sage: K(b) # check that convert calls coerce first; normally this is
 just a
 Expected:
     -a
 Got:
     a
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 873:
     sage: L(0) + a in K # this goes through the coercion mechanism of K
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_21[10]>", line 1, in <module>
         L(Integer(0)) + a in K # this goes through the coercion mechanism
 of K###line 873:
     sage: L(0) + a in K # this goes through the coercion mechanism of K
       File "element.pyx", line 729, in
 sage.structure.element.ModuleElement.__add__
 (sage/structure/element.c:6533)
         return coercion_model.bin_op(left, right, add)
       File "coerce.pyx", line 740, in
 sage.structure.coerce.CoercionModel_cache_maps.bin_op
 (sage/structure/coerce.c:6589)
         raise TypeError, arith_error_message(x,y,op)
     TypeError: unsupported operand parent(s) for '+': 'Univariate
 Polynomial Ring in b over Integer Ring' and 'Univariate Polynomial Ring in
 a over Integer Ring'
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 931:
     sage: R.unset_coercions_used()
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_22[12]>", line 1, in <module>
         R.unset_coercions_used()###line 931:
     sage: R.unset_coercions_used()
     AttributeError: 'sage.rings.polynomial.multi_polynomial_libsingular'
 object has no attribute 'unset_coercions_used'
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 945:
     sage: R.unset_coercions_used()
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_22[16]>", line 1, in <module>
         R.unset_coercions_used()###line 945:
     sage: R.unset_coercions_used()
     AttributeError: 'sage.rings.polynomial.multi_polynomial_libsingular'
 object has no attribute 'unset_coercions_used'
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 975:
     sage: K.unset_coercions_used()
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_23[5]>", line 1, in <module>
         K.unset_coercions_used()###line 975:
     sage: K.unset_coercions_used()
     AttributeError: 'PolynomialRing_integral_domain' object has no
 attribute 'unset_coercions_used'
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 976:
     sage: K.register_conversion(M_into_K)
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_23[6]>", line 1, in <module>
         K.register_conversion(M_into_K)###line 976:
     sage: K.register_conversion(M_into_K)
       File "parent.pyx", line 965, in
 sage.structure.parent.Parent.register_conversion
 (sage/structure/parent.c:8015)
         cpdef register_conversion(self, mor):
       File "parent.pyx", line 985, in
 sage.structure.parent.Parent.register_conversion
 (sage/structure/parent.c:7825)
         assert not self._coercions_used, "coercions must all be registered
 up before use"
     AssertionError: coercions must all be registered up before use
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 1016:
     sage: K.unset_coercions_used()
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_24[7]>", line 1, in <module>
         K.unset_coercions_used()###line 1016:
     sage: K.unset_coercions_used()
     AttributeError: 'NumberField_quadratic' object has no attribute
 'unset_coercions_used'
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 1017:
     sage: K.register_embedding(K_into_MS)
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_24[8]>", line 1, in <module>
         K.register_embedding(K_into_MS)###line 1017:
     sage: K.register_embedding(K_into_MS)
       File "parent.pyx", line 1000, in
 sage.structure.parent.Parent.register_embedding
 (sage/structure/parent.c:8246)
         cpdef register_embedding(self, embedding):
       File "parent.pyx", line 1039, in
 sage.structure.parent.Parent.register_embedding
 (sage/structure/parent.c:8084)
         assert not self._coercions_used, "coercions must all be registered
 up before use"
     AssertionError: coercions must all be registered up before use
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 1022:
     sage: L.unset_coercions_used()
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_24[12]>", line 1, in <module>
         L.unset_coercions_used()###line 1022:
     sage: L.unset_coercions_used()
     AttributeError: 'NumberField_quadratic' object has no attribute
 'unset_coercions_used'
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 1023:
     sage: L.register_embedding(L_into_MS)
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_24[13]>", line 1, in <module>
         L.register_embedding(L_into_MS)###line 1023:
     sage: L.register_embedding(L_into_MS)
       File "parent.pyx", line 1000, in
 sage.structure.parent.Parent.register_embedding
 (sage/structure/parent.c:8246)
         cpdef register_embedding(self, embedding):
       File "parent.pyx", line 1039, in
 sage.structure.parent.Parent.register_embedding
 (sage/structure/parent.c:8084)
         assert not self._coercions_used, "coercions must all be registered
 up before use"
     AssertionError: coercions must all be registered up before use
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 1025:
     sage: K.coerce_embedding()(a)
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_24[14]>", line 1, in <module>
         K.coerce_embedding()(a)###line 1025:
     sage: K.coerce_embedding()(a)
     TypeError: 'NoneType' object is not callable
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 1028:
     sage: L.coerce_embedding()(b)
 Exception raised:
     Traceback (most recent call last):
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1231, in run_one_test
         self.run_one_example(test, example, filename, compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/sagedoctest.py",
 line 38, in run_one_example
         OrigDocTestRunner.run_one_example(self, test, example, filename,
 compileflags)
       File
 
"/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/local/bin/ncadoctest.py",
 line 1172, in run_one_example
         compileflags, 1) in test.globs
       File "<doctest __main__.example_24[15]>", line 1, in <module>
         L.coerce_embedding()(b)###line 1028:
     sage: L.coerce_embedding()(b)
     TypeError: 'NoneType' object is not callable
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 1032:
     sage: a.matrix() * b
 Expected:
     [-272118       0]
     [      0    -462]
 Got:
     [           0      b521155]
     [-462*b521155            0]
 **********************************************************************
 File "/scratch/mhansen/release/4.0.1/alpha0/sage-4.0.1.alpha0/devel/sage-
 main/sage/structure/parent.pyx", line 1035:
     sage: a * b.matrix()
 Expected:
     [-272118       0]
     [      0    -462]
 Got:
     [              0         a161099]
     [-272118*a161099               0]
 **********************************************************************
 4 items had failures:
    6 of  12 in __main__.example_21
    2 of  19 in __main__.example_22
    2 of   9 in __main__.example_23
    8 of  18 in __main__.example_24
 ***Test Failed*** 18 failures.
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5598#comment:19>
Sage <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to