Scientist v0.1.0 Scientist.Experiment behaviour

Summary

Functions

Adds the given function to the experiment as an candidate

Adds the given function to the experiment as the control

Adds a function to the experiment that is used to clean observed values

Adds a function to the experiment that is used to compare observations

Adds an ignore function to the experiment. The experiment will ignore a mismatch whenever this function returns true

Creates an experiment with the given name and context, using Scientist.Default as a callback module when none is provided

Returns true if the two observations match, reporting an error to the callback module if an exception is caught

Runs the experiment, using Scientist.Default as a callback module if none is provided

Returns the value of the experiment’s run_if function, or true if one does not exist. Reports an error to the callback module if an exception is caught

Adds a function to the experiment that should only execute when the experiment is run

Adds a function to the experiment that is used to determine if it should run

Returns true if an experiment determines a mismatch should be ignored, based on its ignore functions

Returns true if the experiment should run, reporting an error to the callback module if an exception is caught

Macros

Executes the given block, calling thrown and raised with the given reason if the block throws or raises an exception

Functions

add_candidate(exp, name \\ "candidate", candidate)

Adds the given function to the experiment as an candidate.

Raises Scientist.DuplicateError if the experiment already has a candidate with name.

add_control(exp, candidate)

Adds the given function to the experiment as the control.

Raises Scientist.DuplicateError if the experiment already has a control.

clean_with(exp, cleaner)

Adds a function to the experiment that is used to clean observed values.

compare_with(exp, c)

Adds a function to the experiment that is used to compare observations.

ignore(exp, i)

Adds an ignore function to the experiment. The experiment will ignore a mismatch whenever this function returns true.

new(name \\ "#{__MODULE__}")

Creates an experiment with the given name and context, using Scientist.Default as a callback module when none is provided.

new(name, opts)
new(module, name, opts)
observations_match?(experiment, control, candidate)

Returns true if the two observations match, reporting an error to the callback module if an exception is caught.

run(exp, opts \\ [])

Runs the experiment, using Scientist.Default as a callback module if none is provided.

Raises Scientist.MissingControlError if the experiment has no control.

Raises Scientist.MismatchError if the experiment has mismatched observations and is configured with raise_on_mismatched: true.

run_if_allows?(experiment)

Returns the value of the experiment’s run_if function, or true if one does not exist. Reports an error to the callback module if an exception is caught.

set_before_run(exp, before_run)

Adds a function to the experiment that should only execute when the experiment is run.

set_run_if(exp, run_if_fn)

Adds a function to the experiment that is used to determine if it should run.

should_ignore_mismatch?(exp, control, candidate)

Returns true if an experiment determines a mismatch should be ignored, based on its ignore functions.

should_run?(experiment)

Returns true if the experiment should run, reporting an error to the callback module if an exception is caught.

Macros

guarded(exp, operation, list)

Executes the given block, calling thrown and raised with the given reason if the block throws or raises an exception.

Callbacks

enabled?()

Specs

enabled? :: Boolean
publish(%)

Specs

publish(%Scientist.Result{candidates: term, control: term, experiment: term, ignored: term, mismatched: term}) :: any