mattloper / chumpy

MIT License
195 stars 118 forks source link

Problem about calling newton-cg optimization method #22

Open sycmio opened 6 years ago

sycmio commented 6 years ago

Hello @mattloper , Thank you very much for this wonderful tool! I am trying to use chumpy in one of my project, and I met one problem when calling the ch.minimize function with method newton-cg. I dive into the source code of chumpy and found that the problem is caused by function ns_jacfunc in chumpy/optimization.py. To be more concrete, a function 'hstack' is called in this function, but actually it is not defined. I know both numpy and chumpy have hstack, but it seems you didn't import them in this py file. I have also tried to import them, but it didn't help (some other problems occur after it, so I guess you don't want to use np.hstack or ch.hstack here). Do you know how to fix this bug?

Best, Yongchi

gdwei commented 6 years ago

I've met the same problem. But adding 'from optimization_internal import hstack' to chumpy/optimization.py solves my problem. And you can also modify the statement to 'result = sp.hstack(jacs)'