コード例 #1
0
def test_rad_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    assert data.inequality("rad") == 0.2600392437248902
コード例 #2
0
def test_gap_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    pline = 0.5 * np.median(data.data.values)
    assert data.poverty("gap", pline=pline) == 0.13715275200855706
コード例 #3
0
def test_gap_valid_pline():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    with pytest.raises(ValueError):
        data.poverty("gap", pline=-1)
コード例 #4
0
def test_herfindahl_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    assert (data.concentration("herfindahl",
                               normalized=True) == 0.0011776319218515382)
    assert (data.concentration("herfindahl",
                               normalized=False) == 0.004507039815445367)
コード例 #5
0
def test_rosenbluth_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    np.testing.assert_allclose(data.concentration("rosenbluth"),
                               0.00506836225627098)
コード例 #6
0
def test_concentration_ratio_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    assert data.concentration.concentration_ratio(k=20) == 0.12913322818634668
コード例 #7
0
def test_concentration_ratio_call_equal_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    call_result = data.concentration("concentration_ratio", k=20)
    method_result = data.concentration.concentration_ratio(k=20)
    assert call_result == method_result
コード例 #8
0
def test_gini_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    np.testing.assert_allclose(data.inequality("gini"), 0.34232535781966483)
コード例 #9
0
def test_bonferroni_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    np.testing.assert_allclose(data.inequality("bonferroni"),
                               0.507498668487682)
コード例 #10
0
def test_sdlog_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    assert data.inequality("sdlog") == 1.057680329912003
コード例 #11
0
def test_merhan_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    assert data.inequality("merhan") == 0.5068579435513223
コード例 #12
0
def test_sdlog_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    assert data.inequality.sdlog() == 1.057680329912003
コード例 #13
0
def test_cv_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    assert data.inequality("cv") == 0.5933902127888603
コード例 #14
0
def test_cv_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    assert data.inequality.cv() == 0.5933902127888603
コード例 #15
0
def test_ratio_invalid_alpha():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    with pytest.raises(ValueError):
        data.inequality.ratio(alpha=-1)
    with pytest.raises(ValueError):
        data.inequality.ratio(alpha=2)
コード例 #16
0
def test_piesch_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    np.testing.assert_allclose(data.inequality("piesch"), 0.25015872424726393)
コード例 #17
0
def test_entropy_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    np.testing.assert_allclose(data.inequality.entropy(), 0.3226715241069237)
コード例 #18
0
def test_piesch_call_equal_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    call_result = data.inequality("piesch")
    method_result = data.inequality.piesch()
    assert call_result == method_result
コード例 #19
0
def test_concentration_ratio_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    assert (data.concentration("concentration_ratio",
                               k=20) == 0.12913322818634668)
コード例 #20
0
def test_gini_call_equal_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    call_result = data.inequality("gini")
    method_result = data.inequality.gini()
    assert call_result == method_result
コード例 #21
0
def test_invalid():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    with pytest.raises(AttributeError):
        data.concentration("foo")
コード例 #22
0
def test_kolm_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    assert data.inequality("kolm", alpha=1) == 0.04278027786607911
コード例 #23
0
def test_herfindahl_call_equal_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    call_result = data.concentration("herfindahl")
    method_result = data.concentration.herfindahl()
    assert call_result == method_result
コード例 #24
0
def test_kolm_call_equal_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    call_result = data.inequality("kolm", alpha=1)
    method_result = data.inequality.kolm(alpha=1)
    assert call_result == method_result
コード例 #25
0
def test_rosenbluth_call_equal_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    call_result = data.concentration("rosenbluth")
    method_result = data.concentration.rosenbluth()
    assert call_result == method_result
コード例 #26
0
def test_ratio_call():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    assert data.inequality("ratio", alpha=0.5) == 0.31651799363507865
コード例 #27
0
def test_gap_call_equal_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    pline = 0.5 * np.median(data.data.values)
    call_result = data.poverty("gap", pline=pline)
    method_result = data.poverty.gap(pline=pline)
    assert call_result == method_result
コード例 #28
0
def test_ratio_call_equal_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    call_result = data.inequality("ratio", alpha=0.5)
    method_result = data.inequality.ratio(alpha=0.5)
    assert call_result == method_result
コード例 #29
0
def test_gap_extreme_values():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    pline_min = np.min(data.data.values) / 2
    pline_max = np.max(data.data.values) + 1
    assert data.poverty("gap", pline=pline_min) == 0
    assert data.poverty("gap", pline=pline_max) <= 1
コード例 #30
0
def test_rrange_call_equal_method():
    data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None)
    call_result = data.inequality("rrange")
    method_result = data.inequality.rrange()
    assert call_result == method_result