diff --git a/modopt/base/__init__.py b/modopt/base/__init__.py index 1c0c8b2c..88424bae 100644 --- a/modopt/base/__init__.py +++ b/modopt/base/__init__.py @@ -9,4 +9,4 @@ """ -__all__ = ['np_adjust', 'transform', 'types', 'wrappers', 'observable'] +__all__ = ['np_adjust', 'transform', 'types', 'observable'] diff --git a/modopt/base/types.py b/modopt/base/types.py index 88051675..16e06f15 100644 --- a/modopt/base/types.py +++ b/modopt/base/types.py @@ -9,12 +9,10 @@ """ import numpy as np - -from modopt.base.wrappers import add_args_kwargs from modopt.interface.errors import warn -def check_callable(input_obj, add_agrs=True): +def check_callable(input_obj): """Check input object is callable. This method checks if the input operator is a callable funciton and @@ -25,30 +23,14 @@ def check_callable(input_obj, add_agrs=True): ---------- input_obj : callable Callable function - add_agrs : bool, optional - Option to add support for agrs and kwargs (default is ``True``) - - Returns - ------- - function - Function wrapped by ``add_args_kwargs`` Raises ------ TypeError For invalid input type - - See Also - -------- - modopt.base.wrappers.add_args_kwargs : wrapper used - """ if not callable(input_obj): raise TypeError('The input object must be a callable function.') - - if add_agrs: - input_obj = add_args_kwargs(input_obj) - return input_obj diff --git a/modopt/base/wrappers.py b/modopt/base/wrappers.py deleted file mode 100644 index baedb891..00000000 --- a/modopt/base/wrappers.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- - -"""WRAPPERS. - -This module contains wrappers for adding additional features to functions. - -:Author: Samuel Farrens - -""" - -from functools import wraps -from inspect import getfullargspec as argspec - - -def add_args_kwargs(func): - """Add args and kwargs. - - This wrapper adds support for additional arguments and keyword arguments to - any callable function. - - Parameters - ---------- - func : callable - Callable function - - Returns - ------- - callable - wrapper - - """ - @wraps(func) - def wrapper(*args, **kwargs): - - props = argspec(func) - - # if 'args' not in props: - if isinstance(props[1], type(None)): - args = args[:len(props[0])] - - if ( - (not isinstance(props[2], type(None))) - or (not isinstance(props[3], type(None))) - ): - return func(*args, **kwargs) - - return func(*args) - - return wrapper