Skip to content
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

Style changes #344

Merged
merged 10 commits into from
Sep 22, 2023
Merged

Style changes #344

merged 10 commits into from
Sep 22, 2023

Conversation

jeremykubica
Copy link
Contributor

This is the first step of making the coding style more consistent.

This PR is a mostly mechanical style changes to the C++ files to:

  • Use camel case for all local or class variables
  • Start struct names with an uppercase.
  • Apply clang-format
  • Move GPU stamp computation from image_kernels.cu to kernels.cu

Copy link
Member

@DinoBektesevic DinoBektesevic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a really quick run through, I initially marked the methods as not-changed-but-should-be but then later noticed you didn't do those. I removed those comments, but just a heads up if there's one or two I missed to ignore them.

Overall the most confusing bit to me were the local variables. Sometimes camelCased sometimes snake_cased - it wasn't always clear what the strategy was. Generally, I'll admit that I'm usually a camelCaser, but PEP8 says underscores for both local vars and funcs and camel-case only for classes and Google C++ style you linked also underscores all local variables, unless they're type names in which case capitalized camel case, and in case they're class members we end them with an extra trailing _. So we should probably just snake_case everything except classes too.

No need to rush with this because it's something we can do alongside the dev-work. I think the ones that hurt a lot are the ones that are exposed to the user in the interface, but renaming those includes changing Py code.

In general, clarity of naming (f.e. PointSpreadFunc.printPSF and hungarian-but-not float pyMinLH) should be improved upon more so than the standard. In any case, an improvement even as-is, so approved.

LayeredImage::LayeredImage(std::string path, const PointSpreadFunc& psf) : psf(psf), psfSQ(psf) {
psfSQ.squarePSF();
LayeredImage::LayeredImage(std::string path, const PointSpreadFunc& psf) : psf(psf), psf_sq(psf) {
psf_sq.squarePSF();
Copy link
Member

@DinoBektesevic DinoBektesevic Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed squarePSF? It's in the PointSpreadFunc - which, if we're renaming stuff we should probably just call PSF tbh.

Comment on lines +13 to +16
extern "C" void deviceSearchFilter(int num_images, int width, int height, float* psi_vect, float* phi_vect,
PerImageData img_data, SearchParameters params, int num_trajectories,
trajectory* trj_to_search, int num_results, trajectory* best_results);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to the current PR, just a general comment. These big blocks of params make it very difficult for me to see the changes. I know it's not C++ style but if we could do a one-per-line after 5 params that would make it really easy to see what changes in a PR and what the func expects. As well as allow inline annotations if/when we need them.

src/kbmod/search/KBMOSearch.cpp Outdated Show resolved Hide resolved
src/kbmod/search/KBMOSearch.cpp Outdated Show resolved Hide resolved
src/kbmod/search/KBMOSearch.h Outdated Show resolved Hide resolved
src/kbmod/search/PointSpreadFunc.cpp Show resolved Hide resolved
Comment on lines +273 to +274
deviceConvolve(pixels.data(), pixels.data(), getWidth(), getHeight(), psf.kernelData(), psf.getSize(),
psf.getDim(), psf.getRadius(), psf.getSum());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just re: earlier proposal of one-per-line-ing this we could have a inline comment or just direct named parameters that would then distinguish between pixels.data() and pixels.data() in this context.

src/kbmod/search/RawImage.cpp Show resolved Hide resolved
src/kbmod/search/image_kernels.cu Outdated Show resolved Hide resolved
src/kbmod/search/image_kernels.cu Outdated Show resolved Hide resolved
@jeremykubica jeremykubica merged commit 9e86cd6 into main Sep 22, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants