Skip to content

Commit

Permalink
Added unit tests for cumulative histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jun 19, 2018
1 parent fc3670b commit 0edd7aa
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/operation/testoperation.py
Expand Up @@ -127,6 +127,35 @@ def test_points_histogram_bin_range(self):
hist = Histogram(([0.25, 0.25, 0.5], [0., 1., 2., 3.]))
self.assertEqual(op_hist, hist)

def test_points_histogram_explicit_bins(self):
points = Points([float(i) for i in range(10)])
op_hist = histogram(points, bins=[0, 1, 3], normed=False)

# Make sure that the name and label are as desired
op_freq_dim = op_hist.get_dimension('x_frequency')
self.assertEqual(op_freq_dim.label, 'x Frequency')

# Because the operation labels are now different from the
# default Element label, change back before comparing.
op_hist = op_hist.redim(x_frequency='Frequency')
hist = Histogram(([0, 1, 3], [1, 3]))
self.assertEqual(op_hist, hist)

def test_points_histogram_cumulative(self):
arr = np.arange(4)
points = Points(arr)
op_hist = histogram(points, cumulative=True, num_bins=3, normed=False)

# Make sure that the name and label are as desired
op_freq_dim = op_hist.get_dimension('x_frequency')
self.assertEqual(op_freq_dim.label, 'x Frequency')

# Because the operation labels are now different from the
# default Element label, change back before comparing.
op_hist = op_hist.redim(x_frequency='Frequency')
hist = Histogram(([0, 1, 2, 3], [1, 2, 4]))
self.assertEqual(op_hist, hist)

def test_points_histogram_not_normed(self):
points = Points([float(i) for i in range(10)])
op_hist = histogram(points, num_bins=3, normed=False)
Expand Down

0 comments on commit 0edd7aa

Please sign in to comment.