def test_construct_signals_proportions(self):
     """Tests that constructed signals are actual proportions."""
     cbg_df = construct_signals(pd.read_csv('raw_data/sample_raw_data.csv'),
                                SIGNALS)
     assert np.all(cbg_df['completely_home_prop'].values <= 1)
     assert np.all(cbg_df['full_time_work_prop'].values <= 1)
     assert np.all(cbg_df['part_time_work_prop'].values <= 1)
 def test_construct_signals_present(self):
     """Tests that all signals are constructed."""
     cbg_df = construct_signals(pd.read_csv('raw_data/sample_raw_data.csv'),
                                SIGNALS)
     assert 'completely_home_prop' in set(cbg_df.columns)
     assert 'full_time_work_prop' in set(cbg_df.columns)
     assert 'part_time_work_prop' in set(cbg_df.columns)
     assert 'median_home_dwell_time' in set(cbg_df.columns)
    def test_aggregate_hhs(self):
        """Tests that aggregation at the state level creates non-zero-valued signals."""
        cbg_df = construct_signals(pd.read_csv('raw_data/sample_raw_data.csv'),
                                   SIGNALS)
        df = aggregate(cbg_df, SIGNALS, 'hhs')

        assert np.all(df[f'{SIGNALS[0]}_n'].values > 0)
        x = df[f'{SIGNALS[0]}_se'].values
        assert np.all(x[~np.isnan(x)] >= 0)
        assert df.shape == (10, 17)