Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
0d3981fd
Commit
0d3981fd
authored
Mar 26, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit testss for integral helper function.
parent
2094cd11
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
src/rules/integrals.py
src/rules/integrals.py
+1
-1
tests/test_rules_integrals.py
tests/test_rules_integrals.py
+16
-3
No files found.
src/rules/integrals.py
View file @
0d3981fd
...
@@ -56,7 +56,7 @@ def solve_integral(integral, F):
...
@@ -56,7 +56,7 @@ def solve_integral(integral, F):
x
,
lbnd
,
ubnd
=
integral
[
1
:
4
]
x
,
lbnd
,
ubnd
=
integral
[
1
:
4
]
if
x
!=
find_variable
(
F
):
if
x
!=
find_variable
(
F
):
return
replace_variable
(
F
,
x
,
b
)
-
replace_variable
(
F
,
x
,
a
)
return
replace_variable
(
F
,
x
,
ubnd
)
-
replace_variable
(
F
,
x
,
lbnd
)
return
indef
(
F
,
lbnd
,
ubnd
)
return
indef
(
F
,
lbnd
,
ubnd
)
...
...
tests/test_rules_integrals.py
View file @
0d3981fd
from
src.rules.integrals
import
choose_constant
,
match_solve_indef
,
\
from
src.rules.integrals
import
indef
,
choose_constant
,
solve_integral
,
\
solve_indef
,
match_integrate_variable_power
,
integrate_variable_root
,
\
match_solve_indef
,
solve_indef
,
match_integrate_variable_power
,
\
integrate_variable_exponent
integrate_variable_
root
,
integrate_variable_
exponent
from
src.rules.logarithmic
import
ln
from
src.rules.logarithmic
import
ln
#from .goniometry import sin, cos
#from .goniometry import sin, cos
from
src.possibilities
import
Possibility
as
P
from
src.possibilities
import
Possibility
as
P
...
@@ -19,6 +19,19 @@ class TestRulesIntegrals(RulesTestCase):
...
@@ -19,6 +19,19 @@ class TestRulesIntegrals(RulesTestCase):
root
=
tree
(
'[x ^ 2]_a^b'
)
root
=
tree
(
'[x ^ 2]_a^b'
)
self
.
assertEqualPos
(
match_solve_indef
(
root
),
[
P
(
root
,
solve_indef
)])
self
.
assertEqualPos
(
match_solve_indef
(
root
),
[
P
(
root
,
solve_indef
)])
def
test_solve_integral
(
self
):
root
,
F
,
Fc
=
tree
(
'int x ^ 2 dx, 1 / 3 x ^ 3, 1 / 3 x ^ 3 + c'
)
self
.
assertEqual
(
solve_integral
(
root
,
F
),
Fc
)
x2
,
x
,
a
,
b
=
root
=
tree
(
'int_a^b x ^ 2 dx'
)
self
.
assertEqual
(
solve_integral
(
root
,
F
),
indef
(
Fc
,
a
,
b
))
def
test_solve_integral_skip_indef
(
self
):
root
,
x
,
c
,
l1
=
tree
(
'int_a^b y ^ x dy, x, c, 1'
)
F
=
tree
(
'1 / (x + 1)y ^ (x + 1)'
)
y
,
a
,
b
=
root
[
1
:
4
]
Fx
=
lambda
y
:
l1
/
(
x
+
1
)
*
y
**
(
x
+
1
)
+
c
self
.
assertEqual
(
solve_integral
(
root
,
F
),
Fx
(
b
)
-
Fx
(
a
))
def
test_solve_indef
(
self
):
def
test_solve_indef
(
self
):
root
,
expect
=
tree
(
'[x ^ 2]_a^b, b2 - a2'
)
root
,
expect
=
tree
(
'[x ^ 2]_a^b, b2 - a2'
)
self
.
assertEqual
(
solve_indef
(
root
,
()),
expect
)
self
.
assertEqual
(
solve_indef
(
root
,
()),
expect
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment