def test_notPassedStats(self): n = notakeb.notak("","") s = pd.Series([0,0,8,0,0,2,0,2,2,0,3,1,1,1,0,8,8,3,1,1,0,2,2,5,5,0,0,4,6,3], index=["aabadiacaj","aalvardiaz","acarvalper","agarciacha","ajimenemen2","aruedasbal","ausandilor","cmoralegil","dlopezarra","dmoreirpad","etamarerod","gmorenogob","gperezgarc","icabodeder","iiribarjul","imatillbla","jarminogal","jcarazoval","jcorrei1","jotazubosq","myaguancab","nurrutipla","pgayarrarr1","psamperdel","psantamlar1","rsaizherre","tdiallo","vcunhasori","wameziaaho","zcastrogar"]) s.name="grade" s.index.name="uniquename" result = n.notPassedStats(s) expected = {0: 10, 1: 5, 2: 5, 3: 3, 4: 1, 5: 2, 6: 1, 8: 3} self.assertDictEqual(result,expected)
def test_generatePiedata(self): n = notakeb.notak("mendillorriN.db","eu") n.setWorkDir("1ebaluaketa15-16") n.getData("2015-2016", ["1. Ebaluazioa"], 1) n.df = n.df[n.df.year!="2016-2017"] missed = {0: 10, 1: 5, 2: 5, 3: 3, 4: 1, 5: 2, 6: 1, 7: 0, 8: 3} result = (n.generatePiedata(missed)) expected = ([20, 4, 6],[10, 5, 5, 0, 0, 0, 0, 0, 0],[0, 0, 0, 3, 1, 0, 0, 0, 0],[0, 0, 0, 0, 0, 2, 1, 0, 3],[0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5],['0', '1', '2', '3', '4', '5', '6', '7', '8']) self.assertEqual(result,expected)
def test_getGroupPromStats(self): n = notakeb.notak("mendillorriN.db","eu") n.setWorkDir("1ebaluaketa15-16") n.getData("2015-2016", ["1. Ebaluazioa"], 1) n.df = n.df[n.df.year!="2016-2017"] data = {'cgroup':['1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A'], 'year':['2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016'], 'period':['1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa'], 'uniquename':['aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2'], 'grade':[7,8,6,9,8,8,6,6,7,6,7,8,8,7,7,7,8,7,7,6,3,5,3,4,3,4,4,5,4,4,8,8,8,5,8,7,6,7,7,7,7,7,6,8,8,6,6,9,6,9]} n.df = pd.DataFrame(data) result = (n.getGroupPromStats("1º A")) expected = ([80.0, 0.0, 20.0], 1.6) self.assertEqual(result,expected)
def test_generateFinalGrade(self): n = notakeb.notak("mendillorriN.db","eu") data = {'year' : pd.Series(["2015-2016", "2015-2016", "2015-2016","2015-2016","2015-2016","2015-2016","2015-2016"]), 'uniquename' : pd.Series(["john","john","john","john","john","michael","michael"]), 'subject' : pd.Series(["Math","Math","Fis","Fis","ICT","Fis","Fis"]), 'period' : pd.Series(["Azken Ebaluazioa","Ohiz kanpoko Ebaluazioa","Azken Ebaluazioa","Ohiz kanpoko Ebaluazioa","Azken Ebaluazioa","Azken Ebaluazioa","Ohiz kanpoko Ebaluazioa"]), 'grade' : pd.Series([2,5,4,6,10,3,8]),} n.df = pd.DataFrame(data) n.generateFinalGrade() data = {'year' : pd.Series(["2015-2016", "2015-2016", "2015-2016","2015-2016","2015-2016","2015-2016","2015-2016","2015-2016","2015-2016","2015-2016","2015-2016"]), 'uniquename' : pd.Series(["john","john","john","john","john","michael","michael","john","john","john","michael"]), 'subject' : pd.Series(["Math","Math","Fis","Fis","ICT","Fis","Fis","Fis","ICT","Math","Fis"]), 'period' : pd.Series(["Azken Ebaluazioa","Ohiz kanpoko Ebaluazioa","Azken Ebaluazioa","Ohiz kanpoko Ebaluazioa","Azken Ebaluazioa","Azken Ebaluazioa","Ohiz kanpoko Ebaluazioa","Final","Final","Final","Final"]), 'grade' : pd.Series([2,5,4,6,10,3,8,6,10,5,8]),} dfr = pd.DataFrame(data) assert_frame_equal(n.df,dfr)
def test_generateStatsGroup(self): n = notakeb.notak("mendillorriN.db","eu") n.getData("2015-2016", ["1. Ebaluazioa"], 1) data = {'cgroup':['1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A','1º A'], 'year':['2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016','2015-2016'], 'lang':['AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG','AG'], 'period':['1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa','1. Ebaluazioa'], 'subject':['mate','gazte','ing','mus','tek','plas','giz','biogeo','fran','eusk','mate','gazte','ing','mus','tek','plas','giz','biogeo','fran','eusk','mate','gazte','ing','mus','tek','plas','giz','biogeo','fran','eusk','mate','gazte','ing','mus','tek','plas','giz','biogeo','fran','eusk','mate','gazte','ing','mus','tek','plas','giz','biogeo','fran','eusk'], 'uniquename':['aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aabadiacaj','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','aalvardiaz','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','acarvalper','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','agarciacha','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2','ajimenemen2'], 'grade':[3,8,6,9,8,8,6,6,7,6,3,8,8,7,7,7,8,7,7,6,3,5,3,4,3,4,4,5,4,4,3,8,8,5,8,7,6,7,7,7,7,7,6,8,8,6,6,9,6,9]} n.df = pd.DataFrame(data) rsubjectsgrouppt,rbadsubjectsgroup,rgroupgrades,rstudentsnotpasses,rpie,rmean,rpercent = (n.generateStatsGroup("2015-2016",n.periods[n.period-1],n.periods,"1º A", False)) data = {'subject':['biogeo','eusk','fran','gazte','giz','ing','mate','mus','plas','tek','All'], 'grade':['100.0','80.0','80.0','100.0','80.0','80.0','20.0','80.0','80.0','80.0','78.0']} esubjectsgrouppt = pd.DataFrame(data) esubjectsgrouppt.set_index("subject",inplace=True) esubjectsgrouppt['grade'] = esubjectsgrouppt.grade.astype(float) data = {'subject':['mate'], '%':['20.0']} ebadsubjectsgroup = pd.DataFrame(data) ebadsubjectsgroup = ebadsubjectsgroup[["subject","%"]] ebadsubjectsgroup['%'] = ebadsubjectsgroup['%'].astype(float) data = {'subject':['biogeo','eusk','fran','gazte','giz','ing','mate','mus','plas','tek','All'], 'grade':['6.8','6.4','6.2','7.2','6.0','6.2','3.8','6.6','6.4','6.8','6.24']} egroupgrades = pd.DataFrame(data) egroupgrades = egroupgrades[["subject","grade"]] egroupgrades['grade'] = egroupgrades.grade.astype(float) data = {'uniquename':['acarvalper','aabadiacaj','aalvardiaz','agarciacha','ajimenemen2'], '<5':[8,1,1,1,0], 'avg':['3.9','6.7','6.8','6.6','7.2']} index = [2,0,1,3,4] estudentsnotpasses = pd.DataFrame(data,index=index) estudentsnotpasses['avg'] = estudentsnotpasses.avg.astype(float) estudentsnotpasses = estudentsnotpasses[["uniquename","<5","avg"]] epie = '1º A-1. Ebaluazioa-eu.png' emean = '1º A (2015-2016) 1. Ebaluazioa-mean-eu.png' epercent = '1º A (2015-2016) 1. Ebaluazioa-percent-eu.png' expected = ([80.0, 0.0, 20.0], 1.6) self.assertEqual(rpie,epie) self.assertEqual(rmean,emean) self.assertEqual(rpercent,epercent) assert_frame_equal(rsubjectsgrouppt,esubjectsgrouppt) assert_frame_equal(rbadsubjectsgroup,ebadsubjectsgroup) assert_frame_equal(rgroupgrades,egroupgrades) assert_frame_equal(rstudentsnotpasses,estudentsnotpasses)
def run(self): eb = self.ui.periodCB.currentText() ebn = self.ui.periodCB.currentIndex() year = self.ui.yearCB.currentText() ebaluaketak = [ self.ui.periodCB.itemText(i) for i in range(self.ui.periodCB.count()) ] print(ebaluaketak, year, eb, ebn) ucepca = [ "4. C.E.U.", "3. C.E.U", "2. C.E.U.", "1. Oinarrizko Hezkuntza (C.E.U.)", "Programa de Currículo Adaptado", "PCA", "Programa de Currículo Adaptado LOMCE", "1-E.B.O.2 Aula Alternativa", "2-E.B.O.2 Aula Alternativa" ] dbhb = [ "1 ESO", "2 ESO", "3 ESO", "4 ESO", "1º Bach", "1. DBH", "2. DBH", "3. DBH", "4. DBH", "3º Div.Cur.", "4º Div.Cur.", "4º Div. Cur.", "1. Batxilergoa LOE", "1. DBH LOMCE", "1. Batxilergoa LOMCE", "3. DBH LOMCE", "3. Ikaskuntza eta Errendimendua Hobetzeko Programak", "2. DBH LOMCE", "4. DBH LOMCE", "2. Ikaskuntza eta Errendimendua Hobetzeko Programak" ] #,"2. Batxilergoa LOMCE", dbh12 = ["1. DBH LOMCE", "2. DBH LOMCE"] Batx2 = ["2. Batxilergoa LOE", "2. Batxilergoa LOMCE"] if self.ui.CbDBH1Batx.isChecked(): baliogabekokurtsoak = ucepca + Batx2 elif self.ui.CbBatx2.isChecked(): baliogabekokurtsoak = ucepca + dbhb #+dbhb para solo 2bach else: baliogabekokurtsoak = ucepca print(baliogabekokurtsoak) for lang in ['eu', 'es']: self.n = notak.notak(self.db, lang, debug=False) self.n.setWorkDir(eb + year) self.n.getData(year, ebaluaketak, ebn + 1, baliogabekokurtsoak) if eb == 'Final': self.n.generateFinalGrade() mailak = self.n.df[self.n.df.year == year].course.unique() self.n.promcourseplots( ebaluaketak[ebn]) #Needed for groupstats.csv taldeak = self.n.df[self.n.df.year == year].cgroup.unique( ) #Needed for badsubjects.csv for t in taldeak: self.n.generatePassPercent(ebaluaketak[ebn], year, t) print("Course Pass Percentes") for m in mailak: self.n.generateCoursePassPercent(ebaluaketak[ebn], self.n.year, m) if self.ui.coursePlotsEs.isChecked() and lang == 'es': print("course np.mean") self.n.generateCoursePlots(np.mean) print("course percent") self.n.generateCoursePlots(self.n.percent) if self.ui.coursePlotsEu.isChecked() and lang == 'eu': print("course np.mean") self.n.generateCoursePlots(np.mean) print("course percent") self.n.generateCoursePlots(self.n.percent) if self.ui.groupStatsPlotsEs.isChecked() and lang == 'es': taldeak = self.n.df[self.n.df.year == year].cgroup.unique() print("Group stats plots") for t in taldeak: self.n.generateGroupStatsPlots(t) if self.ui.groupStatsPlotsEu.isChecked() and lang == 'eu': taldeak = self.n.df[self.n.df.year == year].cgroup.unique() print("Group stats plots") for t in taldeak: self.n.generateGroupStatsPlots(t) if self.ui.allGroupStatsPlotsEs.isChecked() and lang == 'es': print("All group stats plots") self.n.generateAllGroupStatsPlots() if self.ui.allGroupStatsPlotsEu.isChecked() and lang == 'eu': print("All group stats plots") self.n.generateAllGroupStatsPlots() if self.ui.passPercentEs.isChecked( ) and lang == 'es': #Required before to generate pass percents taldeak = self.n.df[self.n.df.year == year].cgroup.unique() print("Group pass percent") for t in taldeak: self.n.generatePassPercent(ebaluaketak[ebn], year, t) if self.ui.passPercentEu.isChecked() and lang == 'eu': taldeak = self.n.df[self.n.df.year == year].cgroup.unique() print("Group pass percent") for t in taldeak: self.n.generatePassPercent(ebaluaketak[ebn], year, t) if self.ui.allGroupPlotsEs.isChecked() and lang == 'eu': print("All group plots np.mean") self.n.generateAllGroupPlots(np.mean) print("All group plots n.percent") self.n.generateAllGroupPlots(self.n.percent) if self.ui.allGroupPlotsEu.isChecked() and lang == 'eu': print("All group plots np.mean") self.n.generateAllGroupPlots(np.mean) print("All group plots n.percent") self.n.generateAllGroupPlots(self.n.percent) if self.ui.promCoursePlotsEs.isChecked( ) and lang == 'es': #Needed befor to gnerate grouptstats.csv print("course prom plots") self.n.promcourseplots(ebaluaketak[ebn]) if self.ui.promCoursePlotsEu.isChecked() and lang == 'eu': print("course prom plots") self.n.promcourseplots(ebaluaketak[ebn]) if self.ui.bilingualCoursePlotsEs.isChecked() and lang == 'es': print("Bilingual plots") self.n.generateCourseBilPlots([np.mean, self.n.percent]) self.n.generateCourseBilvsCooursePlots( [np.mean, self.n.percent]) if self.ui.bilingualCoursePlotsEu.isChecked() and lang == 'eu': print("Bilingual plots") self.n.generateCourseBilPlots([np.mean, self.n.percent]) self.n.generateCourseBilvsCooursePlots( [np.mean, self.n.percent]) if self.ui.courseStatsPlotsEs.isChecked() and lang == 'es': print("Course stats plots") self.n.generateCourseStatsPlots() if self.ui.courseStatsPlotsEu.isChecked() and lang == 'eu': print("Course stats plots") self.n.generateCourseStatsPlots() if self.ui.allStatsPlotsEs.isChecked() and lang == 'es': print("generate All Stats Plots") self.n.generateAllStatsPlots() if self.ui.allStatsPlotsEu.isChecked() and lang == 'eu': print("generate All Stats Plots") self.n.generateAllStatsPlots() print("generate reportgruoupdata.csv") self.n.generateGroupStats() if self.ui.allStatsStudentsEs.isChecked() and lang == 'es': print("generate Stats Student") self.n.generateStatsAllStudents(doc=True) if self.ui.allStatsStudentsEu.isChecked() and lang == 'eu': print("generate Stats Student") self.n.generateStatsAllStudents(doc=True) if self.ui.deptarmentPlotsEs.isChecked() and lang == 'es': print("Departaments plots") self.n.generateDeptPlots([np.mean, self.n.percent]) if self.ui.deptarmentPlotsEu.isChecked() and lang == 'eu': print("Departaments plots") self.n.generateDeptPlots([np.mean, self.n.percent]) if self.ui.primarySchoolsPlotsEs.isChecked() and lang == 'es': print("Primary School plots") self.n.generatePrymarySchoolPlots(np.mean) if self.ui.primarySchoolsPlotsEu.isChecked() and lang == 'eu': print("Primary School plots") self.n.generatePrymarySchoolPlots(np.mean) #print("Mix askabi and EDUCA for the report") #self.n.generateGroupStats() print("End of generation")