Skip to content

Commit

Permalink
DOC benchmark_utils/__init__.py (#38)
Browse files Browse the repository at this point in the history
Co-authored-by: mathurinm <[email protected]>
  • Loading branch information
ambroiseodt and mathurinm authored Jun 6, 2024
1 parent 9c6c32f commit cebcb6b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion benchmark_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# `benchmark_utils` is a module in which you can define code to reuse in
# the benchmark objective, datasets, and solvers. The folder should have the
# name `benchmark_utils`, and code defined inside will be importable using
# the usual import syntax
# the usual import syntax. To import external packages in this file, use a
# `safe_import_context` named "import_ctx", as follows:

from benchopt.utils import safe_import_context

with safe_import_context() as import_ctx:
import numpy as np


def gradient_ols(X, y, beta):
return X.T @ (X @ beta - y)


def value_ols(X, y, beta):
return 0.5 * np.mean((y - X @ beta) ** 2)
2 changes: 1 addition & 1 deletion objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Objective(BaseObjective):
# solvers or datasets should be declared in Dataset or Solver (see
# simulated.py and python-gd.py).
# Example syntax: requirements = ['numpy', 'pip:jax', 'pytorch:pytorch']
requirements = []
requirements = ["numpy"]

# Minimal version of benchopt required to run this benchmark.
# Bump it up if the benchmark depends on a new feature of benchopt.
Expand Down

0 comments on commit cebcb6b

Please sign in to comment.