Skip to content

Commit

Permalink
Remove all * imports and add it to the linters
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwalter2 committed Oct 11, 2024
1 parent 48d8358 commit d3655a6
Show file tree
Hide file tree
Showing 63 changed files with 487 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
- name: run Flake8
run: |
scripts/ci/run_with_singularity.sh flake8 . --select=F401 --exclude=narf,wremnants-data --max-line-length 88
scripts/ci/run_with_singularity.sh flake8 . --select=F401,F403 --exclude=narf,wremnants-data --max-line-length 88
- name: run Black
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unfolding.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: run Flake8
run: |
scripts/ci/run_with_singularity.sh flake8 . --select=F401 --exclude=narf,wremnants-data --max-line-length 88
scripts/ci/run_with_singularity.sh flake8 . --select=F401,F403 --exclude=narf,wremnants-data --max-line-length 88
- name: run Black
run: |
Expand Down
2 changes: 1 addition & 1 deletion narf
4 changes: 2 additions & 2 deletions scripts/analysisTools/plotUtils/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# sys.path.append(os.getcwd() + "/plotUtils/")
from scripts.analysisTools.plotUtils.CMS_lumi import (
CMS_lumi,
h1,
histMCpartialUnc,
histMCpartialUncLegEntry,
setTDRStyle,
Expand Down Expand Up @@ -1978,6 +1977,8 @@ def drawNTH1(
logger.warning("In drawNTH1: #(hists) != #(legEntries). Abort")
quit()

h1 = hists[0]

if rebinFactorX:
if isinstance(rebinFactorX, int):
h1.Rebin(rebinFactorX)
Expand Down Expand Up @@ -2026,7 +2027,6 @@ def drawNTH1(
else:
canvas.SetBottomMargin(bottomMargin)

h1 = hists[0]
hnums = [hists[i] for i in range(1, len(hists))]
frame = h1.Clone("frame")
frame.GetXaxis().SetLabelSize(0.04)
Expand Down
2 changes: 1 addition & 1 deletion scripts/analysisTools/runAllPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"effStat_trackingMinus": ".*effStat.*_tracking.*q0",
"effSyst": ".*effSyst.*",
"prefireL1": ".*refire.*",
"pdfAndAlphaS": ".*pdf(\d+|.*AlphaS)",
"pdfAndAlphaS": r".*pdf(\d+|.*AlphaS)",
}
if useSmoothSF:
diffNuisanceDict["effStat_isoEffData"] = ".*effStat.*_iso_effData"
Expand Down
14 changes: 11 additions & 3 deletions scripts/analysisTools/tests/buildPseudodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *

from scripts.analysisTools.plotUtils.utility import *
import copy

from scripts.analysisTools.plotUtils.utility import (
common_plot_parser,
copyOutputToEos,
createPlotDirAndCopyPhp,
drawCorrelationPlot,
safeGetObject,
safeOpenFile,
scaleTH2byOtherTH2,
)

## Dictionary with info to build pseudodata
# file is the file to read from
Expand Down
12 changes: 10 additions & 2 deletions scripts/analysisTools/tests/checkEffStatUncertaintyIso.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *
import copy

# sys.path.append(os.getcwd() + "/plotUtils/")
# from utility import *
from scripts.analysisTools.plotUtils.utility import *
from scripts.analysisTools.plotUtils.utility import (
common_plot_parser,
copyOutputToEos,
createPlotDirAndCopyPhp,
drawCorrelationPlot,
fillTH2fromTH2part,
safeGetObject,
safeOpenFile,
)

logging.basicConfig(level=logging.INFO)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *

from scripts.analysisTools.plotUtils.utility import *
from scripts.analysisTools.plotUtils.utility import (
adjustSettings_CMS_lumi,
array,
createPlotDirAndCopyPhp,
drawGraphCMS,
safeOpenFile,
xvals,
)

sys.path.append(os.getcwd())

Expand Down
2 changes: 1 addition & 1 deletion scripts/analysisTools/tests/make2DEffStatVariations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import argparse
import copy
import os

## safe batch mode
Expand All @@ -16,7 +17,6 @@

sys.path.append(os.getcwd() + "/plotUtils/")
from utility import (
copy,
createPlotDirAndCopyPhp,
drawCorrelationPlot,
fillTH3binFromTH2,
Expand Down
12 changes: 10 additions & 2 deletions scripts/analysisTools/tests/makeMtEfficiency.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *
import copy

from scripts.analysisTools.plotUtils.utility import *
from scripts.analysisTools.plotUtils.utility import (
adjustSettings_CMS_lumi,
copyOutputToEos,
createPlotDirAndCopyPhp,
drawGraphCMS,
logger,
safeGetObject,
safeOpenFile,
)
from scripts.analysisTools.tests.cropNegativeTemplateBins import cropNegativeContent

if __name__ == "__main__":
Expand Down
11 changes: 9 additions & 2 deletions scripts/analysisTools/tests/plotAltBkgSyst.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

## safe batch mode
import sys
from copy import *

args = sys.argv[:]
sys.argv = ["-b"]
Expand All @@ -12,7 +11,15 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from scripts.analysisTools.plotUtils.utility import *
from scripts.analysisTools.plotUtils.utility import (
copyOutputToEos,
createPlotDirAndCopyPhp,
drawCorrelationPlot,
getTH2fromTH3,
safeGetObject,
safeOpenFile,
setTDRStyle,
)

step = "tracking" # tracking
outdir_original = f"scripts/analysisTools/plots/TESTPLOTS/{step}_altBkg/"
Expand Down
12 changes: 9 additions & 3 deletions scripts/analysisTools/tests/testFakerateIDIP.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *

from scripts.analysisTools.plotUtils.utility import *
import copy

from scripts.analysisTools.plotUtils.utility import (
adjustSettings_CMS_lumi,
createPlotDirAndCopyPhp,
drawCorrelationPlot,
drawGraphCMS,
drawTH1,
)

sys.path.append(os.getcwd())
from scripts.analysisTools.tests.testPlots1D import plotDistribution1D
Expand Down
31 changes: 27 additions & 4 deletions scripts/analysisTools/tests/testFakesVsMt.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,32 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *

from scripts.analysisTools.plotUtils.utility import *
import copy

from scripts.analysisTools.plotUtils.utility import (
CMS_lumi,
addStringToEnd,
adjustSettings_CMS_lumi,
colors_plots_,
common_plot_parser,
copyOutputToEos,
createPlotDirAndCopyPhp,
drawCorrelationPlot,
drawNTH1,
drawSingleTH1,
drawTH1,
getAxisRangeFromUser,
getMinMaxHisto,
getTH2fromTH3,
partial,
polN_root_,
printLine,
safeOpenFile,
safeSystem,
scaleTH2byOtherTH2,
setTDRStyle,
unroll2Dto1D,
)

# sys.path.append(os.getcwd())
from scripts.analysisTools.tests.cropNegativeTemplateBins import cropNegativeContent
Expand Down Expand Up @@ -2078,6 +2101,7 @@ def runStudyVsDphi(fname, charges, mainOutputFolder, args):

for d in datasetsForStudy:
hnarfTMP = histInfo[d].hists[inputHistName]
s = hist.tag.Slicer()
if charge == "inclusive":
# integrate but keep charge axis with 1 single bin
hnarfTMP = hnarfTMP[{"charge": s[:: hist.rebin(2)]}]
Expand All @@ -2086,7 +2110,6 @@ def runStudyVsDphi(fname, charges, mainOutputFolder, args):
hnarf = hnarfTMP.copy()
# rebin eta-pt for actual test with fakes, while collapsing other axes for the simple plots as needed,
# this is only to avoid that THn are too big
s = hist.tag.Slicer()
hnarf = hnarf[{"pt": s[0 : complex(0, 0.001 + args.maxPt)]}]
hnarf = hnarf[{"eta": s[:: hist.rebin(args.rebinEta)]}]
hnarf = hnarf[{"pt": s[:: hist.rebin(args.rebinPt)]}]
Expand Down
11 changes: 9 additions & 2 deletions scripts/analysisTools/tests/testMirroredSF.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *
import copy

from scripts.analysisTools.plotUtils.utility import *
from scripts.analysisTools.plotUtils.utility import (
adjustSettings_CMS_lumi,
createPlotDirAndCopyPhp,
drawCorrelationPlot,
getMinMaxHisto,
safeGetObject,
safeOpenFile,
)

if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand Down
16 changes: 13 additions & 3 deletions scripts/analysisTools/tests/testPlots1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *

from scripts.analysisTools.plotUtils.utility import *
import copy

from scripts.analysisTools.plotUtils.utility import (
adjustSettings_CMS_lumi,
colors_plots_,
common_plot_parser,
copyOutputToEos,
createPlotDirAndCopyPhp,
drawCorrelationPlot,
drawTH1dataMCstack,
h,
legEntries_plots_,
)

sys.path.append(os.getcwd())
from scripts.analysisTools.tests.cropNegativeTemplateBins import cropNegativeContent
Expand Down
13 changes: 10 additions & 3 deletions scripts/analysisTools/tests/testQCDisoMtCorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *

from scripts.analysisTools.plotUtils.utility import *
import copy

from scripts.analysisTools.plotUtils.utility import (
adjustSettings_CMS_lumi,
common_plot_parser,
copyOutputToEos,
createPlotDirAndCopyPhp,
drawCorrelationPlot,
drawGraphCMS,
)

sys.path.append(os.getcwd())
from scripts.analysisTools.tests.testPlots1D import plotDistribution1D
Expand Down
14 changes: 12 additions & 2 deletions scripts/analysisTools/tests/testShapesIsoMtRegions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *
import copy

# sys.path.append(os.getcwd() + "/plotUtils/")
# from utility import *
from scripts.analysisTools.plotUtils.utility import *
from scripts.analysisTools.plotUtils.utility import (
adjustSettings_CMS_lumi,
common_plot_parser,
copyOutputToEos,
createPlotDirAndCopyPhp,
drawCorrelationPlot,
drawSingleTH1,
getTH2fromTH3,
safeOpenFile,
unroll2Dto1D,
)
from scripts.analysisTools.w_mass_13TeV.plotPrefitTemplatesWRemnants import (
plotPrefitHistograms,
)
Expand Down
12 changes: 10 additions & 2 deletions scripts/analysisTools/tnpPlotting/compareMCefficiency.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *
import copy

# sys.path.append(os.getcwd() + "/plotUtils/")
# from utility import *
from scripts.analysisTools.plotUtils.utility import *
from scripts.analysisTools.plotUtils.utility import (
adjustSettings_CMS_lumi,
common_plot_parser,
copyOutputToEos,
createPlotDirAndCopyPhp,
drawCorrelationPlot,
safeGetObject,
safeOpenFile,
)

sys.path.append(os.getcwd())

Expand Down
11 changes: 9 additions & 2 deletions scripts/analysisTools/tnpPlotting/compareMass.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *

# sys.path.append(os.getcwd() + "/plotUtils/")
# from utility import *
from scripts.analysisTools.plotUtils.utility import *
from scripts.analysisTools.plotUtils.utility import (
adjustSettings_CMS_lumi,
common_plot_parser,
copyOutputToEos,
createPlotDirAndCopyPhp,
getMinMaxMultiHisto,
safeGetObject,
safeOpenFile,
)

sys.path.append(os.getcwd())

Expand Down
12 changes: 10 additions & 2 deletions scripts/analysisTools/tnpPlotting/compareTnpMass.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True

from copy import *
import copy

# sys.path.append(os.getcwd() + "/plotUtils/")
# from utility import *
from scripts.analysisTools.plotUtils.utility import *
from scripts.analysisTools.plotUtils.utility import (
adjustSettings_CMS_lumi,
common_plot_parser,
copyOutputToEos,
createPlotDirAndCopyPhp,
getMinMaxMultiHisto,
safeGetObject,
safeOpenFile,
)

sys.path.append(os.getcwd())

Expand Down
Loading

0 comments on commit d3655a6

Please sign in to comment.