Skip to content

Commit

Permalink
Lint tests (#85)
Browse files Browse the repository at this point in the history
* lint tests
(Common problem is assigning to a variable, and then not making any assertions.)

* whitespace. runs well locally.
  • Loading branch information
mccalluc authored and pkerpedjiev committed May 24, 2019
1 parent e6f6f9d commit ae193e1
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 39 deletions.
28 changes: 15 additions & 13 deletions test/tiles/bedarcsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,37 @@ def get_counts(filename, zoom, pos):

for i, d in enumerate(data[0][1][pos]):
chr1, chr2 = sorted([d['fields'][0], d['fields'][3]])
#print('d:', d)
# print('d:', d)

counts[(chr1, chr2)] += 1
return counts


def test_bedarcsdb_tiles1():
filename = op.join(
'data', '9ae0744a-9bc1-4cd7-b7cf-c6569ed9e4aa.pcawg_consensus_1.6.161022.somatic.sv.bedpe.multires.db')
'data',
'9ae0744a-9bc1-4cd7-b7cf-c6569ed9e4aa'
'.pcawg_consensus_1.6.161022.somatic.sv.bedpe.multires.db')

tiles_to_get = [(2, 2)]

for ttg in tiles_to_get:
counts = get_counts(filename, *ttg)
get_counts(filename, *ttg)
# print(*ttg, counts)
#counts1 = get_counts(filename, 0,0)
#counts1 = get_counts(filename, 1,1)
# counts1 = get_counts(filename, 0,0)
# counts1 = get_counts(filename, 1,1)
# counts2 = get_counts(filename, 2,2)
# counts3 = get_counts(filename, 2,3)

#print('1,1', counts1)
#print('2,2', counts2)
# print('1,1', counts1)
# print('2,2', counts2)
# print('2,3', counts3)

#print('1', counts1[('21', 'X')])
#print('2', counts1[('21', 'X')])
# print('1', counts1[('21', 'X')])
# print('2', counts1[('21', 'X')])

#print("1,1", get_counts(filename, 1,1))
#print('2,2', get_counts(filename, 2,2))
# print("1,1", get_counts(filename, 1,1))
# print('2,2', get_counts(filename, 2,2))

'''
data = hgbad.tiles(filename, ["b.0.0"])
Expand Down Expand Up @@ -85,6 +87,6 @@ def test_bedarcsdb_tiles():
filename = op.join('data', 'arrowhead_domains_short.txt.multires.db')

pos = 2
data = hgbad.tiles(filename, ["b.2.{}".format(pos)])
hgbad.tiles(filename, ["b.2.{}".format(pos)])

pass
# TODO: Do something with the data we get back?
8 changes: 4 additions & 4 deletions test/tiles/beddb_test.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import clodius.tiles.beddb as hgbe
import json
import os.path as op


def test_get_tiles():
filename = op.join('data', 'corrected.geneListwithStrand.bed.multires')

ret = hgbe.tiles(filename, ['x.1.0', 'x.1.1'])
hgbe.tiles(filename, ['x.1.0', 'x.1.1'])
# TODO: Do something with the return value


def test_list_items():
filename = op.join('data', 'gene_annotations.short.db')

ret = hgbe.list_items(filename, 0, 100000000, max_entries=100)
# print('ret:', ret)
hgbe.list_items(filename, 0, 100000000, max_entries=100)
# TODO: Do something with the return value
11 changes: 7 additions & 4 deletions test/tiles/bigwig_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,15 @@ def test_natsorted():
'expected': ['1', '2', '3', '4', 'x', 'y', 'm']
},
{
'input': ['chr1', 'chr4', 'chr5', 'chr2', 'chr3', 'chrMT', 'chrY', 'chrX'],
'expected': ['chr1', 'chr2', 'chr3', 'chr4', 'chr5', 'chrX', 'chrY', 'chrMT']
'input': ['chr1', 'chr4', 'chr5', 'chr2',
'chr3', 'chrMT', 'chrY', 'chrX'],
'expected': ['chr1', 'chr2', 'chr3', 'chr4',
'chr5', 'chrX', 'chrY', 'chrMT']
}
]

for test in chromname_tests:
sorted_output = hgbi.natsorted(test['input'])
assert sorted_output == test['expected'], 'Sorted output was %s\nExpected: %s' % (
sorted_output, test['expected'])
assert sorted_output == test['expected'],\
'Sorted output was %s\nExpected: %s' \
% (sorted_output, test['expected'])
6 changes: 3 additions & 3 deletions test/tiles/cooler_test.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import clodius.tiles.cooler as hgco
import json
import numpy as np
import os.path as op
import base64


def test_cooler_info():
filename = op.join(
'data', 'Dixon2012-J1-NcoI-R1-filtered.100kb.multires.cool')

info = hgco.tileset_info(filename)
hgco.tileset_info(filename)
# TODO: Make assertion about info returned.

tiles = hgco.generate_tiles(filename, ['a.0.0.0'])

import base64
r = base64.decodestring(tiles[0][1]['dense'].encode('utf-8'))
q = np.frombuffer(r, dtype=np.float32)

Expand Down
6 changes: 3 additions & 3 deletions test/tiles/density_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def test_bundled_tiles():
filename = 'data/points_density.h5'

tiles = hgut.bundled_tiles_wrapper_2d(['c.2.0.0', 'c.2.1.1', 'c.2.0.1', 'c.2.1.0'],
ft.partial(hgde.tiles, filename))
tiles = hgut.bundled_tiles_wrapper_2d(
['c.2.0.0', 'c.2.1.1', 'c.2.0.1', 'c.2.1.0'],
ft.partial(hgde.tiles, filename))
assert(len(tiles) == 4)
return
3 changes: 0 additions & 3 deletions test/tiles/hitile_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import dask.array as da
import h5py
import clodius.tiles.hitile as hghi
import math
import numpy as np
import os.path as op
import random
import sys
import tempfile


Expand Down
4 changes: 2 additions & 2 deletions test/tiles/multivec_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
def test_multivec():
filename = op.join('data', 'all.KL.bed.multires.mv5')

tsinfo = hgmu.tileset_info(filename)
# print(hgmu.tileset_info(filename))
hgmu.tileset_info(filename)
# TODO: Make assertions about info returned.
3 changes: 2 additions & 1 deletion test/tiles/npvector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ def test_npvector():
# print('ts:', hgnv.tileset_info(array))
assert('max_width' in hgnv.tileset_info(array))

tile = hgnv.tiles(array, 0, 0)
hgnv.tiles(array, 0, 0)
# TODO: Make assertions about tile returned.
4 changes: 2 additions & 2 deletions test/tiles/time_interval_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
def test_tileset_info():
filename = op.join('data', 'sample_htime.json')

tsinfo = hgti.tileset_info(filename)
# print(hgti.tileset_info(filename))
hgti.tileset_info(filename)
# TODO: Make assertions about info returned.
5 changes: 1 addition & 4 deletions travis_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ flake8 --config=.flake8-ignore
# TODO: Add more files to this list:
flake8 test/tsv_to_mrmatrix_test.py \
scripts/tsv_to_mrmatrix.py \
test/*.py
# TODO: When everything is covered,
# just lint the whole directory once,
# instead of listing special cases.
test/*/*.py
end flake8

start download
Expand Down

0 comments on commit ae193e1

Please sign in to comment.