[Function] Refactor the function code of log (#8199)

1. Support return null when input is invalid
2. Del the unless code in vec function

Co-authored-by: lihaopeng <lihaopeng@baidu.com>
This commit is contained in:
HappenLee
2022-02-24 11:06:58 +08:00
committed by GitHub
parent 90a8ca808a
commit a6bc9cbe53
11 changed files with 226 additions and 314 deletions

View File

@ -144,9 +144,10 @@ TEST(MathFunctionTest, ln_test) {
DataSet data_set = {{{1.0}, 0.0},
{{0.5}, -0.69314718055994529},
{{-2.0}, Null()},
{{100.0}, 4.6051701859880918},
{{1000.0}, 6.9077552789821368}};
check_function<DataTypeFloat64, true>(func_name, input_types, data_set);
}
@ -158,7 +159,8 @@ TEST(MathFunctionTest, log2_test) {
DataSet data_set = {{{1.0}, 0.0},
{{0.5}, -1.0},
{{100.0}, 6.6438561897747244},
{{1000.0}, 9.965784284662087}};
{{1000.0}, 9.965784284662087},
{{-1.0}, Null()}};
check_function<DataTypeFloat64, true>(func_name, input_types, data_set);
}
@ -169,7 +171,8 @@ TEST(MathFunctionTest, log10_test) {
InputTypeSet input_types = {TypeIndex::Float64};
DataSet data_set = {
{{1.0}, 0.0}, {{0.5}, -0.3010299956639812}, {{100.0}, 2.0}, {{1000.0}, 3.0}};
{{1.0}, 0.0}, {{0.5}, -0.3010299956639812},
{{100.0}, 2.0}, {{-1.0}, Null()}, {{1000.0}, 3.0}};
check_function<DataTypeFloat64, true>(func_name, input_types, data_set);
}
@ -182,6 +185,8 @@ TEST(MathFunctionTest, log_test) {
DataSet data_set = {{{10.0, 1.0}, 0.0},
{{10.0, 100.0}, 2.0},
{{0.1, 5.0}, -0.69897000433601886},
{{-2.0, 5.0}, Null()},
{{2.0, -5.0}, Null()},
{{2.0, 0.5}, -1.0}};
check_function<DataTypeFloat64, true>(func_name, input_types, data_set);