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

DM-29775: Fix style issues introduced in DM-29737 and log output for unsorted catalogs #582

Merged
merged 4 commits into from Apr 19, 2021

Conversation

arunkannawadi
Copy link
Member

This PR a) fixes a few style errors introduced in a recent merge DM-29737 and b) create a log message if the catalog is found to be unsorted. The log message is to hint the user of plausible inefficiencies in finding a desired record as a result of having catalog unsorted by the Id.

Unlike std::lower_bound, std::find guarantees that *i = value if the
search is successful. Thus, the second condition on checking if *i !=
value is redundant.
@@ -15,6 +15,7 @@
#include "lsst/afw/table/io/FitsWriter.h"
#include "lsst/afw/table/io/FitsReader.h"
#include "lsst/afw/table/SchemaMapper.h"
#include "lsst/log/Log.h"
Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't find an example where logging is done from another header file. I guess it makes sense in general, but since the implementation of the find method is in this header file, and the info about whether or not the catalog was sorted is not propagated up, the logging has to be done from here (if it's done).

@@ -95,7 +95,7 @@ void toNanojanskyVariance(ndarray::Array<float const, 2, 1> const &instFlux,
}

double toMagnitudeErr(double instFlux, double instFluxErr, double scale, double scaleErr) {
return 2.5 / log(10.0) * hypot(instFluxErr / instFlux, scaleErr / scale);
return 2.5 / std::log(10.0) * hypot(instFluxErr / instFlux, scaleErr / scale);
Copy link
Member Author

Choose a reason for hiding this comment

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

This was necessary to use the natural logarithm and not a logging function, and whether or not we decide to log, we should perhaps keep this change.

return end();
}
LOGL_INFO("afw.table.Catalog", "Catalog is not sorted by the key. Finding a record may be slow.");
Copy link
Member Author

Choose a reason for hiding this comment

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

One of the motivations for logging this at some low level is that this is (probably?) the only direct indication we have to let us know that the catalog is unsorted and I think it'd be useful to keep that at TRACE level at least.

Copy link
Member

Choose a reason for hiding this comment

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

I'd probably recommend DEBUG for this.

return end();
}
Copy link
Member

Choose a reason for hiding this comment

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

Sorry I didn't catch these in my initial review; that's definitely on me (I think it was just a sufficiently busy day that I only looked at correctness and forgot to look at style the first time around).

Copy link
Member Author

Choose a reason for hiding this comment

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

Totally understandable. I wasn't familiar with C++ style guidelines, so I made it a point to go back and check after merging, just in case.

@arunkannawadi arunkannawadi merged commit 56632e8 into master Apr 19, 2021
@arunkannawadi arunkannawadi deleted the tickets/DM-29775 branch April 19, 2021 19:59
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.

None yet

2 participants