X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=tabverges.py;h=12f4a61e187ab6a92d3b1080b9b081bcf2a217e4;hp=b9e4ee39d2cf453b1b8c4d97bb451872ca9fc0f1;hb=c1ef58be7c81fc8f7b6dbc35c306cce25857ec2d;hpb=22cd27b2bbe9ab1ffa7ef06fa764b5147ae17dad diff --git a/tabverges.py b/tabverges.py index b9e4ee3..12f4a61 100644 --- a/tabverges.py +++ b/tabverges.py @@ -10,45 +10,85 @@ import wx import os import sys import tempfile -from chemins import ffr,FFF +from chemins import ffr,FFF, ConstructPathOut import wx.lib.sized_controls as sc from time import sleep -from functions import exec_rcode, check_Rresult -from dialog import ChiDialog +from functions import exec_rcode, check_Rresult, progressbar +from PrintRScript import ProtoScript +from analysematrix import AnalyseMatrix +from dialog import ProtoDial -class Verges : - def __init__(self,parent): +class Prototypical(AnalyseMatrix) : + def __init__(self, parent, parametres): self.parent = parent self.tableau = self.parent.tableau - chioption = { 'valobs' : True, - 'valtheo' : True, - 'resi' : False, - 'contrib' : True, - 'pourcent' : False, - 'pourcentl' : True, - 'pourcentc' : True, - 'graph' : True, - } - self.dlg = ChiDialog(parent, -1, u"Chi2", chioption, size=(400, 350), - style = wx.DEFAULT_DIALOG_STYLE - ) - self.dlg.CenterOnParent() - self.check_val() + self.parametres = parametres + self.parametres['filename'] = parent.tableau.parametre['filename'] + self.parametres['pathout'] = ConstructPathOut(parent.tableau.parametre['filename'], 'proto') + self.parametres['type'] = 'proto' + dlg = progressbar(self.parent, 2) + self.colnames = self.tableau.get_colnames() + AnalyseMatrix.__init__(self, parent, parent.tableau, self.parametres, dlg = dlg) + + def doanalyse(self) : + res = self.check_val() + return res def check_val(self) : - self.val = self.dlg.ShowModal() + self.dial = ProtoDial(self.ira, self.colnames) + self.dial.CenterOnParent() + + self.val = self.dial.ShowModal() if self.val==wx.ID_OK : - self.ColSel1 = self.dlg.list_box_1.GetSelections() - self.ColSel2 = self.dlg.list_box_2.GetSelections() + self.ColSel1 = self.dial.variables.GetSelections() + self.ColSel2 = self.dial.rangs.GetSelections() + if len(self.ColSel1) != len(self.ColSel2) : print 'pas meme taille' self.check_val() else : - self.dotable() + if self.dial.choix_freq.GetSelection() == 0 : + self.parametres['limfreq'] = 'NULL' + else : + self.parametres['limfreq'] = self.dial.freqlim.GetValue() + if self.dial.choix_rang.GetSelection() == 0 : + self.parametres['limrang'] = 'NULL' + else : + self.parametres['limrang'] = self.dial.ranglim.GetValue() + self.parametres['freqmin'] = int(self.dial.m_textCtrl4.GetValue()) + table_assoc, table_rank = self.dotable() + self.makedatas(table_assoc, table_rank) + self.DoR() + else : + return 'stop' def dotable(self) : table_assoc = self.tableau.select_col(self.ColSel1) table_rank = self.tableau.select_col(self.ColSel2) - + return table_assoc, table_rank + + def makedatas(self, table_assoc, table_rank) : + words = {} + for i in range(0, len(table_assoc)) : + for j, word in enumerate(table_assoc[i]) : + if word in words : + words[word][0] += 1 + if table_rank[i][j] != '' : + words[word][1].append(int(table_rank[i][j])) + else : + if table_rank[i][j] != '' : + words[word] = [1, [int(table_rank[i][j])]] + else : + words[word] = [1, []] + res = [[word, words[word][0], float(sum(words[word][1])) / len(words[word][1])] for word in words if len(words[word][1]) != 0 and words[word][0] >= self.parametres['freqmin']] + with open(self.pathout['table.csv'], 'w') as f : + f.write('\n'.join(['\t'.join(['"' + val[0] +'"', `val[1]`, `val[2]`]) for val in res])) + self.parent.tableau.parametres = self.parent.tableau.parametre + self.parent.tableau.save_tableau(self.pathout['analyse.db']) + + def DoR(self) : + script = ProtoScript(self) + script.make_script() + self.doR(script.scriptout)