#5417: Fix some more deepcopy issues (followup to #5403)
-----------------------------+----------------------------------------------
 Reporter:  mabshoff         |       Owner:  justin  
     Type:  defect           |      Status:  new     
 Priority:  major            |   Milestone:  sage-3.4
Component:  quadratic forms  |    Keywords:          
-----------------------------+----------------------------------------------

Comment(by tornaria):

 The patch in #5403 fixes the function {{{scale_by_factor}}} in
 {{{quadratic_form__variable_substitutions.py}}}, by replacing the use of
 {{{copy.deepcopy}}} + {{{__init__}}} by a call to the constructor.

 The issue with this is that the caches for some functions are copied,
 hence the results may be incorrect. There seem to be more instances of
 this bug in the quadratic_forms code, hence this ticket, but that one is
 the only one currently triggered by the following doctest (this only
 happens ''after'' applying the {{{import *}}} fix in #5403 without the
 {{{deepcopy}}} fix):
 {{{
         sage: Q = QuadraticForm(ZZ, 3, [2, -2, 0, 3, -5, 4])
         sage: Q.jordan_blocks_in_unimodular_list_by_scale_power(2)
         Traceback (most recent call last):
         ...
         TypeError: Oops!  The given quadratic form has a Jordan component
 with a negative scale exponent!
         This routine requires an integer-matrix quadratic form for the
 output indexing to work properly!

         sage:
 Q.scale_by_factor(2).jordan_blocks_in_unimodular_list_by_scale_power(2)
         [Quadratic form in 2 variables over Integer Ring with
 coefficients:
         [ 0 2 ]
         [ * 0 ]
         ,
         Quadratic form in 0 variables over Integer Ring with coefficients:
         ,
         Quadratic form in 1 variables over Integer Ring with coefficients:
         [ 345 ]
         ]
 }}}
 In this example, after the first call to
 {{{jordan_blocks_in_unimodular_list_by_scale_power}}}, the result is
 cached, and the function {{{scale_by_factor}}} copies this cached result,
 so that the second call returns the answer for the original quadratic
 form.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5417#comment:1>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel

--~--~---------~--~----~------------~-------~--~----~
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