Skip to content
Snippets Groups Projects
Commit 820fedde authored by Alán Muñoz's avatar Alán Muñoz
Browse files

Merge branch 'coverage' into 'dev'

ci: implement and visualise test coverage

See merge request aliby!8
parents 1cd1c7a8 1492fd6e
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,14 @@ Local Tests: ...@@ -38,7 +38,14 @@ Local Tests:
stage: tests stage: tests
script: script:
# - poetry install -vv # - poetry install -vv
- poetry run pytest ./tests --ignore ./tests/aliby/network --ignore ./tests/aliby/pipeline - poetry run coverage run -m --branch pytest ./tests --ignore ./tests/aliby/network --ignore ./tests/aliby/pipeline
- poetry run coverage report -m
- poetry run coverage xml
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
# Legacy because we use GitLab 14.2.6
artifacts:
reports:
cobertura: coverage.xml
Network Tools Tests: Network Tools Tests:
stage: tests stage: tests
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
[![PyPI version](https://badge.fury.io/py/aliby.svg)](https://badge.fury.io/py/aliby) [![PyPI version](https://badge.fury.io/py/aliby.svg)](https://badge.fury.io/py/aliby)
[![pipeline](https://git.ecdf.ed.ac.uk/swain-lab/aliby/aliby/badges/master/pipeline.svg?key_text=master)](https://git.ecdf.ed.ac.uk/swain-lab/aliby/aliby/-/pipelines) [![pipeline](https://git.ecdf.ed.ac.uk/swain-lab/aliby/aliby/badges/master/pipeline.svg?key_text=master)](https://git.ecdf.ed.ac.uk/swain-lab/aliby/aliby/-/pipelines)
[![dev pipeline](https://git.ecdf.ed.ac.uk/swain-lab/aliby/aliby/badges/dev/pipeline.svg?key_text=dev)](https://git.ecdf.ed.ac.uk/swain-lab/aliby/aliby/-/commits/dev) [![dev pipeline](https://git.ecdf.ed.ac.uk/swain-lab/aliby/aliby/badges/dev/pipeline.svg?key_text=dev)](https://git.ecdf.ed.ac.uk/swain-lab/aliby/aliby/-/commits/dev)
[![coverage](https://git.ecdf.ed.ac.uk/swain-lab/aliby/aliby/badges/dev/coverage.svg)](https://git.ecdf.ed.ac.uk/swain-lab/aliby/aliby/-/commits/dev)
End-to-end processing of cell microscopy time-lapses. ALIBY automates segmentation, tracking, lineage predictions, post-processing and report production. It leverages the existing Python ecosystem and open-source scientific software available to produce seamless and standardised pipelines. End-to-end processing of cell microscopy time-lapses. ALIBY automates segmentation, tracking, lineage predictions, post-processing and report production. It leverages the existing Python ecosystem and open-source scientific software available to produce seamless and standardised pipelines.
......
#!/usr/bin/env python3
import numpy as np
import pandas as pd
from postprocessor.core.processes.interpolate import (
interpolate,
interpolateParameters,
)
def dummy_signal_array(n_cells, n_tps):
"""Creates dummy signal array, i.e. increasing gradient"""
signal = np.array([np.linspace(1, 2, n_tps) for _ in range(n_cells)])
return signal
def test_dummy_signal_array():
ds = dummy_signal_array(5, 10)
# Check dimensions
assert ds.shape[0] == 5
assert ds.shape[1] == 10
def randomly_add_na(input_array, num_of_na):
"""Randomly replaces a 2d numpy array with NaNs, number of NaNs specified"""
input_array.ravel()[
np.random.choice(input_array.size, num_of_na, replace=False)
] = np.nan
return input_array
def test_interpolate():
dummy_array = dummy_signal_array(5, 10)
# Poke holes so interpolate can fill
holey_array = randomly_add_na(dummy_array, 15)
dummy_signal = pd.DataFrame(dummy_array)
holey_signal = pd.DataFrame(holey_array)
interpolate_runner = interpolate(interpolateParameters.default())
interpolated_signal = interpolate_runner.run(holey_signal)
subtr = interpolated_signal - dummy_signal
# Check that interpolated values are the ones that exist in the dummy
assert np.nansum(subtr.to_numpy()) == 0
# TODO: Check that if there are NaNs remaining after interpolation, they
# are at the ends
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment