-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from lcorcodilos/test_dev
Add initial unit tests with GitHub Action support
- Loading branch information
Showing
11 changed files
with
146 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Python package | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-18.04 | ||
strategy: | ||
matrix: | ||
python-version: [2.7,3.6] #3.6.9, | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Hack to get setup-python to work on act | ||
run: | | ||
if [ ! -f "/etc/lsb-release" ] ; then | ||
echo "DISTRIB_RELEASE=18.04" > /etc/lsb-release | ||
fi | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Setup environment | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install virtualenv | ||
python -m virtualenv timber-env | ||
source timber-env/bin/activate | ||
pip install pytest gdown | ||
gdown https://drive.google.com/uc?id=11dXffndcD3OkHqJ3x2iaVZj5C8HVLeg_ -O root_v6-22-00_build.tgz | ||
tar -xzf root_v6-22-00_build.tgz | ||
- name: Pytest | ||
run: | | ||
source timber-env/bin/activate | ||
source setup.sh | ||
source root_v6.22.00.build/bin/thisroot.sh | ||
export TIMBERPATH=$TIMBERPATH | ||
pytest test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
http://opendata.cern.ch/record/12351 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import ROOT | ||
ROOT.gROOT.SetBatch(True) | ||
from TIMBER.Analyzer import analyzer, CutGroup, VarGroup | ||
from TIMBER.Tools.Common import CompileCpp | ||
|
||
class TestAnalyzer(): | ||
def setup(self): | ||
CompileCpp('TIMBER/Framework/include/common.h') # Compile (via gInterpreter) commonly used c++ code | ||
CompileCpp('examples/example.cc') | ||
self.a = analyzer('examples/GluGluToHToTauTau.root') | ||
self.a.Cut("test_cut1", "Jet_pt.size() > 0") | ||
self.a.Define('lead_vector', 'analyzer::TLvector(Jet_pt[0],Jet_eta[0],Jet_phi[0],Jet_mass[0])') | ||
self.a.Define('sublead_vector','analyzer::TLvector(Jet_pt[1],Jet_eta[1],Jet_phi[1],Jet_mass[1])') | ||
self.a.Define('invariantMass','analyzer::invariantMass(lead_vector,sublead_vector)') | ||
|
||
def test_genEventCount_None(self): | ||
'''Test genEventCount is assigned 0 when branch doesn't exist in test file''' | ||
assert self.a.genEventCount == 0 | ||
|
||
def test_lhaid_None(self): | ||
'''Test lhaid is assigned 0 when branch doesn't exist in test file''' | ||
assert self.a.lhaid == '-1' | ||
|
||
def test_GetTrackedNodeNames(self): | ||
'''Test GetTrackNodeNames method after adding a node''' | ||
assert self.a.GetTrackedNodeNames() == ['test_cut1','lead_vector','sublead_vector','invariantMass'] | ||
|
||
def test_makehist(self): | ||
'''Makes a simple histogram of the defined variable''' | ||
h = self.a.DataFrame.Histo1D(('m_jj','m_{jj}',20,0,200),'invariantMass') | ||
h.Draw("lego") | ||
assert True | ||
|
||
def test_snapshot(self,tmp_path): | ||
'''Makes a simple snapshot''' | ||
out_vars = ['nJet','test_define'] | ||
self.a.GetActiveNode().Snapshot(out_vars,str(tmp_path)+'/ex1_out.root','test_snapshot',lazy=False,openOption='RECREATE') | ||
assert True | ||
|
||
def test_AddCorrection(self): | ||
pass | ||
|
||
def test_MakeWeightCols(self): | ||
pass | ||
|
||
def test_MakeTemplateHistos(self): | ||
pass | ||
|
||
def test_DrawTemplates(self): | ||
pass | ||
|
||
def test_Nminus1(self): | ||
pass | ||
|
||
def test_PrintNodeTree(self): | ||
pass | ||
|
||
def test_Groups(): | ||
a = analyzer('examples/GluGluToHToTauTau.root') | ||
CompileCpp('TIMBER/Framework/include/common.h') # Compile (via gInterpreter) commonly used c++ code | ||
CompileCpp('examples/example.cc') | ||
|
||
test_vg = VarGroup('test_vg') | ||
test_vg.Add('lead_vector', 'analyzer::TLvector(Jet_pt[0],Jet_eta[0],Jet_phi[0],Jet_mass[0])') | ||
test_vg.Add('sublead_vector','analyzer::TLvector(Jet_pt[1],Jet_eta[1],Jet_phi[1],Jet_mass[1])') | ||
test_vg.Add('invariantMass','analyzer::invariantMass(lead_vector,sublead_vector)') | ||
|
||
test_cg = CutGroup('test_cg') | ||
test_cg.Add("test_cut1", "Jet_pt.size() > 0") | ||
|
||
a.Apply([test_vg, test_cg]) | ||
rep = a.DataFrame.Report() | ||
rep.Print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from TIMBER.Tools.Common import * | ||
|
||
class CommonTest(): | ||
def setup(self): | ||
self.a = analyzer('examples/GluGluToHToTauTau.root') | ||
|
||
def test_CutflowHist(self): | ||
pass | ||
|
||
def test_CutflowTxt(self): | ||
pass | ||
|
||
def test_openJSON(self): | ||
pass | ||
|
||
def test_GetHistBinningTuple(self): | ||
pass |