当前位置: 首页>>代码示例>>Python>>正文


Python common.assert_traj_equal函数代码示例

本文整理汇总了Python中trackpy.tests.common.assert_traj_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_traj_equal函数的具体用法?Python assert_traj_equal怎么用?Python assert_traj_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了assert_traj_equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_two_isolated

 def test_two_isolated(self):
     shape = (32, 32)
     expected = DataFrame({'x': [8, 16, 24, 16], 'y': [8, 8, 24, 24],
                              'frame': [0, 1, 0, 1], 'particle': [0, 0, 1, 1]})
     for remove in [[], [0], [1], [0, 1]]:
         actual = self.link(expected, shape=shape, remove=remove)
         assert_traj_equal(actual, expected)
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:7,代码来源:test_find_link.py

示例2: test_isolated_continuous_random_walks

    def test_isolated_continuous_random_walks(self):
        # Two 2D random walks
        np.random.seed(0)
        N = 30
        Y = 250
        M = 20 # margin, because negative values raise OutOfHash
        a = DataFrame({'x': M + random_walk(N), 'y': M + random_walk(N), 'frame': np.arange(N)})
        b = DataFrame({'x': M + random_walk(N - 1), 'y': M + Y + random_walk(N - 1), 'frame': np.arange(1, N)})
        f = pd.concat([a, b])
        expected = f.copy().reset_index(drop=True)
        expected['particle'] = np.concatenate([np.zeros(N), np.ones(N - 1)])
        pandas_sort(expected, ['particle', 'frame'], inplace=True)
        actual = self.link_df(f, 5)
        assert_traj_equal(actual, expected)

        # Many 2D random walks
        np.random.seed(0)
        initial_positions = [(100, 100), (200, 100), (100, 200), (200, 200)]
        import itertools
        c = itertools.count()
        def walk(x, y): 
            i = next(c)
            return DataFrame({'x': x + random_walk(N - i), 
                              'y': y + random_walk(N - i),
                             'frame': np.arange(i, N)})
        f = pd.concat([walk(*pos) for pos in initial_positions])
        expected = f.copy().reset_index(drop=True)
        expected['particle'] = np.concatenate([i*np.ones(N - i) for i in range(len(initial_positions))])
        pandas_sort(expected, ['particle', 'frame'], inplace=True)
        actual = self.link_df(f, 5)
        assert_traj_equal(actual, expected)
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:31,代码来源:test_find_link.py

示例3: test_custom_dist_func

    def test_custom_dist_func(self):
        # Several 2D random walkers
        N = 5
        length = 5
        step_size = 2
        search_range = 3

        steps = (np.random.random((2, length, N)) - 0.5) * step_size
        x, y = np.cumsum(steps, axis=2)
        f = DataFrame(dict(x=x.ravel(), y=y.ravel(),
                           frame=np.repeat(np.arange(length), N)))

        # link in normal (2D Euclidean) coordinates
        expected = self.link(f, search_range)

        # compute radial coordinates
        f_radial = f.copy()
        f_radial['angle'] = np.arctan2(f_radial['y'], f_radial['x'])
        f_radial['r'] = np.sqrt(f_radial['y']**2 + f_radial['x']**2)
        # leave x, y for the comparison at the end

        def dist_func(a, b):
            x1 = a[0] * np.cos(a[1])
            y1 = a[0] * np.sin(a[1])
            x2 = b[0] * np.cos(b[1])
            y2 = b[0] * np.sin(b[1])

            return np.sqrt((x1 - x2)**2 + (y1 - y2)**2)

        # link using a custom distance function
        actual = self.link(f_radial, search_range, pos_columns=['r', 'angle'],
                           dist_func=dist_func)
        assert_traj_equal(actual, expected)
开发者ID:caspervdw,项目名称:trackpy,代码行数:33,代码来源:test_linking.py

