-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix step sequence iterator #305
Conversation
Codecov Report
@@ Coverage Diff @@
## master #305 +/- ##
==========================================
- Coverage 81.13% 81.12% -0.01%
==========================================
Files 204 204
Lines 5893 5891 -2
==========================================
- Hits 4781 4779 -2
Misses 1112 1112
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing the tests! I left a minor suggestion about the logic in this method.
src/common/StepSequence.cpp
Outdated
@@ -61,8 +61,11 @@ int StepSequence::getMaxSteps() const | |||
int numSteps = (mEndPoint - mStartPoint) / mStepSize; | |||
if (!mIncludeEndpoints) | |||
{ | |||
// Return numSteps + 1 for the start | |||
return numSteps + 1; | |||
if (fabs(mStartPoint + mStepSize * numSteps - mEndPoint) < 1e-7) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the current logic somewhat difficult to follow. Can we do something like:
int numSteps = (mEndPoint - mStartPoint) / mStepSize;
if (fabs(mStartPoint + mStepSize * numSteps - mEndPoint) > 1e-7)
numSteps++; // include start
return numSteps + mIncludeEndpoints;
* fix step sequence iterator * fabs --> std::abs * address Brian's comments * Update CHANGELOG.md
In current
aikido
, unexpected exception is thrown in some cases.StepSequence seq(0.2, false); for (double v : seq) { DART_UNUSED(v); count++; }
An exception will be throw
In this PR,
StepSequence seq(0.2, true)
returns(0.0, 0.2, 0.4, 0.6, 0.8, 1.0)
andgetMaxSteps()
returns 6.StepSequence seq(0.2, false)
returns(0.0, 0.2, 0.4, 0.6, 0.8)
andgetMaxSteps()
returns 5.Unit tests are updated accordingly.
Document new methods and classes (N/A)
Format code with
make format
Set version target by selecting a milestone on the right side
Summarize this change in
CHANGELOG.md
(N/A)Add unit test(s) for this change