コード例 #1
0
 def test_simple(self):
     bins = [[0, 1, 2], [0, 1, 2]]
     schemas = [binnings.static_binning(None, np.asarray(bs)) for bs in bins]
     frequencies, errors2, missing = histogram_nd.calculate_frequencies(vals, ndim=2, binnings=schemas)
     assert np.array_equal([[1, 3], [0, 1]], frequencies)
     assert missing == 2
     assert np.array_equal(errors2, frequencies)
コード例 #2
0
 def test_errors(self):
     bins = [
         [[-1, 0], [1, 2]],
         [[-2, -1], [1, 2]]
     ]
     weights = [2, 1, 1, 1, 1, 2, 1]
     schemas = [binnings.static_binning(None, np.asarray(bs)) for bs in bins]
     frequencies, errors2, missing = histogram_nd.calculate_frequencies(vals, ndim=2, binnings=schemas, weights=weights)
     # frequencies, errors2, missing = histogram_nd.calculate_frequencies(vals, ndim=2, bins=bins, weights=weights)
     assert np.array_equal([[0, 0], [0, 2]], frequencies)
     assert missing == 7
     assert np.array_equal([[0, 0], [0, 4]], errors2)