Esempio n. 1
0
def test_pareto(get_dataframe):
    """Test pareto proportion is correct for some hand picked subscribers."""
    p = ParetoInteractions("2016-01-01", "2016-01-02")
    assert all(
        get_dataframe(p).set_index("subscriber").loc["VkzMxYjv7mYn53oK"] ==
        0.75)

    p = ParetoInteractions("2016-01-03", "2016-01-04", direction="in")
    assert all(
        get_dataframe(p).set_index("subscriber").loc["ZM3zYAPqx95Rw15J"] == 1)

    p = ParetoInteractions("2016-01-03", "2016-01-04", direction="out")
    assert all(
        get_dataframe(p).set_index("subscriber").loc["YK6z2lXzg7w57Vap"] == 1)
Esempio n. 2
0
def test_pareto_nepal(get_dataframe):
    """Test flowmachine's method against the nepal code."""
    cb = ContactBalance("2016-01-01", "2016-01-07", exclude_self_calls=False)
    p = ParetoInteractions("2016-01-01", "2016-01-07")
    df = get_dataframe(p)
    df2 = paretos(get_dataframe(cb))
    assert all(
        df.set_index("subscriber").sort_index() == df2.set_index(
            "subscriber").sort_index())
Esempio n. 3
0
def test_pareto__call_exclusion(get_length):
    """
    Test that subscribers who only call themselves can be excluded from pareto.
    """

    pi = ParetoInteractions(
        "2016-01-01 00:00:00",
        "2016-01-01 00:00:50",
        exclude_self_calls=True,
        subscriber_subset="self_caller",
    )
    assert 0 == get_length(pi)
Esempio n. 4
0
def test_pareto__call(get_dataframe):
    """
    Test that subscribers who only call themselves get pareto 1.
    """

    pi = get_dataframe(
        ParetoInteractions(
            "2016-01-01 00:00:00",
            "2016-01-01 00:00:50",
            subscriber_subset="self_caller",
        ))
    assert 1.0 == pi.value[0]
    def _flowmachine_query_obj(self):
        """
        Return the underlying flowmachine pareto_interactions object.

        Returns
        -------
        Query
        """
        return ParetoInteractions(
            start=self.start,
            stop=self.stop,
            proportion=self.proportion,
            subscriber_subset=self.subscriber_subset,
        )
Esempio n. 6
0
    def _unsampled_query_obj(self):
        """
        Return the underlying flowmachine pareto_interactions object.

        Returns
        -------
        Query
        """
        return ParetoInteractions(
            start=self.start,
            stop=self.stop,
            proportion=self.proportion,
            tables=self.event_types,
            subscriber_subset=self.subscriber_subset,
        )
Esempio n. 7
0
def test_pareto(get_dataframe):
    """Test pareto proportion is correct for some hand picked subscribers."""
    p = ParetoInteractions("2016-01-01", "2016-01-02")
    assert all(
        get_dataframe(p).set_index("subscriber").ix["VkzMxYjv7mYn53oK"] ==
        0.75)