-
Notifications
You must be signed in to change notification settings - Fork 31
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
shift_index functions added into Grid class #278
Conversation
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.
This looks great. Agree about the 2 private functions. Minor changes requested to keep me super code-neat-happy.
morph/Grid.h
Outdated
* \param dx The horizontal displacement (in units of number of pixels). | ||
* \return The column index of the moved pixel | ||
*/ | ||
I col_after_x_shift (I ind, I dx) |
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 think you're probably right about making these two functions private, so let's do that.
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.
Not sure how to do this without breaking the unit tests.
Is there some preferred way giving the test file permission to access private functions?
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'll have a play - I see that I can actually make changes to this PR myself. I'll sort it. And thanks for the other changes, it looks impeccable now :)
…truct on unit tests
If the function is to be unit tested, then it's simplest to keep it part of the public interface of the Grid class. If you want to unit test private parts of a class, you probably need to write a new class specifically for that purpose, which would provide access to the private members (using the friend keyword). But we're not going to do that. There's no great harm in making these two functions public, so I hereby reverse our previous decision.
Right, sorted. I'll wait for the CI to finish and merge it after that |
I've written three functions into Grid.
The functions work with all GridOrders and all GridWraps.
Comprehensive unit tests are included and are passing.
I wondered whether it would be best if only (3) were a public function and have (1) and (2) as private ones? But I'll leave that up to you.