def test_custom_labels(self, example_freq): """Test method with custom label of a different length""" custom_label = "doing_nothing" freq = freq_method(example_freq, "doing_nothing") example_freq["activity_label"] = None example_freq.loc[example_freq["location_id"] == 0, "activity_label"] = custom_label assert freq["activity_label"].count( ) == example_freq["activity_label"].count() assert_geodataframe_equal(example_freq, freq)
def test_default_labels(self, example_freq): """Test method with default labels""" freq = freq_method(example_freq) example_freq["activity_label"] = None example_freq.loc[example_freq["location_id"] == 0, "activity_label"] = "home" example_freq.loc[example_freq["location_id"] == 1, "activity_label"] = "work" assert freq["activity_label"].count( ) == example_freq["activity_label"].count() assert_geodataframe_equal(example_freq, freq)
def test_pre_filter(self, example_freq, default_kwargs): """Test if function calls pre_filter correctly.""" default_kwargs["agg_level"] = "user" default_kwargs["thresh_sp_at_loc"] = 2 li = location_identifier(example_freq, method="FREQ", pre_filter=True, **default_kwargs) f = pre_filter_locations(example_freq, **default_kwargs) example_freq.loc[f, "activity_label"] = freq_method( example_freq[f])["activity_label"] assert_geodataframe_equal(li, example_freq)
def test_duration(self, example_freq): """Test if function can handle only "duration" column and no columns "started_at", "finished_at".""" example_freq["duration"] = example_freq["finished_at"] - example_freq[ "started_at"] del example_freq["finished_at"] del example_freq["started_at"] freq = freq_method(example_freq) example_freq["activity_label"] = None example_freq.loc[example_freq["location_id"] == 0, "activity_label"] = "home" example_freq.loc[example_freq["location_id"] == 1, "activity_label"] = "work" assert freq["activity_label"].count( ) == example_freq["activity_label"].count() assert_geodataframe_equal(example_freq, freq)
def test_freq_method(self, example_freq): """Test if function calls freq method correctly.""" li = location_identifier(example_freq, method="FREQ", pre_filter=False) fr = freq_method(example_freq) assert_geodataframe_equal(li, fr)