Esempio n. 1
0
    def test_simple_dense(self):

        bcs.main([
            "build_core_space.py", "-l", self.dir_ + "log1.txt", "-i",
            self.dir_ + "mat2", "-o", self.dir_, "--input_format", "dm",
            "--output_format", "dm"
        ])

        s1 = Space.build(data=self.dir_ + "mat2.dm", format="dm")
        s2 = Space.build(data=self.dir_ + "CORE_SS.mat2.dm", format="dm")
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat2.pkl", Space)

        self._test_equal_spaces_dense(s1, s2)
        self._test_equal_spaces_dense(s1, s3)

        bcs.main([
            "build_core_space.py", "-l", self.dir_ + "log1.txt", "-i",
            self.dir_ + "CORE_SS.mat2", "-o", self.dir_, "--input_format",
            "pkl", "--output_format", "dm"
        ])

        s1 = io_utils.load(self.dir_ + "CORE_SS.CORE_SS.mat2.pkl", Space)
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat2.pkl", Space)

        self._test_equal_spaces_dense(s1, s3)
    def test_simple_dense(self):
            
        bcs.main(["build_core_space.py", 
                  "-l", self.dir_ + "log1.txt",
                  "-i", self.dir_ + "mat2", 
                  "-o", self.dir_,
                  "--input_format", "dm",
                  "--output_format", "dm"
                  ])
        
        s1 = Space.build(data = self.dir_ + "mat2.dm", format = "dm")
        s2 = Space.build(data = self.dir_ + "CORE_SS.mat2.dm", format="dm")
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat2.pkl", Space)
        
        self._test_equal_spaces_dense(s1, s2)
        self._test_equal_spaces_dense(s1, s3)        
 
        bcs.main(["build_core_space.py", 
                  "-l", self.dir_ + "log1.txt",
                  "-i", self.dir_ + "CORE_SS.mat2", 
                  "-o", self.dir_,
                  "--input_format", "pkl",
                  "--output_format", "dm"
                  ])
        
        s1 = io_utils.load(self.dir_ + "CORE_SS.CORE_SS.mat2.pkl", Space)
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat2.pkl", Space)
        
        self._test_equal_spaces_dense(s1, s3)  
Esempio n. 3
0
    def setUp(self):
        self.dir_ = data_dir + "pipelines_test_resources/"

        #use as a conversion tool, creates the files we want
        bcs.main([
            "build_core_space.py",
            "-l",
            self.dir_ + "log1.txt",
            "-i",
            self.dir_ + "N_mat",
            "-o",
            self.dir_,
            "--input_format",
            "dm",
        ])

        bcs.main([
            "build_core_space.py",
            "-l",
            self.dir_ + "log1.txt",
            "-i",
            self.dir_ + "AN_mat",
            "-o",
            self.dir_,
            "--input_format",
            "dm",
        ])
    def test_simple_sparse_zipped(self):
            
        bcs.main(["build_core_space.py", 
                  "-l", self.dir_ + "log1.txt",
                  "-i", self.dir_ + "mat1", 
                  "-o", self.dir_,
                  "--input_format", "sm",
                  "--output_format", "sm",
                  "--gz", "True"
                  ])
        
        s1 = Space.build(data=self.dir_ + "mat1.sm.gz",
                         cols= self.dir_ + "mat1.cols",
                         format = "sm")

        s2 = Space.build(data=self.dir_ + "CORE_SS.mat1.sm",
                         cols=self.dir_ + "CORE_SS.mat1.cols",
                         format="sm")
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat1.pkl", Space)
        s4 = Space.build(data=self.dir_ + "mat1.sm",
                         cols= self.dir_ + "mat1.cols",
                         format = "sm")
                
        self._test_equal_spaces_sparse(s1, s2)
        self._test_equal_spaces_sparse(s1, s3)
        self._test_equal_spaces_sparse(s1, s4)
