Exemplo n.º 1
0
 def test_multiple_clusters_3D(self):
     numbers = np.random.randint(1, 10, self.N)
     for number in numbers:
         pos = dummy_clusters(number, 10, 1, 3)
         df = pos_to_df(pos)
         df = cluster(df, 1)
         assert_equal(df['cluster'].nunique(), number)
Exemplo n.º 2
0
 def test_single_cluster_3D(self):
     separation = np.random.random(self.N) * 10
     for sep in separation:
         pos = dummy_clusters(1, 10, sep, 3)
         df = pos_to_df(pos)
         df = cluster(df, sep)
         assert_equal(df['cluster_size'].values, len(pos[0]))
Exemplo n.º 3
0
 def test_multiple_clusters_3D(self):
     numbers = np.random.randint(1, 10, self.N)
     for number in numbers:
         pos = dummy_clusters(number, 10, 1, 3)
         df = pos_to_df(pos)
         df = cluster(df, 1)
         assert_equal(df['cluster'].nunique(), number)
Exemplo n.º 4
0
 def test_single_cluster_3D(self):
     separation = np.random.random(self.N) * 10
     for sep in separation:
         pos = dummy_clusters(1, 10, sep, 3)
         df = pos_to_df(pos)
         df = cluster(df, sep)
         assert_equal(df['cluster_size'].values, len(pos[0]))
Exemplo n.º 5
0
    def test_line_cluster_3D(self):
        separation = np.random.random(self.N) * 10
        phi = np.random.random(self.N) * 2 * np.pi
        theta = np.random.random(self.N) * np.pi
        ds = np.array([
            np.cos(theta),
            np.cos(phi) * np.sin(theta),
            np.sin(phi) * np.sin(theta)
        ]).T
        for vec, sep in zip(ds, separation):
            pos = np.arange(10)[:, np.newaxis] * vec[np.newaxis, :] * sep
            df = pos_to_df([pos])
            df = cluster(df, sep * 1.1)
            assert_equal(df['cluster_size'].values, 10)
            df = cluster(df, sep * 0.9)
            assert_equal(df['cluster_size'].values, 1)

            df = pos_to_df([pos[::-1]])
            df = cluster(df, sep * 1.1)
            assert_equal(df['cluster_size'].values, 10)
            df = cluster(df, sep * 0.9)
            assert_equal(df['cluster_size'].values, 1)

            ind = np.arange(10)
            np.random.shuffle(ind)
            pos = ind[:, np.newaxis] * vec[np.newaxis, :] * sep
            df = pos_to_df([pos])
            df = cluster(df, sep * 1.1)
            assert_equal(df['cluster_size'].values, 10)
            df = cluster(df, sep * 0.9)
            assert_equal(df['cluster_size'].values, 1)
Exemplo n.º 6
0
    def test_line_cluster_3D(self):
        separation = np.random.random(self.N) * 10
        phi = np.random.random(self.N) * 2 * np.pi
        theta = np.random.random(self.N) * np.pi
        ds = np.array([np.cos(theta),
                       np.cos(phi)*np.sin(theta),
                       np.sin(phi)*np.sin(theta)]).T
        for vec, sep in zip(ds, separation):
            pos = np.arange(10)[:, np.newaxis] * vec[np.newaxis, :] * sep
            df = pos_to_df([pos])
            df = cluster(df, sep*1.1)
            assert_equal(df['cluster_size'].values, 10)
            df = cluster(df, sep*0.9)
            assert_equal(df['cluster_size'].values, 1)

            df = pos_to_df([pos[::-1]])
            df = cluster(df, sep*1.1)
            assert_equal(df['cluster_size'].values, 10)
            df = cluster(df, sep*0.9)
            assert_equal(df['cluster_size'].values, 1)

            ind = np.arange(10)
            np.random.shuffle(ind)
            pos = ind[:, np.newaxis] * vec[np.newaxis, :] * sep
            df = pos_to_df([pos])
            df = cluster(df, sep*1.1)
            assert_equal(df['cluster_size'].values, 10)
            df = cluster(df, sep*0.9)
            assert_equal(df['cluster_size'].values, 1)