Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
athena
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
atlas
athena
Merge requests
!28860
PyUtils: Fix handling of NaN in fprint.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
PyUtils: Fix handling of NaN in fprint.
ssnyder/athena:fprintNan.PyUtils-20191213
into
master
Overview
2
Commits
1
Pipelines
1
Changes
1
Merged
Scott Snyder
requested to merge
ssnyder/athena:fprintNan.PyUtils-20191213
into
master
5 years ago
Overview
2
Commits
1
Pipelines
1
Changes
1
Expand
Fix formatting of nan/inf in fprint() functions.
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
5f934a47
1 commit,
5 years ago
1 file
+
6
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Tools/PyUtils/python/fprint.py
+
6
−
1
Options
@@ -35,6 +35,7 @@
from
__future__
import
print_function
import
string
def
_formatFloat
(
x
):
@@ -48,6 +49,10 @@ asd
2.0
>>>
print
(
_formatFloat
(
2e30
))
2e+30
>>>
print
(
_formatFloat
(
float
(
'
nan
'
)))
nan
>>>
print
(
_formatFloat
(
float
(
'
inf
'
)))
inf
"""
# No change if it's not a float.
if
not
isinstance
(
x
,
float
):
@@ -56,7 +61,7 @@ asd
# with 12 significant figures --- except that the g format removes
# a trailing `.0' while py2 preserves it.
s
=
'
%.12g
'
%
x
if
s
.
find
(
'
.
'
)
<
0
and
s
.
find
(
'
e
'
)
<
0
:
if
s
.
find
(
'
.
'
)
<
0
and
s
.
find
(
'
e
'
)
<
0
and
s
[
-
1
]
in
string
.
digits
:
return
s
+
'
.0
'
return
s
Loading