示例4: test_quadrature_distances

    def test_quadrature_distances(self):
        """A simple test to check whether the subnet linker adds
        orthogonal coordinates in quadrature (as in Pythagoras).

        We have two possible linking results:

        1. A->C and B->D, cost (linear) = 16, cost (quadrature) = 200
        2. A->D and B->C, cost (linear) = 28, cost (quadrature) = 200
        """
        def subnet_test(epsilon):
            """Returns 2 features in 2 frames, which represent a special
            case when the subnet linker adds distances in quadrature. With
            epsilon=0, subnet linking is degenerate. Therefore
            linking should differ for positive and negative epsilon."""
            return pd.DataFrame([(0, 6, 0),             #A
                                 (0, 14 + epsilon, 8),  #B
                                 (1, 8, 0),             #C
                                 (1, 0, 8)],            #D
                                columns=['frame', 'x', 'y'])

        trpos = self.link(subnet_test(1), 20)
        expected = subnet_test(1)
        expected['particle'] = np.array([0, 1, 1, 0])
        assert_traj_equal(trpos, expected)

        trneg = self.link(subnet_test(-1), 20)
        expected = subnet_test(-1)
        expected['particle'] = np.array([0, 1, 0, 1])
        assert_traj_equal(trneg, expected)
开发者ID:caspervdw,项目名称:trackpy,代码行数:29,代码来源:test_linking.py

示例5: test_custom_to_eucl

    def test_custom_to_eucl(self):
        # Several 2D random walkers
        N = 5
        length = 5
        step_size = 2
        search_range = 3

        steps = (np.random.random((2, length, N)) - 0.5) * step_size
        x, y = np.cumsum(steps, axis=2)
        f = DataFrame(dict(x=x.ravel(), y=y.ravel(),
                           frame=np.repeat(np.arange(length), N)))

        # link in normal (2D Euclidean) coordinates
        expected = self.link(f, search_range)

        # compute radial coordinates
        f_radial = f.copy()
        f_radial['angle'] = np.arctan2(f_radial['y'], f_radial['x'])
        f_radial['r'] = np.sqrt(f_radial['y'] ** 2 + f_radial['x'] ** 2)
        # leave x, y for the comparison at the end

        def to_eucl(arr):
            r, angle = arr.T
            x = r * np.cos(angle)
            y = r * np.sin(angle)
            return np.array([x, y]).T

        # link using a custom distance function
        actual = self.link(f_radial, search_range, pos_columns=['r', 'angle'],
                           to_eucl=to_eucl)
        assert_traj_equal(actual, expected)
开发者ID:caspervdw,项目名称:trackpy,代码行数:31,代码来源:test_linking.py

示例6: test_one

    def test_one(self):
        expected = DataFrame({'x': [8, 16], 'y': [16, 16],
                              'frame': [0, 1], 'particle': [0, 0]})

        actual = self.link(expected, shape=(24, 24), remove=[0])
        assert_traj_equal(actual, expected)
        actual = self.link(expected, shape=(24, 24), search_range=7, remove=[0])
        assert_equal(len(actual), 1)
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:8,代码来源:test_find_link.py

示例7: test_one_trivial_stepper

 def test_one_trivial_stepper(self):
     # One 1D stepper
     N = 5
     f = DataFrame({'x': np.arange(N), 'y': np.ones(N), 'frame': np.arange(N)})
     expected = f.copy()
     expected['particle'] = np.zeros(N)
     actual = self.link_df(f, 5)
     assert_traj_equal(actual, expected)
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:8,代码来源:test_find_link.py

示例8: test_link_memory

    def test_link_memory(self):
        expected = pd.DataFrame(self.coords_link,
                                columns=self.pos_columns + ['frame'])
        expected['frame'] = expected['frame'].astype(np.int)
        actual = tp.link(expected, memory=self.memory, **self.link_params)
        expected['particle'] = self.expected_link_memory

        assert_traj_equal(actual, expected)
开发者ID:nkeim,项目名称:trackpy,代码行数:8,代码来源:test_reproducibility.py

