nigsp.utils.change_var_type

nigsp.utils.change_var_type(var, dtype, varname='an input variable', stop=True, silent=False)[source]

Make sure var is of type dtype.

Parameters:
varstr, int, or float

Variable to change type of.

dtypetype

Type to change var to.

varnamestr, optional

The name of the variable.

stopbool, optional

If True, raises TypeError if var is not of dtype.

silentbool, optional

If True, don’t return any message.

Returns:
int, float, str, list, or var

The given var in the given dtype, or var if '' or None

Raises:
NotImplementedError

If dtype is not int, float, str, or list.

TypeError

If variable var is not of type and stop is True.