Author Dmitrey
Recipients Dmitrey, christian.heimes, gvanrossum, mlvanbie
Date 2008-01-31.18:38:57
SpamBayes Score 9.63362e-05
Marked as misclassified No
Message-id <47A215C2.7020405@scipy.org>
In-reply-to <1201803092.5.0.721301858589.issue1515@psf.upfronthosting.co.za>
Content
I don't know did you mean it to me (as I've noticed from address) or no. 
I can hardly provide any help for fixing the bug, I'm not skilled enough 
in Python core files. Here's results of the proposition mentioned:

import copy
import types

def _deepcopy_method(x, memo):
    return type(x)(x.im_func, deepcopy(x.im_self, memo), x.im_class)
copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method

from scikits.openopt import NLP
p = NLP(lambda x: x**2, 1)
p3 = _deepcopy_method(p, None)

Traceback (most recent call last):
  File "test_deepcopy.py", line 10, in <module>
    p3 = _deepcopy_method(p, None)
  File "test_deepcopy.py", line 5, in _deepcopy_method
    return type(x)(x.im_func, deepcopy(x.im_self, memo), x.im_class)
AttributeError: NLP instance has no attribute 'im_func'

as for copy.py from Python core, it seems like the file has no 
"_deepcopy_method" function.

Users want to run r = p.solve(solverName) for several different solvers and same p instance. So it needs each time using
for sn in [solverName1, solverName2, ..., solverNameN]:
  p = NLP(dozens of params)
  p.somefiled.paramN+1 =valN+1
  p.somefiled.paramN+2 =valN+2
...
  r{i} = p.solve(sn)
while in my previous MATLAB version of the toolbox it looks just like:

(assign prob only once)
p = ooAssign(params)
for sn in [solverName1, solverName2, ..., solverNameN]
  r{i} = p.solve(sn)
end 

Christian Heimes wrote:
> Christian Heimes added the comment:
>
> Since Guido accepted the proposal can you please provide a patch with at
> least one unit test?
>
> ----------
> resolution:  -> accepted
>
> __________________________________
> Tracker <report@bugs.python.org>
> <http://bugs.python.org/issue1515>
> __________________________________
>
>
>
>
History
Date User Action Args
2008-01-31 18:38:59Dmitreysetspambayes_score: 9.63362e-05 -> 9.63362e-05
recipients: + Dmitrey, gvanrossum, christian.heimes, mlvanbie
2008-01-31 18:38:58Dmitreylinkissue1515 messages
2008-01-31 18:38:57Dmitreycreate