You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have written up a bunch of tests. The tests pass just fine if I run the following
python test_permutation.py
Now if I were to run nosetests as follows
nosetests .
I get the following error
======================================================================
ERROR: Conducts a fishers test on a contingency table.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/mortonjt/miniconda3/envs/canvas/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Users/mortonjt/miniconda3/envs/canvas/lib/python2.7/site-packages/nose/util.py", line 620, in newfunc
return func(*arg, **kw)
TypeError: fisher_mean_test() takes at least 2 arguments (0 given)
----------------------------------------------------------------------
Now the function that I'm trying to test is under permutation.py, the function signature+docstring is as follows
deffisher_mean_test(table, grouping, permutations=1000, random_state=None):
""" Conducts a fishers test on a contingency table. This module will conduct a mean permutation test using numpy matrix algebra. table: pd.DataFrame Contingency table of where columns correspond to features and rows correspond to samples. grouping : pd.Series Vector indicating the assignment of samples to groups. For example, these could be strings or integers denoting which group a sample belongs to. It must be the same length as the samples in `table`. The index must be the same on `table` and `grouping` but need not be in the same order. permutations: int Number of permutations to calculate random_state : int or RandomState, optional Pseudo number generator state used for random sampling. Return ------ pd.DataFrame A table of features, their t-statistics and p-values `"m"` is the t-statistic. `"pvalue"` is the p-value calculated from the permutation test. Examples -------- >>> from canvas.stats.permutation import fisher_mean >>> import pandas as pd >>> table = pd.DataFrame([[12, 11, 10, 10, 10, 10, 10], ... [9, 11, 12, 10, 10, 10, 10], ... [1, 11, 10, 11, 10, 5, 9], ... [22, 21, 9, 10, 10, 10, 10], ... [20, 22, 10, 10, 13, 10, 10], ... [23, 21, 14, 10, 10, 10, 10]], ... index=['s1','s2','s3','s4','s5','s6'], ... columns=['b1','b2','b3','b4','b5','b6','b7']) >>> grouping = pd.Series([0, 0, 0, 1, 1, 1], ... index=['s1','s2','s3','s4','s5','s6']) >>> results = fisher_mean(table, grouping, ... permutations=100, random_state=0) >>> results m pvalue b1 14.333333 0.108910 b2 10.333333 0.108910 b3 0.333333 1.000000 b4 0.333333 1.000000 b5 1.000000 1.000000 b6 1.666667 0.108910 b7 0.333333 1.000000 Notes ----- Only works on binary classes. """
It took me a few hours to realize that nosetest was treating this function as a unittest, and was trying to execute it. Just because the word test is inside the function name. The nosetests worked when I renamed the function the fisher_mean
I'm not sure what the best way around this problem is, but it took a while to hunt down this problem and it would be nice to at least document this issue.
The text was updated successfully, but these errors were encountered:
I have written up a bunch of tests. The tests pass just fine if I run the following
Now if I were to run nosetests as follows
I get the following error
Now the function that I'm trying to test is under
permutation.py
, the function signature+docstring is as followsIt took me a few hours to realize that nosetest was treating this function as a unittest, and was trying to execute it. Just because the word
test
is inside the function name. The nosetests worked when I renamed the function thefisher_mean
I'm not sure what the best way around this problem is, but it took a while to hunt down this problem and it would be nice to at least document this issue.
The text was updated successfully, but these errors were encountered: