Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pycgtool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
James Graham
pycgtool
Commits
82840522
Commit
82840522
authored
7 years ago
by
James Graham
Browse files
Options
Downloads
Patches
Plain Diff
Collect all failing lines in cmp_whitespace_float
parent
ba16605a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pycgtool/util.py
+13
-15
13 additions, 15 deletions
pycgtool/util.py
with
13 additions
and
15 deletions
pycgtool/util.py
+
13
−
15
View file @
82840522
...
@@ -337,20 +337,18 @@ def cmp_whitespace_float(ref_lines, test_lines, rtol=0.01, verbose=False):
...
@@ -337,20 +337,18 @@ def cmp_whitespace_float(ref_lines, test_lines, rtol=0.01, verbose=False):
except
ValueError
:
except
ValueError
:
return
string
return
string
compare
=
True
diff_lines
=
[]
for
ref_line
,
test_line
in
itertools
.
zip_longest
(
ref_lines
,
test_lines
):
for
i
,
(
ref_line
,
test_line
)
in
enumerate
(
itertools
.
zip_longest
(
ref_lines
,
test_lines
)
)
:
# Shortcut trivial comparisons
# Shortcut trivial comparisons
if
ref_line
is
None
or
test_line
is
None
:
if
ref_line
is
None
or
test_line
is
None
:
compare
=
False
diff_lines
.
append
((
i
,
ref_line
,
test_line
))
break
if
ref_line
==
test_line
:
if
ref_line
==
test_line
:
continue
continue
ref_toks
=
ref_line
.
split
()
ref_toks
=
ref_line
.
split
()
test_toks
=
test_line
.
split
()
test_toks
=
test_line
.
split
()
if
len
(
ref_toks
)
!=
len
(
test_toks
):
if
len
(
ref_toks
)
!=
len
(
test_toks
):
compare
=
False
diff_lines
.
append
((
i
,
ref_line
,
test_line
))
break
# Check for float comparison
# Check for float comparison
for
ref_tok
,
test_tok
in
zip
(
map
(
number_or_string
,
ref_toks
),
for
ref_tok
,
test_tok
in
zip
(
map
(
number_or_string
,
ref_toks
),
...
@@ -358,19 +356,19 @@ def cmp_whitespace_float(ref_lines, test_lines, rtol=0.01, verbose=False):
...
@@ -358,19 +356,19 @@ def cmp_whitespace_float(ref_lines, test_lines, rtol=0.01, verbose=False):
if
ref_tok
!=
test_tok
:
if
ref_tok
!=
test_tok
:
try
:
try
:
if
abs
(
ref_tok
-
test_tok
)
>
abs
(
ref_tok
)
*
rtol
:
if
abs
(
ref_tok
-
test_tok
)
>
abs
(
ref_tok
)
*
rtol
:
compare
=
False
diff_lines
.
append
((
i
,
ref_line
,
test_line
))
except
TypeError
:
except
TypeError
:
compare
=
False
diff_lines
.
append
((
i
,
ref_line
,
test_line
))
if
not
compare
:
break
if
verbose
and
not
compare
:
if
verbose
and
diff_lines
:
print
(
"
Lines fail comparison:
"
)
print
(
"
Lines fail comparison:
"
)
print
(
diff_lines
)
for
i
,
ref_line
,
test_line
in
diff_lines
:
print
(
"
Line {}
"
.
format
(
i
))
print
(
"
Ref: {0}
"
.
format
(
ref_line
))
print
(
"
Ref: {0}
"
.
format
(
ref_line
))
print
(
"
Test: {0}
"
.
format
(
test_line
))
print
(
"
Test: {0}
"
.
format
(
test_line
))
return
compare
return
len
(
diff_lines
)
==
0
def
once_wrapper
(
func
):
def
once_wrapper
(
func
):
...
...
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