[Scipy-svn] r3925 - trunk/scipy/stats/models/tests

scipy-svn@scip... scipy-svn@scip...
Tue Feb 12 15:32:41 CST 2008


Author: jonathan.taylor
Date: 2008-02-12 15:32:39 -0600 (Tue, 12 Feb 2008)
New Revision: 3925

Modified:
   trunk/scipy/stats/models/tests/test_formula.py
Log:
fixing one test for ordinal factor, added tests of __sub__ method

Modified: trunk/scipy/stats/models/tests/test_formula.py
===================================================================
--- trunk/scipy/stats/models/tests/test_formula.py	2008-02-12 21:13:12 UTC (rev 3924)
+++ trunk/scipy/stats/models/tests/test_formula.py	2008-02-12 21:32:39 UTC (rev 3925)
@@ -230,7 +230,7 @@
 
     def test_ordinal_factor(self):
         f = ['a','b','c']*3
-        fac = formula.Factor('ff', f, ordinal=True)
+        fac = formula.Factor('ff', ['a','b','c'], ordinal=True)
         fac.namespace = {'ff':f}
 
         assert_equal(fac(), [0,1,2]*3)
@@ -259,5 +259,24 @@
 
         self.assertEquals(estimable, False)
 
+    def test_interactions(self):
+
+        f = formula.interactions([formula.Term(l) for l in ['a', 'b', 'c']])
+        assert_equal(set(f.termnames()), set(['a', 'b', 'c', 'a*b', 'a*c', 'b*c']))
+
+        f = formula.interactions([formula.Term(l) for l in ['a', 'b', 'c', 'd']], order=3)
+        assert_equal(set(f.termnames()), set(['a', 'b', 'c', 'd', 'a*b', 'a*c', 'a*d', 'b*c', 'b*d', 'c*d', 'a*b*c', 'a*c*d', 'a*b*d', 'b*c*d']))
+
+    def test_subtract(self):
+        f = formula.interactions([formula.Term(l) for l in ['a', 'b', 'c']])
+        ff = f - f['a*b']
+        assert_equal(set(ff.termnames()), set(['a', 'b', 'c', 'a*c', 'b*c']))
+        
+        ff = f - f['a*b'] - f['a*c']
+        assert_equal(set(ff.termnames()), set(['a', 'b', 'c', 'b*c']))
+
+        ff = f - (f['a*b'] + f['a*c'])
+        assert_equal(set(ff.termnames()), set(['a', 'b', 'c', 'b*c']))
+
 if __name__ == "__main__":
     nose.run(argv=['', __file__])



More information about the Scipy-svn mailing list