Skip to content

Commit

Permalink
Replace assert with exception for invalid argument
Browse files Browse the repository at this point in the history
The methods `setNumIter` and `setNumSigmaClip` must throw an
exception if the input parameters are invalid instead of asserting that they
are valid.
  • Loading branch information
arunkannawadi committed May 6, 2021
1 parent 2bc2b1e commit 7befe53
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/lsst/afw/math/Statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,17 @@ class StatisticsControl {
bool getCalcErrorFromInputVariance() const noexcept { return _calcErrorFromInputVariance; }

void setNumSigmaClip(double numSigmaClip) {
assert(numSigmaClip > 0);
if (!(numSigmaClip > 0)) {
throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
"numSigmaClip has to be positive.");
}
_numSigmaClip = numSigmaClip;
}
void setNumIter(int numIter) {
assert(numIter > 0);
if (!(numIter > 0)) {
throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
"numIter has to be positive.");
}
_numIter = numIter;
}
void setAndMask(int andMask) { _andMask = andMask; }
Expand Down

0 comments on commit 7befe53

Please sign in to comment.