def test_annotate(self): suppress_plotting() f = DataFrame({ 'x': [0, 1], 'y': [0, 1], 'frame': [0, 0], 'mass': [10, 20] }) frame = np.random.randint(0, 255, (5, 5)) # Basic usage plots.annotate(f, frame) plots.annotate(f, frame, color='r') # Coloring by threshold plots.annotate(f, frame, split_category='mass', split_thresh=15, color=['r', 'g']) plots.annotate(f, frame, split_category='mass', split_thresh=[15], color=['r', 'g']) plots.annotate(f, frame, split_category='mass', split_thresh=[15, 25], color=['r', 'g', 'b']) # Check that bad parameters raise an error. # Too many colors bad_call = lambda: plots.annotate(f, frame, split_category='mass', split_thresh=15, color=['r', 'g', 'b']) self.assertRaises(bad_call) # Not enough colors bad_call = lambda: plots.annotate( f, frame, split_category='mass', split_thresh=15, color=['r']) self.assertRaises(bad_call) bad_call = lambda: plots.annotate( f, frame, split_category='mass', split_thresh=15, color='r') self.assertRaises(bad_call) # Nonexistent column name for split_category bad_call = lambda: plots.annotate(f, frame, split_category='not a column', split_thresh=15, color='r') self.assertRaises(bad_call)
def test_annotate(self): suppress_plotting() f = DataFrame({'x': [0, 1], 'y': [0, 1], 'frame': [0, 0], 'mass': [10, 20]}) frame = np.random.randint(0, 255, (5, 5)) # Basic usage plots.annotate(f, frame) plots.annotate(f, frame, color='r') # Coloring by threshold plots.annotate(f, frame, split_category='mass', split_thresh=15, color=['r', 'g']) plots.annotate(f, frame, split_category='mass', split_thresh=[15], color=['r', 'g']) plots.annotate(f, frame, split_category='mass', split_thresh=[15, 25], color=['r', 'g', 'b']) # Check that bad parameters raise an error. # Too many colors bad_call = lambda: plots.annotate( f, frame, split_category='mass', split_thresh=15, color=['r', 'g', 'b']) self.assertRaises(bad_call) # Not enough colors bad_call = lambda: plots.annotate( f, frame, split_category='mass', split_thresh=15, color=['r']) self.assertRaises(bad_call) bad_call = lambda: plots.annotate( f, frame, split_category='mass', split_thresh=15, color='r') self.assertRaises(bad_call) # Nonexistent column name for split_category bad_call = lambda: plots.annotate( f, frame, split_category='not a column', split_thresh=15, color='r') self.assertRaises(bad_call)