def __call__(self, *args, **kwargs):
# late initialization if necessary
try:
if not self.__initialized:
raise AttributeError
except AttributeError:
Function.initialize(self, None)
# find the "right" callable
callable_ = self.__callable
if callable_ is None:
for name in self.function_names_to_evaluate_first_found:
try:
callable_ = getattr(self, name)
break
except AttributeError:
pass
# call with each vector
if callable_ is not None:
X, list_revert = utils.as_vector_list(args[0])
self.evaluations += len(X)
return list_revert([
callable_(np.asarray(x), *args[1:], **kwargs)
for x in X])
else:
self.evaluations += 1 # somewhat bound to fail
评论列表
文章目录