diff --git a/DESCRIPTION b/DESCRIPTION index c5d893c4..27626c74 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,6 @@ Package: naomi Title: Naomi Model for Subnational HIV Estimates -Version: 2.10.1 - +Version: 2.10.2 Authors@R: person(given = "Jeff", family = "Eaton", diff --git a/NEWS.md b/NEWS.md index 9065d38c..1ccaa0cd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,12 @@ -# naomi 2.10.1 +# naomi 2.10.2 * Improve warning generated when user fits model at admin level where no population data exists. +# naomi 2.10.1 + +* Patch error in reading `anc_already_art` from Spectrum PJNZ file (was errantly + reading number of women initiated ART <4 weeks before delivery). + # naomi 2.10.0 * Update Naomi example and test datasets to current example data for Malawi @@ -20,7 +25,6 @@ * Update Navigator checklist calendar quarter for 2025 estimates to 2024Q4 and 2025Q3 for current period and projection. - # naomi 2.9.29 * Add function to format data for Naomi-Spectrum comparison table. diff --git a/R/inputs-spectrum.R b/R/inputs-spectrum.R index 52b525e0..242a70f7 100644 --- a/R/inputs-spectrum.R +++ b/R/inputs-spectrum.R @@ -387,9 +387,9 @@ read_dp_anc_testing <- function(dp) { ## Note: these values start 1 column later than other arrays in the .DP file ## If value is 0, interpret as not entered (NA) if (exists_dptag("")) { - anc_already_art <- dpsub("", 13, timedat.idx+1) + anc_already_art <- dpsub("", 11, timedat.idx+1) } else if (exists_dptag("")) { - anc_already_art <- dpsub("", 13, timedat.idx+1) + anc_already_art <- dpsub("", 11, timedat.idx+1) } anc_already_art <- sapply(anc_already_art, as.integer) anc_already_art[anc_already_art == 0] <- NA diff --git a/R/run-model.R b/R/run-model.R index 147f7012..05e791c1 100644 --- a/R/run-model.R +++ b/R/run-model.R @@ -91,16 +91,15 @@ run_model <- function(data, options, validate) { progress = progress) - if (fit$convergence !=0) { + if (fit$convergence != 0) { - if(fit$message == "false convergence (8)"){ + if (fit$message == "false convergence (8)"){ msg <- t_("WARNING_FALSE_CONVERGENCE") } else { msg <- t_("WARNING_CONVERGENCE", list(msg = fit$message)) } naomi_warning(msg, "model_fit") - } progress$finalise_fit() @@ -131,7 +130,6 @@ run_model <- function(data, options, validate) { naomi_data = naomi_data, info = info ) - } build_hintr_output <- function(plot_data_path, model_output_path, warnings) { diff --git a/data-raw/survey.R b/data-raw/survey.R index 1e4fcdeb..e55da4a4 100644 --- a/data-raw/survey.R +++ b/data-raw/survey.R @@ -896,6 +896,8 @@ survey_hiv_indicators <- calc_survey_hiv_indicators( survey_biomarker, demo_area_hierarchy) +filter(survey_hiv_indicators, is.na(std_error)) +survey_hiv_indicators$std_error[is.na(survey_hiv_indicators$std_error)] <- 0.0 #' ## Save datasets #' diff --git a/data/demo_survey_hiv_indicators.rda b/data/demo_survey_hiv_indicators.rda index 443f1e5b..891e4e7f 100644 Binary files a/data/demo_survey_hiv_indicators.rda and b/data/demo_survey_hiv_indicators.rda differ diff --git a/inst/extdata/demo_survey_hiv_indicators.csv b/inst/extdata/demo_survey_hiv_indicators.csv index f86111c5..220b8089 100644 --- a/inst/extdata/demo_survey_hiv_indicators.csv +++ b/inst/extdata/demo_survey_hiv_indicators.csv @@ -15908,7 +15908,7 @@ art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,both,Y045_049,177,240,1 art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,both,Y050_054,129,162,120.54389037448695,0.7748599566807669,0.03905360222942496,0.6893738079387397,0.8422048964212699 art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,both,Y055_059,88,109,80.85309273638147,0.7695115138884412,0.044489222350464,0.6712678191657072,0.8451667482868456 art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,both,Y060_064,60,70,54.212237875912976,0.8091266443320001,0.055209812341668336,0.6778028857662217,0.8952003952540727 -art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,both,Y000_000,1,1,1,0,NA,NA,NA +art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,both,Y000_000,1,1,1,0,0,NA,NA art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,both,Y001_004,18,19,14.001704889638258,0.6569553204935843,0.12727378529840955,0.3876681553116353,0.8527877522680566 art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,male,Y015_049,296,559,413.7810042594462,0.6025270373779054,0.024935000059006975,0.5527871489046333,0.6502351252266833 art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,male,Y015_064,330,715,527.9651856480385,0.6349933905516871,0.021412824012724166,0.5920935512814668,0.6758514631593975 @@ -15957,7 +15957,7 @@ art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,female,Y045_049,109,134 art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,female,Y050_054,79,92,67.26084291939691,0.7383353798552105,0.055047935218396404,0.6174825784892003,0.8314295014319167 art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,female,Y055_059,54,58,40.980527410570545,0.8062973593393401,0.05865815216628626,0.6659698999459963,0.8968073503551113 art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,female,Y060_064,31,35,28.865378277878452,0.8141291563780553,0.06993925587137714,0.6390399789700845,0.9155166554304044 -art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,female,Y000_000,1,1,1,0,NA,NA,NA +art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,female,Y000_000,1,1,1,0,0,NA,NA art_coverage,DEMO2016PHIA,CY2016Q1,MWI,Malawi - Demo,all,female,Y001_004,8,8,7.125023177711781,0.450821665090431,0.2012542756391103,0.14300300695794438,0.8015270629465587 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_1_demo,Northern,all,both,Y015_049,47,149,129.9167754259742,0.7095078187744512,0.03299395227896437,0.6408924544039271,0.7697233867575317 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_1_demo,Northern,all,both,Y015_064,51,182,159.15510760305264,0.7271995528723063,0.02939191051171283,0.6659832380873617,0.7808877744617115 @@ -16123,7 +16123,7 @@ art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,both,Y045_049,99,14 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,both,Y050_054,76,95,71.33216353389295,0.7654317997684672,0.053298704879957075,0.6458560365159409,0.8537741512108593 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,both,Y055_059,41,48,35.16776879176661,0.8105785751619565,0.06359671606174175,0.6551955289951933,0.9059869905198982 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,both,Y060_064,44,53,42.27859686695561,0.792880355818035,0.06496072924156025,0.6380880359822956,0.8926093745184708 -art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,both,Y000_000,1,1,1,0,NA,NA,NA +art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,both,Y000_000,1,1,1,0,0,NA,NA art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,both,Y001_004,12,13,9.677498093333027,0.7020247557532454,0.14279478706913773,0.3820267319420337,0.8997879904178266 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,male,Y015_049,158,341,251.73162445844568,0.6280110059125654,0.030301399848660867,0.5669630915577909,0.6852307049151976 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,male,Y015_064,168,428,313.8365771888916,0.6539088283950566,0.02607980646571124,0.6011844780229604,0.703105168512981 @@ -16172,7 +16172,7 @@ art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,female,Y045_049,63, art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,female,Y050_054,47,54,40.356276767680704,0.7222581019604578,0.07329535690746976,0.5596057497573013,0.841818114403322 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,female,Y055_059,25,28,19.107157416862716,0.8298465119087445,0.08015581744009995,0.6158394863709681,0.9368584888491283 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,female,Y060_064,24,27,23.262461904120887,0.8269290431469299,0.07485386157110663,0.6315585086832759,0.9301584463389765 -art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,female,Y000_000,1,1,1,0,NA,NA,NA +art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,female,Y000_000,1,1,1,0,0,NA,NA art_coverage,DEMO2016PHIA,CY2016Q1,MWI_1_3_demo,Southern,all,female,Y001_004,4,4,3.8214178328274997,0.5808147855433148,0.26283549126771677,0.14310356057744214,0.9199734694284686 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_1_demo,Northern,all,both,Y015_049,47,149,129.9167754259742,0.7095078187744512,0.03299395227896437,0.6408924544039271,0.7697233867575317 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_1_demo,Northern,all,both,Y015_064,51,182,159.15510760305264,0.7271995528723063,0.02939191051171283,0.6659832380873617,0.7808877744617115 @@ -16478,7 +16478,7 @@ art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,both,Y045_049,62, art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,both,Y050_054,47,55,40.25105198063331,0.7702540336506881,0.07587604290389445,0.5913080679347493,0.8859594244748754 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,both,Y055_059,25,30,23.643309698961644,0.7846071237709136,0.07818954658150766,0.5952991473553306,0.900206663772158 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,both,Y060_064,30,35,28.54222819769796,0.8417338681594824,0.06840839294112025,0.6603221468549171,0.9356943668513962 -art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,both,Y000_000,1,1,1,0,NA,NA,NA +art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,both,Y000_000,1,1,1,0,0,NA,NA art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,both,Y001_004,6,6,5.062361470955532,0.7076824180773964,0.19608419347533246,0.2741558784349028,0.9394569697215944 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,male,Y015_049,102,240,185.62103250738627,0.631185482012857,0.033752889182644234,0.5629456597244568,0.6945517399000651 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,male,Y015_064,108,297,226.17645181697776,0.6553808467814354,0.03136168114855262,0.5916094824478016,0.7140079994019548 @@ -16527,7 +16527,7 @@ art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,female,Y045_049,4 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,female,Y050_054,27,30,22.310384504820178,0.7684727946846136,0.09428056599320409,0.5401951442385823,0.9036354199787159 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,female,Y055_059,14,17,12.967302486273946,0.8146617204899899,0.114543273456242,0.49842815021013287,0.9510826093278688 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,female,Y060_064,14,16,14.218776381233273,0.8129599303256666,0.1010522740650321,0.5416087994590735,0.9411381575613841 -art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,female,Y000_000,1,1,1,0,NA,NA,NA +art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,female,Y000_000,1,1,1,0,0,NA,NA art_coverage,DEMO2016PHIA,CY2016Q1,MWI_2_5_demo,South-West,all,female,Y001_004,1,1,1,1,0,NA,NA art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_1_demo,Chitipa,all,both,Y015_049,4,14,13.079921524097607,0.5697500395361266,0.09690420400556586,0.37896083604068515,0.7418534116545574 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_1_demo,Chitipa,all,both,Y015_064,4,15,13.962417971284841,0.5901693603411527,0.08628538364704366,0.41713662645085964,0.7434294300508175 @@ -17659,7 +17659,7 @@ art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,both,Y045_049,38,5 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,both,Y050_054,31,37,28.971021157532107,0.7578903195187772,0.08478863112371024,0.5586003626082315,0.8856250953721512 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,both,Y055_059,13,17,16.826643640957975,0.8229920644290639,0.08414212343243836,0.5998121049243477,0.9351616233325795 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,both,Y060_064,14,16,12.37343064787388,0.53422764153731,0.15381061635737578,0.25456619661424157,0.7939097299536315 -art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,both,Y000_000,1,1,1,0,NA,NA,NA +art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,both,Y000_000,1,1,1,0,0,NA,NA art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,both,Y001_004,3,3,2.9685669356661766,0.659421354577168,0.28378121752100083,0.1399316946654481,0.9584050086609006 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,male,Y015_049,63,151,117.2254133741664,0.5505924779260516,0.04582465796283461,0.4601074311530433,0.6378488857573587 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,male,Y015_064,65,184,140.99689221636893,0.5792052685775926,0.041926727264350025,0.49558802246015765,0.6585123948797179 @@ -17708,7 +17708,7 @@ art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,female,Y045_049,24 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,female,Y050_054,17,20,13.489097261708068,0.7636912670847119,0.12379844197501175,0.4572321114467524,0.9253622959017467 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,female,Y055_059,8,11,10.932092422559974,0.8292373699270147,0.10712500257861728,0.5243518087060408,0.9553395968870257 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,female,Y060_064,6,6,4.784013791501877,0.21706432603953751,0.15478125384609845,0.04445038412399939,0.62297608074363 -art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,female,Y000_000,1,1,1,0,NA,NA,NA +art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_23_demo,Blantyre,all,female,Y000_000,1,1,1,0,0,NA,NA art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_24_demo,Mwanza,all,both,Y015_049,3,17,16.253566102685422,0.6179858275360864,0.08388896390947519,0.4463448442931162,0.7644918446869419 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_24_demo,Mwanza,all,both,Y015_064,3,17,16.253566102685422,0.6179858275360864,0.08388479202422319,0.446353403492301,0.7644856086993684 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_3_24_demo,Mwanza,all,both,Y000_064,3,17,16.253566102685422,0.6179858275360864,0.08388413010421227,0.4463547615156104,0.7644846192740784 @@ -19393,7 +19393,7 @@ art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,both,Y045_049 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,both,Y050_054,28,33,30.399052972451507,0.7622677140135403,0.07993068973760899,0.5746015825273446,0.883875625599874 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,both,Y055_059,13,17,16.826643640957975,0.8229920644290639,0.08414212343243836,0.5998121049243477,0.9351616233325795 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,both,Y060_064,13,15,13.87136677542012,0.6513141948956539,0.14392886886733905,0.35039100923771527,0.8661064521174505 -art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,both,Y000_000,1,1,1,0,NA,NA,NA +art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,both,Y000_000,1,1,1,0,0,NA,NA art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,both,Y001_004,3,3,2.9685669356661766,0.659421354577168,0.28378121752100083,0.1399316946654481,0.9584050086609006 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,male,Y015_049,58,139,123.04362621121932,0.5208130984522058,0.04070545064155076,0.4411790635998353,0.5994032623510778 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,male,Y015_064,60,172,150.80269737778997,0.559343474613215,0.03769542445367252,0.4846920031573383,0.6314045665576387 @@ -19442,7 +19442,7 @@ art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,female,Y045_0 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,female,Y050_054,14,16,14.88670670542045,0.7800976185085934,0.10332952234736598,0.5214019678908002,0.9203278928842241 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,female,Y055_059,8,11,10.932092422559974,0.8292373699270147,0.10712500257861728,0.5243518087060408,0.9553395968870257 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,female,Y060_064,5,5,4.677033003604339,0.3292526499520002,0.20756938876381897,0.07217768246736284,0.7559450080669983 -art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,female,Y000_000,1,1,1,0,NA,NA,NA +art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_29_demo,Blantyre City,all,female,Y000_000,1,1,1,0,0,NA,NA art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_30_demo,Thyolo,all,both,Y015_049,12,69,65.55932519254539,0.7074743010501984,0.04501746203468915,0.6122572491293277,0.7874273225463437 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_30_demo,Thyolo,all,both,Y015_064,13,77,73.20869482890575,0.7334283435031405,0.045281767402567695,0.6360233145445926,0.8124529446325933 art_coverage,DEMO2016PHIA,CY2016Q1,MWI_4_30_demo,Thyolo,all,both,Y000_064,13,79,68.51317841292828,0.7519647646915016,0.042277439899731754,0.6603489780726222,0.8254024596619344 diff --git a/tests/testthat/test-outputs.R b/tests/testthat/test-outputs.R index 24192b91..2bcf7ad8 100644 --- a/tests/testthat/test-outputs.R +++ b/tests/testthat/test-outputs.R @@ -164,16 +164,21 @@ test_that("subset_output_package() saves expected output package", { expect_setequal(indicator_sub, sub_keep_out$indicators$indicator) + ## Test that can **drop** selected indicators (rather than keep) + sub_drop_file <- tempfile(fileext = ".zip") - sub_drop_return <- subset_output_package(out$path, - sub_drop_file, - area_id = area_id_sub, - sex = sex_sub, - age_group = age_group_sub, - calendar_quarter = calendar_quarter_sub, - indicator = indicator_sub, - drop = TRUE) + expect_warning( + sub_drop_return <- subset_output_package(out$path, + sub_drop_file, + area_id = area_id_sub, + sex = sex_sub, + age_group = age_group_sub, + calendar_quarter = calendar_quarter_sub, + indicator = indicator_sub, + drop = TRUE), + "Required indicators not in output: plhiv" + ) sub_drop_out <- read_output_package(sub_drop_file) diff --git a/tests/testthat/test-spectrum.R b/tests/testthat/test-spectrum.R index 687b33cc..55c38d8f 100644 --- a/tests/testthat/test-spectrum.R +++ b/tests/testthat/test-spectrum.R @@ -128,7 +128,7 @@ test_that("extract_pjnz_program_data() returns complete data", { expect_setequal(dat_old$anc_testing$spectrum_region_code, 0) expect_setequal(dat_old$anc_testing$indicator[dat_old$anc_testing$year == 2018], c("anc_clients", "anc_tested", "anc_tested_pos", "anc_known_pos", "anc_already_art")) - expect_setequal(dat_old$anc_testing$indicator[dat_old$anc_testing$year == 2010], + expect_setequal(dat_old$anc_testing$indicator[dat_old$anc_testing$year == 2019], c("anc_already_art")) expect_true(all(!is.na(dat_old$anc_testing$value))) @@ -146,7 +146,7 @@ test_that("extract_pjnz_program_data() returns complete data", { expect_setequal(dat_new$anc_testing$spectrum_region_code, 0) expect_setequal(dat_new$anc_testing$indicator[dat_new$anc_testing$year == 2018], c("anc_clients", "anc_tested", "anc_tested_pos", "anc_known_pos", "anc_known_neg", "anc_already_art")) - expect_setequal(dat_new$anc_testing$indicator[dat_new$anc_testing$year == 2010], + expect_setequal(dat_new$anc_testing$indicator[dat_new$anc_testing$year == 2019], c("anc_already_art")) expect_true(all(!is.na(dat_new$anc_testing$value))) diff --git a/tests/testthat/test-warning.R b/tests/testthat/test-warning.R index 51ceda8e..6ef9ebd4 100644 --- a/tests/testthat/test-warning.R +++ b/tests/testthat/test-warning.R @@ -50,23 +50,20 @@ test_that("warning raised after false convergence", { a_fit_bad$convergence <- 1 a_fit_bad$message <- "false convergence (8)" - a_fit_sample_bad <- a_fit_sample - a_fit_sample_bad$convergence <- 1 - a_fit_sample_bad$message <- "false convergence (8)" - - with_mocked_bindings( - { - out <- hintr_run_model(a_hintr_data, a_hintr_options, validate = FALSE) - }, - fit_tmb = mockery::mock(a_fit_bad), - output_package = mockery::mock(a_output) - ) - + mock_fit_tmb <- mockery::mock(a_fit_bad) + mock_output_package <- mockery::mock(a_output) + + with_mock( + fit_tmb = mock_fit_tmb, + output_package = mock_output_package, { + out <- hintr_run_model(a_hintr_data, a_hintr_options, validate = FALSE) + }) + expect_length(out$warnings, 3) expect_match(out$warnings[[1]]$text, "Naomi subnational data not equal to Spectrum national data. Check table on review inputs tab for: \nnumber_on_art: 2011;2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2023") expect_match(out$warnings[[2]]$text, - "Naomi subnational data not equal to Spectrum national data. Check table on review inputs tab for: \nanc_already_art: 2011;2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2023\nanc_clients: 2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2023\nanc_known_neg: 2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2023\nanc_known_pos: 2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2023\nanc_tested: 2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2023") + "Naomi subnational data not equal to Spectrum national data. Check table on review inputs tab for: \nanc_already_art: 2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2023\nanc_clients: 2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2023\nanc_known_neg: 2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2023\nanc_known_pos: 2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2023\nanc_tested: 2012;2013;2014;2015;2016;2017;2018;2019;2020;2021;2022;2023") expect_equal(out$warnings[[3]]$text, "Model fitting to input data has not fully converged. Please review estimates of HIV prevalence and ART coverage across districts and the national distribution of key indicators by age and sex.") })