1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2020 Pierre Ratinaud
4 #modification pour python 3 : Laurent Mérat, 6x7 - mai 2020
7 #------------------------------------
8 # import des modules python
9 #------------------------------------
14 from time import sleep
15 from uuid import uuid4
20 #------------------------------------
21 # import des modules wx
22 #------------------------------------
25 #------------------------------------
26 # import des fichiers du projet
27 #------------------------------------
28 from chemins import ConstructPathOut, simipath, ffr, PathOut
29 from functions import print_liste, exec_rcode, read_list_file, check_Rresult, indices_simi, treat_var_mod, normpath_win32
30 from dialog import SelectColDial, FreqDialog
31 from analysematrix import AnalyseMatrix
33 from configparser import RawConfigParser
36 class Categorisation(AnalyseMatrix):
38 def doparametres(self, dlg = None) :
39 self.listactives = self.parametres.get('listactives', False)
40 self.actives = self.parametres.get('actives', False)
41 self.cmd = self.parametres.get('cmd', False)
42 self.dirout = self.parametres.get('pathout', False)
45 self.pathout = PathOut(dirout = self.dirout)
46 if not self.parametres.get('isopen', False) :
47 if self.tableau is None :
48 self.tableau = parent.tableau
49 self.tableau.parametres['mineff'] = 0
50 dialcol = FreqDialog(self.parent, self.tableau.get_colnames(), _("Select columns"), size=(600, 250), showNA = False)
51 dialcol.CenterOnParent()
52 res = dialcol.ShowModal()
55 self.tableau.selected_col = dialcol.m_listBox1.GetSelections()
56 actives = self.tableau.getactlistfromselection(self.tableau.selected_col)
58 actives = self.actives
59 if isinstance(actives, dict) :
60 actives = [[val, actives[val][0]] for val in actives]
61 self.tableau.actives = dict(actives)
62 self.tableau.make_listactives()
63 actives = dict([[i, val] for i, val in enumerate(actives)])
65 self.parametres['pathout'] = ConstructPathOut(self.parametres['pathout'], 'Categorisation')
67 self.parametres['pathout'] = self.dirout
68 self.pathout.createdir(self.parametres['pathout'])
69 self.pathout.dirout = self.parametres['pathout']
73 self.parametres = None
78 keepGoing = self.dlg.Update(count)
79 #----------------------------------------------------------------
83 self.tableau.dictpathout = self.pathout
84 #self.DictPathOut['mat01'] = fromprof
86 cate = {'TOCATE':{}, 'CATE':{}}
87 for val in self.tableau.actives :
88 cate['TOCATE'][val] = self.tableau.actives[val][0]
89 with open(self.pathout['cate.json'], 'w', encoding='utf8') as f :
90 f.write(json.dumps(cate))
91 self.tableau.save_tableau(self.pathout['analyse.db'])