Skip to content

Commit

Permalink
Merge pull request #109 from nvictus/develop
Browse files Browse the repository at this point in the history
Switch to pytest and add coverage reporting
  • Loading branch information
nvictus authored Sep 30, 2019
2 parents a8acf8d + 40b1400 commit 9490f38
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 85 deletions.
10 changes: 0 additions & 10 deletions .flake8

This file was deleted.

60 changes: 38 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,47 @@
COMMANDS
old
npm-debug.log
.DS_Store
clodius/fast.cpython-35m-darwin.so
clodius/fast.so
tmp
checkpoint
*.py[cod]
__pycache__
*~
*.swn
*.swo
*.swp
*.tiles
*.pyc
/data

# setup and build artifacts
*.egg-info/
.eggs/
dist/
build/
MANIFEST
docs/_templates
docs/_static
docs/_build
clodius/*.c
*.so

# test and coverage artifacts
.cache
.pytest_cache
.coverage
coverage.xml
htmlcov/

# OS-generated files
.DS_Store
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

.ipynb_checkpoints/
.idea/
old
tmp
checkpoint
data/
output/
COMMANDS
npm-debug.log
output.tar
profile.dat
profile.png
output/
aws_keys.py
.ipynb_checkpoints/
/build
/dist
.idea/
clodius.egg-info
.eggs
clodius/*.c
*.so
docs/_templates
docs/_static
docs/_build
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ before_install:
- wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
# Prefer stability to having the latest
# - conda update --yes conda
install:
- conda install --yes python=$TRAVIS_PYTHON_VERSION numpy
- pip install -r requirements-dev.txt
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
?

- Maintenance: Swicthed from nose to pytest and added coverage reporting.

v0.11.1

- Added `max_tile_width` parameter to ct.bam.tiles() so that users can set a
Expand Down
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Clodius <img src="https://travis-ci.org/hms-dbmi/clodius.svg?branch=develop"/>
# Clodius

[![Build Status](https://travis-ci.org/higlass/clodius.svg?branch=develop)](https://travis-ci.org/higlass/clodius)
[![Docs](https://img.shields.io/badge/docs-📖-red.svg?colorB=6680ff)](https://docs.higlass.io/data_preparation.html)

Displaying large amounts of data often requires first turning it into
not-so-large amounts of data. Clodius is a program and library designed
Expand Down Expand Up @@ -45,30 +48,23 @@ The recommended way to develop `clodius` is to use a [conda](https://conda.io/do
install `clodius` with develop mode:

```shell
python setup.py develop
```

Note that making changes to the `clodius/fast.pyx` [cython](http://docs.cython.org/en/latest/src/quickstart/cythonize.html) module requires an
explicit recompile step:

```shell
python setup.py build_ext --inplace
pip install -e .
```

## Testing


The unit tests for clodius can be run using [nosetests](http://nose.readthedocs.io/en/latest/):
The unit tests for clodius can be run using [pytest](https://docs.pytest.org/en/latest/):

```shell
nosetests test
pytest
```

Individual unit tests can be specified by indicating the file and function
they are defined in:

```shell
nosetests test/cli_test.py:test_clodius_aggregate_bedgraph
pytest test/cli_test.py:test_clodius_aggregate_bedgraph
```

## Quick start with Docker
Expand Down
7 changes: 0 additions & 7 deletions pyprof.sh

This file was deleted.

3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-r requirements.txt
flake8
nose==1.3.7
pytest
pytest-cov
autopep8
bumpversion
12 changes: 6 additions & 6 deletions scripts/pyprof.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# https://github.com/martinxyz/config/blob/master/scripts/pyprof
set - e # exit on error
rm - f profile.png profile.dat
python - m cProfile - o profile.dat $@
gprof2dot.py - f pstats profile.dat | dot - Tpng - o profile.png
open profile.png
#https://github.com/martinxyz/config/blob/master/scripts/pyprof
set -e # exit on error
rm -f profile.png profile.dat
python -m cProfile -o profile.dat $@
gprof2dot.py -f pstats profile.dat | dot -Tpng -o profile.png
eog profile.png
39 changes: 39 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[wheel]
universal = 1

[flake8]
exclude =
__init__.py
src/* # src directory is generated during build, and then cleared.
src/**/*

max-line-length = 80

ignore =
E501 # Line too long
E722 # do not use bare 'except'
W503 # line break before binary operator
W504 # line break after binary operator

select =
C # mccabe code complexity
E # pycodestyle error
W # pycodestyle warning
F # pyflakes fatals
# B # bugbear default checks
# B950 # bugbear opinonated warning (Line too long: max-line-length + 10%)

[tool:pytest]
addopts = --cov=clodius --cov-report=term-missing --cov-report=html --cov-report=xml
testpaths =
test

[coverage:run]
source =
clodius/

[coverage:report]
exclude_lines =
pragma: no cover
return NotImplemented
raise NotImplementedError
14 changes: 0 additions & 14 deletions test.py

This file was deleted.

16 changes: 6 additions & 10 deletions test/tiles/bigwig_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import base64


def arr_eq_nan(a, b):
return ((a == b) | (np.isnan(a) & np.isnan(b))).all()


def test_bigwig_tiles():
filename = op.join(
'data',
Expand Down Expand Up @@ -60,14 +56,14 @@ def test_bigwig_tiles():
)

assert min_max_val.shape[0] == 2 * mean_val.shape[0]
assert arr_eq_nan(min_max_val[::2], min_val)
assert arr_eq_nan(min_max_val[1::2], max_val)
assert np.allclose(min_max_val[::2], min_val, equal_nan=True)
assert np.allclose(min_max_val[1::2], max_val, equal_nan=True)

assert whisker_val.shape[0] == 4 * mean_val.shape[0]
assert arr_eq_nan(whisker_val[::4], min_val)
assert arr_eq_nan(whisker_val[1::4], max_val)
assert arr_eq_nan(whisker_val[2::4], mean_val)
assert arr_eq_nan(whisker_val[3::4], std_val)
assert np.allclose(whisker_val[::4], min_val, equal_nan=True)
assert np.allclose(whisker_val[1::4], max_val, equal_nan=True)
assert np.allclose(whisker_val[2::4], mean_val, equal_nan=True)
assert np.allclose(whisker_val[3::4], std_val, equal_nan=True)


def test_tileset_info():
Expand Down
2 changes: 1 addition & 1 deletion travis_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ start download
end download

start test
nosetests test
pytest
end test

0 comments on commit 9490f38

Please sign in to comment.