[aGrUM] finalizing guideline

parent 1e8b305d
Pipeline #13889690 passed with stages
in 35 minutes 26 seconds
......@@ -81,6 +81,7 @@ def initParams():
cfg.default['mvsc32'] = False
cfg.default['build'] = "all"
cfg.default['noSaveParams'] = False
cfg.default['correction'] = False
cfg.actions = set("lib test install doc clean show uninstall package autoindent guideline wheel".split())
cfg.modes = set("debug release".split())
......@@ -88,7 +89,7 @@ def initParams():
cfg.moduleLabels = parseModulesTxt()
cfg.modules = set(cfg.moduleLabels)
cfg.non_persistent = ["fixed_seed", "stats", "no_fun", "static_lib", "oneByOne", "dry_run", "coverage","noSaveParams"]
cfg.non_persistent = ["fixed_seed", "stats", "no_fun", "static_lib", "oneByOne", "dry_run", "coverage","noSaveParams","correction"]
cfg.mains = ["action", "targets", "mode"]
cfg.specialActions = ["show", "clean", "autoindent", "guideline"]
cfg.swapOptions = {
......@@ -210,6 +211,11 @@ def configureOptions(current):
action="store_true",
dest="noSaveParams",
default=False)
cfg.parser.add_option("", "--correction",
help="act guideline will change the files instead of only show them",
action="store_true",
dest="correction",
default=False)
def configureColors(no_fun=False):
......
#!/ usr / bin / python
#- * - coding : utf - 8 - * -
#!/usr/bin/python
# -*- coding : utf-8 -*-
#***************************************************************************
#* Copyright(C) 2015 by Pierre - Henri WUILLEMIN *
......@@ -28,12 +28,20 @@ from .utils import trace, notif, critic, warn, error, recglob, srcAgrum
from .configuration import cfg
def guideline(current,modif=True):
notif("[aGrUM guideline]")
def guideline(current,modif=False):
if modif:
notif("[aGrUM guideline (with correction)]")
else:
notif("[aGrUM guideline]")
nbrError=0
notif(" # [*.cpp] file for every [*.h] file ")
_checkCppFileExists(current,modif)
nbrError+=_checkCppFileExists(current,modif)
notif(" # check for GPL license")
_checkForGPLlicense(current,modif)
nbrError+=_checkForGPLlicense(current,modif)
return nbrError
def __addGPLatTop(filename):
with open(filename,"r") as origine:
......@@ -43,6 +51,8 @@ def __addGPLatTop(filename):
dest.write(code)
def _checkForGPLlicense(current,modif):
nbrError=0
exceptions=['/mvsc/','/external/','/cxxtest/','Parser','Scanner']
for agrumfile in srcAgrum():
if any(subs in agrumfile for subs in exceptions):
......@@ -58,12 +68,15 @@ def _checkForGPLlicense(current,modif):
nbr+=1
if "Copyright (C) 20" not in fragment:
nbrError+=1
if modif:
__addGPLatTop(agrumfile)
notif(" ["+agrumfile+"] has no copyright in its first lines : [changed]")
else:
notif(" ["+agrumfile+"] has no copyright in its first lines")
return nbrError
def __addCppFileForHeader(header, cppfile):
subinclude=header[4:] # remove the /src
cppfile=header[:-1]+"cpp" # name
......@@ -72,8 +85,9 @@ def __addCppFileForHeader(header, cppfile):
out.write(_template_cpp.replace("{include_file}", subinclude))
def _checkCppFileExists(current,modif):
exceptions=['/mvsc/','/signal/','/external/','agrum.h','inline.h']
nbrError=0
exceptions=['/mvsc/','/signal/','/external/','multidim/patterns/','agrum.h','inline.h']
for header in recglob("src/agrum", "*.h"):
if any(subs in header for subs in exceptions):
continue
......@@ -85,12 +99,15 @@ def _checkCppFileExists(current,modif):
continue
cppfile=subs+"cpp"
if not os.path.isfile(cppfile):
nbrError+=1
if modif:
__addCppFileForHeader(header, cppfile)
error("No cpp file for ["+header+"h] : [added]")
else:
error("No cpp file for ["+header+"h]")
return nbrError
_template_license="""
/**************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
......
......@@ -70,8 +70,13 @@ def specialActions(current):
return True
if current["action"] == "guideline":
# trace(current,"Special action [autoindent]")
guideline(current)
# trace(current,"Special action [guideline]")
nbrError=guideline(current,current['correction'])
if nbrError>0:
critic("Guideline error(s) found.",None,nbrError)
else:
notif("No guideline error found.")
print("")
return True
......@@ -79,12 +84,12 @@ def specialActions(current):
wheel(current)
return True
if current["oneByOne"] == True:
if current["oneByOne"]:
trace(current, "Special action [oneByOne]")
checkAgrumMemoryLeaks(current)
return True
if current["stats"] == True:
if current["stats"]:
profileAgrum(current)
return True
......
......@@ -558,7 +558,7 @@ namespace gum {
/// @{
/**
* @brief Operator ++.
* @brief Operator increment.
*
* Note that this operator never throws an exception when it reaches the
* end of the possible values of the tuple of variables of the
......@@ -580,7 +580,7 @@ namespace gum {
void inc();
/**
* @brief Operator --.
* @brief Operator decrement
*
* Note that this operator never throws an exception when it reaches the
* end of the possible values of the tuple of variables of the
......@@ -602,7 +602,7 @@ namespace gum {
void dec();
/**
* @brief Operator ++ for the variables in i.
* @brief Operator increment for the variables in i.
*
* Note that, if the Instantiation is related to a MultiDimAdressable, then
* the corresponding value in the latter is updated.
......@@ -624,7 +624,7 @@ namespace gum {
void incIn(const Instantiation& i);
/**
* @brief Operator -- for the variables in i.
* @brief Operator decrement for the variables in i.
*
* Note that, if the Instantiation is related to a MultiDimAdressable, then
* the corresponding value in the latter is updated.
......@@ -646,7 +646,7 @@ namespace gum {
void decIn(const Instantiation& i);
/**
* @brief Operator ++ for the variables not in i.
* @brief Operator increment for the variables not in i.
*
* Note that, if the Instantiation is related to a MultiDimAdressable, then
* the corresponding value in the latter is updated.
......@@ -668,7 +668,7 @@ namespace gum {
void incOut(const Instantiation& i);
/**
* @brief Operator -- for the variables not in i.
* @brief Operator decrement for the variables not in i.
*
* Note that, if the Instantiation is related to a MultiDimAdressable, then
* the corresponding value in the latter is updated. Note also that this
......@@ -689,7 +689,7 @@ namespace gum {
void decOut(const Instantiation& i);
/**
* @brief Operator ++ for vars which are not v.
* @brief Operator increment for vars which are not v.
*
* Note that, if the Instantiation is related to a MultiDimAdressable, then
* the corresponding value in the latter is updated. Note also that this
......@@ -706,7 +706,7 @@ namespace gum {
void incNotVar(const DiscreteVariable& v);
/**
* @brief Operator -- for vars which are not v.
* @brief Operator decrement for vars which are not v.
*
* Note that, if the Instantiation is related to a MultiDimAdressable,
* then the corresponding value in the latter is updated.
......@@ -725,7 +725,7 @@ namespace gum {
void decNotVar(const DiscreteVariable& v);
/**
* @brief Operator ++ for variable v only.
* @brief Operator increment for variable v only.
*
* This function increment only variable v. Trying to increment the last
* possible value results in an overflow (no exception is thrown in this
......@@ -743,7 +743,7 @@ namespace gum {
void incVar(const DiscreteVariable& v);
/**
* @brief Operator -- for variable v only.
* @brief Operator decrement for variable v only.
*
* This function decrement only variable v. Trying to decrement the last
* possible value results in an overflow (no exception is thrown in this
......
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/completeProjectionPattern4BaseName.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/completeProjectionPattern4MultiDimArray.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/completeProjectionPattern4MultiDimImplementation.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/operatorPattern4BaseName.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/operatorPattern4MultiDimArray.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/operatorPattern4MultiDimFunctionGraph.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/operatorPattern4MultiDimImplementation.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/partialInstantiationPattern4BaseName.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/partialInstantiationPattern4MultiDimArray.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/partialInstantiationPattern4MultiDimImplementation.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/projectionPattern4BaseName.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/projectionPattern4MultiDimArray.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/projectionPattern4MultiDimFunctionGraph.h>
/***************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file
* @brief Class to include at least once this header
*
* @author Pierre-Henri WUILLEMIN and Christophe GONZALES
*/
#include <agrum/multidim/patterns/projectionPattern4MultiDimImplementation.h>
......@@ -51,7 +51,7 @@ int
Returns
-------
double
get the current running time in second (double)
get the current running time in second (double)
"
%feature("docstring") gum::IApproximationSchemeConfiguration::epsilon
......@@ -117,12 +117,12 @@ int
Warnings
--------
MissingVariableInDatabase raised if a variable of the BN is not found in the database.
MissingVariableInDatabase raised if a variable of the BN is not found in the database.
"
%feature("docstring") gum::IApproximationSchemeConfiguration::learnDAG
"
learn a structure from a file (must have read the db before)
learn a structure from a file (must have read the db before)
Returns
-------
......@@ -232,7 +232,7 @@ weight : double
Parameters
----------
b : int
size of burn in on number of iteration
size of burn in on number of iteration
"
%feature("docstring") gum::IApproximationSchemeConfiguration::setEpsilon
......@@ -325,7 +325,7 @@ filename : str
Warnings
--------
à compléter
TBD
"
%feature("docstring") gum::IApproximationSchemeConfiguration::useAprioriSmoothing
......@@ -335,7 +335,7 @@ Use the apriori smoothing.
Parameters
----------
weight : double
pass in argument a weight if you wish to assign a weight to the smoothing, else the current weight of the learner will be used.
pass in argument a weight if you wish to assign a weight to the smoothing, else the current weight of the learner will be used.
"
%feature("docstring") gum::IApproximationSchemeConfiguration::useGreedyHillClimbing
......@@ -359,10 +359,10 @@ indicate that we wish to use a local search with tabu list
Parameters
----------
tabu_size : int
tabu_size : int
The size of the tabu list
nb_decrease : int
The max number of changes decreasing the score consecutively that we allow to apply
nb_decrease : int
The max number of changes decreasing the score consecutively that we allow to apply
"