From 1c71fffd3d0c10762eaff70752c44d80a3a49166 Mon Sep 17 00:00:00 2001 From: Frank Winklmeier <fwinkl@cern> Date: Thu, 26 Nov 2020 11:27:04 +0100 Subject: [PATCH] MVAUtils: enable flake8 and fix code --- Reconstruction/MVAUtils/CMakeLists.txt | 2 +- .../MVAUtils/util/convertLGBMToRootTree.py | 12 ++++++------ .../MVAUtils/util/convertXGBoostToRootTree.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Reconstruction/MVAUtils/CMakeLists.txt b/Reconstruction/MVAUtils/CMakeLists.txt index c93e0b83e7e..4c99e1545ab 100644 --- a/Reconstruction/MVAUtils/CMakeLists.txt +++ b/Reconstruction/MVAUtils/CMakeLists.txt @@ -18,7 +18,7 @@ atlas_add_dictionary( MVAUtilsDict MVAUtils/selection.xml LINK_LIBRARIES MVAUtils) -atlas_install_python_modules( util/*.py ) +atlas_install_python_modules( util/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) atlas_add_executable( convertXmlToRootTree util/convertXmlToRootTree.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} MVAUtils diff --git a/Reconstruction/MVAUtils/util/convertLGBMToRootTree.py b/Reconstruction/MVAUtils/util/convertLGBMToRootTree.py index 962a363f69f..fc663323b69 100755 --- a/Reconstruction/MVAUtils/util/convertLGBMToRootTree.py +++ b/Reconstruction/MVAUtils/util/convertLGBMToRootTree.py @@ -381,8 +381,8 @@ def test_multiclass(booster, mva_utils, ntests=10000, test_file=None): zip(data_input, results_lgbm, results_MVAUtils), 1): if not np.allclose(output_lgbm, output_MVAUtils): stop_event_loop = True - logging.info("output are different on input %d/%d:\n" % - (ievent, len(data_input))) + logging.info("output are different on input %d/%d:\n", + ievent, len(data_input)) for ivar, input_value in enumerate(input_values): logging.info("var %d: %.15f", ivar, input_value) logging.info("=" * 50) @@ -405,13 +405,13 @@ def test_multiclass(booster, mva_utils, ntests=10000, test_file=None): if not np.allclose(output_tree_mva_utils, output_tree_lgbm[0]): stop_tree_loop = True logging.info( - "first tree/class with different answer (%d)" % itree) + "first tree/class with different answer (%d)", itree) for isubtree, (ol, om) in enumerate( zip(output_tree_lgbm[0], output_tree_mva_utils)): if not np.allclose(ol, om): - logging.info("different in position %d" % isubtree) - logging.info("lgbm: %f" % ol) - logging.info("mvautils: %f" % om) + logging.info("different in position %d", isubtree) + logging.info("lgbm: %f", ol) + logging.info("mvautils: %f", om) logging.info("=" * 50) logging.info("tree %d (itree) * %d (nclasses)" "+ %d (isubtree) = %d", diff --git a/Reconstruction/MVAUtils/util/convertXGBoostToRootTree.py b/Reconstruction/MVAUtils/util/convertXGBoostToRootTree.py index 96b7bca5e5e..406de522a22 100755 --- a/Reconstruction/MVAUtils/util/convertXGBoostToRootTree.py +++ b/Reconstruction/MVAUtils/util/convertXGBoostToRootTree.py @@ -150,7 +150,7 @@ def test(model_file, tree_file, objective, tree_name='xgboost', ntests=10000, te tree = f.Get(tree_name) try: _ = ROOT.MVAUtils.BDT - except: + except Exception: print("cannot import MVAUtils") return None -- GitLab