예제 #1
0
 def test_process_observations_providing_list(self):
     observations = [0, 1, 2, 3, 4, 5, 6, 7]
     processed_obs, num_features, labels  = \
         _process_observations(observations, self.comm)
     self.assertTrue(isinstance(processed_obs, Block))
     self.assertEqual(num_features, 1)
     self.assertTrue(isinstance(labels, Block))
예제 #2
0
    def test_process_observations_providing_mpi_np_array(self):
        #Default block distribution
        mpi_np_observations = mpi_np.arange(8, dist='b')
        processed_obs, num_features, labels  = \
            _process_observations(mpi_np_observations, self.comm)
        self.assertTrue(isinstance(processed_obs, Block))
        self.assertEqual(num_features, 1)
        self.assertTrue(isinstance(labels, Block))

        #Replicated distribution
        mpi_np_observations = mpi_np.arange(8, dist='r')
        processed_obs, num_features, labels  = \
            _process_observations(mpi_np_observations, self.comm)
        self.assertTrue(isinstance(processed_obs, Block))
        self.assertEqual(num_features, 1)
        self.assertTrue(isinstance(labels, Block))
예제 #3
0
 def test_process_observations_providing_numpy_array(self):
     np_observations = np.arange(8)
     processed_obs, num_features, labels  = \
         _process_observations(np_observations, self.comm)
     self.assertTrue(isinstance(processed_obs, Block))
     self.assertEqual(num_features, 1)
     self.assertTrue(isinstance(labels, Block))
예제 #4
0
 def test_kmeans_calls_process_observations(self):
     obs = self.dist_obs_1_feature
     k = self.k
     processed_obs, num_features, labels = \
         _process_observations(obs, self.comm)
     with mock.patch('mpids.MPIscipy.cluster._kmeans._process_observations',
                     return_value=(processed_obs, num_features,
                                   labels)) as mock_proc_obs:
         mpi_scipy_cluster.kmeans(obs, k)
     mock_proc_obs.assert_called_with(obs, self.comm)
예제 #5
0
 def test_process_observations_providing_3D_observations_raises_ValueError(
         self):
     observations = np.arange(27).reshape(3, 3, 3)
     with self.assertRaises(ValueError):
         _process_observations(observations, self.comm)