(self)
| 274 | np.histogram([np.array(0.5) for i in range(10)] + [.5]) |
| 275 | |
| 276 | def test_some_nan_values(self): |
| 277 | # gh-7503 |
| 278 | one_nan = np.array([0, 1, np.nan]) |
| 279 | all_nan = np.array([np.nan, np.nan]) |
| 280 | |
| 281 | # the internal comparisons with NaN give warnings |
| 282 | sup = suppress_warnings() |
| 283 | sup.filter(RuntimeWarning) |
| 284 | with sup: |
| 285 | # can't infer range with nan |
| 286 | assert_raises(ValueError, histogram, one_nan, bins='auto') |
| 287 | assert_raises(ValueError, histogram, all_nan, bins='auto') |
| 288 | |
| 289 | # explicit range solves the problem |
| 290 | h, b = histogram(one_nan, bins='auto', range=(0, 1)) |
| 291 | assert_equal(h.sum(), 2) # nan is not counted |
| 292 | h, b = histogram(all_nan, bins='auto', range=(0, 1)) |
| 293 | assert_equal(h.sum(), 0) # nan is not counted |
| 294 | |
| 295 | # as does an explicit set of bins |
| 296 | h, b = histogram(one_nan, bins=[0, 1]) |
| 297 | assert_equal(h.sum(), 2) # nan is not counted |
| 298 | h, b = histogram(all_nan, bins=[0, 1]) |
| 299 | assert_equal(h.sum(), 0) # nan is not counted |
| 300 | |
| 301 | def test_datetime(self): |
| 302 | begin = np.datetime64('2000-01-01', 'D') |
nothing calls this directly
no test coverage detected