Exemplo n.º 1
0
def test_gini_values(income_arrays, inequality_results):
    ad1 = ApodeData(income_arrays, income_column="y1")
    ad2 = ApodeData(income_arrays, income_column="y2")
    ad3 = ApodeData(income_arrays, income_column="y3")
    ad4 = ApodeData(income_arrays, income_column="y4")
    ad5 = ApodeData(income_arrays, income_column="y5")
    ad6 = ApodeData(income_arrays, income_column="y6")
    # Relative tets modified (avoid division by zero):
    #  test = ((val1+1)-(val2+1))/(val1+1)
    np.testing.assert_allclose(ad1.inequality.gini() + 1,
                               inequality_results.gini[0] + 1)
    np.testing.assert_allclose(ad2.inequality.gini(),
                               inequality_results.gini[1])
    np.testing.assert_allclose(ad3.inequality.gini(),
                               inequality_results.gini[2])
    np.testing.assert_allclose(ad4.inequality.gini(),
                               inequality_results.gini[3])
    np.testing.assert_allclose(ad5.inequality.gini(),
                               inequality_results.gini[4])
    np.testing.assert_allclose(ad6.inequality.gini(),
                               inequality_results.gini[5])
Exemplo n.º 2
0
 def make(*, seed, **kwargs):
     random = np.random.RandomState(seed=seed)
     x = random.uniform(**kwargs)
     df1 = pd.DataFrame({"x": x})
     return ApodeData(df1, varx="x")
Exemplo n.º 3
0
def test_herfindahl_empty_array():
    y = []
    df = pd.DataFrame({"x": y})
    data = ApodeData(df, income_column="x")
    assert data.concentration.herfindahl() == 0
Exemplo n.º 4
0
def test_gini_empty_array():
    y = []
    df = pd.DataFrame({"x": y})
    data = ApodeData(df, income_column="x")
    assert data.inequality.gini() == 0
Exemplo n.º 5
0
def test_ratio_empty_array():
    y = []
    df = pd.DataFrame({"x": y})
    data = ApodeData(df, income_column="x")
    assert data.inequality.ratio(alpha=0.5) == 0
Exemplo n.º 6
0
def test_kolm_empty_array():
    y = []
    df = pd.DataFrame({"x": y})
    data = ApodeData(df, income_column="x")
    assert data.inequality.kolm(alpha=1) == 0
Exemplo n.º 7
0
def test_gini_size_one_array():
    y = [2]
    df = pd.DataFrame({"x": y})
    ad = ApodeData(df, income_column="x")
    assert ad.inequality.gini() == 0
Exemplo n.º 8
0
def test_atkinson_size_one_array():
    y = [2]
    df = pd.DataFrame({"x": y})
    ad = ApodeData(df, income_column="x")
    assert ad.inequality.atkinson(alpha=1) == 0
Exemplo n.º 9
0
def test_takayama_avoid_zero_div_error():
    # u = 0
    df = pd.DataFrame({"x": np.zeros(10)})
    ad = ApodeData(df, income_column="x")
    pline = 0.2
    assert ad.poverty.takayama(pline=pline) == 0
Exemplo n.º 10
0
def test_hagenaars_q_zero():
    df = pd.DataFrame({"x": np.arange(1, 12)})
    ad = ApodeData(df, income_column="x")
    pline = np.min(ad.data.values) - 0.1
    assert ad.poverty.hagenaars(pline=pline) == 0