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
d32ba062
Commit
d32ba062
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Added shortcut constructor for equality operator.
parent
4c4344ae
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/node.py
+7
-0
7 additions, 0 deletions
src/node.py
src/rules/__init__.py
+3
-1
3 additions, 1 deletion
src/rules/__init__.py
tests/test_node.py
+5
-1
5 additions, 1 deletion
tests/test_node.py
with
15 additions
and
2 deletions
src/node.py
+
7
−
0
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
)
This diff is collapsed.
Click to expand it.
src/rules/__init__.py
+
3
−
1
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
],
}
This diff is collapsed.
Click to expand it.
tests/test_node.py
+
5
−
1
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
)
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