Skip to content
Snippets Groups Projects
Commit d32ba062 authored by Taddeus Kroes's avatar Taddeus Kroes
Browse files

Added shortcut constructor for equality operator.

parent 4c4344ae
No related branches found
No related tags found
No related merge requests found
......@@ -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)
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],
}
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment