#10577: Deepcopy fails on vectorspaces over GF(2) with inner_product_matrix
specified
------------------------------+---------------------------------------------
   Reporter:  jonhanke        |       Owner:  jason, was                        
  
       Type:  defect          |      Status:  new                               
  
   Priority:  major           |   Milestone:  sage-4.6.1                        
  
  Component:  linear algebra  |    Keywords:  GF(2), vectorspace, 
characteristic 2
     Author:  Jonathan Hanke  |    Upstream:  N/A                               
  
   Reviewer:                  |      Merged:                                    
  
Work_issues:                  |  
------------------------------+---------------------------------------------
Description changed by jonhanke:

Old description:

> Deepcopy fails on vectorspaces over GF(2) with inner_product_matrix
> specified, but works for vectorspaces over GF(p) if either p>2 or the
> inner_product_matrix is not specified.  Apparently there is some issue
> with using mutable matrices.
>
> ==============================================
>
> sage: V3 = VectorSpace(GF(3), 2, inner_product_matrix =
> DiagonalMatrix(GF(3), [1,1]))
> sage: deepcopy(V3)
> Ambient quadratic space of dimension 2 over Finite Field of size 3
> Inner product matrix:
> [1 0]
> [0 1]
>
> sage: V2 = VectorSpace(GF(2), 2)
> sage: deepcopy(V2)
> Vector space of dimension 2 over Finite Field of size 2
>
> sage: M2 = DiagonalMatrix(GF(2), [1,1])
> sage: deepcopy(M2)
> [1 0]
> [0 1]
>
> sage: V2 = VectorSpace(GF(2), 2, inner_product_matrix =
> DiagonalMatrix(GF(2), [1,1]))
> sage:
> sage:
> sage: deepcopy(V2)
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call
> last)
>
> /Users/jonhanke/Documents/SAGE/sage-4.6/<ipython console> in <module>()
>
> /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python/copy.pyc in
> deepcopy(x, memo, _nil)
>     187                             raise Error(
>     188                                 "un(deep)copyable object of type
> %s"
> % cls)
> --> 189                 y = _reconstruct(x, rv, 1, memo)
>     190
>     191     memo[d] = y
>
> /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python/copy.pyc in
> _reconstruct(x, info, deep, memo)
>     321     if deep:
>     322         args = deepcopy(args, memo)
> --> 323     y = callable(*args)
>     324     memo[id(x)] = y
>     325     if listiter is not None:
>
> /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-
> packages/sage/structure/factory.so
> in sage.structure.factory.generic_factory_unpickle
> (sage/structure/factory.c:2277)()
>
> /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-
> packages/sage/structure/factory.so
> in sage.structure.factory.UniqueFactory.get_object
> (sage/structure/factory.c:1633)()
>
> /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-
> packages/sage/structure/factory.so
> in sage.structure.factory.UniqueFactory.get_object
> (sage/structure/factory.c:1049)()
>
> /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-
> packages/sage/matrix/matrix_mod2_dense.so
> in sage.matrix.matrix_mod2_dense.Matrix_mod2_dense.__hash__
> (sage/matrix/matrix_mod2_dense.c:3222)()
>
> TypeError: mutable matrices are unhashable

New description:

 Deepcopy fails on vectorspaces over GF(2) with inner_product_matrix
 specified, but works for vectorspaces over GF(p) if either p>2 or the
 inner_product_matrix is not specified.  Apparently there is some issue
 with using mutable matrices.


 {{{
 sage: V3 = VectorSpace(GF(3), 2, inner_product_matrix =
 DiagonalMatrix(GF(3), [1,1]))
 sage: deepcopy(V3)
 Ambient quadratic space of dimension 2 over Finite Field of size 3
 Inner product matrix:
 [1 0]
 [0 1]

 sage: V2 = VectorSpace(GF(2), 2)
 sage: deepcopy(V2)
 Vector space of dimension 2 over Finite Field of size 2

 sage: M2 = DiagonalMatrix(GF(2), [1,1])
 sage: deepcopy(M2)
 [1 0]
 [0 1]

 sage: V2 = VectorSpace(GF(2), 2, inner_product_matrix =
 DiagonalMatrix(GF(2), [1,1]))
 sage:
 sage:
 sage: deepcopy(V2)
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)

 /Users/jonhanke/Documents/SAGE/sage-4.6/<ipython console> in <module>()

 /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python/copy.pyc in
 deepcopy(x, memo, _nil)
     187                             raise Error(
     188                                 "un(deep)copyable object of type
 %s"
 % cls)
 --> 189                 y = _reconstruct(x, rv, 1, memo)
     190
     191     memo[d] = y

 /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python/copy.pyc in
 _reconstruct(x, info, deep, memo)
     321     if deep:
     322         args = deepcopy(args, memo)
 --> 323     y = callable(*args)
     324     memo[id(x)] = y
     325     if listiter is not None:

 /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-
 packages/sage/structure/factory.so
 in sage.structure.factory.generic_factory_unpickle
 (sage/structure/factory.c:2277)()

 /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-
 packages/sage/structure/factory.so
 in sage.structure.factory.UniqueFactory.get_object
 (sage/structure/factory.c:1633)()

 /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-
 packages/sage/structure/factory.so
 in sage.structure.factory.UniqueFactory.get_object
 (sage/structure/factory.c:1049)()

 /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-
 packages/sage/matrix/matrix_mod2_dense.so
 in sage.matrix.matrix_mod2_dense.Matrix_mod2_dense.__hash__
 (sage/matrix/matrix_mod2_dense.c:3222)()

 TypeError: mutable matrices are unhashable
 }}}

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10577#comment:1>
Sage <http://www.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