Opened 11 years ago

Closed 4 years ago

Trouble with deepcopy of vectorspaces where the inner product matrix is specified

Reported by: Owned by: jonhanke jason, was minor sage-8.3 linear algebra copy, vectorspace was, jonhanke Frédéric Chapoton Travis Scrimshaw N/A bf855a3 bf855a340b4c8325c3878b5f90d24fcefb766e2d

Description

There are some serious problems using deepcopy on vectorspaces where the inner_product_matrix is specified. This fails over GF(p) for large primes, and over RR.

```sage: V = VectorSpace(GF(46337), 2, inner_product_matrix=DiagonalMatrix(ZZ, [1,1]))
sage: deepcopy(V)
Ambient quadratic space of dimension 2 over Finite Field of size 46337
Inner product matrix:
[1 0]
[0 1]
sage:
sage: V = VectorSpace(GF(46349), 2, inner_product_matrix=DiagonalMatrix(ZZ, [1,1]))
sage: deepcopy(V)
---------------------------------------------------------------------------
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)
320         dictiter = None
321     if deep:
--> 322         args = deepcopy(args, memo)
323     y = callable(*args)
324     memo[id(x)] = y

/Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python/copy.pyc in deepcopy(x, memo, _nil)
160     copier = _deepcopy_dispatch.get(cls)
161     if copier:
--> 162         y = copier(x, memo)
163     else:
164         try:

/Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python/copy.pyc in _deepcopy_tuple(x, memo)
233     y = []
234     for a in x:
--> 235         y.append(deepcopy(a, memo))
236     d = id(x)
237     try:

/Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python/copy.pyc in deepcopy(x, memo, _nil)
160     copier = _deepcopy_dispatch.get(cls)
161     if copier:
--> 162         y = copier(x, memo)
163     else:
164         try:

/Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python/copy.pyc in _deepcopy_tuple(x, memo)
233     y = []
234     for a in x:
--> 235         y.append(deepcopy(a, memo))
236     d = id(x)
237     try:

/Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python/copy.pyc in deepcopy(x, memo, _nil)
171             copier = getattr(x, "__deepcopy__", None)
172             if copier:
--> 173                 y = copier(memo)
174             else:
175                 reductor = dispatch_table.get(cls)

TypeError: __deepcopy__() takes no arguments (1 given)
```

comment:1 Changed 8 years ago by jdemeyer

• Milestone changed from sage-5.11 to sage-5.12

comment:2 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.1 to sage-6.2

comment:3 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.2 to sage-6.3

comment:4 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.3 to sage-6.4

comment:5 Changed 4 years ago by chapoton

• Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
• Status changed from new to needs_review

Works in 8.2.b7

comment:6 follow-up: ↓ 7 Changed 4 years ago by sbrandhorst

Shouldn't we add a doctest to show the bug is fixed?

comment:7 in reply to: ↑ 6 Changed 4 years ago by tscrim

Shouldn't we add a doctest to show the bug is fixed?

comment:8 Changed 4 years ago by chapoton

• Authors changed from Jonathan Hanke to Frédéric Chapoton
• Branch set to u/chapoton/10606
• Commit set to eb0d0d5ecb6b0b8a675a12f21ac1b131e710318a
• Milestone changed from sage-duplicate/invalid/wontfix to sage-8.3

New commits:

 ​eb0d0d5 `trac 10606 adding a doctest`

comment:9 Changed 4 years ago by tscrim

• Reviewers set to Travis Scrimshaw
• Status changed from needs_review to positive_review

LGTM.

comment:10 Changed 4 years ago by tscrim

• Priority changed from critical to minor

comment:11 Changed 4 years ago by chapoton

• Status changed from positive_review to needs_work

there is a typo Z Z

comment:12 Changed 4 years ago by git

• Commit changed from eb0d0d5ecb6b0b8a675a12f21ac1b131e710318a to 6ba9925d68d07ca90e0a1456c5f6753cea1a93a5

Branch pushed to git repo; I updated commit sha1. New commits:

 ​6ba9925 `fix a typo`

comment:13 Changed 4 years ago by chapoton

• Status changed from needs_work to positive_review

corrected and tested. I am setting back to positive

comment:14 Changed 4 years ago by chapoton

• Status changed from positive_review to needs_work

pyflakes plugin is not happy

comment:15 Changed 4 years ago by git

• Commit changed from 6ba9925d68d07ca90e0a1456c5f6753cea1a93a5 to bf855a340b4c8325c3878b5f90d24fcefb766e2d

Branch pushed to git repo; I updated commit sha1. New commits:

 ​bf855a3 `fixing pyflakes`

comment:16 Changed 4 years ago by chapoton

• Status changed from needs_work to positive_review

done, setting back to positive

comment:17 Changed 4 years ago by vbraun

• Branch changed from u/chapoton/10606 to bf855a340b4c8325c3878b5f90d24fcefb766e2d
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.