dtypeDecoratorMaker

utilipy.decorators.func_io.dtypeDecoratorMaker(dtype: Any)[source]

Function to make a dtype decorator.

Parameters
dtypetype

intended data type

Returns
dtypeDecoratordecorator class

a decorator which can convert input and output arguments to the intended datatype

Examples

>>> intDecorator = dtypeDecoratorMaker(int)
>>> @intDecorator(inargs=[0, 1], outargs=2)
... def func(x, y, z):
...     return x, y, z, (x, y, z)
>>> x, y, z, orig = func(1.1, 2.2, 3.3)
>>> print(x, y, z, orig)  # z->int before returned
1 2 3 (1, 2, 3.3)