MCPcopy Create free account
hub / github.com/numpy/numpy / test_outliers

Method test_outliers

numpy/lib/tests/test_histograms.py:74–96  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

72 assert_equal(counts, [.25, 0])
73
74 def test_outliers(self):
75 # Check that outliers are not tallied
76 a = np.arange(10) + .5
77
78 # Lower outliers
79 h, b = histogram(a, range=[0, 9])
80 assert_equal(h.sum(), 9)
81
82 # Upper outliers
83 h, b = histogram(a, range=[1, 10])
84 assert_equal(h.sum(), 9)
85
86 # Normalization
87 h, b = histogram(a, range=[1, 9], density=True)
88 assert_almost_equal((h * np.diff(b)).sum(), 1, decimal=15)
89
90 # Weights
91 w = np.arange(10) + .5
92 h, b = histogram(a, range=[1, 9], weights=w, density=True)
93 assert_equal((h * np.diff(b)).sum(), 1)
94
95 h, b = histogram(a, bins=8, range=[1, 9], weights=w)
96 assert_equal(h, w[1:-1])
97
98 def test_arr_weights_mismatch(self):
99 a = np.arange(10) + .5

Callers

nothing calls this directly

Calls 4

histogramFunction · 0.90
assert_equalFunction · 0.90
assert_almost_equalFunction · 0.90
sumMethod · 0.45

Tested by

no test coverage detected