Skip to content

Commit

Permalink
Log warning instead of fatal when parsing float get under/overflow (#…
Browse files Browse the repository at this point in the history
…4336)

* Log warning instead of fatal when parsing float get under/overflow.

For texts that resolve to infinity, under or overflow should be
accepted.

* Remove outdated unit test.

* empty commit to trigger ci
  • Loading branch information
cyfdecyf authored Jun 18, 2021
1 parent 1b567bf commit f126db6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
2 changes: 1 addition & 1 deletion include/LightGBM/utils/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ inline static const char* AtofPrecise(const char* p, double* out) {
Log::Fatal("no conversion to double for: %s", p);
}
if (errno == ERANGE) {
Log::Fatal("convert to double got underflow or overflow: %s", p);
Log::Warning("convert to double got underflow or overflow: %s", p);
}
return end2;
}
Expand Down
5 changes: 0 additions & 5 deletions tests/cpp_tests/test_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ TEST_F(AtofPreciseTest, CornerCases) {
}
}

TEST_F(AtofPreciseTest, UnderOverFlow) {
double got = 0;
ASSERT_THROW(LightGBM::Common::AtofPrecise("1e+400", &got), std::runtime_error);
}

TEST_F(AtofPreciseTest, ErrorInput) {
double got = 0;
ASSERT_THROW(LightGBM::Common::AtofPrecise("x1", &got), std::runtime_error);
Expand Down

0 comments on commit f126db6

Please sign in to comment.