def test_csv_loads_same_as_dat(self):

        headage_householdsize_distribution_path = spdd.get_household_head_age_by_size_path(
            datadir=sp_datadir,
            state_location="Washington",
            country_location="usa")

        headage_distro_datfilename, headage_distro_csvfilename = self.copy_dat_and_make_csv(
            headage_householdsize_distribution_path)

        headage_distro_dat_df = spdd.get_household_head_age_by_size_df(
            datadir="", file_path=headage_distro_datfilename)
        headage_distro_csv_df = spdd.get_household_head_age_by_size_df(
            datadir="", file_path=headage_distro_csvfilename)
        if self.is_debugging:
            print(headage_distro_dat_df.describe())
            print(headage_distro_dat_df.columns)
        dat_household_age_18_20_weights = headage_distro_dat_df[
            'household_head_age_18_20']
        dat_household_size_4_reference_35_39 = headage_distro_dat_df[
            'household_head_age_35_39'][5]
        dat_household_size_1_weights = headage_distro_dat_df.loc[0]

        if self.is_debugging:
            print("Household age 18_20 weights")
            print(dat_household_age_18_20_weights)

            print("Household size 1 relative weights")
            print(dat_household_size_1_weights)

            print("Household size 4, reference person 25-39 relative weight")
            print(dat_household_size_4_reference_35_39)

        csv_household_age_18_20_weights = headage_distro_csv_df[
            'household_head_age_18_20']
        csv_household_size_4_reference_35_39 = headage_distro_csv_df[
            'household_head_age_35_39'][5]

        self.assertTrue(
            csv_household_age_18_20_weights.equals(
                csv_household_age_18_20_weights),
            msg="household_head_age_18_20 columns should be the same")

        self.assertEqual(csv_household_size_4_reference_35_39,
                         dat_household_size_4_reference_35_39,
                         msg="Each cell in the data table should be identical")
Esempio n. 2
0
def test_get_head_age_by_size_path():
    hha_by_size = spdd.get_household_head_age_by_size_path(
        datadir,
        state_location=state_location,
        country_location=country_location)
    assert hha_by_size is not None