Skip to content

Commit f8c2962

Browse files
gshiromaGitHub Enterprise
authored andcommitted
Fix polygon is_complex (#748)
* fix polygon is_complex * substitute assert() by static_assert() and update GDALDataTypeIsComplex test on output_off_diag_terms * substitute assert by if/else throw exception
1 parent 829dc14 commit f8c2962

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

cxx/isce3/geocode/GeocodeCov.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,15 @@ void Geocode<T>::geocodeAreaProj(
728728
<< pyre::journal::newline;
729729
assert(out_off_diag_terms->numBands() == nbands_off_diag_terms);
730730
info << "full covariance: true" << pyre::journal::newline;
731-
assert(isce3::is_complex<T>());
732-
assert(GDALDataTypeIsComplex(out_off_diag_terms->dtype()));
731+
if (!GDALDataTypeIsComplex(input_raster.dtype())){
732+
std::string error_msg = "Input raster must be complex to"
733+
" generate full-covariance matrix";
734+
throw isce3::except::InvalidArgument(ISCE_SRCINFO(), error_msg);
735+
}
736+
if (!GDALDataTypeIsComplex(out_off_diag_terms->dtype())){
737+
std::string error_msg = "Off-diagonal raster must be complex";
738+
throw isce3::except::InvalidArgument(ISCE_SRCINFO(), error_msg);
739+
}
733740
} else {
734741
info << "nbands: " << nbands << pyre::journal::newline;
735742
info << "full covariance: false" << pyre::journal::newline;

cxx/isce3/geocode/GeocodePolygon.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,15 @@ void GeocodePolygon<T>::_getPolygonMean(
299299
<< pyre::journal::endl;
300300
assert(output_off_diag_terms->numBands() == nbands_off_diag_terms);
301301
_info << "full covariance: true" << pyre::journal::endl;
302-
assert(is_complex_t<T>());
303-
assert(GDALDataTypeIsComplex(output_off_diag_terms->dtype()));
302+
if (!GDALDataTypeIsComplex(input_raster.dtype())){
303+
std::string error_msg = "Input raster must be complex to"
304+
" generate full-covariance matrix";
305+
throw isce3::except::InvalidArgument(ISCE_SRCINFO(), error_msg);
306+
}
307+
if (!GDALDataTypeIsComplex(output_off_diag_terms->dtype())){
308+
std::string error_msg = "Off-diagonal raster must be complex";
309+
throw isce3::except::InvalidArgument(ISCE_SRCINFO(), error_msg);
310+
}
304311
} else {
305312
_info << "nbands: " << nbands << pyre::journal::endl;
306313
_info << "full covariance: false" << pyre::journal::endl;

0 commit comments

Comments
 (0)