Skip to content

Commit

Permalink
Added GaussianDistribution Tests (#3221)
Browse files Browse the repository at this point in the history
* Added GaussianDistribution Test.

* Removed unused method and added test for exception.

* Changed comment.

* Added Area3DTests.cpp (#3216)

* Added BasisFunctionTests.cpp. Removed BasisFunction unit test and truthfile.

* changed expectedOutput values for some of the tests

* Made tests for Displacement.cpp using gtest. removed Displacement unitTest and truthfile.

* Added Area3DTests.cpp, removed Area3D truthfile and unit test.

* included TestUtilities.h for use with exception testing, added a test for teh Area3D '=' operator

* changed formatting to adhere to USGS coding standards

* re-addedd the unit test and truth file

* gllssi2isis Original Label Fix (#3226)

* Allowed writting of residuals when value is zero to controlnet pvl

* Updated ControlNetVersioner unit test

* Fixed pvl labels original pvl labels not being written to the resulting cube.

* Updated docstrings and history for updated methods

* Removed the need to set the output cube pixel type

* Reverted proceeimport changes

* Set the dimensions in the process before processing

* Added missing 1 in a history record

* Reverted and applied a more appropriate fix

* Used outfile obtained at the beginning of the program

* Added history comment to app xml

* Removed accidental comma (#3230)

* Update README.md (#3232)

Update readability

* Modifying files for conda build for ISIS3.7.0_RC2 (#3229)

* Modifying files for conda build for ISIS3.7.0_RC_2

* Changes to modifications until issue #3231 can be completed

* Small typo

* One final added comment for clarification

* Adding tab completion for tcsh on conda activation (#3244)

* Modifying meta.yaml and version files for ISIS3.7.0 Public Release (#3254)

* Modifying meta.yaml and version files for ISIS3.7.0 Public Release

* Fixing date on version file

* Put the Probability method back and removed the old unit test and truth data.
  • Loading branch information
kaitlyndlee authored and jessemapel committed May 16, 2019
1 parent 955cc58 commit 14a24c6
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace Isis {
p_stdev = standardDeviation;
}


/**
* Computes and returns the probability of the specified value
* on the gaussian distribution.
Expand All @@ -51,6 +52,7 @@ namespace Isis {
return std::exp(-0.5 * std::pow((value - p_mean) / p_stdev, 2)) / (std::sqrt(2 * PI) * p_stdev);
}


/**
* Computes and returns the cumulative distribution up to the
* specified value on the gaussian distribution.
Expand Down
26 changes: 0 additions & 26 deletions isis/src/base/objs/GaussianDistribution/GaussianDistribution.truth

This file was deleted.

26 changes: 0 additions & 26 deletions isis/src/base/objs/GaussianDistribution/unitTest.cpp

This file was deleted.

67 changes: 67 additions & 0 deletions isis/tests/GaussianDistributionTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include "GaussianDistribution.h"
#include "IException.h"
#include "TestUtilities.h"

#include <gtest/gtest.h>
#include <QPair>
#include <QString>

class DoubleTest : public ::testing::TestWithParam<QPair <double, double> > {
// Intentionally empty
};


TEST(GaussianDistribution, DefaultConstructor) {
Isis::GaussianDistribution dist;
EXPECT_EQ(dist.Mean(), 0);
EXPECT_EQ(dist.StandardDeviation(), 1.0);
}


TEST(GaussianDistribution, Constructor) {
Isis::GaussianDistribution dist(1.0, 2.0);
EXPECT_EQ(dist.Mean(), 1.0);
EXPECT_EQ(dist.StandardDeviation(), 2.0);
}


TEST(GaussianDistribution, InvalidPercentage) {
Isis::GaussianDistribution dist;
QString message = "Argument percent outside of the range 0 to 100";
try {
dist.InverseCumulativeDistribution(110);
}
catch(Isis::IException &e) {
EXPECT_PRED_FORMAT2(Isis::AssertIExceptionMessage, e, message);
}
catch(...) {
FAIL() << "Expected error message: \"" << message.toStdString() << "\"";
}
}


TEST_P(DoubleTest, Distributions) {
Isis::GaussianDistribution dist;
EXPECT_NEAR(dist.CumulativeDistribution(GetParam().first), GetParam().second, .000000000000000001);
EXPECT_NEAR(dist.InverseCumulativeDistribution(GetParam().second), GetParam().first, .000001);
}


QPair <double, double> neg3(-3.0, 0.13498980316295217);
QPair <double, double> neg2point5(-2.5, 0.62096653257757595);
QPair <double, double> neg2(-2.0, 2.2750131948179018);
QPair <double, double> neg1point5(-1.5, 6.6807201268857881);
QPair <double, double> neg1(-1.0, 15.865525393145695);
QPair <double, double> negpoint5(-0.5, 30.853753872598688);
QPair <double, double> zero(0.0, 50);
QPair <double, double> pospoint5(0.5, 69.146246127401312);
QPair <double, double> pos1(1.0, 84.134474606854297);
QPair <double, double> pos1point5(1.5, 93.319279873114212);
QPair <double, double> pos2(2.0, 97.724986805182098);
QPair <double, double> pos2point5(2.5, 99.379033467422431);
QPair <double, double> pos3(3.0, 99.865010196837048);


INSTANTIATE_TEST_CASE_P(GaussianDistribution, DoubleTest, ::testing::Values(neg3, neg2point5,
neg2, neg1point5, neg1, negpoint5, zero, pospoint5, pos1, pos1point5,
pos2, pos2point5, pos3));

0 comments on commit 14a24c6

Please sign in to comment.