Esempio n. 5
0
    def test_simple_nmf(self):

        bcs.main([
            "build_core_space.py", "-l", self.dir_ + "log_nmf.txt", "-i",
            self.dir_ + "mat3", "-w", "raw", "-r", "nmf_2", "-o", self.dir_,
            "--input_format", "dm", "--output_format", "dm"
        ])

        s1 = Space.build(data=self.dir_ + "CORE_SS.mat3.raw.nmf_2.dm",
                         format="dm")
        self.assertEqual(s1.cooccurrence_matrix.mat.shape, (3, 2))
Esempio n. 6
0
    def test_simple_ops(self):

        bcs.main(["build_core_space.py",
                  "-l", self.dir_ + "log1.txt",
                  "-i", self.dir_ + "mat3",
                  "-w", "raw",
                  "-s", "top_sum_3,top_length_3,top_sum_4",
                  "-r", "svd_2,svd_1",
                  "-o", self.dir_,
                  "--input_format", "dm",
                  "--output_format", "dm"
                  ])

        core_mats = ["CORE_SS.mat3.raw.top_sum_3.svd_2",
                     "CORE_SS.mat3.raw.top_sum_3.svd_1",
                     "CORE_SS.mat3.raw.top_length_3.svd_2",
                     "CORE_SS.mat3.raw.top_length_3.svd_1",
                     "CORE_SS.mat3.raw.top_sum_4.svd_2",
                     "CORE_SS.mat3.raw.top_sum_4.svd_1"
                     ]

        core_spaces = [Space.build(data=self.dir_ + suffix + ".dm", format="dm") for suffix in core_mats]

        for i, core_mat in enumerate(core_mats):
            bps.main(["build_peripheral_space.py",
                      "-l", self.dir_ + "log1.txt",
                      "-i", self.dir_ + "mat3",
                      "-o", self.dir_,
                      "-c", self.dir_ + core_mat + ".pkl",
                      "--input_format", "dm",
                      "--output_format", "dm"
                      ])

            s1 = core_spaces[i]
            data_file = self.dir_ + "PER_SS.mat3." + core_mats[i] + ".dm"
            s2 = Space.build(data=data_file, format="dm")
            self._test_equal_spaces_dense(s1, s2)

            bps.main(["build_peripheral_space.py",
                      "-l", self.dir_ + "log1.txt",
                      "-i", self.dir_ + "mat3",
                      "-o", self.dir_,
                      "-c", self.dir_ + core_mat + ".pkl",
                      "--input_format", "sm",
                      "--output_format", "dm"
                      ])

            s1 = core_spaces[i]
            data_file = self.dir_ + "PER_SS.mat3." + core_mats[i] + ".dm"
            s2 = Space.build(data=data_file, format="dm")

            self._test_equal_spaces_dense(s1, s2)
Esempio n. 7
0
def space(tmpdir, data_dir, pipelines_test_resources):
    """Create the spaces required in the tests."""
    path = tmpdir.mkdir('space')

    bcs.main([
        "build_core_space.py", "-l",
        str(path.join('space_creation.log')), "-i",
        str(pipelines_test_resources.join('mat3')), "-w", "raw", "-s",
        "top_sum_3", "-r", "svd_2", "-o",
        str(path), "--input_format", "dm"
    ])

    return path
 def test_simple_nmf(self):
     
     bcs.main(["build_core_space.py", 
       "-l", self.dir_ + "log_nmf.txt",
       "-i", self.dir_ + "mat3",
       "-w", "raw",
       "-r", "nmf_2",
       "-o", self.dir_,
       "--input_format", "dm",
       "--output_format", "dm"
       ])
       
     s1 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.nmf_2.dm", format="dm")  
     self.assertEqual(s1.cooccurrence_matrix.mat.shape, (3,2))
