Skip to content
Commits on Source (3)
......@@ -9,7 +9,7 @@ cmake_minimum_required (VERSION 2.8.11)
project (bpp-core CXX)
# Compile options
#set (CMAKE_CXX_FLAGS "-std=c++11 -g")
set (CMAKE_CXX_FLAGS "-std=c++11 -Wall -Weffc++ -Wshadow -Wconversion")
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
......@@ -25,9 +25,9 @@ ENDIF(NOT CMAKE_BUILD_TYPE)
# library implements.
# In other words, the library implements all the interface numbers in the
# range from number current - age to current.
SET(${PROJECT_NAME}_VERSION_CURRENT "4")
SET(${PROJECT_NAME}_VERSION_CURRENT "5")
SET(${PROJECT_NAME}_VERSION_REVISION "0")
SET(${PROJECT_NAME}_VERSION_AGE "0")
SET(${PROJECT_NAME}_VERSION_AGE "1")
# Effective version number computation
MATH(EXPR ${PROJECT_NAME}_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_CURRENT} - ${${PROJECT_NAME}_VERSION_AGE}")
......@@ -77,10 +77,10 @@ ENDIF (DOXYGEN_FOUND)
# Packager
SET(CPACK_PACKAGE_NAME "libbpp-core")
SET(CPACK_PACKAGE_VENDOR "Bio++ Development Team")
SET(CPACK_PACKAGE_VERSION "2.4.0")
SET(CPACK_PACKAGE_VERSION "2.4.1")
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
SET(CPACK_PACKAGE_VERSION_MINOR "4")
SET(CPACK_PACKAGE_VERSION_PATCH "0")
SET(CPACK_PACKAGE_VERSION_PATCH "1")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Bio++ Core library")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.txt")
SET(CPACK_RESOURCE_FILE_AUTHORS "${CMAKE_SOURCE_DIR}/AUTHORS.txt")
......
06/06/18 Julien Dutheil
* Recursive param argument issue solved (closes #17).
* New version number: current 4 -> 5, age 0 -> 1 because of new symbol in AttributeTools.
19/02/17 -*- Version 2.4.0 -*-
04/01/18 Laurent Guéguen
......
......@@ -38,7 +38,7 @@ PROJECT_NAME = bpp-core
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 2.4.0
PROJECT_NUMBER = 2.4.1
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
......
......@@ -3,7 +3,7 @@
URL: https://github.com/BioPP/bpp-core
Name: bpp-core
Version: 2.4.0
Version: 2.4.1
Release: 1%{?dist}
License: CECILL-2.0
Vendor: The Bio++ Project
......@@ -71,6 +71,8 @@ rm -rf $RPM_BUILD_ROOT
%{_prefix}/include/*
%changelog
* Fri Aug 10 2018 Julien Dutheil <julien.dutheil@univ-montp2.fr> 2.4.1-1
- Update for gcc8 + bug fixes
* Mon Mar 12 2018 Julien Dutheil <julien.dutheil@univ-montp2.fr> 2.4.0-1
- Increased interface number
- Removed dynamic exceptions specifications.
......
libbpp-core (2.4.1-1) UNRELEASED; urgency=medium
* Compatibility with gcc 8.0
Ref: #897780
-- Julien Dutheil <julien.dutheil@univ-montp2.fr> Sat, 18 Aug 2018 13:32:11 +0200
libbpp-core (2.4.0-3) unstable; urgency=medium
* Provide symbols file only for amd64
......
......@@ -8,8 +8,8 @@ Build-Depends: debhelper (>= 11~),
cmake,
d-shlibs
Standards-Version: 4.1.3
Vcs-Browser: https://anonscm.debian.org/cgit/debian-med/libbpp-core.git
Vcs-Git: https://anonscm.debian.org/git/debian-med/libbpp-core.git
Vcs-Browser: https://salsa.debian.org/med-team/libbpp-core
Vcs-Git: https://salsa.debian.org/med-team/libbpp-core.git
Homepage: http://biopp.univ-montp2.fr/wiki/index.php/Main_Page
Package: libbpp-core-dev
......
This diff is collapsed.
......@@ -338,11 +338,12 @@ namespace bpp
*
* @param parameterName The name of the corresponding parameter.
* @param params The attribute map where options may be found.
* @param separator The character used to delimit values.
* @param separator The character used to delimit values (cannot be a space character).
* @param defaultValue The default value to use if the parameter is not found.
* @param suffix A suffix to be applied to the parameter name.
* @param suffixIsOptional Tell if the suffix is absolutely required.
* @param warn Tell if a warning must be sent in case the parameter is not found.
* @throw Exception If a space character is used as separator.
* @return The corresponding value.
*/
template<class T> static std::vector<T> getVectorParameter(
......@@ -354,6 +355,7 @@ namespace bpp
bool suffixIsOptional = true,
int warn = 0)
{
if (separator == ' ') throw Exception("ApplicationTools::getVectorParameter(). Separator cannot be a space character.");
std::string s = getStringParameter(parameterName, params, defaultValue, suffix, suffixIsOptional, warn);
if (TextTools::isEmpty(s)) return std::vector<T>(0);
if (s[0] == '(' && s[s.size() - 1] == ')') {
......
......@@ -564,7 +564,7 @@ Graph::EdgeId GlobalGraph::getAnyEdge(Graph::NodeId nodeA, Graph::NodeId nodeB)
// trying in the given order A->B
return getEdge(nodeA, nodeB);
}
catch (Exception e)
catch (Exception& e)
{
// didn’t work, hence trying in the opposite order B->A
return getEdge(nodeB, nodeA);
......
......@@ -272,7 +272,7 @@ namespace bpp
{
std::vector<Graph::NodeId> incomers = getIncomingNeighbors(node);
if (incomers.size() > 1)
throw Exception("TreeGraphImpl<GraphImpl>::getFather: more than one father for Node " + TextTools::toString(node) + " : " + VectorTools::paste(incomers, ",") + ". Should never happen since validity has been controled. Please report this bug.");
throw Exception("TreeGraphImpl<GraphImpl>::getFather: more than one father for Node " + TextTools::toString(node) + " : " + VectorTools::paste(incomers, ",") + ". Should never happen since validity has been controlled. Please report this bug.");
if (incomers.size() == 0)
throw Exception("TreeGraphImpl<GraphImpl>::getFather: node " + TextTools::toString(node) + " has no father.");
return *incomers.begin();
......
......@@ -178,8 +178,8 @@ void AbstractParameterAliasable::aliasParameters(map<string, string>& unparsedPa
size_t unp_s = unparsedParams.size();
while (unp_s != 0)
{
map<string, string>::iterator it;
for (it = unparsedParams.begin(); it != unparsedParams.end(); it++)
auto it = unparsedParams.begin();
while (it != unparsedParams.end())
{
Parameter* pp = 0;
try
......@@ -199,7 +199,7 @@ void AbstractParameterAliasable::aliasParameters(map<string, string>& unparsedPa
aliasParameters(it->second, it->first);
if (verbose)
ApplicationTools::displayResult("Parameter alias found", it->first + " -> " + it->second + " = " + TextTools::toString(pp->getValue()));
unparsedParams.erase(it);
it = unparsedParams.erase(it);
}
if (unparsedParams.size() == unp_s)
......
......@@ -193,6 +193,8 @@ class AbstractParametrizable:
*/
Parameter& getParameter_(const std::string& name)
{
if (!hasParameter(name))
throw ParameterNotFoundException("AbstractParametrizable::getParameter_().", prefix_ + name);
return parameters_.getParameter(prefix_ + name);
}
......
......@@ -157,7 +157,7 @@ std::shared_ptr<Operator> ComputationTree::readFormula_(const std::string& formu
double v = TextTools::toDouble(formula);
here = shared_ptr<Operator>(new ConstantOperator(v));
}
catch (Exception e)
catch (Exception& e)
{
if (formula[0]=='-')
{
......
......@@ -99,16 +99,16 @@ double PowellMultiDimensions::doStep()
{
size_t n = getParameters().size();
fp_ = fret_;
unsigned int ibig = 0;
size_t ibig = 0;
double del = 0.0; // Will be the biggest function decrease
Vdouble xit(n);
// In each iteration, loop over all directions in the set.
double fptt;
for(unsigned int i = 0; i < n; i++)
for (size_t i = 0; i < n; i++)
{
// Copy the direction:
for(unsigned int j = 0; j < n; j++)
for (size_t j = 0; j < n; j++)
{
xit[j] = xi_[j][i];
}
......@@ -127,7 +127,7 @@ double PowellMultiDimensions::doStep()
}
ParameterList ptt = getParameters();
for (unsigned int j = 0; j < n; j++)
for (size_t j = 0; j < n; j++)
{
ptt[j].setValue(2.0 * getParameters()[j].getValue() - pt_[j].getValue());
xit[j] = getParameters()[j].getValue() - pt_[j].getValue();
......@@ -144,8 +144,9 @@ double PowellMultiDimensions::doStep()
getParameters_(), xit, getStopCondition()->getTolerance(),
0, getMessageHandler(), getVerbose() > 0 ? getVerbose() - 1 : 0);
fret_ = getFunction()->f(getParameters());
if (fret_ > fp_) throw Exception("DEBUG: PowellMultiDimensions::doStep(). Line minimization failed!");
for (unsigned int j = 0; j < n; j++)
if (fret_ > fp_)
throw Exception("DEBUG: PowellMultiDimensions::doStep(). Line minimization failed!");
for (size_t j = 0; j < n; j++)
{
xi_[j][ibig] = xi_[j][n - 1];
xi_[j][n - 1] = xit[j];
......
......@@ -450,7 +450,7 @@ namespace bpp
size_t nrA = A.getNumberOfRows();
size_t nrB = B.getNumberOfRows();
size_t ncB = B.getNumberOfColumns();
if (ncA > ncB) throw DimensionException("MatrixTools::operator+=(). A and B must have the same number of colums.", ncB, ncA);
if (ncA > ncB) throw DimensionException("MatrixTools::operator+=(). A and B must have the same number of columns.", ncB, ncA);
if (nrA > nrB) throw DimensionException("MatrixTools::operator+=(). A and B must have the same number of rows.", nrB, nrA);
......@@ -478,7 +478,7 @@ namespace bpp
size_t nrA = A.getNumberOfRows();
size_t nrB = B.getNumberOfRows();
size_t ncB = B.getNumberOfColumns();
if (ncA != ncB) throw DimensionException("MatrixTools::operator+(). A and B must have the same number of colums.", ncB, ncA);
if (ncA != ncB) throw DimensionException("MatrixTools::operator+(). A and B must have the same number of columns.", ncB, ncA);
if (nrA != nrB) throw DimensionException("MatrixTools::operator+(). A and B must have the same number of rows.", nrB, nrA);
for (size_t i = 0; i < nrA; i++)
......
......@@ -496,13 +496,11 @@ void ParameterList::matchParameters(const ParameterList& params)
/******************************************************************************/
void ParameterList::deleteParameter(const std::string& name)
{
for (unsigned int i = 0; i < size(); i++)
for (auto it = parameters_.begin(); it != parameters_.end(); ++it)
{
Parameter* p = parameters_[i].get();
if (p->getName() == name)
if ((*it)->getName() == name)
{
parameters_.erase(parameters_.begin() + i);
it = parameters_.erase(it);
return;
}
}
......@@ -512,11 +510,11 @@ void ParameterList::deleteParameter(const std::string& name)
/******************************************************************************/
void ParameterList::deleteParameters(const std::vector<std::string>& names, bool mustExist)
{
for (unsigned int i = 0; i < names.size(); i++)
for (auto it = names.begin(); it != names.end(); ++it)
{
try
{
deleteParameter(names[i]);
deleteParameter(*it);
}
catch (ParameterNotFoundException& e)
{
......@@ -532,8 +530,6 @@ void ParameterList::deleteParameters(const std::vector<std::string>& names, bool
void ParameterList::deleteParameter(size_t index)
{
if (index >= size()) throw IndexOutOfBoundsException("ParameterList::deleteParameter.", index, 0, size());
// Parameter* p = parameters_[index].get();
// delete p;
parameters_.erase(parameters_.begin() + static_cast<ptrdiff_t>(index));
}
......
......@@ -517,10 +517,10 @@ double RandomTools::qBeta(double prob, double alpha, double beta)
volatile double xinbta;
if (alpha <= 0. || beta < 0.)
throw ("RandomTools::qBeta wih non positive parameters");
throw ("RandomTools::qBeta with non positive parameters");
if (prob < 0. || prob > 1.)
throw ("RandomTools::qBeta wih bad probability");
throw ("RandomTools::qBeta with bad probability");
/* initialize */
logbeta = lnBeta(alpha, beta);
......
......@@ -44,6 +44,7 @@
#include <fstream>
#include <algorithm>
using namespace std;
#include "AttributesTools.h"
......@@ -53,6 +54,8 @@ using namespace std;
using namespace bpp;
std::vector<std::string> AttributesTools::vParam_;
/******************************************************************************/
std::vector<std::string> AttributesTools::getVector(int argc, char* argv[])
......@@ -119,13 +122,16 @@ void AttributesTools::getAttributesMap(
{
string name = string(arg.begin(), arg.begin() + static_cast<ptrdiff_t>(limit));
string value = string(arg.begin() + static_cast<ptrdiff_t>(limit + delimiter.size()), arg.end());
// if ((name == "param") || (name == "params"))
// {
// //Recursive inclusion:
// getAttributesMapFromFile(value, am, delimiter);
// }
// else
am[name] = value;
if ((name == "param") || (name == "params"))
{
if (std::find(vParam_.begin(),vParam_.end(),value)!=vParam_.end())
throw Exception("Param name " + value + " already seen.");
//Recursive inclusion:
getAttributesMapFromFile(value, am, delimiter);
vParam_.push_back(value);
}
else am[name] = value;
}
}
}
......@@ -162,7 +168,6 @@ void AttributesTools::actualizeAttributesMap(
{
for (map<string, string>::const_iterator i = atts.begin(); i != atts.end(); i++)
{
if ((i->first != "param") && (i->first != "params"))
attMap[i->first] = i->second;
}
}
......@@ -248,14 +253,18 @@ std::map<std::string, std::string> AttributesTools::parseOptions(int args, char*
// Look for a specified file with parameters:
map<string, string> params;
std::map<std::string, std::string>::iterator it;
if (cmdParams.find("param") != cmdParams.end() || cmdParams.find("params") != cmdParams.end())
{
string file;
if (cmdParams.find("param") != cmdParams.end())
{
string file = cmdParams["param"];
file=cmdParams["param"];
if (std::find(vParam_.begin(),vParam_.end(),file)!=vParam_.end())
throw Exception("Param name " + file + " already seen.");
if (!FileTools::fileExists(file))
{
throw Exception("AttributesTools::parseOptions(). Parameter file not found.");
throw Exception("AttributesTools::parseOptions(). Parameter file not found.: " + file);
}
else
{
......@@ -263,53 +272,34 @@ std::map<std::string, std::string> AttributesTools::parseOptions(int args, char*
// Actualize attributes with ones passed to command line:
actualizeAttributesMap(params, cmdParams);
}
vParam_.push_back(file);
}
else
if (cmdParams.find("params") != cmdParams.end())
{
params = cmdParams;
}
// Resolve variables:
resolveVariables(params);
std::vector<string> mapfile;
std::vector<string>::iterator imapfile;
string file;
file=cmdParams["params"];
if (std::find(vParam_.begin(),vParam_.end(),file)!=vParam_.end())
throw Exception("Param name " + file + " already seen.");
while (true)
{
it = params.find("param");
if (it != params.end())
{
file = it->second;
if (std::find(mapfile.begin(), mapfile.end(), file) == mapfile.end())
if (!FileTools::fileExists(file))
{
params.erase(it);
mapfile.push_back(file);
getAttributesMapFromFile(file, params, "=");
resolveVariables(params);
continue;
throw Exception("AttributesTools::parseOptions(). Parameter file not found.: " + file);
}
else
throw Exception("parsing error : Already used file " + file);
}
it = params.find("params");
if (it != params.end())
{
file = it->second;
if (find(mapfile.begin(), mapfile.end(), file) == mapfile.end())
{
params.erase(it);
mapfile.push_back(file);
getAttributesMapFromFile(file, params, "=");
resolveVariables(params);
continue;
params = getAttributesMapFromFile(file, "=");
// Actualize attributes with ones passed to command line:
actualizeAttributesMap(params, cmdParams);
}
else
throw Exception("parsing error : Already used file " + file);
vParam_.push_back(file);
}
break;
}
else
{
params = cmdParams;
}
// Resolve variables:
resolveVariables(params);
return params;
}
......
......@@ -126,6 +126,14 @@ namespace bpp
*/
class AttributesTools
{
private:
/*
* vector of param names already seen, to avoid infinite recursion
*
*/
static std::vector<std::string> vParam_;
public:
AttributesTools() {}
virtual ~AttributesTools() {}
......