[SciPy-dev] scipy.stats._chk_asarray
Pauli Virtanen
pav at iki.fi
Wed Jun 3 03:33:51 EDT 2009
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
--
Pauli Virtanen
More information about the SciPy-Dev
mailing list