Esempio n. 9
0
    def setUp(self):
        self.dir_ = data_dir
        self.log_dir = toolkit_dir + "/log/"

        #create the spaces required in the tests
        bcs.main(["build_core_space.py",
          "-l", self.dir_ + "pipelines_test_resources/log1.txt",
          "-i", self.dir_ + "pipelines_test_resources/mat3",
          "-w", "raw",
          "-s", "top_sum_3",
          "-r", "svd_2",
          "-o", self.dir_ + "pipelines_test_resources/",
          "--input_format", "dm"
          ])
 def setUp(self):
     self.dir_ = data_dir
     self.log_dir = toolkit_dir + "/log/"
     
     #create the spaces required in the tests
     bcs.main(["build_core_space.py", 
       "-l", self.dir_ + "pipelines_test_resources/log1.txt",
       "-i", self.dir_ + "pipelines_test_resources/mat3",
       "-w", "raw",
       "-s", "top_sum_3",
       "-r", "svd_2", 
       "-o", self.dir_ + "pipelines_test_resources/",
       "--input_format", "dm"
       ])
Esempio n. 11
0
def space(tmpdir, data_dir, pipelines_test_resources):
    """Create the spaces required in the tests."""
    path = tmpdir.mkdir('space')

    bcs.main([
        "build_core_space.py",
        "-l", str(path.join('space_creation.log')),
        "-i", str(pipelines_test_resources.join('mat3')),
        "-w", "raw",
        "-s", "top_sum_3",
        "-r", "svd_2",
        "-o", str(path),
        "--input_format", "dm"
    ])

    return path
Esempio n. 12
0
 def setUp(self):
     self.dir_ = data_dir + "pipelines_test_resources/"
     
     #use as a conversion tool, creates the files we want
     bcs.main(["build_core_space.py", 
               "-l", self.dir_ + "log1.txt",
               "-i", self.dir_ + "N_mat", 
               "-o", self.dir_,
               "--input_format", "dm",
               ])
     
     bcs.main(["build_core_space.py", 
               "-l", self.dir_ + "log1.txt",
               "-i", self.dir_ + "AN_mat", 
               "-o", self.dir_,
               "--input_format", "dm",
               ])
Esempio n. 13
0
    def setUp(self):
        self.dir_ = data_dir
        self.log_dir = toolkit_dir + "/log/"
        self.cos = np.array([1.0, 0.585984772383, 1.0, 0.585984772383])
        self.dot_prod = np.array([28.0, 1483.0, 14.0, 2966.0])
        self.euclidean = np.array(
            [0.21089672206, 0.00148105508243, 1.0, 0.00148583482109])
        self.lin = np.array([1.0, 0.995623769303, 1.0, 0.991242564101])

        #create the spaces required in the tests
        bcs.main([
            "build_core_space.py", "-l",
            self.dir_ + "pipelines_test_resources/log1.txt", "-i",
            self.dir_ + "pipelines_test_resources/mat3", "-w", "raw", "-s",
            "top_sum_3", "-r", "svd_2", "-o",
            self.dir_ + "pipelines_test_resources/", "--input_format", "dm"
        ])
Esempio n. 14
0
 def setUp(self):
     self.dir_ = data_dir
     self.log_dir = toolkit_dir + "/log/"
     self.cos = np.array([1.0, 0.585984772383, 1.0, 0.585984772383])
     self.dot_prod = np.array([28.0, 1483.0, 14.0, 2966.0])
     self.euclidean = np.array([0.21089672206, 0.00148105508243, 1.0, 0.00148583482109])
     self.lin = np.array([1.0, 0.995623769303, 1.0, 0.991242564101])
     
             #create the spaces required in the tests
     bcs.main(["build_core_space.py", 
       "-l", self.dir_ + "pipelines_test_resources/log1.txt",
       "-i", self.dir_ + "pipelines_test_resources/mat3",
       "-w", "raw",
       "-s", "top_sum_3",
       "-r", "svd_2", 
       "-o", self.dir_  + "pipelines_test_resources/",
       "--input_format", "dm"
       ])
