[med-svn] [Git][med-team/python-ncls][master] 2 commits: Add a sample autopkgtest

Nilesh Patra gitlab at salsa.debian.org
Sun Aug 2 18:46:10 BST 2020



Nilesh Patra pushed to branch master at Debian Med / python-ncls


Commits:
50f4109d by Nilesh Patra at 2020-08-02T23:08:06+05:30
Add a sample autopkgtest

- - - - -
ed8107d3 by Nilesh Patra at 2020-08-02T23:15:53+05:30
Add myself to uploaders

- - - - -


4 changed files:

- debian/control
- + debian/tests/control
- + debian/tests/run-unit-test
- + debian/tests/sample_test.py


Changes:

=====================================
debian/control
=====================================
@@ -1,6 +1,6 @@
 Source: python-ncls
 Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
-Uploaders: Steffen Moeller <moeller at debian.org>
+Uploaders: Steffen Moeller <moeller at debian.org>, Nilesh Patra <npatra974 at gmail.com>
 Section: science
 Testsuite: autopkgtest-pkg-python
 Priority: optional


=====================================
debian/tests/control
=====================================
@@ -0,0 +1,3 @@
+Tests: run-unit-test
+Depends: @, python3-all, python3-pytest, python3-pandas, python3-pytest
+Restrictions: allow-stderr


=====================================
debian/tests/run-unit-test
=====================================
@@ -0,0 +1,17 @@
+#!/bin/bash
+set -e
+
+CUR_DIR=`pwd`
+
+export LC_ALL=C.UTF-8
+if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
+  AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
+  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
+fi
+
+cp -a ${CUR_DIR}/debian/tests/sample_test.py "${AUTOPKGTEST_TMP}"
+cd "${AUTOPKGTEST_TMP}"
+
+gunzip -r *
+python3 -m pytest -v sample_test.py
+


=====================================
debian/tests/sample_test.py
=====================================
@@ -0,0 +1,33 @@
+from ncls import NCLS
+import pandas as pd
+
+def test_basic():
+	starts = pd.Series(range(0, 5))
+	ends = starts + 100
+	ids = starts
+
+	subject_df = pd.DataFrame({"Start": starts, "End": ends}, index=ids)
+	ncls = NCLS(starts.values, ends.values, ids.values)
+
+	it = ncls.find_overlap(0, 2)
+	overlap_check = []
+	for i in it:
+		for element in i:
+			overlap_check.append(element)
+	assert(overlap_check == [0, 100, 0, 1, 101, 1])
+
+	starts_query = pd.Series([1, 3])
+	ends_query = pd.Series([52, 14])
+	indexes_query = pd.Series([10000, 100])
+
+	query_df = pd.DataFrame({"Start": starts_query.values, "End": ends_query.values}, index=indexes_query.values)
+
+	l_idxs, r_idxs = ncls.all_overlaps_both(starts_query.values, ends_query.values, indexes_query.values)
+	assert(list(l_idxs) == [10000, 10000, 10000, 10000, 10000,  100,   100,   100,   100,   100])
+	assert(list(r_idxs) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4])
+
+	assert(list(query_df.loc[l_idxs]["End"]) == [52, 52, 52, 52, 52, 14, 14, 14, 14, 14])
+	assert(list(subject_df.loc[r_idxs]["End"]) == [100, 101, 102, 103, 104, 100, 101, 102, 103, 104])
+
+	intervals = ncls.intervals()
+	assert(intervals == [(0, 100, 0), (1, 101, 1), (2, 102, 2), (3, 103, 3), (4, 104, 4)])
\ No newline at end of file



View it on GitLab: https://salsa.debian.org/med-team/python-ncls/-/compare/a1f3f401c41587cbcc8dc31032621c160e65c4db...ed8107d372c64bb161b8abe14cb2866972b3ae3b

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-ncls/-/compare/a1f3f401c41587cbcc8dc31032621c160e65c4db...ed8107d372c64bb161b8abe14cb2866972b3ae3b
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20200802/89f5f2c5/attachment-0001.html>


More information about the debian-med-commit mailing list