Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some more deepcopy/caching issues in the quadratic forms code (followup to #5403) #5417

Open
sagetrac-mabshoff mannequin opened this issue Mar 2, 2009 · 2 comments

Comments

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Mar 2, 2009

Gonzalo found some problem in the QF code when working on #5403. These problems are related to deepcopy.

Cheers,

Michael

Component: quadratic forms

Issue created by migration from https://trac.sagemath.org/ticket/5417

@sagetrac-mabshoff sagetrac-mabshoff mannequin added this to the sage-5.11 milestone Mar 2, 2009
@tornaria
Copy link
Contributor

tornaria commented Mar 2, 2009

comment:1

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.

@sagetrac-mabshoff sagetrac-mabshoff mannequin changed the title Fix some more deepcopy issues (followup to #5403) Fix some more deepcopy/caching issues in the quadratic forms code (followup to #5403) Mar 2, 2009
@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@jdemeyer
Copy link

comment:7

Exactly what is the problem here? The description is very vague...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants