예제 #1
0
def test_watts_replication():
    ad = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    k = 2  # factor
    pline = np.mean(ad.data.values)
    y = k * ad.data["x"].tolist()
    df2 = pd.DataFrame({"x": y})
    ad2 = ApodeData(df2, income_column="x")
    np.testing.assert_allclose(ad.poverty("watts", pline=pline),
                               ad2.poverty("watts", pline=pline))
예제 #2
0
def test_watts_symmetry():
    ad = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    pline = np.mean(ad.data.values)
    y = ad.data["x"].tolist()
    np.random.shuffle(y)
    df2 = pd.DataFrame({"x": y})
    ad2 = ApodeData(df2, income_column="x")
    assert ad.poverty(method="watts",
                      pline=pline) == ad2.poverty(method="watts", pline=pline)
예제 #3
0
def test_headcount_replication():
    ad = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    k = 2  # factor
    pline = np.mean(ad.data.values)
    y = k * ad.data["x"].tolist()
    df2 = pd.DataFrame({"x": y})
    ad2 = ApodeData(df2, income_column="x")
    assert ad.poverty("headcount", pline=pline) == ad2.poverty("headcount",
                                                               pline=pline)
예제 #4
0
def test_hagenaars_symmetry():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    pline = np.mean(data.data.values)
    y = data.data["x"].tolist()
    np.random.shuffle(y)
    df2 = pd.DataFrame({"x": y})
    dr2 = ApodeData(df2, income_column="x")
    assert data.poverty(method="hagenaars",
                        pline=pline) == dr2.poverty(method="hagenaars",
                                                    pline=pline)
예제 #5
0
def test_bd_homogeneity():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    k = 2  # factor
    pline = np.mean(data.data.values)
    y = data.data["x"].tolist()
    y = [yi * k for yi in y]
    df2 = pd.DataFrame({"x": y})
    dr2 = ApodeData(df2, income_column="x")
    assert data.poverty("bd", pline=pline) == dr2.poverty("bd",
                                                          pline=pline * k)
예제 #6
0
def test_thon_homogeneity():
    ad = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    k = 2  # factor
    pline = np.mean(ad.data.values)
    y = ad.data["x"].tolist()
    y = [yi * k for yi in y]
    df2 = pd.DataFrame({"x": y})
    ad2 = ApodeData(df2, income_column="x")
    assert ad.poverty("thon", pline=pline) == ad2.poverty("thon",
                                                          pline=pline * k)
예제 #7
0
def test_severity_replication():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    k = 2  # factor
    pline = np.mean(data.data.values)
    y = k * data.data["x"].tolist()
    df2 = pd.DataFrame({"x": y})
    dr2 = ApodeData(df2, income_column="x")
    np.testing.assert_allclose(
        data.poverty("severity", pline=pline),
        dr2.poverty("severity", pline=pline),
    )