Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test template #21

Open
vroulet opened this issue Jul 5, 2023 · 0 comments
Open

Unit test template #21

vroulet opened this issue Jul 5, 2023 · 0 comments

Comments

@vroulet
Copy link

vroulet commented Jul 5, 2023

Hello!

Thanks for developping benchopt!

Would it be possible to add a unit test in the template?
Why:

  • ease debugging base functions (typically this would ease interactive debugging),
  • give a good idea of the flow directly in the template.

For example one could add a file 'test_pipeline.py' with something like.

from datasets.simulated import Dataset
from objective import Objective
from solvers.python-gd import Solver

# This test requires having installed the dependencies before
def test_pipeline():
    # We add manually attributes of dataset, objective, solver for the test

    dataset = Dataset()
    dataset.n_samples = 1000
    dataset.n_features = 500
    dataset.random_state = 27
    dataset_params = dataset.get_data()

    objective = Objective()
    objective.whiten_y = True
    objective.set_data(**dataset_params)
    objective_params = objective.get_objective()

    solver = Solver()
    solver.scale_step = 1.
    solver.set_objective(**objective_params)
    solver.run(n_iter=10)
    results = solver.get_result()

    metrics = objective.compute(*results)
    assert 'value' in metrics.keys()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant