• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python common.assert_traj_equal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_two_double_overlap

 def test_two_double_overlap(self):
     shape = (24, 32)
     # (a b) c --> d    # a-c and b-c overlap
     expected = DataFrame({'x': [8, 8, 16, 24], 'y': [8, 16, 12, 12],
                           '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)
     # (a b) d <-- c    # a-d and b-d overlap
     expected = DataFrame({'x': [8, 8, 16, 24], 'y': [8, 16, 12, 12],
                           'frame': [0, 1, 1, 0], '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,代码行数:14,代码来源:test_find_link.py


示例17: test_multiple_lost_simple

 def test_multiple_lost_simple(self):
     shape = (32, 32)
     #   b      a, b, c, d in frame 0
     # a e c    e in frame 1, disappears, should be linked to correct one
     #   d
     # left
     expected = pd.DataFrame({'x': [8, 16, 24, 16, 15],
                              'y': [16, 8, 16, 24, 16],
                              'frame': [0, 0, 0, 0, 1],
                              'particle': [0, 1, 2, 3, 0]})
     actual = self.link(expected, shape=shape, remove=[0])
     assert_traj_equal(actual, expected)
     # top
     expected = pd.DataFrame({'x': [8, 16, 24, 16, 16],
                              'y': [16, 8, 16, 24, 15],
                              'frame': [0, 0, 0, 0, 1],
                              'particle': [0, 1, 2, 3, 1]})
     actual = self.link(expected, shape=shape, remove=[0])
     assert_traj_equal(actual, expected)
     # right
     expected = pd.DataFrame({'x': [8, 16, 24, 16, 17],
                              'y': [16, 8, 16, 24, 16],
                              'frame': [0, 0, 0, 0, 1],
                              'particle': [0, 1, 2, 3, 2]})
     actual = self.link(expected, shape=shape, remove=[0])
     assert_traj_equal(actual, expected)
     # bottom
     expected = pd.DataFrame({'x': [8, 16, 24, 16, 16],
                              'y': [16, 8, 16, 24, 17],
                              'frame': [0, 0, 0, 0, 1],
                              'particle': [0, 1, 2, 3, 3]})
     actual = self.link(expected, shape=shape, remove=[0])
     assert_traj_equal(actual, expected)
开发者ID:pfigliozzi,项目名称:trackpy,代码行数:33,代码来源:test_find_link.py


示例18: test_copy

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

        # Should add particle column in-place
        # UNLESS diagnostics are enabled (or input dataframe is not writeable)
        actual = self.link_df(f_inplace, 5)
        assert_traj_equal(actual, expected)
        if self.do_diagnostics:
            assert 'particle' not in f_inplace.columns
        else:
            assert_traj_equal(actual, f_inplace)

        # Should copy
        actual = self.link_df(f, 5, copy_features=True)
        assert_traj_equal(actual, expected)
        assert 'particle' not in f.columns

        # Should copy
        actual_iter = self.link_df_iter(f, 5, hash_size=(10, 2))
        assert_traj_equal(actual_iter, expected)
        assert 'particle' not in f.columns
开发者ID:soft-matter,项目名称:trackpy,代码行数:27,代码来源:test_legacy_linking.py


示例19: 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)
     actual_iter = self.link_df_iter(f, 5, hash_size=(10, 2))
     assert_traj_equal(actual_iter, expected)
     if self.do_diagnostics:
         assert 'diag_search_range' in self.diag.columns
         # Except for first frame, all particles should have been labeled
         # with a search_range
         assert not any(self.diag['diag_search_range'][
                            actual_iter.frame > 0].isnull())
开发者ID:soft-matter,项目名称:trackpy,代码行数:16,代码来源:test_legacy_linking.py


示例20: test_blank_frame_no_memory

    def test_blank_frame_no_memory(self):
        N = 5
        f = DataFrame({'x': np.arange(N), 'y': np.ones(N),
                      'frame': [0, 1, 2, 4, 5]})
        expected = f.copy()

        # Using link_df, the particle will be given a new ID after the gap.
        expected['particle'] = np.array([0, 0, 0, 1, 1], dtype=np.float64)
        actual = self.link_df(f, 5)
        assert_traj_equal(actual, expected)

        # link_df_iter will (in this test suite) iterate over only the frames
        # present in the dataframe, so the gap will be ignored.
        expected['particle'] = 0.0
        actual = self.link_df_iter(f, 5, hash_size=(10, 10))
        assert_traj_equal(actual, expected)
开发者ID:soft-matter,项目名称:trackpy,代码行数:16,代码来源:test_legacy_linking.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.pandas_sort函数代码示例发布时间:2022-05-27
下一篇:
Python artificial.draw_spots函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap