[SciPy-dev] scipy.stats._chk_asarray
Ryan May
rmay31@gmail....
Wed Jun 3 08:42:04 CDT 2009
On Wed, Jun 3, 2009 at 2:33 AM, Pauli Virtanen <pav@iki.fi> wrote:
> Wed, 03 Jun 2009 02:17:56 -0400, Pierre GM kirjoitti:
> [clip]
> > def keepthetype(func):
> > def wrapped(*args, **kwargs):
> > first = args[0]
> > if isinstance(first, np.ndarray):
> > output_type = type(first)
> > else:
> > output_type = np.ndarray
> > output = func(*args, **kwargs)
> > if isinstance(output, np.ndarray):
> > return output.view(output_type)
> > return output
> > wrapped.__name__ = func.__name__
> > wrapped.__dict__ = func.__dict__
> > wrapped.__doc__ = func.__doc__
> > return wrapped
>
> This is not enough to preserve the function signature, which is quite
> annoying from the help-POV. It's probably best to take a look at the
> decorator.py:
>
> http://pypi.python.org/pypi/decorator/3.0.1
>
>
There's functools.update_wrapper and functools.wraps in the standard
library. Would those be enough? (The docs make it seem simple enough.)
Ryan
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20090603/06f7351f/attachment.html
More information about the Scipy-dev
mailing list