Пример #1
0
    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'
            ]))

        f = formula.interactions(
            [formula.Term(l) for l in ['a', 'b', 'c', 'd']], order=[1, 2, 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'
            ]))

        f = formula.interactions(
            [formula.Term(l) for l in ['a', 'b', 'c', 'd']], order=[3])
        assert_equal(set(f.termnames()),
                     set(['a*b*c', 'a*c*d', 'a*b*d', 'b*c*d']))
Пример #2
0
    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']))