MCPcopy
hub / github.com/numpy/numpy / test_outliers

Method test_outliers

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

Source from the content-addressed store, hash-verified

79 assert_equal(counts, [.25, 0])
80
81 def test_outliers(self):
82 # Check that outliers are not tallied
83 a = np.arange(10) + .5
84
85 # Lower outliers
86 h, b = histogram(a, range=[0, 9])
87 assert_equal(h.sum(), 9)
88
89 # Upper outliers
90 h, b = histogram(a, range=[1, 10])
91 assert_equal(h.sum(), 9)
92
93 # Normalization
94 h, b = histogram(a, range=[1, 9], density=True)
95 assert_almost_equal((h * np.diff(b)).sum(), 1, decimal=15)
96
97 # Weights
98 w = np.arange(10) + .5
99 h, b = histogram(a, range=[1, 9], weights=w, density=True)
100 assert_equal((h * np.diff(b)).sum(), 1)
101
102 h, b = histogram(a, bins=8, range=[1, 9], weights=w)
103 assert_equal(h, w[1:-1])
104
105 def test_arr_weights_mismatch(self):
106 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