def _unpack_fcn(fcn, p0, y, x):
if y.shape is not None:<EOL><INDENT>if p0.shape is not None:<EOL><INDENT>def nfcn(p, x=x, fcn=fcn, pshape=p0.shape):<EOL><INDENT>po = p.reshape(pshape)<EOL>ans = fcn(po) if x is False else fcn(x, po)<EOL>if hasattr(ans, '<STR_LIT>'):<EOL><INDENT>return ans.flat<EOL><DEDENT>else:<EOL><INDENT>return numpy.array(ans).flat<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>po = _gvar.BufferDict(p0, buf=numpy.zeros(p0.size, float))<EOL>def nfcn(p, x=x, fcn=fcn, po=po):<EOL><INDENT>po.buf = p<EOL>ans = fcn(po) if x is False else fcn(x, po)<EOL>if hasattr(ans, '<STR_LIT>'):<EOL><INDENT>return ans.flat<EOL><DEDENT>else:<EOL><INDENT>return numpy.array(ans).flat<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>yo = _gvar.BufferDict(y, buf=y.size*[None])<EOL>if p0.shape is not None:<EOL><INDENT>def nfcn(p, x=x, fcn=fcn, pshape=p0.shape, yo=yo):<EOL><INDENT>po = p.reshape(pshape)<EOL>fxp = fcn(po) if x is False else fcn(x, po)<EOL>for k in yo:<EOL><INDENT>yo[k] = fxp[k]<EOL><DEDENT>return yo.flat<EOL><DEDENT><DEDENT>else:<EOL><INDENT>po = _gvar.BufferDict(p0, buf=numpy.zeros(p0.size, float))<EOL>def nfcn(p, x=x, fcn=fcn, po=po, yo=yo):<EOL><INDENT>po.buf = p<EOL>fxp = fcn(po) if x is False else fcn(x, po)<EOL>for k in yo:<EOL><INDENT>yo[k] = fxp[k]<EOL><DEDENT>return yo.flat<EOL><DEDENT><DEDENT><DEDENT>return nfcn<EOL>
reconfigure fitting fcn so inputs, outputs = flat arrays; hide x