예제 #1
0
 def test_manage_layers(self):
     """
     Should handle moving plot items around.
     """
     fig = plt.figure()
     ax = fig.add_subplot(111)
     splt = SEGYPlotManager(ax, self.segy)
     # should echo parameters if item is not in dicts
     self.assertTrue(splt._manage_layers(foobar=True)['foobar'])
     self.assertFalse(splt._manage_layers(foobar=False)['foobar'])
     # for active item and True, should do nothing
     splt.ACTIVE_LINES['foobar'] = ax.plot([0,1], [0,1])
     self.assertTrue('foobar' in splt.ACTIVE_LINES)
     self.assertFalse('foobar' in splt.INACTIVE_LINES)
     self.assertFalse(splt._manage_layers(foobar=True)['foobar'])
     self.assertTrue('foobar' in splt.ACTIVE_LINES)
     self.assertFalse('foobar' in splt.INACTIVE_LINES)
     # for active item and False, should move to inactive and return False
     self.assertFalse(splt._manage_layers(foobar=False)['foobar'])
     self.assertFalse('foobar' in splt.ACTIVE_LINES)
     self.assertTrue('foobar' in splt.INACTIVE_LINES)
     # for force_new=True, should remove from active and inactive and return
     # True
     # item is currently in inactive list
     need2plot = splt._manage_layers(force_new=True, foobar=True)
     self.assertTrue(need2plot['foobar'])
     self.assertFalse('foobar' in splt.ACTIVE_LINES)
     self.assertFalse('foobar' in splt.INACTIVE_LINES)
     # item is now in active list
     splt.ACTIVE_LINES['foobar'] = ax.plot([0,1], [0,1])
     need2plot = splt._manage_layers(force_new=True, foobar=True)
     self.assertTrue(need2plot['foobar'])
     self.assertFalse('foobar' in splt.ACTIVE_LINES)
     self.assertFalse('foobar' in splt.INACTIVE_LINES)