unnecessary change

Giorgi Lekishvili gleki at gol.ge
Tue Oct 23 22:34:17 CEST 2001


Thank you for the hint!
The bad news is, that the matrix turned to be un-deep-copyable object:

"""
>>> m1=deepcopy(m)
Traceback (innermost last):
  File "<pyshell#6>", line 1, in ?
    m1=deepcopy(m)
  File "d:\python20\lib\copy.py", line 151, in deepcopy
    y = copierfunction(x, memo)
  File "d:\python20\lib\copy.py", line 237, in _deepcopy_inst
    state = deepcopy(state, memo)
  File "d:\python20\lib\copy.py", line 151, in deepcopy
    y = copierfunction(x, memo)
  File "d:\python20\lib\copy.py", line 200, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(x[key], memo)
  File "d:\python20\lib\copy.py", line 147, in deepcopy
    raise error, \
Error: un-deep-copyable object of type <type 'array'>
"""

however, the copy function did help:

"""

Grtz, Giorgi





Steve Holden wrote:

> "Giorgi Lekishvili" <gleki at gol.ge> wrote in message
> news:3BD5BCDF.B40C1422 at gol.ge...
> > Hi folks!
> >
> > My problem is the following:
> > I want to save initial data matrix, as e.g., follows
> >     self.Mdata=Matr
> > In the same time I need a matrix, which is used and processed. The
> > latter is created as follows
> >     self.Mactual=self.Mdata
> >
> > No the problem is, that, when I have finished to use the Mactual matrix,
> > self.Mdata is always changed and equals the final Mactual matrix.
> >
> > What is the systematic solution of the problem?
> >
> > Thanx in advance,
> > Giorgi
> >
> > PS. I use Numeric module.
> >
> This is because Python variable bindings are actually references. You
> probably need to make a copy of the matric. See if the copy module (and
> particularly copy.deepcopy()) will help.
>
> regards
>  Steve
> --
> http://www.holdenweb.com/




More information about the Python-list mailing list