Esempio n. 1
0
def test_unmoving_at_reference_location_column_names(
        get_column_names_from_run):
    assert get_column_names_from_run(
        UnmovingAtReferenceLocation(
            locations=UniqueLocations(
                SubscriberLocations(
                    "2016-01-01",
                    "2016-01-01 10:00",
                    spatial_unit=make_spatial_unit("admin", level=3),
                )),
            reference_locations=LastLocation("2016-01-01", "2016-01-02"),
        )) == ["subscriber", "value"]
Esempio n. 2
0
def test_unmoving_at_reference_location_values(get_dataframe):
    df = get_dataframe(
        UnmovingAtReferenceLocation(
            locations=UniqueLocations(
                SubscriberLocations(
                    "2016-01-01",
                    "2016-01-01 10:00",
                    spatial_unit=make_spatial_unit("admin", level=3),
                )),
            reference_locations=LastLocation("2016-01-01", "2016-01-02"),
        )).set_index("subscriber")
    assert not df.loc["038OVABN11Ak4W5P"].value
    assert df.loc["3XKdxqvyNxO2vLD1"].value
Esempio n. 3
0
def test_spatial_unit_mismatch_error():
    with pytest.raises(ValueError, match="Spatial unit mismatch"):
        UnmovingAtReferenceLocation(
            locations=UniqueLocations(
                SubscriberLocations(
                    "2016-01-01",
                    "2016-01-01 10:00",
                    spatial_unit=make_spatial_unit("admin", level=2),
                )),
            reference_locations=LastLocation(
                "2016-01-01",
                "2016-01-02",
                spatial_unit=make_spatial_unit("admin", level=3),
            ),
        )
Esempio n. 4
0
    def _flowmachine_query_obj(self):
        """
        Return the underlying flowmachine object.

        Returns
        -------
        Query
        """
        return RedactedUnmovingAtReferenceLocationCounts(
            unmoving_at_reference_location_counts=
            UnmovingAtReferenceLocationCounts(
                UnmovingAtReferenceLocation(
                    locations=self.locations._flowmachine_query_obj,
                    reference_locations=self.reference_locations.
                    _flowmachine_query_obj,
                )))
Esempio n. 5
0
def test_unmoving_at_reference_location_counts_values(get_dataframe):
    df = get_dataframe(
        UnmovingAtReferenceLocationCounts(
            UnmovingAtReferenceLocation(
                locations=UniqueLocations(
                    SubscriberLocations(
                        "2016-01-01",
                        "2016-01-01 10:00",
                        spatial_unit=make_spatial_unit("admin", level=1),
                    )),
                reference_locations=LastLocation(
                    "2016-01-01",
                    "2016-01-02",
                    spatial_unit=make_spatial_unit("admin", level=1),
                ),
            ))).set_index("pcod")
    assert df.loc["524 1"].value == 2
    assert df.loc["524 4"].value == 26
def test_unmoving_at_reference_location_counts_column_names(
        get_column_names_from_run):
    assert (get_column_names_from_run(
        RedactedUnmovingAtReferenceLocationCounts(
            unmoving_at_reference_location_counts=
            UnmovingAtReferenceLocationCounts(
                UnmovingAtReferenceLocation(
                    locations=UniqueLocations(
                        SubscriberLocations(
                            "2016-01-01",
                            "2016-01-01 10:00",
                            spatial_unit=make_spatial_unit("admin", level=1),
                        )),
                    reference_locations=LastLocation(
                        "2016-01-01",
                        "2016-01-02",
                        spatial_unit=make_spatial_unit("admin", level=1),
                    ),
                )))) == ["pcod", "value"])
 def __init__(self,
              unmoving_at_reference_location: UnmovingAtReferenceLocation):
     self.unmoving_subscribers = unmoving_at_reference_location.subset(
         "value", True)
     self.spatial_unit = unmoving_at_reference_location.spatial_unit
     super().__init__()