Mailing List Archive

NEWBIE: opaque error message
I've got this piece of code here, kindly donated as a point of
departure.

from MMTK import *
from MMTK.Lattice import BravaisLattice

a = 4.516*Units.Ang
b = 4.516*Units.Ang
c = 7.354*Units.Ang
alpha = 90*Units.deg
beta = 90*Units.deg
gamma = 120*Units.deg

ex = Vector(1., 0., 0.)
ey = Vector(0., 1., 0.)
ez = Vector(0., 0., 1.)

# Caution: this works only for beta=90*Units.deg
a1 = a*ex
a2 = b*Rotation(ez, alpha)(ex)
a3 = c*Rotation(ey, gamma)(ex)

water = Molecule('water')
water.O.setPosition(0.3333*a1 + 0.6667*a2 + 0.0629*a3)
water.H1.setPosition(0.3333*a1 + 0.6667*a2 + 0.1989*a3)
water.H2.setPosition(0.4551*a1 + 0.9102*a2 + 0.0182*a3)

universe = InfiniteUniverse()
for point in BravaisLattice((a1, a2, a3), (3, 3, 3)):
molecule = copy(water)
molecule.translateTo(point)
universe.addObject(molecule)


which produces the following error message:

Traceback (innermost last):
File "ice.py", line 27, in ?
molecule = copy(water)
File "/usr/lib/python1.5/copy.py", line 76, in copy
y = copierfunction(x)
File "/usr/lib/python1.5/copy.py", line 110, in _copy_inst
return x.__copy__()
File "/usr/lib/python1.5/site-packages/MMTK/ChemicalObjects.py", line 116, in __copy__
return copy.deepcopy(self, {id(self.parent): None})
File "/usr/lib/python1.5/copy.py", line 151, in deepcopy
y = copierfunction(x, memo)
File "/usr/lib/python1.5/copy.py", line 236, in _deepcopy_inst
state = deepcopy(state, memo)
File "/usr/lib/python1.5/copy.py", line 151, in deepcopy
y = copierfunction(x, memo)
File "/usr/lib/python1.5/copy.py", line 199, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(x[key], memo)
File "/usr/lib/python1.5/copy.py", line 151, in deepcopy
y = copierfunction(x, memo)
File "/usr/lib/python1.5/copy.py", line 172, in _deepcopy_list
y.append(deepcopy(a, memo))
File "/usr/lib/python1.5/copy.py", line 151, in deepcopy
y = copierfunction(x, memo)
File "/usr/lib/python1.5/copy.py", line 236, in _deepcopy_inst
state = deepcopy(state, memo)
File "/usr/lib/python1.5/copy.py", line 151, in deepcopy
y = copierfunction(x, memo)
File "/usr/lib/python1.5/copy.py", line 199, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(x[key], memo)
File "/usr/lib/python1.5/copy.py", line 151, in deepcopy
y = copierfunction(x, memo)
File "/usr/lib/python1.5/copy.py", line 221, in _deepcopy_inst
return x.__deepcopy__(memo)
TypeError: too many arguments; expected 1, got 2

<duh>Huh? Can somebody comment what it means?</duh>
NEWBIE: opaque error message [ In reply to ]
A hint.

>>> import copy
>>> class X:
... def __deepcopy__(self):
... pass
...
>>> x=X()
>>> copy.deepcopy(x)
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "d:\python\Lib\copy.py", line 151, in deepcopy
y = copierfunction(x, memo)
File "d:\python\Lib\copy.py", line 221, in _deepcopy_inst
return x.__deepcopy__(memo)
TypeError: too many arguments; expected 1, got 2
>>>

--
--Darrell
NEWBIE: opaque error message [ In reply to ]
Eugene Leitl wrote:
>
> File "/usr/lib/python1.5/copy.py", line 221, in _deepcopy_inst
> return x.__deepcopy__(memo)
> TypeError: too many arguments; expected 1, got 2

I suspect that the __deepcopy__ method of one of
your objects is missing a 'self' argument.

Greg