示例#1
0
    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(ValueError, bad_call)

        # Not enough colors
        bad_call = lambda: plots.annotate(
            f, frame, split_category='mass', split_thresh=15, color=['r'])
        self.assertRaises(ValueError, bad_call)
        bad_call = lambda: plots.annotate(
            f, frame, split_category='mass', split_thresh=15, color='r')
        self.assertRaises(ValueError, 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(ValueError, bad_call)

        # 3D image
        bad_call = lambda: plots.annotate(f, frame[np.newaxis, :, :])
        self.assertRaises(ValueError, bad_call)
示例#2
0
 def test_ptraj_t_column(self):
     suppress_plotting()
     df = self.sparse.copy()
     cols = list(df.columns)
     cols[cols.index('frame')] = 'arbitrary name'
     df.columns = cols
     plots.plot_traj(df, t_column='arbitrary name')
示例#3
0
 def test_ptraj_t_column(self):
     suppress_plotting()
     df = self.sparse.copy()
     cols = list(df.columns)
     cols[cols.index('frame')] = 'arbitrary name'
     df.columns = cols
     plots.plot_traj(df, t_column='arbitrary name')
示例#4
0
    def test_annotate3d(self):
        suppress_plotting()
        f = DataFrame({'x': [0, 1], 'y': [0, 1], 'z': [0, 1], 'frame': [0, 0],
                      'mass': [10, 20]})
        frame = np.random.randint(0, 255, (5, 5, 5))

        plots.annotate3d(f, frame)
        plots.annotate3d(f, frame, color='r')

        # 2D image
        bad_call = lambda: plots.annotate3d(f, frame[0])
        self.assertRaises(ValueError, bad_call)
示例#5
0
    def test_annotate3d(self):
        _skip_if_no_pims()
        suppress_plotting()
        f = DataFrame({'x': [0, 1], 'y': [0, 1], 'z': [0, 1], 'frame': [0, 0],
                      'mass': [10, 20]})
        frame = np.random.randint(0, 255, (5, 5, 5))

        plots.annotate3d(f, frame)
        plots.annotate3d(f, frame, color='r')

        # 2D image
        bad_call = lambda: plots.annotate3d(f, frame[0])
        self.assertRaises(ValueError, bad_call)
示例#6
0
    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(ValueError, bad_call)

        # Not enough colors
        bad_call = lambda: plots.annotate(
            f, frame, split_category='mass', split_thresh=15, color=['r'])
        self.assertRaises(ValueError, bad_call)
        bad_call = lambda: plots.annotate(
            f, frame, split_category='mass', split_thresh=15, color='r')
        self.assertRaises(ValueError, 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(ValueError, bad_call)

        # 3D image
        bad_call = lambda: plots.annotate(f, frame[np.newaxis, :, :])
        self.assertRaises(ValueError, bad_call)
示例#7
0
 def test_fit_powerlaw(self):
     # smoke test
     suppress_plotting()
     em = Series([1, 2, 3], index=[1, 2, 3])
     fit_powerlaw(em)
     fit_powerlaw(em, plot=False)
示例#8
0
 def test_ptraj_empty(self):
     suppress_plotting()
     f = lambda: plots.plot_traj(DataFrame(columns=self.sparse.columns))
     self.assertRaises(ValueError, f)
示例#9
0
 def test_labeling_sparse_trajectories(self):
     suppress_plotting()
     plots.plot_traj(self.sparse, label=True)
示例#10
0
 def test_labeling_sparse_trajectories(self):
     suppress_plotting()
     plots.plot_traj(self.sparse, label=True)
示例#11
0
 def test_labeling_sparse_trajectories(self):
     suppress_plotting()
     ptraj(self.sparse, label=True) # No errors?
示例#12
0
 def test_fit_powerlaw(self):
     # smoke test
     suppress_plotting()
     em = Series([1, 2, 3], index=[1, 2, 3])
     fit_powerlaw(em)
     fit_powerlaw(em, plot=False)
示例#13
0
 def test_ptraj_empty(self):
     suppress_plotting()
     f = lambda: plots.plot_traj(DataFrame(columns=self.sparse.columns))
     self.assertRaises(ValueError, f)
示例#14
0
 def test_labeling_sparse_trajectories(self):
     suppress_plotting()
     ptraj(self.sparse, label=True) # No errors?