Esempio n. 15
0
    def test_simple_sparse(self):

        bcs.main([
            "build_core_space.py", "-l", self.dir_ + "log1.txt", "-i",
            self.dir_ + "mat1", "-o", self.dir_, "--input_format", "sm",
            "--output_format", "sm"
        ])

        s1 = Space.build(data=self.dir_ + "mat1.sm",
                         cols=self.dir_ + "mat1.cols",
                         format="sm")
        s2 = Space.build(data=self.dir_ + "CORE_SS.mat1.sm",
                         cols=self.dir_ + "CORE_SS.mat1.cols",
                         format="sm")
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat1.pkl", Space)

        self._test_equal_spaces_sparse(s1, s2)
        self._test_equal_spaces_sparse(s1, s3)
Esempio n. 16
0
    def setUp(self):

        self.dir_ = data_dir + "pipelines_test_resources/"

        #use as a conversion tool, creates the files we want
        bcs.main([
            "build_core_space.py", "-l", self.dir_ + "log1.txt", "-i",
            self.dir_ + "N_mat", "-o", self.dir_, "--input_format", "dm"
        ])

        bcs.main([
            "build_core_space.py", "-l", self.dir_ + "log1.txt", "-i",
            self.dir_ + "AN_mat", "-o", self.dir_, "--input_format", "dm"
        ])

        bcs.main([
            "build_core_space.py", "-l", self.dir_ + "log1.txt", "-i",
            self.dir_ + "A_mat", "-o", self.dir_, "--input_format", "dm"
        ])

        tc.main([
            "train_composition.py", "-l", self.dir_ + "log1.txt", "-i",
            self.dir_ + "an_train_data.txt", "-o", self.dir_, "-m",
            "lexical_func", "-p", self.dir_ + "CORE_SS.AN_mat.pkl", "-a",
            self.dir_ + "CORE_SS.N_mat.pkl", "-r", "lstsq", "--intercept",
            "False", "--export_params", "True"
        ])
Esempio n. 17
0
    def test_as_conversion_tool(self):
        
        bcs.main(["build_core_space.py", 
                  "-i", self.dir_ + "mat3", 
                  "-o", self.dir_,
                  "--input_format", "sm",
                  "--output_format", "sm"
                  ])        
        
        s1 = Space.build(data=self.dir_ + "mat3.sm",
                         cols= self.dir_ + "mat3.cols",
                         format = "sm")
        s2 = Space.build(data=self.dir_ + "CORE_SS.mat3.sm",
                         rows=self.dir_ + "CORE_SS.mat3.rows",
                         cols=self.dir_ + "CORE_SS.mat3.cols", 
                         format="sm")
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat3.pkl", Space)
        
        self._test_equal_spaces_sparse(s1, s2)
        self._test_equal_spaces_sparse(s1, s3)
        
        bcs.main(["build_core_space.py", 
                  "-i", self.dir_ + "mat3", 
                  "-o", self.dir_,
                  "--input_format", "sm",
                  "--output_format", "dm"
                  ])
        
        s1 = Space.build(data=self.dir_ + "mat3.dm",
                         cols=self.dir_ + "CORE_SS.mat3.cols",
                         format = "dm")
        s2 = Space.build(data=self.dir_ + "CORE_SS.mat3.dm",
                         rows=self.dir_ + "CORE_SS.mat3.rows",
                         cols=self.dir_ + "CORE_SS.mat3.cols",
                         format = "dm")                 
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat3.pkl", Space)

        self._test_equal_spaces_dense(s1, s2)
        s3.to_dense()
        self._test_equal_spaces_dense(s1, s3)
        
        bcs.main(["build_core_space.py", 
                  "-i", self.dir_ + "mat3", 
                  "-o", self.dir_,
                  "--input_format", "dm",
                  "--output_format", "dm"
                  ])        
       
        s1 = Space.build(data=self.dir_ + "CORE_SS.mat3.dm",
                         cols=self.dir_ + "CORE_SS.mat3.cols",
                         format = "dm")                 
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat3.pkl", Space)
        
        s3.to_dense()
        self._test_equal_spaces_dense(s1, s3)
