Skip to content

Commit c3b93bb

Browse files
authored
Merge pull request sympy#16356 from Upabjojr/fix_matchpy_register
Fix RUBI code to connect to latest MatchPy master
2 parents 16ce867 + 13159af commit c3b93bb

26 files changed

+185
-365
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ before_install:
261261
conda clean --all;
262262
fi
263263
if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then
264-
conda install matchpy;
264+
# Change this back to conda once matchpy 0.5.0 gets updated on conda-forge
265+
pip install matchpy;
265266
fi
266267
elif [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then
267268
pip list | grep "numpy" && pip uninstall -y numpy;

sympy/core/tests/test_args.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4595,13 +4595,13 @@ def test_sympy__integrals__rubi__utility_function__rubi_unevaluated_expr():
45954595
a = symbols('a')
45964596
assert _test_args(rubi_unevaluated_expr(a))
45974597

4598-
def test_sympy__integrals__rubi__utility_function__exp():
4599-
from sympy.integrals.rubi.utility_function import exp
4600-
assert _test_args(exp(5))
4598+
def test_sympy__integrals__rubi__utility_function__rubi_exp():
4599+
from sympy.integrals.rubi.utility_function import rubi_exp
4600+
assert _test_args(rubi_exp(5))
46014601

4602-
def test_sympy__integrals__rubi__utility_function__log():
4603-
from sympy.integrals.rubi.utility_function import log
4604-
assert _test_args(log(5))
4602+
def test_sympy__integrals__rubi__utility_function__rubi_log():
4603+
from sympy.integrals.rubi.utility_function import rubi_log
4604+
assert _test_args(rubi_log(5))
46054605

46064606
def test_sympy__integrals__rubi__utility_function__Int():
46074607
from sympy.integrals.rubi.utility_function import Int

sympy/integrals/rubi/constraints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if matchpy:
1111
from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match
1212
from sympy.integrals.rubi.utility_function import (
13-
sympy_op_factory, Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
13+
Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
1414
ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ,
1515
PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ,
1616
ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ,
@@ -116,7 +116,7 @@
116116
TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor,
117117
PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral,
118118
CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial,
119-
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, exp, log, Discriminant,
119+
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant,
120120
Negative, Quotient
121121
)
122122
from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul,

sympy/integrals/rubi/parsetools/header.py.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ from sympy.utilities.decorator import doctest_depends_on
1010
if matchpy:
1111
from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match
1212
from sympy.integrals.rubi.utility_function import (
13-
sympy_op_factory, Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
13+
Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
1414
ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ,
1515
PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ,
1616
ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ,
@@ -116,7 +116,7 @@ if matchpy:
116116
TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor,
117117
PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral,
118118
CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial,
119-
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, exp, log, Discriminant,
119+
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant,
120120
Negative, Quotient
121121
)
122122
from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul,

sympy/integrals/rubi/rubi.py

Lines changed: 3 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -8,174 +8,16 @@
88
if matchpy:
99
from matchpy import (Operation, CommutativeOperation, AssociativeOperation,
1010
ManyToOneReplacer, OneIdentityOperation, CustomConstraint)
11-
from matchpy.expressions.functions import register_operation_iterator, register_operation_factory
1211
from sympy import Pow, Add, Integral, Basic, Mul, S, Function, E
1312
from sympy.functions import (log, sin, cos, tan, cot, csc, sec, sqrt, erf,
1413
exp as sym_exp, gamma, acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh,
1514
tanh, coth, sech, csch, atan, acsc, asin, acot, acos, asec, fresnels,
1615
fresnelc, erfc, erfi, Ei, uppergamma, polylog, zeta, factorial, polygamma, digamma, li,
1716
expint, LambertW, loggamma)
18-
from sympy.integrals.rubi.utility_function import (Gamma, exp, log, ProductLog, PolyGamma,
19-
rubi_unevaluated_expr, process_trig)
17+
from sympy.integrals.rubi.utility_function import (Gamma, rubi_exp, rubi_log, ProductLog, PolyGamma,
18+
rubi_unevaluated_expr, process_trig)
2019

21-
Operation.register(Integral)
22-
register_operation_iterator(Integral, lambda a: (a._args[0],) + a._args[1], lambda a: len((a._args[0],) + a._args[1]))
23-
24-
Operation.register(Pow)
25-
OneIdentityOperation.register(Pow)
26-
register_operation_iterator(Pow, lambda a: a._args, lambda a: len(a._args))
27-
28-
Operation.register(Add)
29-
OneIdentityOperation.register(Add)
30-
CommutativeOperation.register(Add)
31-
AssociativeOperation.register(Add)
32-
register_operation_iterator(Add, lambda a: a._args, lambda a: len(a._args))
33-
34-
Operation.register(Mul)
35-
OneIdentityOperation.register(Mul)
36-
CommutativeOperation.register(Mul)
37-
AssociativeOperation.register(Mul)
38-
register_operation_iterator(Mul, lambda a: a._args, lambda a: len(a._args))
39-
40-
Operation.register(exp)
41-
register_operation_iterator(exp, lambda a: a._args, lambda a: len(a._args))
42-
43-
Operation.register(log)
44-
register_operation_iterator(log, lambda a: a._args, lambda a: len(a._args))
45-
46-
Operation.register(Gamma)
47-
register_operation_iterator(Gamma, lambda a: a._args, lambda a: len(a._args))
48-
49-
Operation.register(gamma)
50-
register_operation_iterator(gamma, lambda a: a._args, lambda a: len(a._args))
51-
52-
Operation.register(polygamma)
53-
register_operation_iterator(polygamma, lambda a: a._args, lambda a: len(a._args))
54-
55-
Operation.register(loggamma)
56-
register_operation_iterator(loggamma, lambda a: a._args, lambda a: len(a._args))
57-
58-
Operation.register(PolyGamma)
59-
register_operation_iterator(PolyGamma, lambda a: a._args, lambda a: len(a._args))
60-
61-
Operation.register(LambertW)
62-
register_operation_iterator(LambertW, lambda a: a._args, lambda a: len(a._args))
63-
64-
Operation.register(uppergamma)
65-
register_operation_iterator(uppergamma, lambda a: a._args, lambda a: len(a._args))
66-
67-
Operation.register(polylog)
68-
register_operation_iterator(polylog, lambda a: a._args, lambda a: len(a._args))
69-
70-
Operation.register(ProductLog)
71-
register_operation_iterator(ProductLog, lambda a: a._args, lambda a: len(a._args))
72-
73-
Operation.register(zeta)
74-
register_operation_iterator(zeta, lambda a: a._args, lambda a: len(a._args))
75-
76-
Operation.register(li)
77-
register_operation_iterator(li, lambda a: a._args, lambda a: len(a._args))
78-
79-
Operation.register(expint)
80-
register_operation_iterator(expint, lambda a: a._args, lambda a: len(a._args))
81-
82-
Operation.register(factorial)
83-
register_operation_iterator(factorial, lambda a: a._args, lambda a: len(a._args))
84-
85-
Operation.register(fresnels)
86-
register_operation_iterator(fresnels, lambda a: a._args, lambda a: len(a._args))
87-
88-
Operation.register(fresnelc)
89-
register_operation_iterator(fresnelc, lambda a: a._args, lambda a: len(a._args))
90-
91-
Operation.register(erf)
92-
register_operation_iterator(erf, lambda a: a._args, lambda a: len(a._args))
93-
94-
Operation.register(Ei)
95-
register_operation_iterator(Ei, lambda a: a._args, lambda a: len(a._args))
96-
97-
Operation.register(erfc)
98-
register_operation_iterator(erfc, lambda a: a._args, lambda a: len(a._args))
99-
100-
Operation.register(erfi)
101-
register_operation_iterator(erfi, lambda a: a._args, lambda a: len(a._args))
102-
103-
Operation.register(sin)
104-
register_operation_iterator(sin, lambda a: a._args, lambda a: len(a._args))
105-
106-
Operation.register(cos)
107-
register_operation_iterator(cos, lambda a: a._args, lambda a: len(a._args))
108-
109-
Operation.register(tan)
110-
register_operation_iterator(tan, lambda a: a._args, lambda a: len(a._args))
111-
112-
Operation.register(cot)
113-
register_operation_iterator(cot, lambda a: a._args, lambda a: len(a._args))
114-
115-
Operation.register(csc)
116-
register_operation_iterator(csc, lambda a: a._args, lambda a: len(a._args))
117-
118-
Operation.register(sec)
119-
register_operation_iterator(sec, lambda a: a._args, lambda a: len(a._args))
120-
121-
Operation.register(sinh)
122-
register_operation_iterator(sinh, lambda a: a._args, lambda a: len(a._args))
123-
124-
Operation.register(cosh)
125-
register_operation_iterator(cosh, lambda a: a._args, lambda a: len(a._args))
126-
127-
Operation.register(tanh)
128-
register_operation_iterator(tanh, lambda a: a._args, lambda a: len(a._args))
129-
130-
Operation.register(coth)
131-
register_operation_iterator(coth, lambda a: a._args, lambda a: len(a._args))
132-
133-
Operation.register(csch)
134-
register_operation_iterator(csch, lambda a: a._args, lambda a: len(a._args))
135-
136-
Operation.register(sech)
137-
register_operation_iterator(sech, lambda a: a._args, lambda a: len(a._args))
138-
139-
Operation.register(asin)
140-
register_operation_iterator(asin, lambda a: a._args, lambda a: len(a._args))
141-
142-
Operation.register(acos)
143-
register_operation_iterator(acos, lambda a: a._args, lambda a: len(a._args))
144-
145-
Operation.register(atan)
146-
register_operation_iterator(atan, lambda a: a._args, lambda a: len(a._args))
147-
148-
Operation.register(acot)
149-
register_operation_iterator(acot, lambda a: a._args, lambda a: len(a._args))
150-
151-
Operation.register(acsc)
152-
register_operation_iterator(acsc, lambda a: a._args, lambda a: len(a._args))
153-
154-
Operation.register(asec)
155-
register_operation_iterator(asec, lambda a: a._args, lambda a: len(a._args))
156-
157-
Operation.register(asinh)
158-
register_operation_iterator(asinh, lambda a: a._args, lambda a: len(a._args))
159-
160-
Operation.register(acosh)
161-
register_operation_iterator(acosh, lambda a: a._args, lambda a: len(a._args))
162-
163-
Operation.register(atanh)
164-
register_operation_iterator(atanh, lambda a: a._args, lambda a: len(a._args))
165-
166-
Operation.register(acoth)
167-
register_operation_iterator(acoth, lambda a: a._args, lambda a: len(a._args))
168-
169-
Operation.register(acsch)
170-
register_operation_iterator(acsch, lambda a: a._args, lambda a: len(a._args))
171-
172-
Operation.register(asech)
173-
register_operation_iterator(asech, lambda a: a._args, lambda a: len(a._args))
174-
175-
def sympy_op_factory(old_operation, new_operands, variable_name):
176-
return type(old_operation)(*new_operands)
177-
178-
register_operation_factory(Basic, sympy_op_factory)
20+
from sympy.utilities.matchpy_connector import op_iter, op_len
17921

18022
@doctest_depends_on(modules=('matchpy',))
18123
def rubi_object():

sympy/integrals/rubi/rules/binomial_products.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if matchpy:
1111
from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match
1212
from sympy.integrals.rubi.utility_function import (
13-
sympy_op_factory, Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
13+
Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
1414
ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ,
1515
PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ,
1616
ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ,
@@ -116,7 +116,7 @@
116116
TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor,
117117
PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral,
118118
CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial,
119-
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, exp, log, Discriminant,
119+
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant,
120120
Negative, Quotient
121121
)
122122
from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul,

sympy/integrals/rubi/rules/exponential.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if matchpy:
1111
from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match
1212
from sympy.integrals.rubi.utility_function import (
13-
sympy_op_factory, Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
13+
Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
1414
ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ,
1515
PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ,
1616
ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ,
@@ -116,7 +116,7 @@
116116
TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor,
117117
PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral,
118118
CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial,
119-
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, exp, log, Discriminant,
119+
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant,
120120
Negative, Quotient
121121
)
122122
from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul,

sympy/integrals/rubi/rules/hyperbolic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if matchpy:
1111
from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match
1212
from sympy.integrals.rubi.utility_function import (
13-
sympy_op_factory, Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
13+
Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
1414
ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ,
1515
PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ,
1616
ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ,
@@ -116,7 +116,7 @@
116116
TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor,
117117
PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral,
118118
CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial,
119-
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, exp, log, Discriminant,
119+
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant,
120120
Negative, Quotient
121121
)
122122
from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul,

sympy/integrals/rubi/rules/integrand_simplification.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if matchpy:
1111
from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match
1212
from sympy.integrals.rubi.utility_function import (
13-
sympy_op_factory, Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
13+
Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
1414
ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ,
1515
PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ,
1616
ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ,
@@ -116,7 +116,7 @@
116116
TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor,
117117
PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral,
118118
CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial,
119-
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, exp, log, Discriminant,
119+
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant,
120120
Negative, Quotient
121121
)
122122
from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul,
@@ -287,7 +287,7 @@ def replacement29(p, u, m, b, r, a, c, x, q):
287287
pattern30 = Pattern(Integral(x_**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons21, cons4, cons53)
288288
def replacement30(m, b, a, n, x):
289289
rubi.append(30)
290-
return Simp(log(RemoveContent(a + b*x**n, x))/(b*n), x)
290+
return Simp(rubi_log(RemoveContent(a + b*x**n, x))/(b*n), x)
291291
rule30 = ReplacementRule(pattern30, replacement30)
292292
pattern31 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons4, cons5, cons53, cons54)
293293
def replacement31(p, m, b, a, n, x):

sympy/integrals/rubi/rules/inverse_hyperbolic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if matchpy:
1111
from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match
1212
from sympy.integrals.rubi.utility_function import (
13-
sympy_op_factory, Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
13+
Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ,
1414
ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ,
1515
PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ,
1616
ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ,
@@ -116,7 +116,7 @@
116116
TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor,
117117
PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral,
118118
CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial,
119-
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, exp, log, Discriminant,
119+
Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant,
120120
Negative, Quotient
121121
)
122122
from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy