Ejemplo n.º 1
0
 def test_scale(self):
     seed = 1
     # set param
     average_student_teacher_ratio = 22
     average_student_all_staff_ratio = 15
     datadir = self.dataDir
     location = 'seattle_metro'
     state_location = 'Washington'
     country_location = 'usa'
     i = 0
     for n in [2001, 10001]:
         try:
             pop = {}
             sp.set_seed(seed)
             print(seed)
             pop = sp.generate_synthetic_population(n, datadir,average_student_teacher_ratio=average_student_teacher_ratio,
                                                    average_student_all_staff_ratio=average_student_all_staff_ratio,
                                                    return_popdict=True)
             sc.savejson(os.path.join(self.resultdir, f"calltwice_{n}_{i}.json"), pop, indent=2)
             result = utilities.check_teacher_staff_ratio(pop, self.dataDir, f"calltwice_{n}_{i}", average_student_teacher_ratio,
                                                          average_student_all_staff_ratio=average_student_all_staff_ratio, err_margin=2)
             utilities_dist.check_enrollment_distribution(pop, n, datadir, location, state_location, country_location,
                                                     test_prefix=f"calltwice{n}_{i}", skip_stat_check=True, do_close=self.do_close)
             utilities_dist.check_age_distribution(pop, n, datadir, self.resultdir, location, state_location, country_location,
                                              test_prefix=f"calltwice{n}_{i}", do_close=self.do_close)
             i += 1
         except:
             print("check failed, continue...")
     return result
Ejemplo n.º 2
0
    def test_with_ltcf(self):
        """
        test with long term care facilities options
        """
        rand_seed = 1
        sp.set_seed(rand_seed)
        # set param
        n = self.n
        datadir = self.dataDir
        location = 'seattle_metro'
        state_location = 'Washington'
        country_location = 'usa'
        sheet_name = 'United States of America'
        use_two_group_reduction = True
        average_LTCF_degree = 20
        ltcf_staff_age_min = 20
        ltcf_staff_age_max = 65
        with_school_types = True
        average_class_size = 20
        inter_grade_mixing = 0.1
        average_student_teacher_ratio = 20.0
        average_teacher_teacher_degree = 3
        teacher_age_min = 25
        teacher_age_max = 70

        with_non_teaching_staff = True
        average_student_all_staff_ratio = 11
        average_additional_staff_degree = 20
        staff_age_min = 20
        staff_age_max = 75
        school_mixing_type = {'pk': 'age_and_class_clustered', 'es': 'random', 'ms': 'age_clustered', 'hs': 'random', 'uv': 'random'}
        return_popdict = True
        vals = locals()
        test_prefix = sys._getframe().f_code.co_name
        pop = utilities.runpop(resultdir=self.resultdir, testprefix=test_prefix, actual_vals=vals,
                               method=None)
        if self.do_plot:
            utilities.check_class_size(pop, average_class_size, average_student_teacher_ratio,
                                       average_student_all_staff_ratio, 1)
            result = utilities.check_teacher_staff_ratio(pop, datadir, test_prefix, average_student_teacher_ratio,
                                                         average_student_all_staff_ratio, err_margin=2)
            utilities_dist.check_age_distribution(pop, self.n, datadir, self.resultdir, location, state_location, country_location, test_prefix=test_prefix, do_close=self.do_close)
            utilities_dist.check_enrollment_distribution(pop, self.n, datadir, self.resultdir, location, state_location, country_location, test_prefix=test_prefix, do_close=self.do_close)
Ejemplo n.º 3
0
    def test_staff_generate(self):

        """
        generate a population and check if teacher/staff ratio match
        """
        rand_seed = 1
        sp.set_seed(rand_seed)
        #set param
        n = self.n
        datadir = self.dataDir
        location = 'seattle_metro'
        state_location = 'Washington'
        country_location = 'usa'
        sheet_name = 'United States of America'
        school_enrollment_counts_available = False
        with_school_types = False
        school_mixing_type = 'random'
        average_class_size = 20
        inter_grade_mixing = 0.1
        average_student_teacher_ratio = 20
        average_teacher_teacher_degree = 3
        teacher_age_min = 25
        teacher_age_max = 75
        average_student_all_staff_ratio = 12
        average_additional_staff_degree = 18
        staff_age_min = 20
        staff_age_max = 75
        return_popdict = True
        test_prefix = sys._getframe().f_code.co_name
        vals = locals()
        pop = utilities.runpop(resultdir=self.resultdir, testprefix=f"{test_prefix}", actual_vals=vals, method=sp.generate_synthetic_population)
        if self.do_plot:
            utilities.check_class_size(pop, average_class_size, average_student_teacher_ratio,
                                           average_student_all_staff_ratio, 1)
            result = utilities.check_teacher_staff_ratio(pop, self.dataDir, f"{test_prefix}", average_student_teacher_ratio, average_student_all_staff_ratio, err_margin=2)
            utilities_dist.check_age_distribution(pop, self.n, datadir, self.resultdir, location, state_location, country_location, test_prefix=test_prefix, do_close=self.do_close)
            utilities_dist.check_enrollment_distribution(pop, self.n, datadir, self.resultdir, location, state_location, country_location, test_prefix=f"{test_prefix}", do_close=self.do_close)
Ejemplo n.º 4
0
            country_location=country_location,
            setting_code=setting_code,
            decimal=3)
        utilities.plot_array(
            average,
            datadir=figdir,
            testprefix=f"{setting_code} {test_prefix} contact by age bracket",
            expect_label="contacts",
            names=age_brackets_labels,
            xlabel_rotation=50)

    utilities_dist.check_age_distribution(pop,
                                          n,
                                          datadir=datadir,
                                          figdir=figdir,
                                          location=location,
                                          state_location=state_location,
                                          country_location=country_location,
                                          test_prefix=test_prefix,
                                          skip_stat_check=True)

    utilities_dist.check_enrollment_distribution(
        pop,
        n,
        datadir=datadir,
        figdir=figdir,
        location=location,
        state_location=state_location,
        country_location=country_location,
        test_prefix=test_prefix,
        skip_stat_check=True,