-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.py
32 lines (24 loc) · 924 Bytes
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from abc import ABCMeta, abstractmethod
import types
import warnings
""" Pulled from scikit-opt sko.base module by @guofei9987"""
class SkoBase(metaclass=ABCMeta):
def register(self, operator_name, operator, *args, **kwargs):
'''
regeister udf to the class
:param operator_name: string
:param operator: a function, operator itself
:param args: arg of operator
:param kwargs: kwargs of operator
:return:
'''
def operator_wapper(*wrapper_args):
return operator(*(wrapper_args + args), **kwargs)
setattr(self, operator_name, types.MethodType(operator_wapper, self))
return self
def fit(self, *args, **kwargs):
warnings.warn('.fit() will be deprecated in the future. use .run() instead.'
, DeprecationWarning)
return self.run(*args, **kwargs)
class Problem(object):
pass