Skip to content

Commit

Permalink
Squashed 'externals/coda-oss/' changes from 1b77f1c..163168f
Browse files Browse the repository at this point in the history
163168f Merge pull request #303 from mdaus/update_waf
15aef50 Update .gitignore
e40f4d0 Update notes
8e60f52 Update waffile again
c15215a Attempt to update waffile
4dbe4be Attempt to update waffile
dbe1a53 Attempt to update waffile
12bd2a1 Try to update waffile again
12d3112 Update notes and gitignore
96ec887 Update Python3 errors in msvc.py
30d7dff Merge pull request #302 from mdaus/python_bindings
5295ad3 Regenerate Python bindings
7b46a4a Merge pull request #301 from mdaus/ES_Removal
35bd221 Remove exception specifications.
14523c9 Merge pull request #300 from mdaus/str-trim-isspace-fix
0976788 Use C++ style include
aca8e70 Include wctype.h
77fd4d8 Update str::trim to properly handle non-ASCII characters on Windows
e05052d Merge pull request #299 from mdaus/fixFitCoeffOOB
a3e26c3 PR changes
d08c2f9 Added order check when combining component coefficients for a vector-valued polynomial fit. Will fill coefficients that are not present with 0.0

git-subtree-dir: externals/coda-oss
git-subtree-split: 163168fa5c7d5fbf200f15e739c18d7c0dc24e3b
  • Loading branch information
JonathanMeans committed May 7, 2019
1 parent ca0f4a0 commit fae862f
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 82 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ target/

.waf-*
waf-*
.waf3-*
waf3-*
.lock-waf*

# Eclipse
Expand Down
Binary file modified build/waf
Binary file not shown.
5 changes: 0 additions & 5 deletions modules/c++/cli/include/cli/Results.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ class Results
}

cli::Value* operator[](const std::string& key) const
throw (except::NoSuchKeyException)
{
return getValue(key);
}

cli::Value* getValue(const std::string& key) const
throw (except::NoSuchKeyException)
{
ConstValueIter_T p = mValues.find(key);
if (p == mValues.end())
Expand All @@ -78,20 +76,17 @@ class Results

template<typename T>
T get(const std::string& key, unsigned int index = 0) const
throw (except::NoSuchKeyException)
{
return getValue(key)->get<T>(index);
}

template<typename T>
T operator()(const std::string& key, unsigned int index = 0) const
throw (except::NoSuchKeyException)
{
return get<T>(key, index);
}

cli::Results* getSubResults(const std::string& key) const
throw (except::NoSuchKeyException)
{
ConstResultsIter_T p = mResults.find(key);
if (p == mResults.end())
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/dbi/include/dbi/DatabaseClientFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class DatabaseClientFactory
const std::string& user = "",
const std::string& pass = "",
const std::string& host = "localhost",
unsigned int port = 0) throw (except::Exception);
unsigned int port = 0);

/*!
* Destroy a previously created connection
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/dbi/source/DatabaseClientFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dbi::DatabaseConnection * dbi::DatabaseClientFactory::create(const std::string&
const std::string& user,
const std::string& pass,
const std::string& host,
unsigned int port) throw (except::Exception)
unsigned int port)
{
dbi::DatabaseConnection * connection = NULL;
# if defined(USE_PGSQL)
Expand Down
6 changes: 3 additions & 3 deletions modules/c++/io/include/io/FileUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ class FileUtils
* given one. If the given filename is empty, a temporary name is used.
*/
static std::string createFile(std::string dirname, std::string filename =
std::string(""), bool overwrite = true) throw (except::IOException);
std::string(""), bool overwrite = true);

static void touchFile(std::string filename) throw (except::IOException);
static void touchFile(std::string filename);

static void forceMkdir(std::string dirname) throw (except::IOException);
static void forceMkdir(std::string dirname);

private:
//private constructor
Expand Down
6 changes: 3 additions & 3 deletions modules/c++/io/source/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void io::copy(const std::string& path,
}

