wrf.decorators.cast_type¶
- wrf.decorators.cast_type(ref_idx=0, arg_idxs=None, karg_names=None, alg_dtype=<MagicMock id='140499232605584'>, outviews='outview')¶
A decorator to handle type casting.
This decorator is used to cast variables to and from the required
numpy.dtype
used in the wrapped function.- Parameters:
ref_idx (
int
, optional) – The index in the wrapped function’s positional arguments to be used as the reference variable for determining thenumpy.dtype
to return. Default is 0.arg_idxs (sequence of
int
, optional) – A sequence of indexes in the wrapped function’s positional arguments that indicate which arguments to cast. Must be specified if karg_names is None. Default is None.karg_names (sequence of
str
) – A sequence of keyword arguments in the wrapped function’s keyword arguments that indicate the arguments to cast. Must be specified if arg_idxs is None. Default is None.alg_dtype (
numpy.dtype
orstr
) – The numpy data type used in the wrapped function.outviews (
str
or a sequence) – A single key or sequence of keys that indicate the wrapped function’s keyword argument to use as the output variable(s) in the wrapped function.
- Returns:
The wrapped function’s output cast to the same
numpy.dtype
as the reference variable.- Return type: