-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimalisations, unit testing, travis (#60)
- Loading branch information
Showing
12 changed files
with
237 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
language: bash | ||
|
||
os: | ||
- windows | ||
- linux | ||
|
||
# jobs: | ||
# include: | ||
# - os: linux | ||
# python: 3.8.1 | ||
|
||
branches: | ||
only: | ||
- master | ||
- dev | ||
- "/^pull.$" | ||
- "/^hotfix-.+$/" | ||
|
||
before_install: | ||
- . scripts/travis/before_install_nix_win.sh | ||
|
||
install: | ||
# Install miniconda | ||
- . scripts/travis/install_nix_win.sh | ||
|
||
- source $MINICONDA_PATH/etc/profile.d/conda.sh; | ||
- hash -r | ||
|
||
# Setting up conda env and install deps | ||
- conda env create -q -n minian -f environment.yml | ||
- conda activate minian | ||
- conda list | ||
- conda install -c conda-forge -y jupyterlab | ||
- jupyter labextension install @pyviz/jupyterlab_pyviz | ||
- conda env export | ||
- conda install -y pytest-cov | ||
- conda install -c anaconda -y black | ||
|
||
script: | ||
# The test/check scripts go here | ||
- travis_fold start "Black-check code quality" | ||
- black --check minian | ||
- travis_fold end "Black-check code quality" | ||
|
||
- travis_fold start "pytest" | ||
- pytest -v --color=yes --cov=minian --pyargs minian | ||
- travis_fold end "pytest" | ||
|
||
# - travis_fold start "Jupyter notebook pipeline" | ||
# - papermill pipeline.ipynb pipeline_output.ipynb | ||
# - travis_fold end "Jupyter notebook pipeline" | ||
|
||
after_success: | ||
- echo conda install codecov | ||
- echo codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Minian | ||
|
||
## Running unit tests | ||
Minian uses pytest for unit testing. | ||
|
||
To run the unit tests run the following command from the root of the Minian project: | ||
``` | ||
pytest --pyargs minian | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pytest | ||
import numpy as np | ||
import holoviews as hv | ||
|
||
from ..utilities import load_videos | ||
from ..preprocessing import denoise | ||
|
||
dpath = "./demo_movies" | ||
|
||
param_load_videos = { | ||
'pattern': 'msCam[0-9]+\.avi$', | ||
'dtype': np.uint8, | ||
'downsample': dict(frame=2,height=1,width=1), | ||
'downsample_strategy': 'subset' | ||
} | ||
|
||
param_denoise = { | ||
'method': 'median', | ||
'ksize': 7 | ||
} | ||
|
||
@pytest.fixture | ||
def varr(): | ||
return load_videos(dpath, **param_load_videos) | ||
|
||
def test_can_load_videos(varr): | ||
assert varr.shape[0] == 1000 # frames | ||
assert varr.shape[1] == 480 # height | ||
assert varr.shape[2] == 752 # width | ||
return varr | ||
|
||
def test_can_init_holoviews(): | ||
hv.notebook_extension('bokeh') | ||
|
||
def test_subset_part_video(varr): | ||
subset = dict(frame=slice(0,None)) | ||
varr_ref = varr.sel(subset) | ||
assert varr_ref.all() == varr.all() | ||
|
||
def test_denoise(varr): | ||
varr_ref = denoise(varr, **param_denoise) | ||
assert varr_ref.all() != varr.all() # when both are equal the denoise didn't do anything --> fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.