Skip to content

Commit

Permalink
Merge pull request #582 from lsst/tickets/DM-29775
Browse files Browse the repository at this point in the history
DM-29775: Fix style issues introduced in DM-29737 and log output for unsorted catalogs
  • Loading branch information
arunkannawadi committed Apr 19, 2021
2 parents 795c156 + 20ecdc1 commit 56632e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions include/lsst/afw/table/Catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

namespace lsst {
namespace afw {
Expand Down Expand Up @@ -760,14 +761,16 @@ typename CatalogT<RecordT>::iterator CatalogT<RecordT>::find(typename Field<T>::
detail::KeyExtractionFunctor<RecordT, T> f = {key};
// Iterator adaptor that makes a CatalogT iterator work like an iterator over field values.
typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>, iterator> SearchIter;
// Try binary search for log n search assuming the table is sorted.
// If the search is unsuccessful, try a brute-force search before quitting.
/* Try binary search for log n search assuming the table is sorted.
* If the search is unsuccessful, try a brute-force search before quitting.
*/
SearchIter i = std::lower_bound(SearchIter(begin(), f), SearchIter(end(), f), value);
if (i.base() == end() || *i != value)
{
if (i.base() == end() || *i != value) {
i = std::find(SearchIter(begin(), f), SearchIter(end(), f), value);
if (i.base() == end() || *i != value)
if (i.base() == end()) {
return end();
}
LOGL_DEBUG("afw.table.Catalog", "Catalog is not sorted by the key. Finding a record may be slow.");
}
return i.base();
}
Expand All @@ -779,14 +782,16 @@ typename CatalogT<RecordT>::const_iterator CatalogT<RecordT>::find(typename Fiel
detail::KeyExtractionFunctor<RecordT, T> f = {key};
// Iterator adaptor that makes a CatalogT iterator work like an iterator over field values.
typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>, const_iterator> SearchIter;
// Try binary search for log n search assuming the table is sorted.
// If the search is unsuccessful, try a brute-force search before quitting.
/* Try binary search for log n search assuming the table is sorted.
* If the search is unsuccessful, try a brute-force search before quitting.
*/
SearchIter i = std::lower_bound(SearchIter(begin(), f), SearchIter(end(), f), value);
if (i.base() == end() || *i != value)
{
if (i.base() == end() || *i != value) {
i = std::find(SearchIter(begin(), f), SearchIter(end(), f), value);
if (i.base() == end() || *i != value)
if (i.base() == end()) {
return end();
}
LOGL_DEBUG("afw.table.Catalog", "Catalog is not sorted by the key. Finding a record may be slow.");
}
return i.base();
}
Expand Down
2 changes: 1 addition & 1 deletion src/image/PhotoCalib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

} // anonymous namespace
Expand Down

0 comments on commit 56632e8

Please sign in to comment.