def test_keep_existing_small_cols(self): ''' test that columns that already exist in df_small are retained''' df_large, df_small = load_dfs('reference.shp', 'keep.shp') large_cols = ['large_str'] small_cols = ['col_str'] df = distribute_label(df_large, large_cols, df_small, small_cols) check_df(df, ['col_str', 'keep_col'])
def test_reset_small_cols(self): ''' test that prior duplicate columns in df_small will be deleted''' df_large, df_small = load_dfs('reference.shp', 'reset.shp') large_cols = ['large_str', 'large_int', 'large_flt'] # Apply and test df = distribute_label(df_large, large_cols, df_small) check_df(df, large_cols, True)
def test_default_small_cols(self): ''' test that the default columns work. This will just use all of the large_cols''' df_large, df_small = load_dfs('reference.shp', 'within.shp') large_cols = ['large_str', 'large_int', 'large_flt'] # Apply and test df = distribute_label(df_large, large_cols, df_small) check_df(df, large_cols, True)
def test_centroid(self): ''' Check label distribution when bounding box does not intersect with any larger geometry''' df_large, df_small = load_dfs('reference.shp', 'centroid.shp') large_cols = ['large_str'] small_cols = ['col_str'] # Apply and test df = distribute_label(df_large, large_cols, df_small, small_cols) check_df(df, small_cols)
def test_shared(self): ''' Check label distribution when bounding box interesects with multiple larger geometries''' df_large, df_small = load_dfs('reference.shp', 'shared.shp') large_cols = ['large_str'] small_cols = ['col_str'] # Apply and test df = distribute_label(df_large, large_cols, df_small, small_cols) check_df(df, small_cols)
def test_within(self): ''' Check label distribution when bounding box intersection is with only one large geometry''' df_large, df_small = load_dfs('reference.shp', 'within.shp') large_cols = ['large_str'] small_cols = ['col_str'] # Apply and test df = distribute_label(df_large, large_cols, df_small, small_cols) check_df(df, small_cols)
def test_attribute_subset(self): ''' Check that False is returned when the an element of large_cols is not in the dataframe itself''' # load dataframe df_large, df_small = load_dfs('reference.shp', 'within.shp') # Get same length column sizes large_cols = df_large.columns large_cols = [x + 'foo' for x in large_cols] df = distribute_label(df_large, large_cols, df_small) assert df == False
def test_attribute_list_size_comparison(self): ''' Check that False is returned when the size of attribute lists are not of the same length''' # load df_large, df_small = load_dfs('reference.shp', 'within.shp') # Get different length column sizes large_cols = df_large.columns small_cols = ['a'] df = distribute_label(df_large, large_cols, df_small, small_cols) assert df == False