Skip to content

Commit

Permalink
Test Bio.Cluster error handling (fails on Python 3)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjc committed Jun 13, 2014
1 parent fa59704 commit 5b99854
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions Tests/test_Cluster.py
Expand Up @@ -135,6 +135,19 @@ def test_kcluster(self):
[ 1, 1, 1, 1, 1],
[ 1, 1, 1, 1, 1]], int)

#TODO - Use a context manager here once we drop Python 2.6
#Method should be one letter:
self.assertRaises(ValueError, kcluster, data,
**{"nclusters": nclusters, "mask": mask,
"weight": weight, "transpose": 0, "npass": 100,
"method": "any", "dist": "e"})

#Distance should be one letter:
self.assertRaises(ValueError, kcluster, data,
**{"nclusters": nclusters, "mask": mask,
"weight": weight, "transpose": 0, "npass": 100,
"method": "a", "dist": "euclidean"})

clusterid, error, nfound = kcluster(data, nclusters=nclusters,
mask=mask, weight=weight,
transpose=0, npass=100,
Expand Down Expand Up @@ -175,6 +188,19 @@ def test_kcluster(self):
[ 1, 1 ],
[ 1, 1 ]], int)

#TODO - Use a context manager here once we drop Python 2.6
#Method should be one letter:
self.assertRaises(ValueError, kcluster, data,
**{"nclusters": 3, "mask": mask,
"weight": weight, "transpose": 0, "npass": 100,
"method": "any", "dist": "e"})

#Distance should be one letter:
self.assertRaises(ValueError, kcluster, data,
**{"nclusters": 3, "mask": mask,
"weight": weight, "transpose": 0, "npass": 100,
"method": "a", "dist": "euclidean"})

clusterid, error, nfound = kcluster(data, nclusters=3, mask=mask,
weight=weight, transpose=0,
npass=100, method='a', dist='e')
Expand Down Expand Up @@ -207,6 +233,19 @@ def test_clusterdistance(self):
c2 = [1, 2]
c3 = [3]

#TODO - Use a context manager here once we drop Python 2.6
#Method should be one letter:
self.assertRaises(ValueError, clusterdistance, data,
**{"mask": mask, "weight": weight,
"index1": c1, "index2": c2, "transpose": 0,
"method": "any", "dist": "e"})

#Distance should be one letter:
self.assertRaises(ValueError, clusterdistance, data,
**{"mask": mask, "weight": weight,
"index1": c1, "index2": c2, "transpose": 0,
"method": "a", "dist": "euclidean"})

distance = clusterdistance(data, mask=mask, weight=weight,
index1=c1, index2=c2, dist='e',
method='a', transpose=0)
Expand Down Expand Up @@ -254,6 +293,21 @@ def test_clusterdistance(self):
c2 = [ 4, 5, 6, 7 ]
c3 = [ 8 ]

#TODO - Use a context manager here once we drop Python 2.6
#Method should be one letter:
self.assertRaises(ValueError, clusterdistance, data,
**{"mask": mask, "weight": weight,
"index1": c1, "index2": c2,
"method": "any", "dist": "e",
"transpose":0})

#Distance should be one letter:
self.assertRaises(ValueError, clusterdistance, data,
**{"mask": mask, "weight": weight,
"index1": c1, "index2": c2,
"method": "a", "dist": "euclidena",
"transpose":0})

distance = clusterdistance(data, mask=mask, weight=weight,
index1=c1, index2=c2, dist='e',
method='a', transpose=0)
Expand Down Expand Up @@ -284,6 +338,17 @@ def test_treecluster(self):
[ 1, 1, 1, 1, 1],
[ 1, 1, 1, 1, 1]], int)

#TODO - Use a context manager here once we drop Python 2.6
#Method should be one letter:
self.assertRaises(ValueError, treecluster,
**{"data": data1, "mask": mask1, "weight": weight1,
"transpose":0, "method": "any", "dist": "e"})

#Distance should be one letter:
self.assertRaises(ValueError, treecluster,
**{"data": data1, "mask": mask1, "weight": weight1,
"transpose":0, "method": "any", "dist": "euclidean"})

# test first data set
# Pairwise average-linkage clustering"
tree = treecluster(data=data1, mask=mask1, weight=weight1,
Expand Down Expand Up @@ -552,6 +617,13 @@ def test_somcluster(self):
[ 1, 1, 1, 1, 1],
[ 1, 1, 1, 1, 1]], int)

#TODO - Use a context manager here once we drop Python 2.6
#Distance should be one letter:
self.assertRaises(ValueError, somcluster,
**{"data": data, "mask": mask, "weight": weight,
"transpose": 0, "nxgrid": 10, "nygrid": 10,
"inittau": 0.02, "niter": 100, "dist": "euclidean"})

clusterid, celldata = somcluster(data=data, mask=mask, weight=weight,
transpose=0, nxgrid=10, nygrid=10,
inittau=0.02, niter=100, dist='e')
Expand Down

0 comments on commit 5b99854

Please sign in to comment.