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
92f3a4e9
Commit
92f3a4e9
authored
Jan 08, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added type check to ExpressionLeaf equality check.
- Now, integer- and float-leaves are never considered equal.
parent
6843d12e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
8 deletions
+7
-8
src/node.py
src/node.py
+4
-5
tests/test_rules_powers.py
tests/test_rules_powers.py
+3
-3
No files found.
src/node.py
View file @
92f3a4e9
...
...
@@ -242,13 +242,12 @@ class ExpressionLeaf(Leaf, ExpressionBase):
self
.
type
=
TYPE_MAP
[
type
(
args
[
0
])]
def
__eq__
(
self
,
other
):
if
type
(
other
)
in
(
int
,
float
,
str
):
return
self
.
value
==
other
other_type
=
type
(
other
)
if
other
.
is_leaf
()
:
return
self
.
value
==
other
.
value
if
other
_type
in
TYPE_MAP
:
return
TYPE_MAP
[
other_type
]
==
self
.
type
and
self
.
value
==
other
return
Fals
e
return
other
.
type
==
self
.
type
and
self
.
value
==
other
.
valu
e
def
extract_polynome_properties
(
self
):
"""
...
...
tests/test_rules_powers.py
View file @
92f3a4e9
...
...
@@ -88,14 +88,14 @@ class TestRulesPowers(RulesTestCase):
[
P
(
root
,
remove_negative_exponent
,
(
a
,
p
))])
def
test_match_exponent_to_root
(
self
):
a
,
n
,
m
=
tree
(
'a,n,m'
)
root
=
a
**
(
n
/
m
)
a
,
n
,
m
,
l1
=
tree
(
'a,n,m,1'
)
root
=
a
**
(
n
/
m
)
possibilities
=
match_exponent_to_root
(
root
)
self
.
assertEqualPos
(
possibilities
,
[
P
(
root
,
exponent_to_root
,
(
a
,
n
,
m
))])
n
.
value
=
1
root
=
a
**
(
l1
/
m
)
possibilities
=
match_exponent_to_root
(
root
)
self
.
assertEqualPos
(
possibilities
,
[
P
(
root
,
exponent_to_root
,
(
a
,
1
,
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