Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ Metrics should take an AnnData object and return a `float`.
function metric(AnnData adata) -> float
```

Note that the AnnData object is passed to the metric function as a copy, so there is no
need to copy it internally, even if you modify the object.

Task-specific APIs are described in the README for each task.

* [Label Projection](openproblems/tasks/label_projection)
Expand Down
4 changes: 2 additions & 2 deletions openproblems/tools/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ def metric(metric_name, maximize, paper_reference, image="openproblems"):

def decorator(func):
@functools.wraps(func)
def apply_metric(*args, **kwargs):
def apply_metric(adata: anndata.AnnData, *args, **kwargs):
log.debug("Running {} metric".format(func.__name__))
return func(*args, **kwargs)
return func(adata.copy(), *args, **kwargs)

apply_metric.metadata = dict(
metric_name=metric_name,
Expand Down