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
73a3bf06
Commit
73a3bf06
authored
Jan 25, 2012
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added remaining possibility messages to the rules.
parent
0551ec1b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
17 deletions
+22
-17
src/rules/factors.py
src/rules/factors.py
+2
-3
src/rules/fractions.py
src/rules/fractions.py
+1
-1
src/rules/negation.py
src/rules/negation.py
+5
-3
src/rules/numerics.py
src/rules/numerics.py
+7
-2
src/rules/powers.py
src/rules/powers.py
+7
-8
No files found.
src/rules/factors.py
View file @
73a3bf06
...
@@ -53,7 +53,7 @@ def expand_single(root, args):
...
@@ -53,7 +53,7 @@ def expand_single(root, args):
return
scope
.
as_nary_node
()
return
scope
.
as_nary_node
()
MESSAGES
[
expand_single
]
=
_
(
'Expand {1}({2})
to {1}({2[0]}) + {1}({2[1]})
.'
)
MESSAGES
[
expand_single
]
=
_
(
'Expand {1}({2}).'
)
def
expand_double
(
root
,
args
):
def
expand_double
(
root
,
args
):
...
@@ -74,5 +74,4 @@ def expand_double(root, args):
...
@@ -74,5 +74,4 @@ def expand_double(root, args):
return
scope
.
as_nary_node
()
return
scope
.
as_nary_node
()
MESSAGES
[
expand_double
]
=
_
(
'Expand ({1})({2}) to {1[0]}{2[0]} + {1[0]}{2[1]}'
MESSAGES
[
expand_double
]
=
_
(
'Expand ({1})({2}).'
)
' + {1[1]}{2[0]} + {1[1]}{2[1]}.'
)
src/rules/fractions.py
View file @
73a3bf06
...
@@ -171,7 +171,7 @@ def add_nominators(root, args):
...
@@ -171,7 +171,7 @@ def add_nominators(root, args):
# TODO: convert this to a lambda. Example: 22 / 77 - 28 / 77. the "-" is above
# TODO: convert this to a lambda. Example: 22 / 77 - 28 / 77. the "-" is above
# the "28/77" division.
# the "28/77" division.
MESSAGES
[
add_nominators
]
=
_
(
'Add
nominators {1[0]} and {2[0]} of the division
.'
)
MESSAGES
[
add_nominators
]
=
_
(
'Add
the nominators of {1} and {2}
.'
)
def
match_expand_and_add_fractions
(
node
):
def
match_expand_and_add_fractions
(
node
):
...
...
src/rules/negation.py
View file @
73a3bf06
...
@@ -82,6 +82,9 @@ def double_negation(root, args):
...
@@ -82,6 +82,9 @@ def double_negation(root, args):
return
node
[
0
][
0
]
return
node
[
0
][
0
]
MESSAGES
[
double_negation
]
=
_
(
'Remove double negation in {1}.'
)
def
match_negated_division
(
node
):
def
match_negated_division
(
node
):
"""
"""
-a / -b -> a / b
-a / -b -> a / b
...
@@ -109,6 +112,8 @@ def single_negated_division(root, args):
...
@@ -109,6 +112,8 @@ def single_negated_division(root, args):
"""
"""
a
,
b
=
args
a
,
b
=
args
# FIXME: "-a/b" results in "-(a/b)", which will cause a loop.
return
-
(
a
/
b
)
return
-
(
a
/
b
)
...
@@ -127,6 +132,3 @@ def double_negated_division(root, args):
...
@@ -127,6 +132,3 @@ def double_negated_division(root, args):
MESSAGES
[
double_negated_division
]
=
\
MESSAGES
[
double_negated_division
]
=
\
_
(
'Eliminate top and bottom negation in {1}.'
)
_
(
'Eliminate top and bottom negation in {1}.'
)
MESSAGES
[
double_negation
]
=
_
(
'Remove double negation in {1}.'
)
src/rules/numerics.py
View file @
73a3bf06
...
@@ -38,8 +38,7 @@ def add_numerics(root, args):
...
@@ -38,8 +38,7 @@ def add_numerics(root, args):
return
scope
.
as_nary_node
()
return
scope
.
as_nary_node
()
MESSAGES
[
add_numerics
]
=
_
(
'Combine the constants {1} and {2}, which'
MESSAGES
[
add_numerics
]
=
_
(
'Combine the constants {1} and {2}.'
)
' will reduce to {1} + {2}.'
)
#def match_subtract_numerics(node):
#def match_subtract_numerics(node):
...
@@ -106,6 +105,9 @@ def divide_numerics(root, args):
...
@@ -106,6 +105,9 @@ def divide_numerics(root, args):
return
Leaf
(
n
/
d
)
return
Leaf
(
n
/
d
)
MESSAGES
[
divide_numerics
]
=
_
(
'Divide constant {1} by constant {2}.'
)
def
match_multiply_zero
(
node
):
def
match_multiply_zero
(
node
):
"""
"""
a * 0 -> 0
a * 0 -> 0
...
@@ -201,3 +203,6 @@ def multiply_numerics(root, args):
...
@@ -201,3 +203,6 @@ def multiply_numerics(root, args):
scope
.
remove
(
n1
)
scope
.
remove
(
n1
)
return
scope
.
as_nary_node
()
return
scope
.
as_nary_node
()
MESSAGES
[
multiply_numerics
]
=
_
(
'Multiply constant {1} with {2}.'
)
src/rules/powers.py
View file @
73a3bf06
...
@@ -62,8 +62,7 @@ def add_exponents(root, args):
...
@@ -62,8 +62,7 @@ def add_exponents(root, args):
return
scope
.
as_nary_node
()
return
scope
.
as_nary_node
()
MESSAGES
[
add_exponents
]
=
_
(
'Add the exponents of {1} and {2}, which'
MESSAGES
[
add_exponents
]
=
_
(
'Add the exponents of {1} and {2}.'
)
' will reduce to {1[0]}^({1[1]} + {2[1]}).'
)
def
match_subtract_exponents
(
node
):
def
match_subtract_exponents
(
node
):
...
@@ -186,8 +185,7 @@ def subtract_exponents(root, args):
...
@@ -186,8 +185,7 @@ def subtract_exponents(root, args):
return
a
**
(
p
-
q
)
return
a
**
(
p
-
q
)
MESSAGES
[
subtract_exponents
]
=
_
(
'Substract the exponents {1} and {2},'
MESSAGES
[
subtract_exponents
]
=
_
(
'Substract the exponents {2} and {3}.'
)
' which will reduce to {1[0]}^({1[1]} - {2[1]}).'
)
def
multiply_exponents
(
root
,
args
):
def
multiply_exponents
(
root
,
args
):
...
@@ -199,8 +197,7 @@ def multiply_exponents(root, args):
...
@@ -199,8 +197,7 @@ def multiply_exponents(root, args):
return
a
**
(
p
*
q
)
return
a
**
(
p
*
q
)
MESSAGES
[
multiply_exponents
]
=
_
(
'Multiply the exponents {1} and {2},'
MESSAGES
[
multiply_exponents
]
=
_
(
'Multiply the exponents {2} and {3}.'
)
' which will reduce to {1[0]}^({1[1]} * {2[1]}).'
)
def
duplicate_exponent
(
root
,
args
):
def
duplicate_exponent
(
root
,
args
):
...
@@ -217,8 +214,7 @@ def duplicate_exponent(root, args):
...
@@ -217,8 +214,7 @@ def duplicate_exponent(root, args):
return
result
return
result
MESSAGES
[
duplicate_exponent
]
=
_
(
'Duplicate the exponents {1} and {2},'
MESSAGES
[
duplicate_exponent
]
=
_
(
'Duplicate the exponent {2}.'
)
' which will reduce to {1[0]}^({1[1]} * {2[1]}).'
)
def
remove_negative_exponent
(
root
,
args
):
def
remove_negative_exponent
(
root
,
args
):
...
@@ -230,6 +226,9 @@ def remove_negative_exponent(root, args):
...
@@ -230,6 +226,9 @@ def remove_negative_exponent(root, args):
return
L
(
1
)
/
a
**
p
return
L
(
1
)
/
a
**
p
MESSAGES
[
remove_negative_exponent
]
=
_
(
'Remove negative exponent {2}.'
)
def
exponent_to_root
(
root
,
args
):
def
exponent_to_root
(
root
,
args
):
"""
"""
a^(1 / m) -> sqrt(a, m)
a^(1 / m) -> sqrt(a, m)
...
...
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