示例9: test_two_full_overlap

 def test_two_full_overlap(self):
     shape = (24, 24)
     # a --> b
     # c --> d    # a-c, b-c, b-d, a-d overlap
     expected = DataFrame({'x': [8, 15, 8, 15], 'y': [8, 8, 16, 16],
                           'frame': [0, 1, 0, 1], 'particle': [0, 0, 1, 1]})
     for remove in [[], [0], [1], [0, 1]]:
         actual = self.link(expected, shape=shape, remove=remove)
         assert_traj_equal(actual, expected)
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:9,代码来源:test_find_link.py

示例10: test_blank_frame_no_memory

 def test_blank_frame_no_memory(self):
     # One 1D stepper
     N = 5
     f = DataFrame({'x': np.arange(N), 'y': np.ones(N),
                   'frame': [0, 1, 2, 4, 5],
                   'particle': [0, 0, 0, 1, 1]})
     expected = f.copy()
     actual = self.link_df(f, 5)
     assert_traj_equal(actual, expected)
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:9,代码来源:test_find_link.py

示例11: test_start_at_frame_other_than_zero

 def test_start_at_frame_other_than_zero(self):
     # One 1D stepper
     N = 5
     FIRST_FRAME = 3
     f = DataFrame({'x': np.arange(N), 'y': np.ones(N), 
                   'frame': FIRST_FRAME + np.arange(N)})
     expected = f.copy()
     expected['particle'] = np.zeros(N)
     actual = self.link_df(f, 5)
     assert_traj_equal(actual, expected)
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:10,代码来源:test_find_link.py

示例12: test_splitting_subnets

    def test_splitting_subnets(self):
        shape = (24, 48)
        expected = pd.DataFrame({'x': [8, 12, 16, 20, 32, 28, 40, 36],
                                 'y': [8, 16, 8, 16, 8, 16, 8, 16],
                                 'frame': [1, 0, 1, 0, 1, 0, 1, 0],
                                 'particle': [0, 0, 1, 1, 2, 2, 3, 3]})

        for n in range(5):
            for remove in itertools.combinations(range(4), n):
                actual = self.link(expected, shape=shape, remove=remove)
                assert_traj_equal(actual, expected)
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:11,代码来源:test_find_link.py

示例13: test_args_dtype

    def test_args_dtype(self):
        """Check whether find_link accepts float typed arguments"""
        # One 1D stepper
        N = 5
        f = DataFrame(
            {'x': np.arange(N), 'y': np.ones(N), 'frame': np.arange(N)})
        expected = f.copy()
        expected['particle'] = np.zeros(N)

        # Should not raise
        actual = self.link_df(f, 5.2, separation=9.5, diameter=15.2)
        assert_traj_equal(actual, expected)
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:12,代码来源:test_find_link.py

示例14: test_copy

    def test_copy(self):
        """Check inplace/copy behavior of link_df """
        # One 1D stepper
        N = 5
        f = DataFrame({'x': np.arange(N), 'y': np.ones(N), 'frame': np.arange(N)})
        expected = f.copy()
        expected['particle'] = np.zeros(N)

        # Should copy
        actual = self.link_df(f, 5)
        assert_traj_equal(actual, expected)
        assert 'particle' not in f.columns
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:12,代码来源:test_find_link.py

示例15: test_shifting_string

    def test_shifting_string(self):
        shape = (24, 48)
        shift = 5
        expected = pd.DataFrame({'x': [8, 8+shift, 16, 16+shift,
                                       24, 24+shift, 32, 32+shift],
                                 'y': [8, 16, 8, 16, 8, 16, 8, 16],
                                 'frame': [0, 1, 0, 1, 0, 1, 0, 1],
                                 'particle': [0, 0, 1, 1, 2, 2, 3, 3]})

        for n in range(5):
            for remove in itertools.combinations(range(4), n):
                actual = self.link(expected, shape=shape, remove=remove)
                assert_traj_equal(actual, expected)
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:13,代码来源:test_find_link.py


注:本文中的trackpy.tests.common.assert_traj_equal函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。