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
d32ba062
Commit
d32ba062
authored
Mar 29, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added shortcut constructor for equality operator.
parent
4c4344ae
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
src/node.py
src/node.py
+7
-0
src/rules/__init__.py
src/rules/__init__.py
+3
-1
tests/test_node.py
tests/test_node.py
+5
-1
No files found.
src/node.py
View file @
d32ba062
...
...
@@ -691,3 +691,10 @@ def indef(*args):
Create an indefinite integral node.
"""
return ExpressionNode(OP_INT_INDEF, *args)
def eq(left, right):
"""
Create an equality operator node.
"""
return ExpressionNode(OP_EQ, left, right)
src/rules/__init__.py
View file @
d32ba062
from
..node
import
OP_ADD
,
OP_MUL
,
OP_DIV
,
OP_POW
,
OP_NEG
,
OP_SIN
,
OP_COS
,
\
OP_TAN
,
OP_DER
,
OP_LOG
,
OP_INT
,
OP_INT_INDEF
OP_TAN
,
OP_DER
,
OP_LOG
,
OP_INT
,
OP_INT_INDEF
,
OP_EQ
from
.groups
import
match_combine_groups
from
.factors
import
match_expand
from
.powers
import
match_add_exponents
,
match_subtract_exponents
,
\
...
...
@@ -27,6 +27,7 @@ from src.rules.logarithmic import match_constant_logarithm, \
from
src.rules.integrals
import
match_solve_indef
,
match_constant_integral
,
\
match_integrate_variable_power
,
match_factor_out_constant
,
\
match_division_integral
,
match_function_integral
from
src.rules.lineq
import
match_subtract_addition_term
RULES
=
{
OP_ADD
:
[
match_add_numerics
,
match_add_constant_fractions
,
...
...
@@ -60,4 +61,5 @@ RULES = {
match_factor_out_constant
,
match_division_integral
,
match_function_integral
],
OP_INT_INDEF
:
[
match_solve_indef
],
OP_EQ
:
[
match_subtract_addition_term
],
}
tests/test_node.py
View file @
d32ba062
from
src.node
import
ExpressionNode
as
N
,
ExpressionLeaf
as
L
,
Scope
,
\
nary_node
,
get_scope
,
OP_ADD
,
infinity
,
absolute
,
sin
,
cos
,
tan
,
log
,
\
ln
,
der
,
integral
,
indef
ln
,
der
,
integral
,
indef
,
eq
from
tests.rulestestcase
import
RulesTestCase
,
tree
...
...
@@ -291,3 +291,7 @@ class TestNode(RulesTestCase):
def
test_indef
(
self
):
x2
,
a
,
b
,
expect
=
tree
(
'x ^ 2, a, b, [x ^ 2]_a^b'
)
self
.
assertEqual
(
indef
(
x2
,
a
,
b
),
expect
)
def
test_eq
(
self
):
x
,
a
,
b
,
expect
=
tree
(
'x, a, b, x + a = b'
)
self
.
assertEqual
(
eq
(
x
+
a
,
b
),
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