Skip to content

Commit

Permalink
Merge pull request #741 from lsst/tickets/DM-45486
Browse files Browse the repository at this point in the history
DM-45486: Use cpputils rather than deprecated utils in C++ code
  • Loading branch information
timj committed Jul 31, 2024
2 parents e3d4d39 + 0cf02cb commit 7f10267
Show file tree
Hide file tree
Showing 159 changed files with 639 additions and 646 deletions.
4 changes: 2 additions & 2 deletions doc/lsst.afw.math/SpatialCellSet-example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Start by including needed headers, and declaring namespace aliases and a routine
#include <string>
#include "lsst/geom.h"
#include "lsst/utils/Utils.h"
#include "lsst/cpputils/Utils.h"
#include "lsst/pex/exceptions.h"
#include "lsst/daf/base.h"
#include "lsst/afw/detection.h"
Expand Down Expand Up @@ -177,7 +177,7 @@ The use of a ``boost::shared_ptr<MaskedImage>`` (written as ``MaskedImage::Ptr``
std::shared_ptr<afwImage::MaskedImage<PixelT>> mi;
try {
std::string dataDir = lsst::utils::getPackageDir("afwdata");
std::string dataDir = lsst::cpputils::getPackageDir("afwdata");
std::string filename = dataDir + "/CFHT/D4/cal-53535-i-797722_1.fits";
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/afw/coord/Observatory.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include <iostream>

#include "lsst/utils/hashCombine.h"
#include "lsst/cpputils/hashCombine.h"
#include "lsst/geom/Angle.h"

namespace lsst {
Expand Down Expand Up @@ -102,7 +102,7 @@ class Observatory final {
/// Return a hash of this object
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
return utils::hashCombine(17, _latitude.wrapCtr(), _longitude.wrapCtr(), _elevation);
return cpputils::hashCombine(17, _latitude.wrapCtr(), _longitude.wrapCtr(), _elevation);
}

private:
Expand Down
6 changes: 3 additions & 3 deletions include/lsst/afw/detection/Psf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <memory>

#include "lsst/pex/exceptions.h"
#include "lsst/utils/CacheFwd.h"
#include "lsst/cpputils/CacheFwd.h"
#include "lsst/afw/geom/ellipses/Quadrupole.h"
#include "lsst/afw/math/Kernel.h"
#include "lsst/afw/image/Color.h"
Expand All @@ -41,7 +41,7 @@ namespace afw {
namespace detection {
namespace detail {

/// Key for caching PSFs with lsst::utils::Cache
/// Key for caching PSFs with lsst::cpputils::Cache
struct PsfCacheKey;

} // namespace detail
Expand Down Expand Up @@ -364,7 +364,7 @@ class Psf : public afw::table::io::PersistableFacade<Psf>,
//@}

bool const _isFixed;
using PsfCache = utils::Cache<detail::PsfCacheKey, std::shared_ptr<Image>>;
using PsfCache = cpputils::Cache<detail::PsfCacheKey, std::shared_ptr<Image>>;
std::unique_ptr<PsfCache> _imageCache;
std::unique_ptr<PsfCache> _kernelImageCache;
};
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/afw/geom/Span.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <iostream>

#include "lsst/base.h"
#include "lsst/utils/hashCombine.h"
#include "lsst/cpputils/hashCombine.h"
#include "lsst/geom.h"
#include "lsst/afw/geom/SpanPixelIterator.h"

Expand Down Expand Up @@ -121,7 +121,7 @@ class Span final {
/// Return a hash of this object.
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
return utils::hashCombine(42, getY(), getMinX(), getMaxX());
return cpputils::hashCombine(42, getY(), getMinX(), getMaxX());
}

/* Required to make Span "LessThanComparable" so they can be used
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/afw/image/PhotoCalib.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "lsst/afw/image/MaskedImage.h"
#include "lsst/daf/base/PropertyList.h"
#include "lsst/pex/exceptions/Exception.h"
#include "lsst/utils/Magnitude.h"
#include "lsst/cpputils/Magnitude.h"

namespace lsst {
namespace afw {
Expand Down Expand Up @@ -436,7 +436,7 @@ class PhotoCalib final : public table::io::PersistableFacade<PhotoCalib>, public
*
* @returns The instFlux magnitude zero point.
*/
double getInstFluxAtZeroMagnitude() const { return utils::referenceFlux / _calibrationMean; }
double getInstFluxAtZeroMagnitude() const { return cpputils::referenceFlux / _calibrationMean; }

/**
* Get the local calibration at a point.
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/afw/image/Pixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <iostream>
#include <type_traits>

#include "lsst/utils/hashCombine.h"
#include "lsst/cpputils/hashCombine.h"

namespace lsst {
namespace afw {
Expand Down Expand Up @@ -239,7 +239,7 @@ class Pixel : public detail::MaskedImagePixel_tag {
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
// Convert to double to avoid inconsistently hashing equal numbers of different types
return utils::hashCombine(17, static_cast<double>(image()), static_cast<double>(mask()),
return cpputils::hashCombine(17, static_cast<double>(image()), static_cast<double>(mask()),
static_cast<double>(variance()));
}

Expand Down
4 changes: 2 additions & 2 deletions include/lsst/afw/table/Flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <cstdint>

#include "lsst/utils/hashCombine.h"
#include "lsst/cpputils/hashCombine.h"

#include "lsst/afw/table/misc.h"
#include "lsst/afw/table/FieldBase.h"
Expand Down Expand Up @@ -119,7 +119,7 @@ class Key<Flag> : public KeyBase<Flag>, public FieldBase<Flag> {
/// Return a hash of this object.
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
return utils::hashCombine(17, _offset, _bit);
return cpputils::hashCombine(17, _offset, _bit);
}

/// Return the offset in bytes of the integer element that holds this field's bit.
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/afw/table/Key.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef AFW_TABLE_Key_h_INCLUDED
#define AFW_TABLE_Key_h_INCLUDED

#include "lsst/utils/hashCombine.h"
#include "lsst/cpputils/hashCombine.h"

#include "lsst/afw/table/FieldBase.h"
#include "lsst/afw/table/Flag.h"
Expand Down Expand Up @@ -80,7 +80,7 @@ class Key : public KeyBase<T>, public FieldBase<T> {
/// Return a hash of this object.
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
return utils::hashCombine(17, _offset, this->getElementCount());
return cpputils::hashCombine(17, _offset, this->getElementCount());
}

/// Return the offset (in bytes) of this field within a record.
Expand Down
14 changes: 7 additions & 7 deletions include/lsst/afw/table/aggregates.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifndef AFW_TABLE_aggregates_h_INCLUDED
#define AFW_TABLE_aggregates_h_INCLUDED

#include "lsst/utils/hashCombine.h"
#include "lsst/cpputils/hashCombine.h"

#include "lsst/afw/table/FunctorKey.h"
#include "lsst/afw/table/Schema.h"
Expand Down Expand Up @@ -99,7 +99,7 @@ class PointKey : public FunctorKey<lsst::geom::Point<T, 2> > {
/// Return a hash of this object.
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
return utils::hashCombine(17, _x, _y);
return cpputils::hashCombine(17, _x, _y);
}

/// Return True if both the x and y Keys are valid.
Expand Down Expand Up @@ -175,7 +175,7 @@ class Point3Key : public FunctorKey<lsst::geom::Point<T, 3> > {
/// Return a hash of this object.
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
return utils::hashCombine(137, _x, _y, _z);
return cpputils::hashCombine(137, _x, _y, _z);
}

/// Return True if all of the x, y, and z Keys are valid.
Expand Down Expand Up @@ -251,7 +251,7 @@ class BoxKey : public FunctorKey<Box> {
/// Return a hash of this object.
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
return utils::hashCombine(17, _min, _max);
return cpputils::hashCombine(17, _min, _max);
}

/// Get a Box from the given record
Expand Down Expand Up @@ -344,7 +344,7 @@ class CoordKey : public FunctorKey<lsst::geom::SpherePoint> {
/// Return a hash of this object.
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
return utils::hashCombine(17, _ra, _dec);
return cpputils::hashCombine(17, _ra, _dec);
}

bool isValid() const noexcept { return _ra.isValid() && _dec.isValid(); }
Expand Down Expand Up @@ -422,7 +422,7 @@ class QuadrupoleKey : public FunctorKey<lsst::afw::geom::ellipses::Quadrupole> {
/// Return a hash of this object.
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
return utils::hashCombine(17, _ixx, _iyy, _ixy);
return cpputils::hashCombine(17, _ixx, _iyy, _ixy);
}

/// Return True if all the constituent Keys are valid.
Expand Down Expand Up @@ -498,7 +498,7 @@ class EllipseKey : public FunctorKey<lsst::afw::geom::ellipses::Ellipse> {
/// Return a hash of this object.
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
return utils::hashCombine(17, _qKey, _pKey);
return cpputils::hashCombine(17, _qKey, _pKey);
}

/// Return True if all the constituent Keys are valid.
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/afw/table/arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifndef AFW_TABLE_arrays_h_INCLUDED
#define AFW_TABLE_arrays_h_INCLUDED

#include "lsst/utils/hashCombine.h"
#include "lsst/cpputils/hashCombine.h"

#include "lsst/afw/table/FunctorKey.h"
#include "lsst/afw/table/Schema.h"
Expand Down Expand Up @@ -130,7 +130,7 @@ class ArrayKey : public FunctorKey<ndarray::Array<T const, 1, 1> >,
/// Return a hash of this object.
std::size_t hash_value() const noexcept {
// Completely arbitrary seed
return utils::hashCombine(17, _begin, _size);
return cpputils::hashCombine(17, _begin, _size);
}

/// Return True if the FunctorKey contains valid scalar keys.
Expand Down
8 changes: 4 additions & 4 deletions include/lsst/afw/table/python/catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "pybind11/pybind11.h"

#include "ndarray/pybind11.h"
#include "lsst/utils/python.h"
#include "lsst/cpputils/python.h"
#include "lsst/afw/table/BaseColumnView.h"
#include "lsst/afw/table/Catalog.h"

Expand Down Expand Up @@ -273,7 +273,7 @@ void declareCatalogArrayOverloads(PyCatalog<Record> &cls) {
* (used to set the class name).
*/
template <typename Record>
PyCatalog<Record> declareCatalog(utils::python::WrapperCollection &wrappers, std::string const &name,
PyCatalog<Record> declareCatalog(cpputils::python::WrapperCollection &wrappers, std::string const &name,
bool isBase = false) {
namespace py = pybind11;
using namespace pybind11::literals;
Expand Down Expand Up @@ -328,7 +328,7 @@ PyCatalog<Record> declareCatalog(utils::python::WrapperCollection &wrappers, std
cls.def("_append",
[](Catalog &self, std::shared_ptr<Record> const &rec) { self.push_back(rec); });
cls.def("_delitem_", [](Catalog &self, std::ptrdiff_t i) {
self.erase(self.begin() + utils::python::cppIndex(self.size(), i));
self.erase(self.begin() + cpputils::python::cppIndex(self.size(), i));
});
cls.def("_delslice_", [](Catalog &self, py::slice const &s) {
Py_ssize_t start = 0, stop = 0, step = 0, length = 0;
Expand All @@ -344,7 +344,7 @@ PyCatalog<Record> declareCatalog(utils::python::WrapperCollection &wrappers, std

cls.def("set", &Catalog::set);
cls.def("_getitem_", [](Catalog &self, int i) {
return self.get(utils::python::cppIndex(self.size(), i));
return self.get(cpputils::python::cppIndex(self.size(), i));
});
cls.def("__iter__", [](Catalog & self) {
// We wrap a custom iterator class here for two reasons:
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/afw/table/python/columnView.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "pybind11/pybind11.h"

#include "ndarray/pybind11.h"
#include "lsst/utils/python.h"
#include "lsst/cpputils/python.h"

#include "lsst/afw/table/BaseColumnView.h"

Expand All @@ -50,7 +50,7 @@ using PyColumnView =
* (used to set the class name).
*/
template <typename Record>
PyColumnView<Record> declareColumnView(utils::python::WrapperCollection& wrappers, std::string const& name,
PyColumnView<Record> declareColumnView(cpputils::python::WrapperCollection& wrappers, std::string const& name,
bool isBase = false) {
std::string fullName;
if (isBase) {
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/afw/table/python/sortedCatalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "pybind11/pybind11.h"

#include "lsst/utils/python.h"
#include "lsst/cpputils/python.h"

#include "lsst/afw/table/SortedCatalog.h"
#include "lsst/afw/table/python/catalog.h"
Expand Down Expand Up @@ -54,7 +54,7 @@ using PySortedCatalog =
*
*/
template <typename Record>
PySortedCatalog<Record> declareSortedCatalog(utils::python::WrapperCollection &wrappers,
PySortedCatalog<Record> declareSortedCatalog(cpputils::python::WrapperCollection &wrappers,
std::string const &name, bool isBase = false) {
namespace py = pybind11;
using namespace pybind11::literals;
Expand Down
2 changes: 1 addition & 1 deletion include/lsst/afw/typehandling/Storable.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ LSST_EXCEPTION_TYPE(UnsupportedOperationException, pex::exceptions::RuntimeError
*
* @note Any C++ subclass `X` of Storable that supports Python subclasses must
* have a %pybind11 wrapper that uses `StorableHelper<X>` (or a subclass)
* and lsst::utils::python::PySharedPtr.
* and lsst::cpputils::python::PySharedPtr.
*/
class Storable : public table::io::Persistable {
public:
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/afw/cameraGeom/_amplifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

#include "pybind11/pybind11.h"
#include <lsst/utils/python.h>
#include <lsst/cpputils/python.h>
#include "pybind11/stl.h"

#include "ndarray/pybind11.h"
Expand All @@ -40,7 +40,7 @@ namespace cameraGeom {
using PyAmplifier = py::class_<Amplifier, std::shared_ptr<Amplifier>>;
using PyAmplifierBuilder = py::class_<Amplifier::Builder, Amplifier, std::shared_ptr<Amplifier::Builder>>;

void wrapAmplifier(lsst::utils::python::WrapperCollection &wrappers) {
void wrapAmplifier(lsst::cpputils::python::WrapperCollection &wrappers) {
wrappers.addInheritanceDependency("lsst.afw.table");
wrappers.wrapType(py::enum_<ReadoutCorner>(wrappers.module, "ReadoutCorner"), [](auto &mod, auto &enm) {
enm.value("LL", ReadoutCorner::LL);
Expand Down
5 changes: 2 additions & 3 deletions python/lsst/afw/cameraGeom/_camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
*/

#include "pybind11/pybind11.h"
#include <lsst/utils/python.h>
#include <lsst/cpputils/python.h>

#include "pybind11/stl.h"

#include "lsst/utils/python.h"
#include "lsst/afw/table/io/python.h"
#include "lsst/afw/cameraGeom/Camera.h"

Expand All @@ -45,7 +44,7 @@ using PyCameraBuilder = py::class_<Camera::Builder, DetectorCollectionBase<Detec
// Camera.h to the greatest extent possible; modifications to this file should
// attempt to preserve this.

void wrapCamera(lsst::utils::python::WrapperCollection &wrappers) {
void wrapCamera(lsst::cpputils::python::WrapperCollection &wrappers) {
wrappers.addInheritanceDependency("lsst.afw.table.io");
wrappers.addSignatureDependency("lsst.afw.cameraGeom");
auto camera = wrappers.wrapType(PyCamera(wrappers.module, "Camera"), [](auto &mod, auto &cls) {
Expand Down
18 changes: 9 additions & 9 deletions python/lsst/afw/cameraGeom/_cameraGeom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
*/

#include <pybind11/pybind11.h>
#include <lsst/utils/python.h>
#include <lsst/cpputils/python.h>
namespace lsst {
namespace afw {
namespace cameraGeom {

void wrapAmplifier(lsst::utils::python::WrapperCollection &);
void wrapCamera(lsst::utils::python::WrapperCollection &);
void wrapCameraSys(lsst::utils::python::WrapperCollection &);
void wrapDetector(lsst::utils::python::WrapperCollection &);
void wrapDetectorCollection(lsst::utils::python::WrapperCollection &);
void wrapOrientation(lsst::utils::python::WrapperCollection &);
void wrapTransformMap(lsst::utils::python::WrapperCollection &);
void wrapAmplifier(lsst::cpputils::python::WrapperCollection &);
void wrapCamera(lsst::cpputils::python::WrapperCollection &);
void wrapCameraSys(lsst::cpputils::python::WrapperCollection &);
void wrapDetector(lsst::cpputils::python::WrapperCollection &);
void wrapDetectorCollection(lsst::cpputils::python::WrapperCollection &);
void wrapOrientation(lsst::cpputils::python::WrapperCollection &);
void wrapTransformMap(lsst::cpputils::python::WrapperCollection &);

PYBIND11_MODULE(_cameraGeom, mod) {
lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.cameraGeom");
lsst::cpputils::python::WrapperCollection wrappers(mod, "lsst.afw.cameraGeom");
wrapAmplifier(wrappers);
wrapDetectorCollection(wrappers);
wrapDetector(wrappers);
Expand Down
Loading

0 comments on commit 7f10267

Please sign in to comment.