Esempio n. 18
0
    def test_as_conversion_tool(self):

        bcs.main([
            "build_core_space.py", "-i", self.dir_ + "mat3", "-o", self.dir_,
            "--input_format", "sm", "--output_format", "sm"
        ])

        s1 = Space.build(data=self.dir_ + "mat3.sm",
                         cols=self.dir_ + "mat3.cols",
                         format="sm")
        s2 = Space.build(data=self.dir_ + "CORE_SS.mat3.sm",
                         rows=self.dir_ + "CORE_SS.mat3.rows",
                         cols=self.dir_ + "CORE_SS.mat3.cols",
                         format="sm")
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat3.pkl", Space)

        self._test_equal_spaces_sparse(s1, s2)
        self._test_equal_spaces_sparse(s1, s3)

        bcs.main([
            "build_core_space.py", "-i", self.dir_ + "mat3", "-o", self.dir_,
            "--input_format", "sm", "--output_format", "dm"
        ])

        s1 = Space.build(data=self.dir_ + "mat3.dm",
                         cols=self.dir_ + "CORE_SS.mat3.cols",
                         format="dm")
        s2 = Space.build(data=self.dir_ + "CORE_SS.mat3.dm",
                         rows=self.dir_ + "CORE_SS.mat3.rows",
                         cols=self.dir_ + "CORE_SS.mat3.cols",
                         format="dm")
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat3.pkl", Space)

        self._test_equal_spaces_dense(s1, s2)
        s3.to_dense()
        self._test_equal_spaces_dense(s1, s3)

        bcs.main([
            "build_core_space.py", "-i", self.dir_ + "mat3", "-o", self.dir_,
            "--input_format", "dm", "--output_format", "dm"
        ])

        s1 = Space.build(data=self.dir_ + "CORE_SS.mat3.dm",
                         cols=self.dir_ + "CORE_SS.mat3.cols",
                         format="dm")
        s3 = io_utils.load(self.dir_ + "CORE_SS.mat3.pkl", Space)

        s3.to_dense()
        self._test_equal_spaces_dense(s1, s3)
Esempio n. 19
0
    def setUp(self):

        self.dir_ = data_dir + "pipelines_test_resources/"

        #use as a conversion tool, creates the files we want
        bcs.main(["build_core_space.py",
                  "-l", self.dir_ + "log1.txt",
                  "-i", self.dir_ + "N_mat",
                  "-o", self.dir_,
                  "--input_format", "dm"
                  ])

        bcs.main(["build_core_space.py",
                  "-l", self.dir_ + "log1.txt",
                  "-i", self.dir_ + "AN_mat",
                  "-o", self.dir_,
                  "--input_format", "dm"
                  ])

        bcs.main(["build_core_space.py",
                  "-l", self.dir_ + "log1.txt",
                  "-i", self.dir_ + "A_mat",
                  "-o", self.dir_,
                  "--input_format", "dm"
                  ])

        tc.main(["train_composition.py",
                  "-l", self.dir_ + "log1.txt",
                  "-i", self.dir_ + "an_train_data.txt",
                  "-o", self.dir_,
                  "-m", "lexical_func",
                  "-p", self.dir_ + "CORE_SS.AN_mat.pkl",
                  "-a", self.dir_ + "CORE_SS.N_mat.pkl",
                  "-r", "lstsq",
                  "--intercept", "False",
                  "--export_params", "True"
                  ])
