def test_rad_call(): data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None) assert data.inequality("rad") == 0.2600392437248902
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
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)
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)
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)
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
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
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)
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)
def test_sdlog_call(): data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None) assert data.inequality("sdlog") == 1.057680329912003
def test_merhan_call(): data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None) assert data.inequality("merhan") == 0.5068579435513223
def test_sdlog_method(): data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None) assert data.inequality.sdlog() == 1.057680329912003
def test_cv_call(): data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None) assert data.inequality("cv") == 0.5933902127888603
def test_cv_method(): data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None) assert data.inequality.cv() == 0.5933902127888603
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)
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)
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)
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
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)
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
def test_invalid(): data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None) with pytest.raises(AttributeError): data.concentration("foo")
def test_kolm_call(): data = datasets.make_uniform(seed=42, size=300, mu=1, nbin=None) assert data.inequality("kolm", alpha=1) == 0.04278027786607911
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
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
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
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
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
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
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
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