Skip to content

Commit

Permalink
Merge pull request #95 from lsst/tickets/DM-6056
Browse files Browse the repository at this point in the history
DM-6056: replace CONST_PTR and PTR macros by std::shared
  • Loading branch information
mwittgen committed Aug 30, 2021
2 parents 1b65d06 + 82de0c3 commit e470956
Show file tree
Hide file tree
Showing 27 changed files with 106 additions and 106 deletions.
6 changes: 3 additions & 3 deletions include/lsst/meas/modelfit/AdaptiveImportanceSampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ class AdaptiveImportanceSampler : public Sampler {
*/
AdaptiveImportanceSampler(
afw::table::Schema & sampleSchema,
PTR(afw::math::Random) rng,
std::shared_ptr<afw::math::Random> rng,
std::map<int,ImportanceSamplerControl> const & ctrls,
bool doSaveIterations=false
);

void run(
SamplingObjective const & objective,
PTR(Mixture) proposal,
std::shared_ptr<Mixture> proposal,
afw::table::BaseCatalog & samples
) const override;

Expand All @@ -99,7 +99,7 @@ class AdaptiveImportanceSampler : public Sampler {

private:
bool _doSaveIterations;
PTR(afw::math::Random) _rng;
std::shared_ptr<afw::math::Random> _rng;
std::map<int,ImportanceSamplerControl> _ctrls;
afw::table::Key<Scalar> _weightKey;
afw::table::Key<Scalar> _objectiveKey;
Expand Down
14 changes: 7 additions & 7 deletions include/lsst/meas/modelfit/CModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ struct CModelStageControl {
return shapelet::RadialProfile::get(profileName);
}

PTR(Model) getModel() const;
std::shared_ptr<Model> getModel() const;

PTR(Prior) getPrior() const;
std::shared_ptr<Prior> getPrior() const;

LSST_CONTROL_FIELD(
profileName, std::string,
Expand Down Expand Up @@ -308,10 +308,10 @@ struct CModelStageResult {

CModelStageResult();

PTR(Model) model; ///< Model object that defines the parametrization (defined fully by Control struct)
PTR(Prior) prior; ///< Bayesian priors on the parameters (defined fully by Control struct)
PTR(OptimizerObjective) objfunc; ///< Objective class used by the optimizer
PTR(UnitTransformedLikelihood) likelihood; ///< Object used to evaluate models and compare to data.
std::shared_ptr<Model> model; ///< Model object that defines the parametrization (defined fully by Control struct)
std::shared_ptr<Prior> prior; ///< Bayesian priors on the parameters (defined fully by Control struct)
std::shared_ptr<OptimizerObjective> objfunc; ///< Objective class used by the optimizer
std::shared_ptr<UnitTransformedLikelihood> likelihood; ///< Object used to evaluate models and compare to data.
Scalar instFlux; ///< Flux measured from just this stage fit.
Scalar instFluxErr; ///< Flux uncertainty from just this stage fit.
Scalar instFluxInner; ///< Flux measured strictly within the fit region (no extrapolation).
Expand Down Expand Up @@ -583,7 +583,7 @@ class CModelAlgorithm {
class Impl;

Control _ctrl;
PTR(Impl) _impl;
std::shared_ptr<Impl> _impl;
};

}}} // namespace lsst::meas::modelfit
Expand Down
2 changes: 1 addition & 1 deletion include/lsst/meas/modelfit/DoubleShapeletPsfApprox.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class DoubleShapeletPsfApproxAlgorithm : public meas::base::SimpleAlgorithm {
* Probably the result of a call to
* Psf::computeKernelImage().
*/
static PTR(OptimizerObjective) makeObjective(
static std::shared_ptr<OptimizerObjective> makeObjective(
afw::geom::ellipses::Ellipse const & moments,
Control const & ctrl,
afw::image::Image<Scalar> const & psfImage
Expand Down
12 changes: 6 additions & 6 deletions include/lsst/meas/modelfit/GeneralPsfFitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ class GeneralPsfFitter {
* define the center of the prior; the "nonlinear" parameters are the free-to-vary ellipse
* parameters minus the corresponding initial values.
*/
PTR(Model) getModel() const { return _model; }
std::shared_ptr<Model> getModel() const { return _model; }

/**
* Return the Prior object that corresponds to the configuration.
*
* This Prior class only supports evaluate() and evaluateDerivatives(), reflecting the fact
* that we only intend to use it with a Optimizer, not a Sampler.
*/
PTR(Prior) getPrior() const { return _prior; }
std::shared_ptr<Prior> getPrior() const { return _prior; }

/**
* Adapt a differently-configured previous fit to be used as an starting point for this GeneralPsfFitter.
Expand All @@ -195,7 +195,7 @@ class GeneralPsfFitter {
*/
shapelet::MultiShapeletFunction adapt(
shapelet::MultiShapeletFunction const & previousFit,
PTR(Model) previousModel
std::shared_ptr<Model> previousModel
) const;

//@{
Expand Down Expand Up @@ -260,8 +260,8 @@ class GeneralPsfFitter {

private:
GeneralPsfFitterControl _ctrl;
PTR(Model) _model;
PTR(Prior) _prior;
std::shared_ptr<Model> _model;
std::shared_ptr<Prior> _prior;
};

class GeneralPsfFitterAlgorithm : public GeneralPsfFitter {
Expand Down Expand Up @@ -318,7 +318,7 @@ class MultiShapeletPsfLikelihood : public Likelihood {
MultiShapeletPsfLikelihood(
ndarray::Array<Pixel const,2,1> const & image,
geom::Point2I const & xy0,
PTR(Model) model,
std::shared_ptr<Model> model,
Scalar sigma,
ndarray::Array<Scalar const,1,1> const & fixed
);
Expand Down
6 changes: 3 additions & 3 deletions include/lsst/meas/modelfit/Likelihood.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Likelihood
ndarray::Array<Pixel const,1,1> getVariance() const { return _variance; }

/// Return an object that defines the model and its parameters
PTR(Model) getModel() const { return _model; }
std::shared_ptr<Model> getModel() const { return _model; }

/**
* @brief Evaluate the model for the given vector of nonlinear parameters.
Expand Down Expand Up @@ -135,7 +135,7 @@ class Likelihood

protected:

Likelihood(PTR(Model) model, ndarray::Array<Scalar const,1,1> const & fixed) :
Likelihood(std::shared_ptr<Model> model, ndarray::Array<Scalar const,1,1> const & fixed) :
_model(model), _fixed(fixed) {
LSST_THROW_IF_NE(
fixed.getSize<0>(), static_cast<std::size_t>(model->getFixedDim()),
Expand All @@ -144,7 +144,7 @@ class Likelihood
);
}

PTR(Model) _model;
std::shared_ptr<Model> _model;
ndarray::Array<Scalar const,1,1> _fixed;
ndarray::Array<Pixel,1,1> _data;
ndarray::Array<Pixel,1,1> _unweightedData;
Expand Down
6 changes: 3 additions & 3 deletions include/lsst/meas/modelfit/Mixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ class Mixture : public afw::table::io::PersistableFacade<Mixture>, public afw::t
virtual int getComponentCount() const { return size(); }

/// Project the distribution onto the given dimensions (marginalize over all others)
PTR(Mixture) project(int dim) const;
std::shared_ptr<Mixture> project(int dim) const;

/// Project the distribution onto the given dimensions (marginalize over all others)
PTR(Mixture) project(int dim1, int dim2) const;
std::shared_ptr<Mixture> project(int dim1, int dim2) const;

/// Return the number of dimensions
int getDimension() const { return _dim; }
Expand Down Expand Up @@ -342,7 +342,7 @@ class Mixture : public afw::table::io::PersistableFacade<Mixture>, public afw::t
);

/// Polymorphic deep copy
virtual PTR(Mixture) clone() const;
virtual std::shared_ptr<Mixture> clone() const;

/**
* @brief Construct a mixture model.
Expand Down
6 changes: 3 additions & 3 deletions include/lsst/meas/modelfit/MixturePrior.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace lsst { namespace meas { namespace modelfit {
class MixturePrior : public Prior {
public:

explicit MixturePrior(PTR(Mixture const) mixture, std::string const & tag="");
explicit MixturePrior(std::shared_ptr<Mixture const> mixture, std::string const & tag="");

/// @copydoc Prior::evaluate
Scalar evaluate(
Expand Down Expand Up @@ -85,10 +85,10 @@ class MixturePrior : public Prior {
*/
static MixtureUpdateRestriction const & getUpdateRestriction();

PTR(Mixture const) getMixture() const { return _mixture; }
std::shared_ptr<Mixture const> getMixture() const { return _mixture; }

private:
PTR(Mixture const) _mixture;
std::shared_ptr<Mixture const> _mixture;
};

}}} // namespace lsst::meas::modelfit
Expand Down
12 changes: 6 additions & 6 deletions include/lsst/meas/modelfit/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Prior;

struct LocalUnitTransform;

typedef std::vector<PTR(Model)> ModelVector;
typedef std::vector<std::shared_ptr<Model>> ModelVector;

/**
* @brief Abstract base class and concrete factories that define multi-shapelet galaxy models
Expand All @@ -63,7 +63,7 @@ class Model {
};

typedef std::vector<std::string> NameVector;
typedef std::vector<PTR(shapelet::MultiShapeletBasis)> BasisVector;
typedef std::vector<std::shared_ptr<shapelet::MultiShapeletBasis>> BasisVector;
typedef std::vector<afw::geom::ellipses::Ellipse> EllipseVector;
typedef std::vector<afw::geom::ellipses::Ellipse>::iterator EllipseIterator;
typedef std::vector<afw::geom::ellipses::Ellipse>::const_iterator EllipseConstIterator;
Expand All @@ -83,7 +83,7 @@ class Model {
* fixed center (FIXED_CENTER), the same center (SINGLE_CENTER), or
* independent centers (MULTI_CENTER).
*/
static PTR(Model) make(BasisVector basisVector, NameVector const & prefixes, CenterEnum center);
static std::shared_ptr<Model> make(BasisVector basisVector, NameVector const & prefixes, CenterEnum center);

/**
* Construct a concrete Model instance with a single ellipse and multishapelet basis
Expand All @@ -104,7 +104,7 @@ class Model {
* afw::geom::ellipses::SeparableConformalShearLogTraceRadius. For the basis objects provided
* by lsst.shapelet.tractor, that generally means that logR=0 corresponds to the half-light radius.
*/
static PTR(Model) make(PTR(shapelet::MultiShapeletBasis) basis, CenterEnum center);
static std::shared_ptr<Model> make(std::shared_ptr<shapelet::MultiShapeletBasis> basis, CenterEnum center);

/**
* Construct a concrete Model instance that represents a single elliptical Gaussian function.
Expand All @@ -118,7 +118,7 @@ class Model {
* (i.e. radius=1 corresponds to a model in which the radius parameter
* is ln(sigma)).
*/
static PTR(Model) makeGaussian(CenterEnum center, double radius=1.0);
static std::shared_ptr<Model> makeGaussian(CenterEnum center, double radius=1.0);

/// Return the number of free nonlinear parameters
int getNonlinearDim() const { return _nonlinearNames.size(); }
Expand Down Expand Up @@ -152,7 +152,7 @@ class Model {
) const;

/// Given an arbitrary prior, return one compatible with this Model or throw LogicError
virtual PTR(Prior) adaptPrior(PTR(Prior) prior) const = 0;
virtual std::shared_ptr<Prior> adaptPrior(std::shared_ptr<Prior> prior) const = 0;

/**
* Return an uninitialized vector of afw::geom::ellipses::Ellipse with the parametrization expected
Expand Down
2 changes: 1 addition & 1 deletion include/lsst/meas/modelfit/MultiModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MultiModel : public Model {
ModelVector const & getComponents() const { return _components; }

/// @copydoc Model::adaptPrior
PTR(Prior) adaptPrior(PTR(Prior) prior) const override;
std::shared_ptr<Prior> adaptPrior(std::shared_ptr<Prior> prior) const override;

/// @copydoc Model::makeEllipseVector
EllipseVector makeEllipseVector() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/lsst/meas/modelfit/PixelFitRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class PixelFitRegion {
void applyMask(afw::image::Mask<> const & mask, geom::Point2D const & center);

afw::geom::ellipses::Quadrupole ellipse;
PTR(afw::detection::Footprint) footprint;
std::shared_ptr<afw::detection::Footprint> footprint;
bool usedFootprintArea;
bool usedPsfArea;
bool maxArea;
Expand Down
6 changes: 3 additions & 3 deletions include/lsst/meas/modelfit/Sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class SamplingObjective {
virtual ~SamplingObjective() {}

protected:
explicit SamplingObjective(PTR(Likelihood) likelihood);
explicit SamplingObjective(std::shared_ptr<Likelihood> likelihood);

PTR(Likelihood) _likelihood;
std::shared_ptr<Likelihood> _likelihood;
ndarray::Array<Pixel,2,-1> _modelMatrix;
};

Expand All @@ -54,7 +54,7 @@ class Sampler {

virtual void run(
SamplingObjective const & objective,
PTR(Mixture) proposal,
std::shared_ptr<Mixture> proposal,
afw::table::BaseCatalog & samples
) const = 0;

Expand Down
2 changes: 1 addition & 1 deletion include/lsst/meas/modelfit/SemiEmpiricalPrior.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class SemiEmpiricalPrior : public Prior {

struct Impl;

PTR(Impl) _impl;
std::shared_ptr<Impl> _impl;
};

}}} // namespace lsst::meas::modelfit
Expand Down
6 changes: 3 additions & 3 deletions include/lsst/meas/modelfit/TruncatedGaussian.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ class TruncatedGaussian {

class Impl;

explicit TruncatedGaussian(PTR(Impl) impl) : _impl(impl) {}
explicit TruncatedGaussian(std::shared_ptr<Impl> impl) : _impl(impl) {}

PTR(Impl) _impl;
std::shared_ptr<Impl> _impl;
};

/**
Expand Down Expand Up @@ -336,7 +336,7 @@ class TruncatedGaussianSampler {
class Impl; // public so we can inherit from it in the .cc file

private:
PTR(Impl) _impl;
std::shared_ptr<Impl> _impl;
};

inline TruncatedGaussian::Sampler TruncatedGaussian::sample(SampleStrategy strategy) const {
Expand Down
6 changes: 3 additions & 3 deletions include/lsst/meas/modelfit/UnitTransformedLikelihood.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ class UnitTransformedLikelihood : public Likelihood {
* @param[in] ctrl Control object with various options
*/
explicit UnitTransformedLikelihood(
PTR(Model) model,
std::shared_ptr<Model> model,
ndarray::Array<Scalar const,1,1> const & fixed,
UnitSystem const & fitSys,
geom::SpherePoint const & position,
std::vector<PTR(EpochFootprint)> const & epochFootprintList,
std::vector<std::shared_ptr<EpochFootprint>> const & epochFootprintList,
UnitTransformedLikelihoodControl const & ctrl
);

Expand All @@ -141,7 +141,7 @@ class UnitTransformedLikelihood : public Likelihood {
* @param[in] ctrl Control object with various options
*/
explicit UnitTransformedLikelihood(
PTR(Model) model,
std::shared_ptr<Model> model,
ndarray::Array<Scalar const,1,1> const & fixed,
UnitSystem const & fitSys,
geom::SpherePoint const & position,
Expand Down
14 changes: 7 additions & 7 deletions include/lsst/meas/modelfit/optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class OptimizerObjective {
* however, so simple problems where analytic derivatives are easy to
* implement may merit a custom OptimizerObjective.
*/
static PTR(OptimizerObjective) makeFromLikelihood(
PTR(Likelihood) likelihood,
PTR(Prior) prior = PTR(Prior)()
static std::shared_ptr<OptimizerObjective> makeFromLikelihood(
std::shared_ptr<Likelihood> likelihood,
std::shared_ptr<Prior> prior = std::shared_ptr<Prior>()
);

/**
Expand Down Expand Up @@ -300,7 +300,7 @@ class OptimizerHistoryRecorder {

OptimizerHistoryRecorder(
afw::table::Schema & schema,
PTR(Model) model,
std::shared_ptr<Model> model,
bool doRecordDerivatives
);

Expand Down Expand Up @@ -424,12 +424,12 @@ class Optimizer {
};

Optimizer(
PTR(Objective const) objective,
std::shared_ptr<Objective const> objective,
ndarray::Array<Scalar const,1,1> const & parameters,
Control const & ctrl
);

PTR(Objective const) getObjective() const { return _objective; }
std::shared_ptr<Objective const> getObjective() const { return _objective; }

Control const & getControl() const { return _ctrl; }

Expand Down Expand Up @@ -486,7 +486,7 @@ class Optimizer {
void _computeDerivatives();

int _state;
PTR(Objective const) _objective;
std::shared_ptr<Objective const> _objective;
Control _ctrl;
double _trustRadius;
IterationData _current;
Expand Down

0 comments on commit e470956

Please sign in to comment.