Esempio n. 20
0
    def test_simple_ops(self):

        #x = matrix([[ -2.19426495e+00,   3.16751379e+00,  -3.89945798e-01],
        #x = np.mat([[1,2,3],[2,4,6],[4,675,43]])

        us = np.mat([[2.19272110e+00, 3.03174768e+00],
                     [4.38544220e+00, 6.06349536e+00],
                     [6.76369708e+02, -4.91431927e-02]])
        us2 = np.mat([[2.19426495e+00, 3.16751379e+00],
                      [4.38703714e+00, 6.14112794e+00],
                      [6.76380808e+02, -5.01074549e-02]])

        bcs.main([
            "build_core_space.py", "-l", self.dir_ + "log1.txt", "-i",
            self.dir_ + "mat3", "-w", "raw", "-s",
            "top_sum_3,top_length_3,top_sum_4", "-r", "svd_2,svd_1", "-n",
            "none,all,row", "-o", self.dir_, "--input_format", "dm",
            "--output_format", "dm"
        ])

        s1 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_sum_3.svd_2.dm",
                         format="dm")
        s2 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_sum_3.svd_1.dm",
                         format="dm")
        s3 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_length_3.svd_2.dm",
                         format="dm")
        s4 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_length_3.svd_1.dm",
                         format="dm")
        s5 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_sum_4.svd_2.dm",
                         format="dm")
        s6 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_sum_4.svd_1.dm",
                         format="dm")
        s7 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_sum_4.svd_1.all.dm",
                         format="dm")
        s8 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_sum_4.svd_1.row.dm",
                         format="dm")
        s9 = s6.apply(Normalization())
        s10 = s6.apply(RowNormalization())

        self._test_equal_spaces_dense(s1, s3)
        self._test_equal_spaces_dense(s2, s4)
        self._test_equal_spaces_dense(s7, s9)
        self._test_equal_spaces_dense(s8, s10)

        np.testing.assert_array_almost_equal(abs(s1.cooccurrence_matrix.mat),
                                             abs(us), 2)
        np.testing.assert_array_almost_equal(abs(s2.cooccurrence_matrix.mat),
                                             abs(us[:, 0:1]), 2)
        np.testing.assert_array_almost_equal(abs(s5.cooccurrence_matrix.mat),
                                             abs(us2), 2)
        np.testing.assert_array_almost_equal(abs(s6.cooccurrence_matrix.mat),
                                             abs(us2[:, 0:1]), 2)

        self._test_equal_spaces_structs(s3, s5)
        self._test_equal_spaces_structs(s2, s6)

        bcs.main([
            "build_core_space.py", "-l", self.dir_ + "log1.txt", "-i",
            self.dir_ + "mat3", "--weighting", "raw", "--selection",
            "top_sum_3,top_length_3,top_sum_4", "--reduction", "svd_2,svd_1",
            "-o", self.dir_, "--input_format", "sm", "--output_format", "dm"
        ])

        s1 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_sum_3.svd_2.dm",
                         format="dm")
        s2 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_sum_3.svd_1.dm",
                         format="dm")
        s3 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_length_3.svd_2.dm",
                         format="dm")
        s4 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_length_3.svd_1.dm",
                         format="dm")
        s5 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_sum_4.svd_2.dm",
                         format="dm")
        s6 = Space.build(data=self.dir_ +
                         "CORE_SS.mat3.raw.top_sum_4.svd_1.dm",
                         format="dm")

        self._test_equal_spaces_dense(s1, s3)
        self._test_equal_spaces_dense(s2, s4)

        np.testing.assert_array_almost_equal(abs(s1.cooccurrence_matrix.mat),
                                             abs(us), 2)
        np.testing.assert_array_almost_equal(abs(s2.cooccurrence_matrix.mat),
                                             abs(us[:, 0:1]), 2)
        np.testing.assert_array_almost_equal(abs(s5.cooccurrence_matrix.mat),
                                             abs(us2), 2)
        np.testing.assert_array_almost_equal(abs(s6.cooccurrence_matrix.mat),
                                             abs(us2[:, 0:1]), 2)

        self._test_equal_spaces_structs(s3, s5)
        self._test_equal_spaces_structs(s2, s6)
