Comments (7)
https://github.com/ashishkg0022/sympy/tree/rubi_progress/sympy/integrals/rubi
Here is the rubi module
rubi.py
contains the manytoonereplacer
rules
contain all rules
constraints.py
contain constraints.
There are around 7000 rules.
from matchpy.
For few rules I tried this
import re
import os
from sympy.core.expr import Basic
from sympy.integrals.rubi.rubi import rubi_object
from sympy.integrals.rubi.rubi import *
from sympy import *
from sympy.core.singleton import Singleton
from matchpy.matching.code_generation import CodeGenerator
rubi = rubi_object()[0]
GENERATED_TEMPLATE = '''
# -*- coding: utf-8 -*-
from matchpy import *
from sympy import *
from sympy.integrals.rubi.utility_function import *
from sympy.integrals.rubi.constraints import *
from sympy.integrals.rubi.symbol import *
{}
{}
'''.strip()
generator = CodeGenerator(rubi.matcher)
global_code, code = generator.generate_code()
code = GENERATED_TEMPLATE.format(global_code, code)
with open('generated.py', 'w', encoding='utf-8') as f:
f.write(code)
from generated import match_root
x = symbols('x')
for r, _ in match_root(Integral(x, x)):
print(r)
But this gives an key_error
~/generated.py in match_root(subject)
27036 yield 6, tmp_subst
27037 subjects2.appendleft(tmp120)
> 27038 if 'i1' in subst1 and CustomConstraint(cons_f16)(subst1):
27039 # State 6226
27040 if len(subjects2) >= 1:
~/Envs/sym/lib/python3.6/site-packages/matchpy/expressions/constraints.py in __call__(self, match)
186
187 def __call__(self, match: substitution.Substitution) -> bool:
--> 188 args = dict((name, match[var_name]) for name, var_name in self._variables.items())
189
190 return self.constraint(**args)
~/Envs/sym/lib/python3.6/site-packages/matchpy/expressions/constraints.py in <genexpr>(.0)
186
187 def __call__(self, match: substitution.Substitution) -> bool:
--> 188 args = dict((name, match[var_name]) for name, var_name in self._variables.items())
189
190 return self.constraint(**args)
KeyError: 'u'
What can be the cause of this ?
from matchpy.
Here is some progress sympy/sympy#14988
I got the code generator working. But it is able to match few expression and unable to match many.
from matchpy.
The cause for the error is likely that you are using a variable u
in your constraint which is not matched.
I don't have time to help you debug that though. You might also want to look into overriding constraint_repr
of the code generator for your custom constraint classes.
from matchpy.
Actually that problem is solved. We have faced a new issue, in which it is able to match some expressions and unable for some. Progress can be seen here sympy/sympy#14988
from matchpy.
@wheerd we are observing that, in code_generation matching, if any constraint returns False
, matching is not continued any further. Probably this is the only issue. If this is fixed, our work is done.
from matchpy.
@wheerd we are observing that, in code_generation matching, if any constraint returns
False
, matching is not continued any further. Probably this is the only issue. If this is fixed, our work is done.
If I'm not mistaken, this problem is fixed (see #41).
from matchpy.
Related Issues (20)
- Wildcard that matches multiple symbols HOT 1
- Create `new` class method on Symbol HOT 1
- ManyToOneMatcher: Position of constraints logic HOT 3
- GPL'd dependency: hopcroftkarp library HOT 6
- Usage of type unions HOT 1
- [Feature] Visualization of Expressions with Graphviz
- ANN: MatchPyCpp port to C++ HOT 7
- New release? HOT 5
- Remove dependency on pkg_resources/setuptools HOT 1
- Inconsistent output of match_anywhere HOT 4
- Improve checking correctness of input
- Match arbitrary function HOT 4
- One-to-one matching: symbols with variable_name do not work in commutative functions HOT 2
- substitute not working with SymPy HOT 11
- Optional wildcards to match the identity element of the current node HOT 7
- FreeQ equivalent in MatchPy? HOT 1
- New MatchPy version? HOT 5
- Expression matching with patterns without wildcards HOT 4
- Overridable node visitors instead of typed-nodes in expression trees HOT 2
- Project fails on test cases
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matchpy.