(self)
| 175 | assert_almost_equal(a, [.2, .1, .1, .075]) |
| 176 | |
| 177 | def test_exotic_weights(self): |
| 178 | |
| 179 | # Test the use of weights that are not integer or floats, but e.g. |
| 180 | # complex numbers or object types. |
| 181 | |
| 182 | # Complex weights |
| 183 | values = np.array([1.3, 2.5, 2.3]) |
| 184 | weights = np.array([1, -1, 2]) + 1j * np.array([2, 1, 2]) |
| 185 | |
| 186 | # Check with custom bins |
| 187 | wa, wb = histogram(values, bins=[0, 2, 3], weights=weights) |
| 188 | assert_array_almost_equal(wa, np.array([1, 1]) + 1j * np.array([2, 3])) |
| 189 | |
| 190 | # Check with even bins |
| 191 | wa, wb = histogram(values, bins=2, range=[1, 3], weights=weights) |
| 192 | assert_array_almost_equal(wa, np.array([1, 1]) + 1j * np.array([2, 3])) |
| 193 | |
| 194 | # Decimal weights |
| 195 | from decimal import Decimal |
| 196 | values = np.array([1.3, 2.5, 2.3]) |
| 197 | weights = np.array([Decimal(1), Decimal(2), Decimal(3)]) |
| 198 | |
| 199 | # Check with custom bins |
| 200 | wa, wb = histogram(values, bins=[0, 2, 3], weights=weights) |
| 201 | assert_array_almost_equal(wa, [Decimal(1), Decimal(5)]) |
| 202 | |
| 203 | # Check with even bins |
| 204 | wa, wb = histogram(values, bins=2, range=[1, 3], weights=weights) |
| 205 | assert_array_almost_equal(wa, [Decimal(1), Decimal(5)]) |
| 206 | |
| 207 | def test_no_side_effects(self): |
| 208 | # This is a regression test that ensures that values passed to |
nothing calls this directly
no test coverage detected