print('###################################')
print('longueur < 0')
malcl<-length(vdelta)
+
if ((it>1)&&(!is.logical(listsub[[it]]))&&(!is.logical(listsub[[it-1]]))){
if (all(listsub[[it]]==listsub[[(it-1)]])){
malcl<-0
#t2<-dtable[dtable[,'cl']==clnb+1,][,-ncol(dtable)]
t1<-dtable[which(cl[,1]==clnb),]#[,-ncol(dtable)]
t2<-dtable[which(cl[,1]==clnb+1),]#[,-ncol(dtable)]
- if (class(t1)=='numeric') {
+ if (inherits(t1, "numeric")) {
sc1 <- as.vector(t1)
nrowt1 <- 1
} else {
sc1 <- colSums(t1)
nrowt1 <- nrow(t1)
}
- if (class(t2)=='numeric') {
+ if (inherits(t2, "numeric")) {
sc2 <- as.vector(t2)
nrowt2 <- 1
} else {
chitable[2,1]<-poids2[j]-chitable[1,1]
chitable[2,2]<-nrow(classeuce1)-poids2[j]-chitable[1,2]
chitest<-chisq.test(chitable,correct=FALSE)
- if ((chitable[1,1]-chitest$expected)<0) {
+ if ((chitable[1,1]-chitest$expected[1,1])<0) {
chicroise[i,j]<--round(chitest$statistic,digits=7)
} else {
chicroise[i,j]<-round(chitest$statistic,digits=7)
grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
self.spin1 = wx.SpinCtrl(self, -1, '',size = wx.DefaultSize, min=1, max=500)
grid_sizer.Add(self.spin1, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
- sizer.Add(grid_sizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
+ sizer.Add(grid_sizer, 0, wx.GROW | wx.ALL, 5)
line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
- sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)
+ sizer.Add(line, 0, wx.GROW | wx.RIGHT | wx.TOP, 5)
btnsizer = wx.StdDialogButtonSizer()
if wx.Platform != "__WXMSW__":
btn = wx.ContextHelpButton(self)
btn = wx.Button(self, wx.ID_CANCEL)
btnsizer.AddButton(btn)
btnsizer.Realize()
- sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5)
+ sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_HORIZONTAL, 5)
self.SetSizer(sizer)
sizer.Fit(self)
# vu comme elle est écrite, impossible de gérer
# l'affichage/masquage des toolbars en fonction du contexte
def ShowMenu(self, menu, Show=True):
+ print("showmenu")
if menu == 'text' :
menu_pos = 4
if Show :
self._mgr.GetPane('tb_text').Show()
+ self._mgr.GetPane('tb_mat').Hide()
+ self.mb.EnableTop(menu_pos, Show)
+ self.mb.EnableTop(3, False)
else :
self._mgr.GetPane('tb_text').Hide()
elif menu == 'matrix' :
menu_pos = 3
if Show :
self._mgr.GetPane('tb_mat').Show()
+ self._mgr.GetPane('tb_text').Hide()
+ self.mb.EnableTop(menu_pos, Show)
+ self.mb.EnableTop(4, False)
else :
self._mgr.GetPane('tb_mat').Hide()
elif menu == 'view' :
else :
menu_pos = None
if not menu_pos is None :
- self.mb.EnableTop(menu_pos, Show)
+ #self.mb.EnableTop(menu_pos, Show)
self.mb.Refresh()
- #self._mgr.Update()
+ self._mgr.Update()
#--------------------------------------------------------------------
# fin de __init__ du wx.Frame
# action ou évènement ?
def OnPageChanged(self, event) :
+ print("OnPageChange")
new = event.GetSelection()
nobject = event.GetEventObject()
parent = nobject.GetParent()
if 'parametres' in dir(npage) :
#self.tree.GiveFocus(uuid=npage.parametres['uuid'])
if npage.parametres.get('matrix', False) :
- self.ShowMenu('text', False)
+ #self.ShowMenu('text', False)
self.ShowMenu('matrix', True)
elif npage.parametres.get('corpus', False) :
self.ShowMenu('text')
- self.ShowMenu('matrix', False)
- #self._mgr.Update()
- #wx.CallAfter(self.nb.SendSizeEvent)
- #self.Refresh()
+ #self.ShowMenu('matrix', False)
+ wx.CallAfter(self.nb.SendSizeEvent)
+ self.Refresh()
# action ou évènement ?
def OnCloseTab(self, evt):
pane.Hide()
self._mgr.GetPane(panel).Show()
self._mgr.Update()
- print('show a pane refresh')
wx.CallAfter(self.nb.SendSizeEvent)
self.Refresh()
"""
txt += write_afc_graph(self)
filetmp = tempfile.mktemp()
- with open(filetmp, 'w') as f :
+ with open(filetmp, 'w', encoding='utf8') as f :
f.write(txt)
pid = exec_rcode(self.ira.RPath, filetmp)
check_Rresult(self.ira, pid)
""" % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, svg, type_dendro, bw)
tmpfile = tempfile.mktemp()
# ecriture du fichier de script à éxécuter
- with open(tmpfile, 'w') as f :
+ with open(tmpfile, 'w', encoding='utf8') as f :
f.write(txt)
# dialogue d'attente
busy = wx.BusyInfo(_("Please wait..."), self.parent)
"""
# ecriture du fichier de script à éxécuter
filetmp = tempfile.mktemp()
- with open(filetmp, 'w') as f :
+ with open(filetmp, 'w', encoding='utf8') as f :
f.write(txt)
exec_rcode(self.ira.RPath, filetmp)
GraphToJson(nodesfile, edgesfile, jsonout)
#self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
def redosimi(self,evt) :
- with open(self.pathout['selected.csv'],'r') as f :
+ with open(self.pathout['selected.csv'],'r', encoding='utf8') as f :
selected = f.read()
selected = [int(val) for val in selected.splitlines()]
#if self.actives is None :
actives = [[val, self.tableau.actives[val]] for val in self.tableau.actives]
#self.tableau.make_listactives()
actives = dict([[i, val] for i, val in enumerate(actives)])
+ print(actives)
#dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)])
self.dial = PrefSimi(self.parent, -1, self.parametres, self.indices, wordlist = actives, selected = selected, actives = self.tableau.listactives)
self.dial.CenterOnParent()
indexes.append(self.dial.listcol.getColumnText(last,0))
self.column = [self.tableau.listactives.index(val) for val in indexes]
self.column.sort()
- with open(self.pathout['selected.csv'], 'w') as f :
+ with open(self.pathout['selected.csv'], 'w', encoding='utf8') as f :
f.write('\n'.join([repr(val) for val in self.column]))
self.make_param()
self.dial.Destroy()
#saveAsGEXF(graph, filepath = fileout)
""" % (ffr(self.pathout['RData.RData']), ffr(self.parent.RscriptsPath['simi']), fileout)
filetmp = tempfile.mktemp()
- with open(filetmp, 'w') as f :
+ with open(filetmp, 'w', encoding='utf8') as f :
f.write(txt)
exec_rcode(self.ira.RPath, filetmp)
mss = wx.MessageDialog(self.ira, fileout, _('File exported'), wx.OK)
""" % (ffr(self.parametres['pathout']),ffr(self.OutFrame))
tmpfile=tempfile.mktemp(dir=self.TEMPDIR)
print(tmpfile)
- tmpscript=open(tmpfile,'w')
+ tmpscript=open(tmpfile,'w', encoding='utf8')
tmpscript.write(txt)
tmpscript.close()
pid = exec_rcode(self.RPath, tmpfile, wait = False)
def dolayout(self, option):
ListFile=[False]
- file=open(self.OutFrame,'r')
+ file=open(self.OutFrame,'r', encoding='utf8')
content=file.readlines()
file.close()
lcont = [line.replace('"','').replace('\n','').split(';') for line in content]
allhtml.append(html_graphs)
header="""
<html>\n
- <meta http-equiv="content-Type" content="text/html; charset=%s" />\n
+ <meta http-equiv="content-Type" content="text/html; charset=utf8" />\n
<body>\n
<h1>Test du Chi2</h1>\n
<br>
<font color=blue>p <= 0.05 mais il y a des valeurs théoriques < 5</font><br>
<font color=red>p > 0.05</font>
</td></tr></table><br><br>
- """%self.parent.SysEncoding
+ """
pretxt = '<br>\n'.join(links)+'<br><hr><br>\n'
txt = '<br><hr><br>\n'.join(['<br><br>'.join([tab[i] for tab in allhtml]) for i,val in enumerate(res)])
txt = header + pretxt + txt + '\n</body></html>'
fileout=os.path.join(self.parametres['pathout'],'resultats-chi2.html')
- with open(fileout, 'w') as f :
+ with open(fileout, 'w',encoding='utf8') as f :
f.write(txt)
ListFile.append(fileout)
return ListFile
def dolayout(self):
listtab = []
tab = []
- with open(self.outframe) as f :
+ with open(self.outframe, 'r', encoding='utf8') as f :
content = f.read().splitlines()
content.pop(0)
content.pop(0)
# else :
# tab.append(ligne)
pretexte = '''<html>
- <meta http-equiv="content-Type" content="text/html; charset=%s" />
+ <meta http-equiv="content-Type" content="text/html; charset=utf8" />
<body>\n<h1>Fréquences</h1>
<a name="deb"></a><br>
- ''' % self.parent.SysEncoding
+ '''
for i in range(0, len(listtab)):
pretexte += '<p><a href="#%s">%s</a></p>' % (str(i), self.listtitre[i])
texte += '<hr size="5" align="center" width="50%" color="green">\n'
""" % os.path.basename(self.fileforR[i])
texte += '</body>\n</html>'
fileout = os.path.join(self.pathout.dirout, 'resultats.html')
- with open(fileout, 'w') as f :
+ with open(fileout, 'w', encoding='utf8') as f :
f.write(pretexte + texte)
#return fileout
freq = [[line[0], repr(line[1]), line[2], line[3], line[4]] for line in freq]
freq.insert(0, ['mod', 'freq', 'percent of total', 'row number', 'percent of rows'])
self.freq = freq
- with open(self.pathout['frequences.csv'], 'w') as f :
+ with open(self.pathout['frequences.csv'], 'w', encoding='utf8') as f :
f.write('\n'.join(['\t'.join(line) for line in freq]))
self.rscript = FreqMultiScript(self)
self.rscript.make_script()
def dolayout(self):
pretexte = '''<html>
- <meta http-equiv="content-Type" content="text/html; charset=%s" />
+ <meta http-equiv="content-Type" content="text/html; charset=utf8" />
<body>\n<h1>Fréquences</h1>
<a name="deb"></a><br>
- ''' % self.parent.SysEncoding
+ '''
txt = """
<table>\n<tr><td>\n
<table border=1><tr><td>
txt += '</td></tr><tr><td>'.join(['</td><td>'.join(line) for line in self.freq]) + '</td></tr></table></td></tr>'
txt += '<tr><td><img src="%s" alt="graph"/></td><td><img src="%s" alt="graph"/></td></tr></table>' % (os.path.basename(self.pathout['barplotfreq.png']), os.path.basename(self.pathout['barplotrow.png']))
txt += "</body>\n</html>"
- with open(self.pathout['resultats.html'], 'w') as f :
+ with open(self.pathout['resultats.html'], 'w', encoding='utf8') as f :
f.write(pretexte + txt)
self.linecontent = [[val.replace('"','').replace(';',' ').replace('\t', ' ').strip() for val in line] for line in self.linecontent]
def write_csvfile(self) :
- with open(self.parametres['csvfile'], 'w') as f :
+ with open(self.parametres['csvfile'], 'w', encoding='utf8') as f :
f.write('\n'.join(['\t'.join(line) for line in self.csvtable]))
def make_tmpfile(self) :
self.write_csvfile()
def read_csvfile(self):
- with codecs.open(self.parametres['csvfile'], 'r', self.parametres['syscoding']) as f:
+ with open(self.parametres['csvfile'], 'r', encoding='utf8') as f:
self.csvtable = [line.split('\t') for line in f.read().splitlines()]
self.linecontent = [line[1:] for line in self.csvtable]
self.linecontent.pop(0)
#out = [[self.rownames[i]] + out[i] for i in range(len(linecontent))]
#out.insert(0,[self.idname] + self.listactives)
out.insert(0, self.listactives)
- with open(fileout, 'w') as f :
+ with open(fileout, 'w', encoding='utf8') as f :
f.write('\n'.join([';'.join(line) for line in out]))
def make_01_from_selection(self, listact, listsup = None, dowrite = True) :
#table = [[self.rownames[i]] + table[i] for i in range(len(self.rownames))]
#table.insert(0, [self.idname] + self.listactives)
table.insert(0, self.listactives)
- with open(fileout, 'w') as f:
+ with open(fileout, 'w', encoding='utf8') as f:
f.write('\n'.join([';'.join(line) for line in table]))
def printtable(self, filename, Table, sep = ';'):
- with open(filename, 'w') as f :
+ with open(filename, 'w', encoding='utf8') as f :
f.write('\n'.join([sep.join(line) for line in Table]))
def buildprofil(self) :
- with open(self.pathout['uce'], 'r') as filein :
+ with open(self.pathout['uce'], 'r', encoding='utf8') as filein :
content = filein.readlines()
content.pop(0)
lsucecl = []
event.Skip()
def OnSelChanged(self, event = None, pydata = None):
+ print("OnSelChange")
if event is not None :
item = event.GetItem()
pydata = self.GetPyData(item)
- print('selchange',pydata)
if pydata is not None :
if 'corpus_name' in pydata or 'corpus' in pydata :
- self.ira.ShowMenu('matrix', False)
+ #self.ira.ShowMenu('matrix', False)
self.ira.ShowMenu('text', True)
if 'matrix_name' in pydata or 'matrix' in pydata:
- self.ira.ShowMenu('text', False)
+ #self.ira.ShowMenu('text', False)
self.ira.ShowMenu('matrix', True)
if 'uuid' in pydata :
if pydata['uuid'] in ['textroot', 'matroot'] :
self.parent.nb.SetSelection(i)
break
#self.parent._mgr.Update()
- #wx.CallAfter(self.parent.nb.SendSizeEvent)
+ wx.CallAfter(self.parent.nb.SendSizeEvent)
self.parent.Refresh()
#if event is not None :
# event.Skip()
else:
olditemtext = self.GetItemText(olditem)
#self.log.info("OnSelChanging: From %s" % olditemtext + " To %s" % self.GetItemText(item) + "\n")
- event.Skip()
+ #event.Skip()
def OnBeginDrag(self, event):
self.item = event.GetItem()