MCPcopy
hub / github.com/hyperopt/hyperopt / json_call

Function json_call

hyperopt/utils.py:79–101  ·  view source on GitHub ↗

Return a dataset class instance based on a string, tuple or dictionary .. code-block:: python iris = json_call('datasets.toy.Iris') This function works by parsing the string, and calling import and getattr a lot. (XXX)

(json, args=(), kwargs=None)

Source from the content-addressed store, hash-verified

77
78
79def json_call(json, args=(), kwargs=None):
80 """
81 Return a dataset class instance based on a string, tuple or dictionary
82
83 .. code-block:: python
84
85 iris = json_call('datasets.toy.Iris')
86
87 This function works by parsing the string, and calling import and getattr a
88 lot. (XXX)
89
90 """
91 if kwargs is None:
92 kwargs = {}
93 if isinstance(json, basestring):
94 symbol = json_lookup(json)
95 return symbol(*args, **kwargs)
96 elif isinstance(json, dict):
97 raise NotImplementedError("dict calling convention undefined", json)
98 elif isinstance(json, (tuple, list)):
99 raise NotImplementedError("seq calling convention undefined", json)
100 else:
101 raise TypeError(json)
102
103
104def get_obj(f, argfile=None, argstr=None, args=(), kwargs=None):

Callers 2

get_objFunction · 0.85
run_oneMethod · 0.85

Calls 1

json_lookupFunction · 0.85

Tested by

no test coverage detected