コード例 #1
0
 def setup_method(self, method):
     real = np.random.random((8,8))
     imag = np.random.random((8,8))
     s_complex_dtype = signals.ComplexSignal1D(real + 1j*imag - 1j*imag)
     s_real_dtype = signals.ComplexSignal1D(real)
     s_complex_dtype.decomposition()
     s_real_dtype.decomposition()
     self.s_complex_dtype = s_complex_dtype
     self.s_real_dtype = s_real_dtype
コード例 #2
0
ファイル: test_decomposition.py プロジェクト: jat255/hyperspy
 def setup_method(self, method):
     rng = np.random.RandomState(123)
     real = rng.random_sample(size=(8, 8))
     imag = rng.random_sample(size=(8, 8))
     s_complex_dtype = signals.ComplexSignal1D(real + 1j * imag - 1j * imag)
     s_real_dtype = signals.ComplexSignal1D(real)
     s_complex_dtype.decomposition()
     s_real_dtype.decomposition()
     self.s_complex_dtype = s_complex_dtype
     self.s_real_dtype = s_real_dtype
コード例 #3
0
    def test_first_r_values_of_scree_non_zero(self):
        """For low-rank matrix by creating a = RandomComplex(m, r) and
        b = RandomComplex(n, r), then performing PCA on the result of a.b^T
        (i.e. an m x n matrix).
        The first r values of scree plot / singular values should be non-zero.
        """
        m, n, r = 32, 32, 3

        A = (np.random.random((m,r)) + 1j* np.random.random((m,r)))
        B = (np.random.random((n,r)) + 1j* np.random.random((n,r)))

        s = signals.ComplexSignal1D(np.dot(A,B.T))
        s.decomposition()
        np.testing.assert_almost_equal(
            s.get_explained_variance_ratio().data[r:].sum(), 0)