Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions laboratory/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,6 @@ def __init__(self, name='Experiment', context=None, raise_on_mismatch=False):
self._control = None
self._candidates = []

@classmethod
def decorator(cls, candidate, *exp_args, **exp_kwargs):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I actually don't entirely hate this pattern, but I think it's for the best that we get rid of it now and we can add it back in later in a more Kraken style approach

'''
Decorate a control function in order to conduct an experiment when called.

:param callable candidate: your candidate function
:param iterable exp_args: positional arguments passed to :class:`Experiment`
:param dict exp_kwargs: keyword arguments passed to :class:`Experiment`

Usage::

candidate_func = lambda: True

@Experiment.decorator(candidate_func)
def control_func():
return True

'''
def wrapper(control):
@wraps(control)
def inner(*args, **kwargs):
experiment = cls(*exp_args, **exp_kwargs)
experiment.control(control, args=args, kwargs=kwargs)
experiment.candidate(candidate, args=args, kwargs=kwargs)
return experiment.conduct()
return inner
return wrapper

def control(self, control_func, args=None, kwargs=None, name='Control', context=None):
'''
Set the experiment's control function. Must be set before ``conduct()`` is called.
Expand Down
29 changes: 0 additions & 29 deletions tests/test_decorator.py

This file was deleted.