-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(evaluators, autoware_universe_utils): rename Stat class to A…
…ccumulator and move it to autoware_universe_utils (#9459) * add Accumulator class to autoware_universe_utils Signed-off-by: xtk8532704 <[email protected]> * use Accumulator on all evaluators. Signed-off-by: xtk8532704 <[email protected]> * pre-commit Signed-off-by: xtk8532704 <[email protected]> * found and fixed a bug. add more tests. Signed-off-by: xtk8532704 <[email protected]> * pre-commit Signed-off-by: xtk8532704 <[email protected]> * Update common/autoware_universe_utils/include/autoware/universe_utils/math/accumulator.hpp Co-authored-by: Kosuke Takeuchi <[email protected]> Signed-off-by: xtk8532704 <[email protected]> --------- Signed-off-by: xtk8532704 <[email protected]> Co-authored-by: Kosuke Takeuchi <[email protected]>
- Loading branch information
1 parent
f23916f
commit 12a86f6
Showing
39 changed files
with
215 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
common/autoware_universe_utils/test/src/math/test_accumulator.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2024 Tier IV, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "autoware/universe_utils/math/accumulator.hpp" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
TEST(accumulator, empty) | ||
{ | ||
autoware::universe_utils::Accumulator<double> acc; | ||
|
||
EXPECT_DOUBLE_EQ(acc.mean(), 0.0); | ||
EXPECT_DOUBLE_EQ(acc.min(), std::numeric_limits<double>::max()); | ||
EXPECT_DOUBLE_EQ(acc.max(), std::numeric_limits<double>::lowest()); | ||
EXPECT_EQ(acc.count(), 0); | ||
} | ||
|
||
TEST(accumulator, addValues) | ||
{ | ||
autoware::universe_utils::Accumulator<double> acc; | ||
acc.add(100.0); | ||
|
||
EXPECT_DOUBLE_EQ(acc.mean(), 100.0); | ||
EXPECT_DOUBLE_EQ(acc.min(), 100.0); | ||
EXPECT_DOUBLE_EQ(acc.max(), 100.0); | ||
EXPECT_EQ(acc.count(), 1); | ||
} | ||
|
||
TEST(accumulator, positiveValues) | ||
{ | ||
autoware::universe_utils::Accumulator<double> acc; | ||
acc.add(10.0); | ||
acc.add(40.0); | ||
acc.add(10.0); | ||
|
||
EXPECT_DOUBLE_EQ(acc.mean(), 20.0); | ||
EXPECT_DOUBLE_EQ(acc.min(), 10.0); | ||
EXPECT_DOUBLE_EQ(acc.max(), 40.0); | ||
EXPECT_EQ(acc.count(), 3); | ||
} | ||
|
||
TEST(accumulator, negativeValues) | ||
{ | ||
autoware::universe_utils::Accumulator<double> acc; | ||
acc.add(-10.0); | ||
acc.add(-40.0); | ||
acc.add(-10.0); | ||
|
||
EXPECT_DOUBLE_EQ(acc.mean(), -20.0); | ||
EXPECT_DOUBLE_EQ(acc.min(), -40.0); | ||
EXPECT_DOUBLE_EQ(acc.max(), -10.0); | ||
EXPECT_EQ(acc.count(), 3); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.