Experiments Module

This module contains helper functions for authoring and running experiment workflows. Use it when you need reusable pieces around scenario execution and results handling.

Typical usage

from discopygal.experiments import run_scenarios

run_scenarios(scenarios, result_root_dir="results")

See also

class discopygal.experiments.Experiment_CompareFunctions(fs: List[Callable], experiment_args: Dict[str, List])

Class that allows running comparison experiments on two given functions. The functions should have the same signature. This also allows exporting results to various formats.

Parameters:
  • f1 (function) – list of functions

  • experiment_args (dict<str, list>) – dict that pairs experiment name with arguments to pass to each function

export_time(time_metric: str, path: str, names: List[str]) None

Export the times to a readable csv. User needs to supply a list of names for each function (which will be in the headers), export a table of runtimes.

run_experiment(n_times: int = 1) None

Run the experiment for n times. We store the average, max and min times as well as the last experiment result

run_function(f_idx: int, args: List) Dict[str, Any]

Run self.f1 with given args. Return the runtime and the result.