std::string io::FileUtils::createFile(std::string dirname,
std::string filename, bool overwrite) throw (except::IOException)
std::string filename, bool overwrite)
{
sys::OS os;

Expand Down Expand Up @@ -171,7 +171,7 @@ std::string io::FileUtils::createFile(std::string dirname,
return outFilename;
}

void io::FileUtils::touchFile(std::string filename) throw (except::IOException)
void io::FileUtils::touchFile(std::string filename)
{
sys::OS os;
if (os.exists(filename))
Expand All @@ -188,7 +188,7 @@ void io::FileUtils::touchFile(std::string filename) throw (except::IOException)
}
}

void io::FileUtils::forceMkdir(std::string dirname) throw (except::IOException)
void io::FileUtils::forceMkdir(std::string dirname)
{
sys::OS os;
if (os.exists(dirname))
Expand Down
19 changes: 16 additions & 3 deletions modules/c++/math.poly/include/math/poly/Fit.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,27 @@ inline math::poly::OneD< math::linear::VectorN< 3, double > > fit(
const math::poly::OneD<double> fit1 = fit(xObs, yObs1, order);
const math::poly::OneD<double> fit2 = fit(xObs, yObs2, order);

// There is a non-zero chance that one or more of the resulting polynomials
// are of a lower order than the requested order -- this results when the
// highest order coefficients are identically 0.0. As a result, care must be
// taken when combining the coefficients to avoid running outside of the
// actual number of coefficients in any particular fit.
// Note: There is a choice to be made here if /all/ polynomials have their
// orders reduced. In an ideal world, this would reduce the order
// of the output poly from 'order' to the maximum of the component
// orders. However, this code has been in production for awhile,
// and I cannot guarantee that someone, somewhere, isn't expecting
// 'order'+1 coefficients and attempting to extract/modify them.
// So, we'll retain the original desired order of the polynomial
// and simply fill with zeros.
math::poly::OneD< math::linear::VectorN< 3, double > > polyVector3 =
math::poly::OneD< math::linear::VectorN< 3, double > >(order);
for (size_t term = 0; term <= order; term++)
{
math::linear::VectorN< 3, double >& coeffs = polyVector3[term];
coeffs[0] = fit0[term];
coeffs[1] = fit1[term];
coeffs[2] = fit2[term];
coeffs[0] = (term <= fit0.order()) ? fit0[term] : 0.0;
coeffs[1] = (term <= fit1.order()) ? fit1[term] : 0.0;
coeffs[2] = (term <= fit2.order()) ? fit2[term] : 0.0;
}

return polyVector3;
Expand Down
105 changes: 105 additions & 0 deletions modules/c++/math.poly/unittests/test_llsq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,109 @@ TEST_CASE(test2DPolyfitLarge)

TEST_ASSERT_ALMOST_EQ(meanResidualError, 0.0);
}

TEST_CASE(testVectorValuedOrderChange)
{
// When fitting a vector-valued polynomial, math::poly::fit()
// will perform 3 independent fits, and then assemble the coefficients
// into vector-valued coefficients for the resulting polynomial.
// During each independent fit, however, the order may end up being reduced
// if the leading coefficient (and any sub-leading coefficients) are
// identically 0. As a result, care must be taken when assembling
// the scalar coefficients into a vector that zeros are added when
// we exceed the order of one of the reduced polynomials.

std::vector<double> indep(3);
indep[0] = 0.0; indep[1] = 1.0; indep[2] = 2.0;
std::vector<double> compZeroed(3);
compZeroed[0] = 0.0; compZeroed[1] = 0.0; compZeroed[2] = 0.0;
std::vector<double> comp1(3);
comp1[0] = 1.0; comp1[1] = 2.0; comp1[2] = 4.0;
std::vector<double> comp2(3);
comp2[0] = 0.1; comp2[1] = 0.9; comp2[2] = 0.1;

// First, test that we're actually reducing the order of some of the fits
const OneD<double> polyZeroed = fit(indep, compZeroed, 2);
const OneD<double> poly1 = fit(indep, comp1, 2);
const OneD<double> poly2 = fit(indep, comp2, 2);

TEST_ASSERT_EQ(polyZeroed.order(), 0);
TEST_ASSERT_EQ(poly1.order(), 2);
TEST_ASSERT_EQ(poly2.order(), 2);

// Now, attempt to fit the vector-vector version.
// We'll check reshuffle the zero component to make sure we caught all
// component order reductions.

// Zeroed values in the X component
{
const OneD<VectorN<3, double> > poly =
fit(indep, compZeroed, comp1, comp2, 2);

TEST_ASSERT_EQ(poly.order(), 2);

// X-component
TEST_ASSERT_ALMOST_EQ(poly[0][0], 0.0);
TEST_ASSERT_ALMOST_EQ(poly[1][0], 0.0);
TEST_ASSERT_ALMOST_EQ(poly[2][0], 0.0);

// Y-component
TEST_ASSERT_ALMOST_EQ(poly[0][1], 1.0);
TEST_ASSERT_ALMOST_EQ(poly[1][1], 0.5);
TEST_ASSERT_ALMOST_EQ(poly[2][1], 0.5);

// Z-component
TEST_ASSERT_ALMOST_EQ(poly[0][2], 0.1);
TEST_ASSERT_ALMOST_EQ(poly[1][2], 1.6);
TEST_ASSERT_ALMOST_EQ(poly[2][2], -0.8);
}

// Zeroed values in the Y component
{
const OneD<VectorN<3, double> > poly =
fit(indep, comp1, compZeroed, comp2, 2);

TEST_ASSERT_EQ(poly.order(), 2);

// X-component
TEST_ASSERT_ALMOST_EQ(poly[0][0], 1.0);
TEST_ASSERT_ALMOST_EQ(poly[1][0], 0.5);
TEST_ASSERT_ALMOST_EQ(poly[2][0], 0.5);

// Y-component
TEST_ASSERT_ALMOST_EQ(poly[0][1], 0.0);
TEST_ASSERT_ALMOST_EQ(poly[1][1], 0.0);
TEST_ASSERT_ALMOST_EQ(poly[2][1], 0.0);

// Z-component
TEST_ASSERT_ALMOST_EQ(poly[0][2], 0.1);
TEST_ASSERT_ALMOST_EQ(poly[1][2], 1.6);
TEST_ASSERT_ALMOST_EQ(poly[2][2], -0.8);
}

// Zeroed values in the Z component
{
const OneD<VectorN<3, double> > poly =
fit(indep, comp1, comp2, compZeroed, 2);

TEST_ASSERT_EQ(poly.order(), 2);

// X-component
TEST_ASSERT_ALMOST_EQ(poly[0][0], 1.0);
TEST_ASSERT_ALMOST_EQ(poly[1][0], 0.5);
TEST_ASSERT_ALMOST_EQ(poly[2][0], 0.5);

// Y-component
TEST_ASSERT_ALMOST_EQ(poly[0][1], 0.1);
TEST_ASSERT_ALMOST_EQ(poly[1][1], 1.6);
TEST_ASSERT_ALMOST_EQ(poly[2][1], -0.8);

// Z-component
TEST_ASSERT_ALMOST_EQ(poly[0][2], 0.0);
TEST_ASSERT_ALMOST_EQ(poly[1][2], 0.0);
TEST_ASSERT_ALMOST_EQ(poly[2][2], 0.0);
}
}
}

