Skip to content

Instantly share code, notes, and snippets.

@hunse
hunse / hyperopt_wrap_cost.py
Last active August 30, 2021 08:33
A wrapper to execute Hyperopt cost functions safely on a separate process, with timeout
"""A wrapper to execute Hyperopt cost functions safely on a separate process, with timeout
This code is based off parts of https://github.com/hyperopt/hyperopt-sklearn,
which falls under the following license:
=======
Copyright (c) 2013, James Bergstra
All rights reserved.
@hunse
hunse / array_like
Created January 26, 2015 19:10
Decorator to run specific function arguments through `asarray`
class array_like(object):
def __init__(self, *args):
self.arguments = args # the arguments to run `asarray` on
def __call__(self, wrapped):
import inspect
# check that self.arguments are valid
argspec = inspect.getargspec(wrapped)