Skip to content

Commit

Permalink
Unit Test Fixes
Browse files Browse the repository at this point in the history
Fixed the categorical unit test output.
Fixed a recently introduced bug in GraphBoxplot.
  • Loading branch information
cmmorrow committed Aug 16, 2018
1 parent e76cdb6 commit bba51d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
4 changes: 3 additions & 1 deletion sci_analysis/graphs/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,9 @@ def draw(self):
if self._nqp:
w_ratio.append(4 if self._circles else 1)
self._ncols += 1
groups, data = zip(*self._data.groups.items())
# This needed to be overly complex to ensure reset_index is called.
# Apparently, violinplot() doesn't like it when the index doesn't start at zero.
groups, data = zip(*[(g, v.reset_index(drop=True)) for g, v in self._data.groups.items()])

# Create the quantile plot arrays
prob = [probplot(v) for v in data]
Expand Down
24 changes: 5 additions & 19 deletions sci_analysis/test/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ def test_124_create_categorical_simple_with_simple_groups(self):
self.assertEqual(input_array.num_of_categories, 8)
self.assertListEqual([1, 2], input_array.group_names.tolist())
self.assertTrue(input_array.groups.equals(Series(groups).astype('category')))
self.assertEqual(input_array.categories.tolist(), [('b', 1), ('a', 1), ('b', 2), ('c', 1),
('c', 2), ('d', 2), ('a', 2), ('d', 1)])
self.assertEqual(input_array.categories.tolist(), ['b, 1', 'a, 1', 'b, 2', 'c, 1',
'c, 2', 'd, 2', 'a, 2', 'd, 1'])
self.assertDictEqual(input_array.counts.to_dict(), {('a', 1): 1, ('a', 2): 0, ('b', 1): 2, ('b', 2): 1,
('c', 1): 1, ('c', 2): 1, ('d', 1): 0, ('d', 2): 1})
self.assertDictEqual(input_array.ranks.to_dict(), {('a', 1): 2, ('a', 2): 3, ('b', 1): 1, ('b', 2): 2,
Expand Down Expand Up @@ -515,7 +515,7 @@ def test_127_create_categorical_simple_with_simple_groups_ordered(self):
self.assertListEqual([1, 2], input_array.group_names.tolist())
self.assertTrue(input_array.groups.equals(Series(groups).astype('category')))
self.assertEqual(input_array.categories.tolist(), [
('d', 1), ('d', 2), ('c', 1), ('c', 2), ('b', 1), ('b', 2), ('a', 1), ('a', 2)
'd, 1', 'd, 2', 'c, 1', 'c, 2', 'b, 1', 'b, 2', 'a, 1', 'a, 2'
])
self.assertDictEqual(input_array.counts.to_dict(), {('a', 1): 1, ('a', 2): 0, ('b', 1): 2, ('b', 2): 1,
('c', 1): 1, ('c', 2): 1, ('d', 1): 0, ('d', 2): 1})
Expand Down Expand Up @@ -559,14 +559,7 @@ def test_128_create_categorical_drop_missing_data_with_groups(self):
('d', 2): 1,
})
self.assertEqual(input_array.categories.tolist(), [
('b', 2),
('c', 1),
('a', 1),
('b', 1),
('d', 2),
('a', 2),
('c', 2),
('d', 1)
'b, 2', 'c, 1', 'a, 1', 'b, 1', 'd, 2', 'a, 2', 'c, 2', 'd, 1'
])
self.assertDictEqual(input_array.ranks.to_dict(), {
('a', 1): 2,
Expand Down Expand Up @@ -600,14 +593,7 @@ def test_129_create_categorical_simple_with_missing_groups(self):
self.assertListEqual(Series([1.0, 2.0]).tolist(), input_array.group_names.tolist())
self.assertTrue(input_array.groups.equals(Series(groups).astype('category')))
self.assertEqual(input_array.categories.tolist(), [
('a', 1.0),
('b', 1.0),
('c', 1.0),
('c', 2.0),
('d', 2.0),
('a', 2.0),
('b', 2.0),
('d', 1.0)
'a, 1.0', 'b, 1.0', 'c, 1.0', 'c, 2.0', 'd, 2.0', 'a, 2.0', 'b, 2.0', 'd, 1.0'
])
self.assertDictEqual(input_array.counts.to_dict(), {
('a', 1.0): 1.0,
Expand Down

0 comments on commit bba51d1

Please sign in to comment.