int main(int, char**)
Expand All @@ -237,4 +340,6 @@ int main(int, char**)
TEST_CHECK(test1DPolyfitLarge);
TEST_CHECK(test2DPolyfit);
TEST_CHECK(test2DPolyfitLarge);
TEST_CHECK(testVectorValuedOrderChange);
return 0;
}
6 changes: 3 additions & 3 deletions modules/c++/net/include/net/URL.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ class URLParams
URLParams(const std::string paramString = "");

bool contains(std::string key) const;
ParamValues& get(std::string key) throw (except::NoSuchKeyException);
const ParamValues& get(std::string key) const throw (except::NoSuchKeyException);
ParamValues& get(std::string key);
const ParamValues& get(std::string key) const;
Params& get() { return mParams; }
const Params& get() const { return mParams; }
std::string getFirst(std::string key) const throw (except::NoSuchKeyException);
std::string getFirst(std::string key) const;
void add(std::string key, std::string value = "");
void remove(std::string key);

Expand Down
3 changes: 0 additions & 3 deletions modules/c++/net/source/URL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ bool net::URLParams::contains(std::string key) const
}

net::URLParams::ParamValues& net::URLParams::get(std::string key)
throw (except::NoSuchKeyException)
{
net::URLParams::Params::iterator it = mParams.find(key);
if (it == mParams.end() || it->second.size() == 0)
Expand All @@ -161,15 +160,13 @@ net::URLParams::ParamValues& net::URLParams::get(std::string key)
}

