Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
trs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
trs
Commits
6add540a
Commit
6add540a
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Changed function name.
parent
b4b5542d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/rules/integrals.py
+3
-3
3 additions, 3 deletions
src/rules/integrals.py
src/rules/utils.py
+2
-2
2 additions, 2 deletions
src/rules/utils.py
tests/test_rules_utils.py
+5
-5
5 additions, 5 deletions
tests/test_rules_utils.py
with
10 additions
and
10 deletions
src/rules/integrals.py
+
3
−
3
View file @
6add540a
from
.utils
import
find_variables
,
replace_variabl
e
,
find_variable
from
.utils
import
find_variables
,
substitut
e
,
find_variable
from
..node
import
ExpressionLeaf
as
L
,
OP_INT
,
OP_INT_INDEF
,
OP_MUL
,
OP_DIV
,
\
OP_LOG
,
OP_SIN
,
OP_COS
,
Scope
,
sin
,
cos
,
ln
,
integral
,
indef
,
absolute
from
..possibilities
import
Possibility
as
P
,
MESSAGES
...
...
@@ -40,7 +40,7 @@ def solve_integral(integral, F):
x
,
lbnd
,
ubnd
=
integral
[
1
:
4
]
if
x
!=
find_variable
(
F
):
return
replace_variabl
e
(
F
,
x
,
ubnd
)
-
replace_variabl
e
(
F
,
x
,
lbnd
)
return
substitut
e
(
F
,
x
,
ubnd
)
-
substitut
e
(
F
,
x
,
lbnd
)
return
indef
(
F
,
lbnd
,
ubnd
)
...
...
@@ -61,7 +61,7 @@ def solve_indef(root, args):
Fx
,
a
,
b
=
root
x
=
find_variable
(
Fx
)
return
replace_variable
(
Fx
,
x
,
b
)
-
replace_variabl
e
(
Fx
,
x
,
a
)
return
substitute
(
Fx
,
x
,
b
)
-
substitut
e
(
Fx
,
x
,
a
)
def
match_integrate_variable_power
(
node
):
...
...
This diff is collapsed.
Click to expand it.
src/rules/utils.py
+
2
−
2
View file @
6add540a
...
...
@@ -111,7 +111,7 @@ def find_variable(exp):
return
L
(
first_sorted_variable
(
variables
))
def
replace_variabl
e
(
f
,
x
,
replacement
):
def
substitut
e
(
f
,
x
,
replacement
):
"""
Replace all occurences of variable x in function f with the specified
replacement.
...
...
@@ -122,6 +122,6 @@ def replace_variable(f, x, replacement):
if
f
.
is_leaf
:
return
f
children
=
map
(
lambda
c
:
replace_variabl
e
(
c
,
x
,
replacement
),
f
)
children
=
map
(
lambda
c
:
substitut
e
(
c
,
x
,
replacement
),
f
)
return
N
(
f
.
op
,
*
children
)
This diff is collapsed.
Click to expand it.
tests/test_rules_utils.py
+
5
−
5
View file @
6add540a
from
src.rules
import
utils
from
src.rules.utils
import
least_common_multiple
,
is_fraction
,
partition
,
\
find_variables
,
first_sorted_variable
,
find_variable
,
replace_variabl
e
find_variables
,
first_sorted_variable
,
find_variable
,
substitut
e
from
tests.rulestestcase
import
tree
,
RulesTestCase
...
...
@@ -50,10 +50,10 @@ class TestRulesUtils(RulesTestCase):
self
.
assertEqual
(
find_variable
(
tree
(
'
1 + 2
'
)),
x
)
self
.
assertEqual
(
find_variable
(
tree
(
'
y ^ 2
'
)),
y
)
def
test_
replace_variabl
e
(
self
):
def
test_
substitut
e
(
self
):
x
,
a
=
tree
(
'
x, a
'
)
self
.
assertEqual
(
replace_variabl
e
(
x
,
x
,
a
),
a
)
self
.
assertEqual
(
replace_variabl
e
(
tree
(
'
x2
'
),
x
,
a
),
tree
(
'
a2
'
))
self
.
assertEqual
(
replace_variabl
e
(
tree
(
'
y + x + 1
'
),
x
,
a
),
self
.
assertEqual
(
substitut
e
(
x
,
x
,
a
),
a
)
self
.
assertEqual
(
substitut
e
(
tree
(
'
x2
'
),
x
,
a
),
tree
(
'
a2
'
))
self
.
assertEqual
(
substitut
e
(
tree
(
'
y + x + 1
'
),
x
,
a
),
tree
(
'
y + a + 1
'
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment