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
a455b76b
Commit
a455b76b
authored
Apr 23, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added left-or-right check to application that brings an expression into a fraction nominator.
parent
5f556a4e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
8 deletions
+11
-8
TODO
TODO
+0
-2
src/rules/fractions.py
src/rules/fractions.py
+7
-2
tests/test_leiden_oefenopgave_v12.py
tests/test_leiden_oefenopgave_v12.py
+3
-3
tests/test_rules_derivatives.py
tests/test_rules_derivatives.py
+1
-1
No files found.
TODO
View file @
a455b76b
...
@@ -60,8 +60,6 @@ Division of 0 by 1 reduces to 0.
...
@@ -60,8 +60,6 @@ Division of 0 by 1 reduces to 0.
- Parser: 'apia' -> 'aa'
- Parser: 'apia' -> 'aa'
- 'x(1 / x)' -> '(x * 1) / x' (currently no left/right check: '1x / x')
- Unit tests for strategy.
- Unit tests for strategy.
- MESSAGES needs to be expanded.
- MESSAGES needs to be expanded.
...
...
src/rules/fractions.py
View file @
a455b76b
...
@@ -217,12 +217,17 @@ MESSAGES[multiply_fractions] = _('Multiply fractions {2} and {3}.')
...
@@ -217,12 +217,17 @@ MESSAGES[multiply_fractions] = _('Multiply fractions {2} and {3}.')
def
multiply_with_fraction
(
root
,
args
):
def
multiply_with_fraction
(
root
,
args
):
"""
"""
a / b * c and
a, c in Z or a == 1 -> ac
/ b
a / b * c and
(eval(c) in Z or eval(a / b) not in Z) -> (ac)
/ b
"""
"""
scope
,
ab
,
c
=
args
scope
,
ab
,
c
=
args
a
,
b
=
ab
a
,
b
=
ab
scope
.
replace
(
ab
,
(
a
*
c
/
b
).
negate
(
ab
.
negated
))
if
scope
.
index
(
ab
)
-
scope
.
index
(
c
)
<
0
:
replacement
=
a
*
c
/
b
else
:
replacement
=
c
*
a
/
b
scope
.
replace
(
ab
,
replacement
.
negate
(
ab
.
negated
))
scope
.
remove
(
c
)
scope
.
remove
(
c
)
return
scope
.
as_nary_node
()
return
scope
.
as_nary_node
()
...
...
tests/test_leiden_oefenopgave_v12.py
View file @
a455b76b
...
@@ -57,10 +57,10 @@ class TestLeidenOefenopgaveV12(TestCase):
...
@@ -57,10 +57,10 @@ class TestLeidenOefenopgaveV12(TestCase):
def
test_2_a
(
self
):
def
test_2_a
(
self
):
self
.
assertRewrite
([
self
.
assertRewrite
([
'(a
^2b^-1)^3(ab^
2)'
,
'(a
^ 2 * b ^ -1) ^ 3(ab ^
2)'
,
'(a ^ 2 * 1 / b ^ 1) ^ 3 * ab ^ 2'
,
'(a ^ 2 * 1 / b ^ 1) ^ 3 * ab ^ 2'
,
'(a ^ 2 * 1 / b) ^ 3 * ab ^ 2'
,
'(a ^ 2 * 1 / b) ^ 3 * ab ^ 2'
,
'((
1a ^ 2
) / b) ^ 3 * ab ^ 2'
,
'((
a ^ 2 * 1
) / b) ^ 3 * ab ^ 2'
,
'(a ^ 2 / b) ^ 3 * ab ^ 2'
,
'(a ^ 2 / b) ^ 3 * ab ^ 2'
,
'(a ^ 2) ^ 3 / b ^ 3 * ab ^ 2'
,
'(a ^ 2) ^ 3 / b ^ 3 * ab ^ 2'
,
'a ^ (2 * 3) / b ^ 3 * ab ^ 2'
,
'a ^ (2 * 3) / b ^ 3 * ab ^ 2'
,
...
@@ -103,7 +103,7 @@ class TestLeidenOefenopgaveV12(TestCase):
...
@@ -103,7 +103,7 @@ class TestLeidenOefenopgaveV12(TestCase):
self
.
assertRewrite
([
self
.
assertRewrite
([
'4b^-2'
,
'4b^-2'
,
'4 * 1 / b ^ 2'
,
'4 * 1 / b ^ 2'
,
'(
1 * 4
) / b ^ 2'
,
'(
4 * 1
) / b ^ 2'
,
'4 / b ^ 2'
,
'4 / b ^ 2'
,
])
])
...
...
tests/test_rules_derivatives.py
View file @
a455b76b
...
@@ -110,7 +110,7 @@ class TestRulesDerivatives(RulesTestCase):
...
@@ -110,7 +110,7 @@ class TestRulesDerivatives(RulesTestCase):
"x ^ x * (1ln(x) + x[ln(x)]')"
,
"x ^ x * (1ln(x) + x[ln(x)]')"
,
"x ^ x * (ln(x) + x[ln(x)]')"
,
"x ^ x * (ln(x) + x[ln(x)]')"
,
"x ^ x * (ln(x) + x * 1 / x)"
,
"x ^ x * (ln(x) + x * 1 / x)"
,
"x ^ x * (ln(x) + (
1x
) / x)"
,
"x ^ x * (ln(x) + (
x * 1
) / x)"
,
"x ^ x * (ln(x) + x / x)"
,
"x ^ x * (ln(x) + x / x)"
,
"x ^ x * (ln(x) + 1)"
,
"x ^ x * (ln(x) + 1)"
,
"x ^ x * ln(x) + x ^ x * 1"
,
"x ^ x * ln(x) + x ^ x * 1"
,
...
...
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