def test_match_reduce_sqrt_dividers(self): root = tree('sqrt(8)') self.assertEqualPos(match_reduce_sqrt(root), [P(root, split_dividers, (4, 2))]) root = tree('sqrt(27)') self.assertEqualPos(match_reduce_sqrt(root), [P(root, split_dividers, (9, 3))])
def test_match_reduce_sqrt_mult(self): ((l2, x),) = root = tree('sqrt(2x)') self.assertEqualPos(match_reduce_sqrt(root), [P(root, extract_sqrt_multiplicant, (Scope(root[0]), l2)), P(root, extract_sqrt_multiplicant, (Scope(root[0]), x))]) (((l2, x), y),) = root = tree('sqrt(2xy)') self.assertEqualPos(match_reduce_sqrt(root), [P(root, extract_sqrt_multiplicant, (Scope(root[0]), l2)), P(root, extract_sqrt_multiplicant, (Scope(root[0]), x)), P(root, extract_sqrt_multiplicant, (Scope(root[0]), y))])
def test_match_reduce_sqrt_mult(self): ((l2, x), ) = root = tree('sqrt(2x)') self.assertEqualPos(match_reduce_sqrt(root), [ P(root, extract_sqrt_multiplicant, (Scope(root[0]), l2)), P(root, extract_sqrt_multiplicant, (Scope(root[0]), x)) ]) (((l2, x), y), ) = root = tree('sqrt(2xy)') self.assertEqualPos(match_reduce_sqrt(root), [ P(root, extract_sqrt_multiplicant, (Scope(root[0]), l2)), P(root, extract_sqrt_multiplicant, (Scope(root[0]), x)), P(root, extract_sqrt_multiplicant, (Scope(root[0]), y)) ])
def test_match_reduce_sqrt_mult_priority(self): root = tree('sqrt(9 * 3)') self.assertEqualPos(match_reduce_sqrt(root), [P(root, extract_sqrt_mult_priority, (Scope(root[0]), 9)), P(root, extract_sqrt_multiplicant, (Scope(root[0]), 3))])
def test_match_reduce_sqrt_constant(self): root = tree('sqrt(4)') self.assertEqualPos(match_reduce_sqrt(root), [P(root, constant_sqrt, (2,))])
def test_match_reduce_sqrt_quadrant(self): root = tree('sqrt(a ^ 2)') self.assertEqualPos(match_reduce_sqrt(root), [P(root, quadrant_sqrt)])
def test_match_reduce_sqrt_none(self): root = tree('sqrt(a)') self.assertEqualPos(match_reduce_sqrt(root), []) root = tree('sqrt(-4)') self.assertEqualPos(match_reduce_sqrt(root), [])
def test_match_reduce_sqrt_mult_priority(self): root = tree('sqrt(9 * 3)') self.assertEqualPos(match_reduce_sqrt(root), [ P(root, extract_sqrt_mult_priority, (Scope(root[0]), 9)), P(root, extract_sqrt_multiplicant, (Scope(root[0]), 3)) ])
def test_match_reduce_sqrt_constant(self): root = tree('sqrt(4)') self.assertEqualPos(match_reduce_sqrt(root), [P(root, constant_sqrt, (2, ))])