diff --git a/sympy/core/add.py b/sympy/core/add.py index 5afd6683b7..92dc05c3fe 100644 --- a/sympy/core/add.py +++ b/sympy/core/add.py @@ -363,8 +363,8 @@ def _matches_simple(self, expr, repl_dict): return terms[0].matches(expr - coeff, repl_dict) return - def matches(self, expr, repl_dict={}, old=False): - return AssocOp._matches_commutative(self, expr, repl_dict, old) + def matches(self, expr, repl_dict={}): + return AssocOp._matches_commutative(self, expr, repl_dict) @staticmethod def _combine_inverse(lhs, rhs): diff --git a/sympy/core/basic.py b/sympy/core/basic.py index 65137a2552..aaa1c99db3 100644 --- a/sympy/core/basic.py +++ b/sympy/core/basic.py @@ -1379,7 +1379,7 @@ def count(self, query): query = _make_find_query(query) return sum(bool(query(sub)) for sub in preorder_traversal(self)) - def matches(self, expr, repl_dict={}, old=False): + def matches(self, expr, repl_dict={}): """Helper method for match() that looks for a match between Wild symbols in self and expressions in expr. @@ -1408,12 +1408,12 @@ def matches(self, expr, repl_dict={}, old=False): for arg, other_arg in zip(self.args, expr.args): if arg == other_arg: continue - d = arg.xreplace(d).matches(other_arg, d, old=old) + d = arg.xreplace(d).matches(other_arg, d) if d is None: return return d - def match(self, pattern, old=False): + def match(self, pattern): """Pattern matching. Wild symbols match all. @@ -1441,15 +1441,6 @@ def match(self, pattern, old=False): True >>> (p*q**r).xreplace(e.match(p*q**r)) 4*x**2 - - The ``old`` flag will give the old-style pattern matching where - expressions and patterns are essentially solved to give the - match. Both of the following give None unless ``old=True``: - - >>> (x - 2).match(p - x, old=True) - {p_: 2*x - 2} - >>> (2/x).match(p*x, old=True) - {p_: 2/x**2} """ from sympy import signsimp pattern = sympify(pattern) @@ -1458,9 +1449,9 @@ def match(self, pattern, old=False): # if we still have the same relationship between the types of # input, then use the sign simplified forms if (pattern.func == self.func) and (s.func == p.func): - rv = p.matches(s, old=old) + rv = p.matches(s) else: - rv = pattern.matches(self, old=old) + rv = pattern.matches(self) return rv def count_ops(self, visual=None): @@ -1590,7 +1581,7 @@ class Atom(Basic): __slots__ = [] - def matches(self, expr, repl_dict={}, old=False): + def matches(self, expr, repl_dict={}): if self == expr: return repl_dict diff --git a/sympy/core/function.py b/sympy/core/function.py index ceb3dee49d..6f57a63a04 100644 --- a/sympy/core/function.py +++ b/sympy/core/function.py @@ -773,7 +773,7 @@ def __init__(cls, name, **assumptions): nargs = FiniteSet(*nargs) cls.nargs = nargs - def matches(self, expr, repl_dict={}, old=False): + def matches(self, expr, repl_dict={}): if not isinstance(expr, (AppliedUndef, Function)): return if len(expr.args) not in self.nargs: diff --git a/sympy/core/mul.py b/sympy/core/mul.py index 509ba5d22a..34f11a2f64 100644 --- a/sympy/core/mul.py +++ b/sympy/core/mul.py @@ -812,10 +812,10 @@ def _matches_simple(self, expr, repl_dict): return terms[0].matches(newexpr, repl_dict) return - def matches(self, expr, repl_dict={}, old=False): + def matches(self, expr, repl_dict={}): expr = sympify(expr) if self.is_commutative and expr.is_commutative: - return AssocOp._matches_commutative(self, expr, repl_dict, old) + return AssocOp._matches_commutative(self, expr, repl_dict) elif self.is_commutative is not expr.is_commutative: return c1, nc1 = self.args_cnc() @@ -826,7 +826,7 @@ def matches(self, expr, repl_dict={}, old=False): c2 = [1] a = self.func(*c1) if isinstance(a, AssocOp): - repl_dict = a._matches_commutative(self.func(*c2), repl_dict, old) + repl_dict = a._matches_commutative(self.func(*c2), repl_dict) else: repl_dict = a.matches(self.func(*c2), repl_dict) if repl_dict: diff --git a/sympy/core/operations.py b/sympy/core/operations.py index bb7c99936d..3eafe1d889 100644 --- a/sympy/core/operations.py +++ b/sympy/core/operations.py @@ -125,7 +125,7 @@ def flatten(cls, seq): # c_part, nc_part, order_symbols return [], new_seq, None - def _matches_commutative(self, expr, repl_dict={}, old=False): + def _matches_commutative(self, expr, repl_dict={}): """ Matches Add/Mul "pattern" to an expression "expr". @@ -200,7 +200,7 @@ def _matches_commutative(self, expr, repl_dict={}, old=False): return newpattern = self.func(*wild_part) newexpr = self._combine_inverse(expr, exact) - if not old and (expr.is_Add or expr.is_Mul): + if expr.is_Add or expr.is_Mul: if newexpr.count_ops() > expr.count_ops(): return return newpattern.matches(newexpr, repl_dict) diff --git a/sympy/core/power.py b/sympy/core/power.py index 6320f48fee..5b2c578d9b 100644 --- a/sympy/core/power.py +++ b/sympy/core/power.py @@ -1077,7 +1077,7 @@ def as_numer_denom(self): exp = -exp return self.func(n, exp), self.func(d, exp) - def matches(self, expr, repl_dict={}, old=False): + def matches(self, expr, repl_dict={}): expr = _sympify(expr) # special case, pattern = 1 and expr.exp can match to 0 @@ -1101,13 +1101,13 @@ def matches(self, expr, repl_dict={}, old=False): return sb.matches(expr**(1/se), repl_dict) d = repl_dict.copy() - d = self.base.matches(b, d, old=old) + d = self.base.matches(b, d) if d is None: return - d = self.exp.xreplace(d).matches(e, d, old=old) + d = self.exp.xreplace(d).matches(e, d) if d is None: - return Expr.matches(self, expr, repl_dict, old=old) + return Expr.matches(self, expr, repl_dict) return d def _eval_nseries(self, x, n, logx): diff --git a/sympy/core/symbol.py b/sympy/core/symbol.py index 2875c33dfa..8286504446 100644 --- a/sympy/core/symbol.py +++ b/sympy/core/symbol.py @@ -296,7 +296,7 @@ def _hashable_content(self): return super(Wild, self)._hashable_content() + (self.exclude, self.properties) # TODO add check against another Wild - def matches(self, expr, repl_dict={}, old=False): + def matches(self, expr, repl_dict={}): if any(expr.has(x) for x in self.exclude): return if any(not f(expr) for f in self.properties): diff --git a/sympy/integrals/meijerint.py b/sympy/integrals/meijerint.py index f3b0650393..0fad866df7 100644 --- a/sympy/integrals/meijerint.py +++ b/sympy/integrals/meijerint.py @@ -112,6 +112,9 @@ def eval(cls, arg): add((t**a - b**a)/(t - b), [0, a], [], [0, a], [], t/b, b**(a - 1)*sin(a*pi)/pi) + add((z**a - b**a)/(z - b), [0, a], [], [0, a], [], z/b, + b**(a - 1)*sin(a*pi)/pi) + # 12 def A1(r, sign, nu): return pi**(-S(1)/2)*(-sign*nu/2)**(1 - 2*r) @@ -139,7 +142,7 @@ def tmpadd(r, sgn): # (those after look obscure) # Section 8.4.3 - add(exp(polar_lift(-1)*t), [], [], [0], []) + add(exp(t), [], [], [0], [], t/polar_lift(-1)) # TODO can do sin^n, sinh^n by expansion ... where? # 8.4.4 (hyperbolic functions) @@ -1441,7 +1444,7 @@ def _rewrite_single(f, x, recursive=True): if t in _lookup_table: l = _lookup_table[t] for formula, terms, cond, hint in l: - subs = f.match(formula, old=True) + subs = f.match(formula) if subs: subs_ = {} for fro, to in subs.items():