Skip to content

Commit

Permalink
Merge pull request #250 from ngageoint/update_tests
Browse files Browse the repository at this point in the history
Add new tests, and make output more friendly for reading automated ou…
  • Loading branch information
asylvest committed Nov 16, 2018
2 parents 2c05e9d + 7a8d6d2 commit f2ab9f6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
30 changes: 15 additions & 15 deletions six/modules/c++/six.sicd/tests/test_mesh_polyfit.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* =========================================================================
* This file is part of six.sicd-c++
* =========================================================================
*
*
* (C) Copyright 2004 - 2018, MDA Information Systems LLC
*
* six.sicd-c++ is free software; you can redistribute it and/or modify
Expand All @@ -14,8 +14,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/
Expand Down Expand Up @@ -74,7 +74,7 @@ six::sicd::PlanarCoordinateMesh populatePlanarCoordinateMeshVectors(
}

int main(int argc, char** argv)
{
{
try
{
cli::ArgumentParser parser;
Expand Down Expand Up @@ -159,11 +159,11 @@ int main(int argc, char** argv)
{
std::cout << "sceneExtent: (" << sceneExtent.row
<< "," << sceneExtent.col << ")" << std::endl;
std::cout << "slantSampleSpacing: (" << slantSampleSpacing.row
std::cout << "slantSampleSpacing: (" << slantSampleSpacing.row
<< "," << slantSampleSpacing.col << ")" << std::endl;
std::cout << "slantCenter: (" << slantCenter.row
<< "," << slantCenter.col << ")" << std::endl;
std::cout << "outputSampleSpacing: (" << outputSampleSpacing.row
std::cout << "outputSampleSpacing: (" << outputSampleSpacing.row
<< "," << outputSampleSpacing.col << ")" << std::endl;
std::cout << "outputCenter: (" << outputCenter.row
<< "," << outputCenter.col << ")" << std::endl;
Expand All @@ -184,10 +184,10 @@ int main(int argc, char** argv)
sceneExtent);

// Compute (x,y) to (x,y) projection polynomials
six::Poly2D outputXYToSlantX;
six::Poly2D outputXYToSlantY;
six::Poly2D slantXYToOutputX;
six::Poly2D slantXYToOutputY;
six::Poly2D outputXYToSlantX;
six::Poly2D outputXYToSlantY;
six::Poly2D slantXYToOutputX;
six::Poly2D slantXYToOutputY;
six::sicd::Utilities::fitXYProjectionPolys(
outputMesh,
slantMesh,
Expand All @@ -200,7 +200,7 @@ int main(int argc, char** argv)

// Compute the output (row, col) to slant (row, col) projection polynomials.
six::Poly2D outputRowColToSlantRow;
six::Poly2D outputRowColToSlantCol;
six::Poly2D outputRowColToSlantCol;
six::sicd::Utilities::transformXYProjectionPolys(
outputXYToSlantX,
outputXYToSlantY,
Expand All @@ -212,8 +212,8 @@ int main(int argc, char** argv)
outputRowColToSlantCol);

// Compute the slant (row, col) to output (row, col) projection polynomials.
six::Poly2D slantRowColToOutputRow;
six::Poly2D slantRowColToOutputCol;
six::Poly2D slantRowColToOutputRow;
six::Poly2D slantRowColToOutputCol;
six::sicd::Utilities::transformXYProjectionPolys(
slantXYToOutputX,
slantXYToOutputY,
Expand Down Expand Up @@ -261,9 +261,9 @@ int main(int argc, char** argv)
slantRowColToOutputCol(slantCenter.row, slantCenter.col),
outputCenter.col, pixelTol, oss);

if (verbose)
if (!pass || verbose)
{
std::cout << "Test results:" << std::endl << oss.str() << std::endl;
std::cerr << "Test results:" << std::endl << oss.str() << std::endl;

std::cout << "Fitted Polynomials:" << std::endl;
std::cout << "outputXYToSlantX:" << std::endl
Expand Down
55 changes: 26 additions & 29 deletions six/modules/c++/six.sicd/tests/test_mesh_roundtrip.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* =========================================================================
* This file is part of six.sicd-c++
* =========================================================================
*
*
* (C) Copyright 2004 - 2018, MDA Information Systems LLC
*
* six.sicd-c++ is free software; you can redistribute it and/or modify
Expand All @@ -14,8 +14,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/
Expand Down Expand Up @@ -69,7 +69,7 @@ void populateNoiseMeshVectors(const types::RowCol<size_t>& meshDims,
for (size_t ci = 0; ci < meshDims.col; ++ci)
{
mainBeamNoise.push_back((double) std::rand() / (double) RAND_MAX);
azimuthAmbiguityNoise.push_back((double) std::rand() /
azimuthAmbiguityNoise.push_back((double) std::rand() /
(double) RAND_MAX);
combinedNoise.push_back((double) std::rand() / (double) RAND_MAX);
}
Expand Down Expand Up @@ -101,13 +101,10 @@ bool comparePlanarCoordinateMesh(

if (diffRows > 0 || diffCols > 0)
{
if (verbose)
{
std::cout << "PlanarCoordinateMesh comparison failed. "
<< "Mesh dimensions do not agree:" << std::endl
<< " diffRows: " << diffRows << std::endl
<< " diffCols: " << diffCols << std::endl;
}
std::cerr << "PlanarCoordinateMesh comparison failed. "
<< "Mesh dimensions do not agree:" << std::endl
<< " diffRows: " << diffRows << std::endl
<< " diffCols: " << diffCols << std::endl;
return false;
}

Expand Down Expand Up @@ -151,15 +148,12 @@ bool compareNoiseMesh(

if (!coordsMatch)
{
if (verbose)
{
std::cout << "NoiseMesh comparison failed. "
<< "Coordinates do not agree:" << std::endl
<< " diffRows: " << diffRows << std::endl
<< " diffCols: " << diffCols << std::endl
<< " maxDiffX: " << maxDiffX << std::endl
<< " maxDiffY: " << maxDiffY << std::endl;
}
std::cerr << "NoiseMesh comparison failed. "
<< "Coordinates do not agree:" << std::endl
<< " diffRows: " << diffRows << std::endl
<< " diffCols: " << diffCols << std::endl
<< " maxDiffX: " << maxDiffX << std::endl
<< " maxDiffY: " << maxDiffY << std::endl;
return false;
}

Expand All @@ -171,19 +165,19 @@ bool compareNoiseMesh(
maxDiffMainBeamNoise = std::max(
maxDiffMainBeamNoise,
std::abs(
meshA->getMainBeamNoise()[ii] -
meshA->getMainBeamNoise()[ii] -
meshB->getMainBeamNoise()[ii]));

maxDiffAzimuthAmbiguityNoise = std::max(
maxDiffAzimuthAmbiguityNoise,
std::abs(
meshA->getAzimuthAmbiguityNoise()[ii] -
meshA->getAzimuthAmbiguityNoise()[ii] -
meshB->getAzimuthAmbiguityNoise()[ii]));

maxDiffCombinedNoise = std::max(
maxDiffCombinedNoise,
std::abs(
meshA->getCombinedNoise()[ii] -
meshA->getCombinedNoise()[ii] -
meshB->getCombinedNoise()[ii]));
}

Expand Down Expand Up @@ -223,11 +217,11 @@ bool roundTripPlanarMesh(const types::RowCol<size_t>& meshDims,
std::vector<sys::byte> serializedValues;
serializedMesh.serialize(serializedValues);

// Deserialize the mesh.
// Deserialize the mesh.
x.clear();
y.clear();

six::sicd::PlanarCoordinateMesh deserializedMesh(name);//name, meshDims, x, y);
six::sicd::PlanarCoordinateMesh deserializedMesh(name);
const sys::byte* serializedValuesBuffer = &serializedValues[0];
deserializedMesh.deserialize(serializedValuesBuffer);

Expand Down Expand Up @@ -267,7 +261,7 @@ bool roundTripNoiseMesh(const types::RowCol<size_t>& meshDims,
std::vector<sys::byte> serializedValues;
serializedNoiseMesh.serialize(serializedValues);

// Deserialize the mesh.
// Deserialize the mesh.
six::sicd::NoiseMesh deserializedNoiseMesh(name);

const sys::byte* serializedValuesBuffer = &serializedValues[0];
Expand Down Expand Up @@ -304,9 +298,12 @@ int main(int argc, char** argv)
options->get<size_t>("numCols"));
const bool verbose = options->get<bool>("verbose");

std::cout << "numRows = " << options->get<size_t>("numRows") << std::endl;
std::cout << "numCols = " << options->get<size_t>("numCols") << std::endl;
std::cout << "MeshDims: (" << meshDims.row << "," << meshDims.col << ")" << std::endl;
if (verbose)
{
std::cout << "numRows = " << options->get<size_t>("numRows") << std::endl;
std::cout << "numCols = " << options->get<size_t>("numCols") << std::endl;
std::cout << "MeshDims: (" << meshDims.row << "," << meshDims.col << ")" << std::endl;
}

bool success = true;
success &= roundTripPlanarMesh(meshDims, verbose);
Expand Down
7 changes: 5 additions & 2 deletions six/modules/python/six/tests/runMiscTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def getSampleSicdXML():
return os.path.join(samples, random.choice(os.listdir(samples)))

def runTests(testDir, testName, *args):
print('Running {}'.format(testName))
argList = [utils.executableName(os.path.join(testDir, testName))]
argList.extend(args)
result = call(argList, stdout=subprocess.PIPE)
Expand All @@ -62,11 +63,13 @@ def runSICDTests():
testDir = os.path.join(utils.installPath(), 'tests', 'six.sicd')

success = runTests(testDir, 'test_add_additional_des', getSampleSicdXML())
success = runTests(testDir, 'test_mesh_roundtrip') and success
success = runTests(testDir, 'test_mesh_polyfit') and success

# Need it for just this test
os.environ['NITF_PLUGIN_PATH'] = os.environ['NITF_PLUGIN_PATH_REAL']
success = success and runTests(testDir, 'test_read_sicd_with_extra_des',
getSampleSicdXML())
success = runTests(testDir, 'test_read_sicd_with_extra_des',
getSampleSicdXML()) and success
del os.environ['NITF_PLUGIN_PATH']

return success
Expand Down

0 comments on commit f2ab9f6

Please sign in to comment.