const net::URLParams::ParamValues& net::URLParams::get(std::string key) const
throw (except::NoSuchKeyException)
{
net::URLParams::Params::const_iterator it = mParams.find(key);
if (it == mParams.end() || it->second.size() == 0)
throw except::NoSuchKeyException(Ctxt(key));
return it->second;
}
std::string net::URLParams::getFirst(std::string key) const
throw (except::NoSuchKeyException)
{
net::URLParams::Params::const_iterator it = mParams.find(key);
if (it == mParams.end() || it->second.size() == 0)
Expand Down
3 changes: 1 addition & 2 deletions modules/c++/sio.lite/include/sio/lite/FileHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ class FileHeader
* Get the raw byte user data for a given user data ID.
* @return An array of user data for a given key
*/
std::vector<sys::byte>& getUserData(const std::string& key)
throw (except::NoSuchKeyException);
std::vector<sys::byte>& getUserData(const std::string& key);

/**
* Get back the whole hash table
Expand Down
1 change: 0 additions & 1 deletion modules/c++/sio.lite/include/sio/lite/UserDataDictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class OrderedDictionary
ConstIterator end() const { return mList.end(); }

virtual Value_T& operator[] (const Key_T& key)
throw(except::NoSuchKeyException)
{
typename std::map < Key_T, Value_T >::iterator it = mMap.find(key);
if (it == mMap.end())
Expand Down
1 change: 0 additions & 1 deletion modules/c++/sio.lite/source/FileHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ void sio::lite::FileHeader::getAllUserDataFields(
}

std::vector<sys::byte>& sio::lite::FileHeader::getUserData(const std::string& key)
throw (except::NoSuchKeyException)
{
if (!userData.exists(key))
throw except::NoSuchKeyException(key);
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/str/include/str/Convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ template<> int getPrecision(const long double& type);
@throw BadCastException thrown if cast cannot be performed.
*/
template<typename T>
T generic_cast(const std::string& value) throw (except::BadCastException)
T generic_cast(const std::string& value)
{
return str::toType<T>(value);
}
Expand Down
5 changes: 3 additions & 2 deletions modules/c++/str/source/Manip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cwctype>

#include <str/Manip.h>

Expand Down Expand Up @@ -65,14 +66,14 @@ void trim(std::string & s)
size_t i;
for (i = 0; i < s.length(); i++)
{
if (!isspace(s[i]))
if (!iswspace(s[i]))
break;
}
s.erase(0, i);

for (i = s.length() - 1; (int) i >= 0; i--)
{
if (!isspace(s[i]))
if (!iswspace(s[i]))
break;

}
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/unique/include/unique/UUID.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typedef except::InvalidFormatException UUIDException;
/*!
* Create a 36-character UUID and return as a std::string
*/
std::string generateUUID() throw(unique::UUIDException);
std::string generateUUID();

}
#endif
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/unique/source/UUID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <uuid/uuid.h>
#endif

std::string unique::generateUUID() throw(unique::UUIDException)
std::string unique::generateUUID()
{
#ifdef WIN32
GUID uuid;
Expand Down
Loading

0 comments on commit fae862f

Please sign in to comment.