def validate_expanding_func(name, args, kwargs) -> None: numpy_args = ("axis", "dtype", "out") msg = (f"numpy operations are not valid with window objects. " f"Use .expanding(...).{name}() instead ") if len(args) > 0: raise UnsupportedFunctionCall(msg) for arg in numpy_args: if arg in kwargs: raise UnsupportedFunctionCall(msg)
def validate_window_func(name, args, kwargs): numpy_args = ("axis", "dtype", "out") msg = (f"numpy operations are not valid with window objects. " f"Use .{name}() directly instead ") if len(args) > 0: raise UnsupportedFunctionCall(msg) for arg in numpy_args: if arg in kwargs: raise UnsupportedFunctionCall(msg)
def validate_expanding_func(name, args, kwargs): numpy_args = ('axis', 'dtype', 'out') msg = ("numpy operations are not " "valid with window objects. " "Use .expanding(...).{func}() instead ".format(func=name)) if len(args) > 0: raise UnsupportedFunctionCall(msg) for arg in numpy_args: if arg in kwargs: raise UnsupportedFunctionCall(msg)
def validate_resampler_func(method: str, args, kwargs) -> None: """ 'args' and 'kwargs' should be empty because all of their necessary parameters are explicitly listed in the function signature """ if len(args) + len(kwargs) > 0: if method in RESAMPLER_NUMPY_OPS: raise UnsupportedFunctionCall( "numpy operations are not valid with resample. " f"Use .resample(...).{method}() instead") else: raise TypeError("too many arguments passed in")
def validate_groupby_func(name, args, kwargs, allowed=None) -> None: """ 'args' and 'kwargs' should be empty, except for allowed kwargs because all of their necessary parameters are explicitly listed in the function signature """ if allowed is None: allowed = [] kwargs = set(kwargs) - set(allowed) if len(args) + len(kwargs) > 0: raise UnsupportedFunctionCall( "numpy operations are not valid with groupby. " f"Use .groupby(...).{name}() instead")