예제 #1
0
 def flat_pattern(self):
     pd = PolarDiffraction2D(data=np.ones(shape=(2, 2, 5, 5)))
     pd.axes_manager.signal_axes[0].scale = 0.5
     pd.axes_manager.signal_axes[0].name = "theta"
     pd.axes_manager.signal_axes[1].scale = 2
     pd.axes_manager.signal_axes[1].name = "k"
     return pd
예제 #2
0
 def flat_pattern(self):
     rng = np.random.default_rng(seed=1)
     pd = PolarDiffraction2D(data=rng.random((2, 2, 50, 15)))
     pd.axes_manager.signal_axes[0].scale = 0.5
     pd.axes_manager.signal_axes[0].name = "theta"
     pd.axes_manager.signal_axes[1].scale = 0.1
     pd.axes_manager.signal_axes[1].name = "k"
     return pd
예제 #3
0
 def test_2_fold_corr(self):
     rand_number = np.random.random(10)
     tiled_random = np.tile(rand_number, (2, 3, 2))
     p = PolarDiffraction2D(tiled_random)
     cor = p.get_pearson_correlation()
     sym_coeff = cor.get_symmetry_coefficient(
         method="average",
         angular_range=0.0,
         include_duplicates=True,
         normalize=False,
     )
     np.testing.assert_almost_equal(sym_coeff.data[0, 0], 1)
예제 #4
0
 def test_2d_data_as_lazy(self):
     data = np.random.random((100, 150))
     s = PolarDiffraction2D(data)
     scale0, scale1, metadata_string = 0.5, 1.5, "test"
     s.axes_manager[0].scale = scale0
     s.axes_manager[1].scale = scale1
     s.metadata.Test = metadata_string
     s_lazy = s.as_lazy()
     assert s_lazy.__class__ == LazyPolarDiffraction2D
     assert hasattr(s_lazy.data, "compute")
     assert s_lazy.axes_manager[0].scale == scale0
     assert s_lazy.axes_manager[1].scale == scale1
     assert s_lazy.metadata.Test == metadata_string
     assert data.shape == s_lazy.data.shape
예제 #5
0
 def test_4d_data_as_lazy(self):
     data = np.random.random((4, 10, 15))
     s = PolarDiffraction2D(data)
     s_lazy = s.as_lazy()
     assert s_lazy.__class__ == LazyPolarDiffraction2D
     assert data.shape == s_lazy.data.shape
예제 #6
0
 def test_decomposition_class_assignment(self, diffraction_pattern):
     s = PolarDiffraction2D(diffraction_pattern)
     s.decomposition()
     assert isinstance(s, PolarDiffraction2D)
예제 #7
0
 def test_decomposition_is_performed(self, diffraction_pattern):
     s = PolarDiffraction2D(diffraction_pattern)
     s.decomposition()
     assert s.learning_results is not None