This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dmitrey
Recipients Dmitrey, christian.heimes, gvanrossum, mlvanbie
Date 2008-01-31.18:38:57
SpamBayes Score 9.633622e-05
Marked as misclassified No
Message-id <>
In-reply-to <>
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 "", line 10, in <module>
    p3 = _deepcopy_method(p, None)
  File "", 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 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)

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 <>
> <>
> __________________________________
Date User Action Args
2008-01-31 18:38:59Dmitreysetspambayes_score: 9.63362e-05 -> 9.633622e-05
recipients: + Dmitrey, gvanrossum, christian.heimes, mlvanbie
2008-01-31 18:38:58Dmitreylinkissue1515 messages
2008-01-31 18:38:57Dmitreycreate