Example #1
0
 def test_nonsense(self):
     arr = np.array([[0, 1], [0.1, 2.1]])
     with pytest.raises(RuntimeError):
         bin_utils.to_numpy_bins_with_mask(arr)
     arr = np.array([[[0, 1], [0.1, 2.1]], [[0, 1], [0.1, 2.1]]])
     with pytest.raises(RuntimeError):
         bin_utils.to_numpy_bins_with_mask(arr)
Example #2
0
 def test_unconsecutive(self):
     arr = np.array([[0, 1], [1.1, 2.1]])
     edges, mask = bin_utils.to_numpy_bins_with_mask(arr)
     assert np.array_equal(edges, [0, 1, 1.1, 2.1])
     assert np.array_equal(mask, [0, 2])
Example #3
0
 def test_numpy_style(self):
     arr = np.array([1, 2, 3.1, 4])
     edges, mask = bin_utils.to_numpy_bins_with_mask(arr)
     assert np.array_equal(edges, [1, 2, 3.1, 4])
     assert np.array_equal(mask, [0, 1, 2])