Skip to content

Commit 19e09ee

Browse files
authored
Merge pull request #6566 from gadfort/handle-tcl-nan
utl: provide ability to convert NaN from tcl
2 parents 992f278 + e3d98bf commit 19e09ee

File tree

6 files changed

+12
-18
lines changed

6 files changed

+12
-18
lines changed

src/utl/src/LoggerCommon.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ void metric_float(const char* metric, const double value)
106106
logger->metric(metric, value);
107107
}
108108

109+
void metric_float(const char* metric, const char* value)
110+
{
111+
Logger* logger = getLogger();
112+
logger->metric(metric, std::stod(value));
113+
}
114+
109115
void set_metrics_stage(const char* fmt)
110116
{
111117
Logger* logger = getLogger();

src/utl/src/LoggerCommon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ void close_metrics(const char* metrics_filename);
4747
void metric(const char* metric, const char* value);
4848
void metric_integer(const char* metric, const int value);
4949
void metric_float(const char* metric, const double value);
50+
void metric_float(const char* metric, const char* value);
5051
void set_metrics_stage(const char* fmt);
5152
void clear_metrics_stage();
5253
void push_metrics_stage(const char* fmt);

src/utl/test/metrics-py.jsonok

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"float0": 0,
66
"float1": 1000,
77
"float2": 1e+39,
8+
"float3": "NaN",
89
"float4": "Infinity",
910
"float5": "-Infinity",
1011
"string0": "",

src/utl/test/test_metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
utl.metric_float("float5", float("-inf"))
1818

1919
utl.metric("string0", "")
20-
utl.metric("string1", "(one")
20+
utl.metric("string1", "one")
2121

2222
utl.close_metrics(metrics_file)
23-
helpers.diff_files("metrics-py.jsonok", metrics_file)
23+
helpers.diff_files("metrics.jsonok", metrics_file)
2424

2525

2626
utl.metric_float("float6", float("-inf"))

src/utl/test/test_metrics.tcl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ utl::metric_integer "integer2" 1
1111
utl::metric_float "float0" 0
1212
utl::metric_float "float1" 1e3
1313
utl::metric_float "float2" 1e39
14-
# TCL cannot convert NaN
15-
#utl::metric_float "float3" nan
14+
utl::metric_float "float3" nan
1615
utl::metric_float "float4" INF
1716
utl::metric_float "float5" -INF
1817

1918
utl::metric "string0" ""
2019
utl::metric "string1" "one"
2120

2221
utl::close_metrics $metrics_file
23-
diff_files "metrics-tcl.jsonok" $metrics_file
22+
diff_files "metrics.jsonok" $metrics_file

0 commit comments

Comments
 (0)