MCPcopy
hub / github.com/hyperopt/hyperopt / inject

Method inject

hyperopt/pyll/base.py:155–172  ·  view source on GitHub ↗

Add symbols from self into a dictionary and return the dict. This is used for import-like syntax: see `import_`.

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

153 return wrapper
154
155 def inject(self, *args, **kwargs):
156 """
157 Add symbols from self into a dictionary and return the dict.
158
159 This is used for import-like syntax: see `import_`.
160 """
161 rval = {}
162 for k in args:
163 try:
164 rval[k] = getattr(self, k)
165 except AttributeError:
166 raise PyllImportError(k)
167 for k, origk in list(kwargs.items()):
168 try:
169 rval[k] = getattr(self, origk)
170 except AttributeError:
171 raise PyllImportError(origk)
172 return rval
173
174 def import_(self, _globals, *args, **kwargs):
175 _globals.update(self.inject(*args, **kwargs))

Callers 1

import_Method · 0.95

Calls 2

PyllImportErrorClass · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected