1 from __future__
import print_function
2 from __future__
import absolute_import
3 from builtins
import range
9 from .genericValidation
import ValidationForPresentation, ValidationWithPlotsSummary
10 from .helperFunctions
import recursivesubclasses
11 from .presentationTemplates
import *
12 from .TkAlExceptions
import AllInOneError
17 if not os.path.isdir(path):
18 print(
"Error: Directory "+path+
" not found!")
20 if not path.endswith(
'/'):
22 path = path.replace(
'\\',
'/')
25 self.
plots = [file
for file
in os.listdir(path)
26 if file.endswith(
'.eps')]
32 if cls.__abstractmethods__:
continue 33 if cls.plotsdirname() == os.path.basename(os.path.realpath(self.
path.rstrip(
"/"))):
35 possiblenames.append(cls.plotsdirname())
39 from collections
import OrderedDict
40 classes = [validation.validationclass
for validation
in validations]
42 classes = list(OrderedDict.fromkeys(classes))
47 def __init__(self, pattern=[], width=1, height=1):
60 nplots = sum(len(p)
for p
in plots)
61 length =
int(math.ceil(math.sqrt(nplots)))
63 fullRows =
int(nplots/length)
64 residual = nplots - length*fullRows
67 rowlengths.append(residual)
69 for _
in range(fullRows):
70 rowlengths.append(length)
74 if residual == 0
and len(plots[0])%length != 0
and\
75 len(plots[0])%nrows == 0:
77 self.
pattern.extend(list(
range(i, i+nrows*(length-1)+1, nrows))
78 for i
in range(1, nrows+1))
83 range(residual+1, nplots-length+2, length))
85 self.
width = 1.0/length
96 __metaclass__ = abc.ABCMeta
100 script =
'\n'.
join(_
for _
in self.
pages(validations)
if _)
102 script = subsectionTemplate.replace(
'[title]', self.
title)+script
108 class SubsectionOnePage(SubsectionBase):
111 super(SubsectionOnePage, self).
__init__(title)
118 super(SubsectionFromList, self).
__init__(title)
121 self.
title+
': ' +pagetitle, validations)
123 @abc.abstractproperty
127 class SummarySection(SubsectionBase):
129 super(SummarySection, self).
__init__(
"Summary")
131 return [summaryTemplate.replace(
'[title]', self.
title)
132 .
replace(
'[summary]', validation.validationclass.summaryitemsstring(folder=validation.path, latex=
True))
133 .
replace(
"tabular",
"longtable")
for validation
in validations
134 if issubclass(validation.validationclass, ValidationWithPlotsSummary)]
144 for validation
in validations:
145 valiplots = [validation.path+plot
for plot
in validation.plots
146 if re.search(identifier, plot)]
147 valiplots.sort(key=plotSortKey)
148 plots.append(valiplots)
149 if sum(len(p)
for p
in plots) == 0:
150 print(
'Warning: no plots matching ' + identifier)
158 return writePage([p
for vali
in plots
for p
in vali], title, layout)
168 for row
in layout.pattern:
170 for i
in range(len(row)):
171 plotrow.append(plotTemplate.replace(
'[width]',
str(layout.width)).\
173 replace(
'[path]', plots[row[i]-1]))
174 plotrows.append(
'\n'.
join(plotrow))
175 script =
' \\\\\n'.
join(plotrows)
177 return frameTemplate.replace(
'[plots]', script).
replace(
'[title]', title)
184 if plot.find(
'normchi2') != -1:
186 if plot.find(
'chi2Prob') != -1:
190 import Alignment.OfflineValidation.TkAlAllInOneTool.geometryComparison
def writePageReg(identifier, title, validations, layout=0)
def pages(self, validations)
def replace(string, replacements)
def validationclass(self)
def pages(self, validations)
def validationclasses(validations)
def __init__(self, identifier, title)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def pages(self, validations)
def __init__(self, identifier, title)
def __init__(self, title)
static std::string join(char **cmd)
def pageidentifiers(self)
def __init__(self, pattern=[], width=1, height=1)
def write(self, validations)
def writePage(plots, title, layout)
def recursivesubclasses(cls)
def pages(self, validations)