Esempio n. 21
0
    def test_simple_ops(self):
        
        #x = matrix([[ -2.19426495e+00,   3.16751379e+00,  -3.89945798e-01],
        #x = np.mat([[1,2,3],[2,4,6],[4,675,43]])
        
        us = np.mat([[  2.19272110e+00,   3.03174768e+00],
                               [  4.38544220e+00,   6.06349536e+00],
                               [  6.76369708e+02,  -4.91431927e-02]])
        us2 = np.mat([[ 2.19426495e+00,   3.16751379e+00],
                      [ 4.38703714e+00,   6.14112794e+00],
                      [ 6.76380808e+02,  -5.01074549e-02]])
        

        bcs.main(["build_core_space.py", 
                  "-l", self.dir_ + "log1.txt",
                  "-i", self.dir_ + "mat3",
                  "-w", "raw",
                  "-s", "top_sum_3,top_length_3,top_sum_4",
                  "-r", "svd_2,svd_1",
                  "-n", "none,all,row",
                  "-o", self.dir_,
                  "--input_format", "dm",
                  "--output_format", "dm"
                  ])        
        
        s1 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_sum_3.svd_2.dm", format="dm")
        s2 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_sum_3.svd_1.dm", format="dm")
        s3 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_length_3.svd_2.dm", format="dm")
        s4 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_length_3.svd_1.dm", format="dm")
        s5 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_sum_4.svd_2.dm", format="dm")
        s6 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_sum_4.svd_1.dm", format="dm")
        s7 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_sum_4.svd_1.all.dm", format="dm")
        s8 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_sum_4.svd_1.row.dm", format="dm")
        s9 = s6.apply(Normalization())
        s10 = s6.apply(RowNormalization())
        
        self._test_equal_spaces_dense(s1, s3)            
        self._test_equal_spaces_dense(s2, s4)
        self._test_equal_spaces_dense(s7, s9)
        self._test_equal_spaces_dense(s8, s10)
        
        np.testing.assert_array_almost_equal(abs(s1.cooccurrence_matrix.mat), abs(us), 2)
        np.testing.assert_array_almost_equal(abs(s2.cooccurrence_matrix.mat), abs(us[:,0:1]), 2)
        np.testing.assert_array_almost_equal(abs(s5.cooccurrence_matrix.mat), abs(us2), 2)
        np.testing.assert_array_almost_equal(abs(s6.cooccurrence_matrix.mat), abs(us2[:,0:1]), 2)

        self._test_equal_spaces_structs(s3, s5)
        self._test_equal_spaces_structs(s2, s6)
        
        
        bcs.main(["build_core_space.py", 
          "-l", self.dir_ + "log1.txt",
          "-i", self.dir_ + "mat3",
          "--weighting", "raw",
          "--selection", "top_sum_3,top_length_3,top_sum_4",
          "--reduction", "svd_2,svd_1",
          "-o", self.dir_,
          "--input_format", "sm",
          "--output_format", "dm"
          ])        
        
        s1 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_sum_3.svd_2.dm", format="dm")
        s2 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_sum_3.svd_1.dm", format="dm")
        s3 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_length_3.svd_2.dm", format="dm")
        s4 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_length_3.svd_1.dm", format="dm")
        s5 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_sum_4.svd_2.dm", format="dm")
        s6 = Space.build(data = self.dir_ + "CORE_SS.mat3.raw.top_sum_4.svd_1.dm", format="dm")
            
        self._test_equal_spaces_dense(s1, s3)            
        self._test_equal_spaces_dense(s2, s4)
        
        np.testing.assert_array_almost_equal(abs(s1.cooccurrence_matrix.mat), abs(us), 2)
        np.testing.assert_array_almost_equal(abs(s2.cooccurrence_matrix.mat), abs(us[:,0:1]), 2)
        np.testing.assert_array_almost_equal(abs(s5.cooccurrence_matrix.mat), abs(us2), 2)
        np.testing.assert_array_almost_equal(abs(s6.cooccurrence_matrix.mat), abs(us2[:,0:1]), 2)

        self._test_equal_spaces_structs(s3, s5)
        self._test_equal_spaces_structs(s2, s6)