comparison python/utils.py @ 978:184f1dd307f9

corrected print and exception statements for Python 3
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 08 Feb 2018 05:53:50 -0500
parents 4f3f88a27dae
children 94bee7b604eb
comparison
equal deleted inserted replaced
977:9c27a0315c4d 978:184f1dd307f9
419 from storage import openCheck 419 from storage import openCheck
420 out = openCheck(filenamePrefix+'-{}-{}.tex'.format(dependentVariable, independentVariable), 'w') 420 out = openCheck(filenamePrefix+'-{}-{}.tex'.format(dependentVariable, independentVariable), 'w')
421 for x in independentVariableValues: 421 for x in independentVariableValues:
422 print('Shapiro-Wilk normality test for {} when {}={}: {} obs'.format(dependentVariable,independentVariable, x, len(tmp.loc[tmp[independentVariable] == x, dependentVariable]))) 422 print('Shapiro-Wilk normality test for {} when {}={}: {} obs'.format(dependentVariable,independentVariable, x, len(tmp.loc[tmp[independentVariable] == x, dependentVariable])))
423 if len(tmp.loc[tmp[independentVariable] == x, dependentVariable]) >= 3: 423 if len(tmp.loc[tmp[independentVariable] == x, dependentVariable]) >= 3:
424 print shapiro(tmp.loc[tmp[independentVariable] == x, dependentVariable]) 424 print(shapiro(tmp.loc[tmp[independentVariable] == x, dependentVariable]))
425 if plotFigure: 425 if plotFigure:
426 plt.figure() 426 plt.figure()
427 plt.boxplot([tmp.loc[tmp[independentVariable] == x, dependentVariable] for x in independentVariableValues]) 427 plt.boxplot([tmp.loc[tmp[independentVariable] == x, dependentVariable] for x in independentVariableValues])
428 #q25, q75 = tmp[dependentVariable].quantile([.25, .75]) 428 #q25, q75 = tmp[dependentVariable].quantile([.25, .75])
429 #plt.ylim(ymax = q75+1.5*(q75-q25)) 429 #plt.ylim(ymax = q75+1.5*(q75-q25))
440 +'\\captionof{table}{'+(kwCaption.format(dependentVariable, independentVariable, *testResult))+'}\n' 440 +'\\captionof{table}{'+(kwCaption.format(dependentVariable, independentVariable, *testResult))+'}\n'
441 +table.to_latex(float_format = lambda x: '{:.3f}'.format(x)).encode('ascii')+'\n' 441 +table.to_latex(float_format = lambda x: '{:.3f}'.format(x)).encode('ascii')+'\n'
442 +'\\end{minipage}\n' 442 +'\\end{minipage}\n'
443 +'\\ \\vspace{0.5cm}\n') 443 +'\\ \\vspace{0.5cm}\n')
444 else: 444 else:
445 print table 445 print(table)
446 return testResult 446 return testResult
447 else: 447 else:
448 return None 448 return None
449 449
450 def prepareRegression(data, dependentVariable, independentVariables, maxCorrelationThreshold, correlations, maxCorrelationP, correlationFunc, stdoutText = ['Removing {} (constant: {})', 'Removing {} (correlation {} with {})', 'Removing {} (no correlation: {}, p={})'], saveFiles = False, filenamePrefix = None, latexHeader = '', latexTable = None, latexFooter=''): 450 def prepareRegression(data, dependentVariable, independentVariables, maxCorrelationThreshold, correlations, maxCorrelationP, correlationFunc, stdoutText = ['Removing {} (constant: {})', 'Removing {} (correlation {} with {})', 'Removing {} (no correlation: {}, p={})'], saveFiles = False, filenamePrefix = None, latexHeader = '', latexTable = None, latexFooter=''):