Ejemplo n.º 1
0
def test_redacted_unique_visitor_counts(get_dataframe):
    """
    Values test for redacted unique visitor counts.
    """
    activity = RedactedUniqueVisitorCounts(
        unique_visitor_counts=UniqueVisitorCounts(
            ActiveAtReferenceLocationCounts(
                ActiveAtReferenceLocation(
                    subscriber_locations=UniqueLocations(
                        SubscriberLocations(
                            "2016-01-01",
                            "2016-01-02",
                            spatial_unit=make_spatial_unit("admin", level=3),
                        )),
                    reference_locations=daily_location("2016-01-03"),
                )),
            UniqueSubscriberCounts(
                "2016-01-01",
                "2016-01-02",
                spatial_unit=make_spatial_unit("admin", level=3),
            ),
        ))
    df = get_dataframe(activity).set_index("pcod")
    assert len(df) == 2
    assert df.loc["524 3 08 44"].value == 170
Ejemplo n.º 2
0
def test_unique_locations_column_names(get_column_names_from_run):
    assert get_column_names_from_run(
        UniqueLocations(
            SubscriberLocations(
                "2016-01-01",
                "2016-01-02",
                spatial_unit=make_spatial_unit("admin", level=3),
            ))) == ["subscriber", "pcod"]
Ejemplo n.º 3
0
def test_active_at_reference_location_column_names(get_column_names_from_run):
    assert (get_column_names_from_run(
        ActiveAtReferenceLocation(
            subscriber_locations=UniqueLocations(
                SubscriberLocations(
                    "2016-01-01",
                    "2016-01-02",
                    spatial_unit=make_spatial_unit("admin", level=3),
                )),
            reference_locations=daily_location("2016-01-03"),
        )) == ["subscriber", "value"])
def test_redacted_active_at_reference_location_counts_column_names(
    get_column_names_from_run, ):
    assert get_column_names_from_run(
        RedactedActiveAtReferenceLocationCounts(
            active_at_reference_location_counts=ActiveAtReferenceLocationCounts(
                ActiveAtReferenceLocation(
                    subscriber_locations=UniqueLocations(
                        SubscriberLocations(
                            "2016-01-01",
                            "2016-01-02",
                            spatial_unit=make_spatial_unit("admin", level=3),
                        )),
                    reference_locations=daily_location("2016-01-03"),
                )))) == ["pcod", "value"]
Ejemplo n.º 5
0
def test_active_at_reference_location(get_dataframe):
    """
    Values test for active at reference location.
    """
    activity = ActiveAtReferenceLocation(
        subscriber_locations=UniqueLocations(
            SubscriberLocations(
                "2016-01-01",
                "2016-01-02",
                spatial_unit=make_spatial_unit("admin", level=3),
            )),
        reference_locations=daily_location("2016-01-03"),
    )
    df = get_dataframe(activity).set_index("subscriber")
    assert not df.loc["038OVABN11Ak4W5P"][0]
    assert df.loc["09NrjaNNvDanD8pk"][0]
Ejemplo n.º 6
0
def test_active_at_reference_location_counts(get_dataframe):
    """
    Values test for active at reference location counts.
    """
    activity = ActiveAtReferenceLocationCounts(
        ActiveAtReferenceLocation(
            subscriber_locations=UniqueLocations(
                SubscriberLocations(
                    "2016-01-01",
                    "2016-01-02",
                    spatial_unit=make_spatial_unit("admin", level=3),
                )),
            reference_locations=daily_location("2016-01-03"),
        ))
    df = get_dataframe(activity).set_index("pcod")
    assert df.loc["524 1 01 04"][0] == 1
Ejemplo n.º 7
0
    def _unsampled_query_obj(self):
        """
        Return the underlying flowmachine unique locations object.

        Returns
        -------
        Query
        """
        return UniqueLocations(
            SubscriberLocations(
                self.start_date,
                self.end_date,
                spatial_unit=self.aggregation_unit,
                table=self.event_types,
                subscriber_subset=self.subscriber_subset,
            )
        )
Ejemplo n.º 8
0
def test_unique_locations(get_dataframe):
    """
    Values test for unique locations.
    """
    unique_locs = UniqueLocations(
        SubscriberLocations(
            "2016-01-01",
            "2016-01-02",
            spatial_unit=make_spatial_unit("admin", level=3),
        ))
    df = get_dataframe(unique_locs).set_index("subscriber")
    assert df.loc["038OVABN11Ak4W5P"].pcod.tolist() == [
        "524 2 04 20",
        "524 3 08 43",
        "524 4 12 62",
        "524 4 12 65",
    ]
def test_unique_visitor_counts_column_names(get_column_names_from_run):
    assert (get_column_names_from_run(
        UniqueVisitorCounts(
            ActiveAtReferenceLocationCounts(
                ActiveAtReferenceLocation(
                    subscriber_locations=UniqueLocations(
                        SubscriberLocations(
                            "2016-01-01",
                            "2016-01-02",
                            spatial_unit=make_spatial_unit("admin", level=3),
                        )),
                    reference_locations=daily_location("2016-01-03"),
                )),
            UniqueSubscriberCounts(
                "2016-01-01",
                "2016-01-02",
                spatial_unit=make_spatial_unit("admin", level=3),
            ),
        )) == ["pcod", "value"])
def test_redacted_active_at_reference_location_counts(get_dataframe):
    """
    Values test for redacted active at reference location counts.
    """
    activity = RedactedActiveAtReferenceLocationCounts(
        active_at_reference_location_counts=ActiveAtReferenceLocationCounts(
            ActiveAtReferenceLocation(
                subscriber_locations=UniqueLocations(
                    SubscriberLocations(
                        "2016-01-01",
                        "2016-01-02",
                        spatial_unit=make_spatial_unit("admin", level=3),
                    )),
                reference_locations=daily_location("2016-01-03"),
            )))
    df = get_dataframe(activity).set_index("pcod")
    assert all(df.value > 15)
    assert len(df) == 2
    assert df.loc["524 3 08 44"].value == 25