示例#1
0
def test_unmoving_column_names(get_column_names_from_run):
    assert (get_column_names_from_run(
        Unmoving(locations=UniqueLocations(
            SubscriberLocations(
                "2016-01-01",
                "2016-01-01 10:00",
                spatial_unit=make_spatial_unit("admin", level=3),
            )))) == ["subscriber", "value"])
def test_unmoving_counts_column_names(get_column_names_from_run):
    assert get_column_names_from_run(
        RedactedUnmovingCounts(unmoving_counts=UnmovingCounts(
            Unmoving(locations=UniqueLocations(
                SubscriberLocations(
                    "2016-01-01",
                    "2016-01-01 10:00",
                    spatial_unit=make_spatial_unit("admin", level=3),
                )))))) == ["pcod", "value"]
示例#3
0
def test_unmoving_values(get_dataframe):
    df = get_dataframe(
        Unmoving(locations=UniqueLocations(
            SubscriberLocations(
                "2016-01-01",
                "2016-01-01 10:00",
                spatial_unit=make_spatial_unit("admin", level=3),
            )))).set_index("subscriber")
    assert not df.loc["038OVABN11Ak4W5P"].value
    assert df.loc["0Gl95NRLjW2aw8pW"].value
示例#4
0
    def _flowmachine_query_obj(self):
        """
        Return the underlying flowmachine object.

        Returns
        -------
        Query
        """
        return RedactedUnmovingCounts(unmoving_counts=UnmovingCounts(
            Unmoving(self.locations._flowmachine_query_obj)))
示例#5
0
def test_unmoving_counts_values(get_dataframe):
    df = get_dataframe(
        UnmovingCounts(
            Unmoving(locations=UniqueLocations(
                SubscriberLocations(
                    "2016-01-01",
                    "2016-01-01 10:00",
                    spatial_unit=make_spatial_unit("admin", level=3),
                ))))).set_index("pcod")
    assert df.loc["524 1 02 09"].value == 5
    assert df.loc["524 2 04 20"].value == 7
def test_unmoving_counts_values(get_dataframe):
    df = get_dataframe(
        RedactedUnmovingCounts(unmoving_counts=UnmovingCounts(
            Unmoving(locations=UniqueLocations(
                SubscriberLocations(
                    "2016-01-01",
                    "2016-01-01 10:00",
                    spatial_unit=make_spatial_unit("admin", level=2),
                )))))).set_index("pcod")
    with pytest.raises(KeyError):
        assert df.loc["524 1 02"].value
    assert df.loc["524 4 12"].value == 29
示例#7
0
 def __init__(self, unmoving: Unmoving):
     self.unmoving_subscribers = unmoving.subset("value", True)
     self.spatial_unit = unmoving.spatial_unit
     super().__init__()