[agrum] updating guideline and formatting

parent 254cc0f8
Pipeline #13912030 passed with stages
in 43 minutes 21 seconds
......@@ -83,7 +83,7 @@ def initParams():
cfg.default['noSaveParams'] = False
cfg.default['correction'] = False
cfg.actions = set("lib test install doc clean show uninstall package autoindent guideline wheel".split())
cfg.actions = set("lib test install doc clean show uninstall package guideline wheel".split())
cfg.modes = set("debug release".split())
cfg.targets = set("aGrUM pyAgrum jAgrum".split())
cfg.moduleLabels = parseModulesTxt()
......@@ -91,7 +91,7 @@ def initParams():
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.specialActions = ["show", "clean", "guideline"]
cfg.swapOptions = {
"verbose": {
True : "verbose",
......
#!/usr/bin/python
# -*- coding : utf-8 -*-
#***************************************************************************
#* Copyright(C) 2015 by Pierre - Henri WUILLEMIN *
#* {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.*
#***************************************************************************
# ***************************************************************************
# * Copyright(C) 2015 by Pierre - Henri WUILLEMIN *
# * {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.*
# ***************************************************************************
from __future__ import print_function
import os.path
from subprocess import call
from .utils import trace, notif, critic, warn, error, recglob, srcAgrum
from .configuration import cfg
def guideline(current,modif=False):
def guideline(current, modif=False):
if modif:
notif("[aGrUM guideline (with correction)]")
else:
notif("[aGrUM guideline]")
nbrError=0
nbrError = 0
notif(" (1) [*.cpp] file for every [*.h] file ")
nbrError += _checkCppFileExists(current, modif)
notif(" (2) check for GPL license")
nbrError += _checkForGPLlicense(current, modif)
notif(" (3) check for format")
nbrError += _checkForFormat(current, modif)
return nbrError
notif(" # [*.cpp] file for every [*.h] file ")
nbrError+=_checkCppFileExists(current,modif)
notif(" # check for GPL license")
nbrError+=_checkForGPLlicense(current,modif)
def _checkForFormat(current, modif):
nbrError = 0
if cfg.clangformat is None:
error("No [clang-format] tool has been found.")
with open(os.devnull, "w") as blackhole:
for src in srcAgrum():
exceptions = ['/external/', 'Parser', 'Scanner']
if any(subs in src for subs in exceptions):
continue
line = cfg.clangformat + " " + src + " | cmp " + src + " -"
if call(line, shell=True, stderr=blackhole, stdout=blackhole)==1:
nbrError += 1
if modif:
line = cfg.clangformat + " -i " + src
call(line, shell=True)
notif(" [" + src + "] not correctly formatted : [changed]")
else:
notif(" [" + src + "] not correctly formatted")
return nbrError
def __addGPLatTop(filename):
with open(filename,"r") as origine:
code=origine.read()
with open(filename,"w") as dest:
with open(filename, "r") as origine:
code = origine.read()
with open(filename, "w") as dest:
dest.write(_template_license)
dest.write(code)
def _checkForGPLlicense(current,modif):
nbrError=0
exceptions=['/mvsc/','/external/','/cxxtest/','Parser','Scanner']
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):
continue
fragment=""
nbr=0
with open(agrumfile,"r") as f:
fragment = ""
nbr = 0
with open(agrumfile, "r") as f:
for line in f:
if nbr==4:
continue
fragment+=line
nbr+=1
if nbr == 4:
continue
fragment += line
nbr += 1
if "Copyright (C) 20" not in fragment:
nbrError+=1
nbrError += 1
if modif:
__addGPLatTop(agrumfile)
notif(" ["+agrumfile+"] has no copyright in its first lines : [changed]")
notif(" [" + agrumfile + "] has no copyright in its first lines : [changed]")
else:
notif(" ["+agrumfile+"] has no copyright in its first lines")
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
subinclude = header[4:] # remove the /src
cppfile = header[:-1] + "cpp" # name
with open(cppfile, 'w') as out:
out.write(_template_cpp.replace("{include_file}", subinclude))
def _checkCppFileExists(current,modif):
nbrError=0
exceptions=['/mvsc/','/signal/','/external/','multidim/patterns/','agrum.h','inline.h']
def _checkCppFileExists(current, modif):
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
......@@ -97,18 +126,19 @@ def _checkCppFileExists(current,modif):
continue
if subs.endswith("_inl."):
continue
cppfile=subs+"cpp"
cppfile = subs + "cpp"
if not os.path.isfile(cppfile):
nbrError+=1
nbrError += 1
if modif:
__addCppFileForHeader(header, cppfile)
error("No cpp file for ["+header+"h] : [added]")
error("No cpp file for [" + header + "h] : [added]")
else:
error("No cpp file for ["+header+"h]")
error("No cpp file for [" + header + "h]")
return nbrError
_template_license="""
_template_license = """
/**************************************************************************
* Copyright (C) 2017 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
* {prenom.nom}_at_lip6.fr *
......@@ -131,7 +161,7 @@ _template_license="""
"""
_template_cpp= _template_license+"""
_template_cpp = _template_license + """
/**
* @file
......
......@@ -45,7 +45,7 @@ def isSpecialAction(current):
if current["action"] == 'doc' and current["target"] == 'pyAgrum':
return True
return current["action"] in set(["clean", "show", "autoindent"])
return current["action"] in set(cfg.specialActions)
def specialActions(current):
......@@ -63,17 +63,13 @@ def specialActions(current):
print("")
return True
if current["action"] == "autoindent":
# trace(current,"Special action [autoindent]")
autoindent(current)
print("")
return True
if current["action"] == "guideline":
# trace(current,"Special action [guideline]")
nbrError=guideline(current,current['correction'])
if nbrError>0:
critic("Guideline error(s) found.",None,nbrError)
critic(("{} Guideline error(s) found.\n"+
"Please consider using [act guideline --correction] in order to correct those errors.").format(nbrError),
None,nbrError)
else:
notif("No guideline error found.")
......@@ -126,14 +122,3 @@ def showAct2Config(current):
for k in cfg.non_persistent:
aff(k)
def autoindent(current):
if cfg.clangformat == None:
critic("No clang-format tool has been found.")
for src in srcAgrum():
line = cfg.clangformat + " -i " + src
notif("autoindent [{0}]".format(src))
trace(current, line)
if not current["dry_run"]:
call(line, shell=True)
......@@ -26,4 +26,3 @@
*/
#include <agrum/BN/IBayesNetFactory.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/BN/inference/tools/relevantPotentialsFinderType.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/CN/LpInterface.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/CN/LrsWrapper.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/IfmdpFactory.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/SDyna/Strategies/IDecisionStrategy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/SDyna/Strategies/ILearningStrategy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/SDyna/Strategies/IPlanningStrategy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/learning/core/templateStrategy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/learning/core/testPolicy/Chi2TestPolicy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/learning/core/testPolicy/GTestPolicy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/learning/core/testPolicy/ITestPolicy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/learning/core/testPolicy/leastSquareTestPolicy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/learning/datastructure/IVisitableGraphLearner.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/planning/IOperatorStrategy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/planning/actionSet.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/planning/mddOperatorStrategy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/planning/structuredPlaner.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/FMDP/planning/treeOperatorStrategy.h>
......@@ -18,6 +18,3 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
......@@ -26,4 +26,3 @@
*/
#include <agrum/PRM/IPRMFactory.h>
......@@ -24,23 +24,23 @@
/// gum is the global namespace for all aGrUM entities
namespace gum {
/// Internal namespace for aGrUM signaler/listener components
namespace __sig__ {}
/// Internal namespace for aGrUM signaler/listener components
namespace __sig__ {}
/// Internal namespace for aGrUM debugging tools
namespace __debug__ {}
/// Internal namespace for aGrUM debugging tools
namespace __debug__ {}
/// Aggregators are functional description of CPTs
namespace aggregator {}
/// Aggregators are functional description of CPTs
namespace aggregator {}
/// Internal namespace for complexity tools (quite empty for now)
namespace complexity {}
/// Internal namespace for complexity tools (quite empty for now)
namespace complexity {}
/// namespace for all credal networks entities
namespace credal {
/// namespace for all credal networks entities
namespace credal {
/// namespace for constraint-based description of credal sets
namespace lp {}
/// namespace for constraint-based description of credal sets
namespace lp {}
}
/// namespace for all probabilistic relational models entities
......
......@@ -26,4 +26,3 @@
*/
#include <agrum/core/approximations/approximationPolicy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/core/functors.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/core/math/math.h>
......@@ -250,7 +250,7 @@ int64_t
redund_main(int argc,
char* argv[]); /* redund driver, argv[1]=input file, [2]=output file */
lrs_dat*
lrs_alloc_dat(const char* name); /* allocate for lrs_dat structure "name" */
lrs_alloc_dat(const char* name); /* allocate for lrs_dat structure "name" */
lrs_dic* lrs_alloc_dic(lrs_dat* Q); /* allocate for lrs_dic structure corr. to Q */
int64_t lrs_estimate(lrs_dic* P,
lrs_dat* Q); /* get estimates only and returns est number of
......
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/schedule.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduleCliqueStoreMultiDim.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduleCombination.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduleCombinationBasic.h>
......@@ -76,8 +76,8 @@
#include <agrum/agrum.h>
#include <agrum/core/sequence.h>
#include <agrum/core/priorityQueue.h>
#include <agrum/core/sequence.h>
#include <agrum/graphicalModels/inference/scheduleCombination.h>
#include <agrum/variables/discreteVariable.h>
......
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduleCombine.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduleDeleteMultiDim.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduleMultiDim.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduleOperation.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduleProject.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduleProjection.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduleProjectionBasic.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduleSeparatorStoreMultiDim.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/scheduler.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/graphicalModels/inference/schedulerBasic.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/aprioris/apriori.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/aprioris/aprioriDirichletFromDatabase.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/aprioris/aprioriNoApriori.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/aprioris/aprioriSmoothing.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/constraints/structuralConstraint.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/constraints/structuralConstraintPattern4UndiGraphHeader.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/constraints/structuralConstraintPattern4UndiGraphInline.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/constraints/structuralConstraintPattern4UndiGraphRootInline.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/constraints/structuralConstraintPatternHeader.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/constraints/structuralConstraintPatternInline.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/constraints/structuralConstraintPatternRootInline.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/constraints/structuralConstraintSetStatic.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/database/DBCellTranslator.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/database/DBHandler.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/database/DBRowFilter.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/database/DBRowTranslatorSet.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/database/filteredRow.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/database/filteredRowGeneratorSet.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/paramUtils/paramEstimator.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/paramUtils/paramEstimatorML.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/structureUtils/IGraphChangesGenerator4DiGraph.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/structureUtils/IGraphChangesGenerator4UndiGraph.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/structureUtils/graphChangesGenerator4DiGraph.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/structureUtils/graphChangesGenerator4K2.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/structureUtils/graphChangesGenerator4UndiGraph.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/structureUtils/graphChangesGeneratorOnSubDiGraph.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/learning/structureUtils/graphChangesSelector4DiGraph.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/multidim/FunctionGraphUtilities/terminalNodePolicies/ExactTerminalNodePolicy.h>
......@@ -26,4 +26,3 @@
*/
#include <agrum/multidim/FunctionGraphUtilities/terminalNodePolicies/ITerminalNodePolicy.h>