def test_stog_fourier_filter_with_plot_flag(self, mock_show): # Load S(Q) for Argon from test data stog = StoG(**self.kwargs_for_stog_input) stog.files = self.kwargs_for_files['Files'] stog.plot_flag = True stog.read_all_data() stog.merge_data() stog.transform_merged() stog.fourier_filter() mock_show.assert_called_with()
def setUp(self): super(TestStogOutputDataFrameMethods, self).setUp() stog = StoG(**self.kwargs_for_stog_input) stog.plot_flag = False stog.stem_name = "dog" stog.files = self.kwargs_for_files['Files'] stog.read_all_data() stog.merge_data() stog.transform_merged() self.stog = stog
def test_stog_get_lowR_mean_square(self): # Load S(Q) for Argon from test data stog = StoG(**self.kwargs_for_stog_input) stog.files = self.kwargs_for_files['Files'] stog.plot_flag = False stog.read_all_data() stog.merge_data() stog.transform_merged() q, sq, r, gr = stog.fourier_filter() cost = stog._get_lowR_mean_square() self.assertAlmostEqual(cost, self.lowR_target, places=7)
def test_stog_lowR_mean_square(self): # Load S(Q) for Argon from test data stog = StoG(**self.kwargs_for_stog_input) stog.files = self.kwargs_for_files['Files'] stog.plot_flag = False stog.read_all_data() stog.merge_data() stog.transform_merged() gr = stog.df_gr_master[stog.gr_title].values cost = stog._lowR_mean_square(stog.dr, gr) self.assertAlmostEqual(cost, self.lowR_target, places=7)
def test_stog_apply_lorch_default(self): # Number of decimal places for precision places = 5 # Load S(Q) for Argon from test data stog = StoG(**self.kwargs_for_stog_input) stog.files = self.kwargs_for_files['Files'] stog.plot_flag = False stog.read_all_data() stog.merge_data() stog.transform_merged() q, sq, r, gr = stog.fourier_filter() stog.apply_lorch(q, sq, r) self.assertAlmostEqual( stog.df_gr_master.iloc[self.real_space_first][stog.gr_lorch_title], self.gofr_lorch_target[0], places=places)
def test_stog_fourier_filter_for_nan_after_filter(self): # Load S(Q) for Argon from test data stog = StoG(**self.kwargs_for_stog_input) stog.files = self.kwargs_for_files['Files'] stog.plot_flag = False stog.read_all_data() stog.merge_data() stog.transform_merged() stog.fourier_filter() self.assertFalse( np.isnan(stog.df_gr_master[stog.gr_title].values).any()) self.assertFalse( np.isnan(stog.df_sq_master[stog.sq_title].values).any()) self.assertFalse( np.isnan(stog.df_sq_master[stog._ft_title].values).any()) self.assertFalse( np.isnan(stog.df_sq_master[stog.sq_ft_title].values).any())
def test_stog_fourier_filter_before_transform_merged_call(self): # Number of decimal places for precision places = 1 # Load S(Q) for Argon from test data stog = StoG(**self.kwargs_for_stog_input) stog.files = self.kwargs_for_files['Files'] stog.plot_flag = False stog.read_all_data() stog.merge_data() stog.fourier_filter() # Check g(r) data against targets self.assertAlmostEqual( stog.df_gr_master.iloc[self.real_space_first].name, self.real_xtarget, places=places) self.assertAlmostEqual( stog.df_gr_master.iloc[self.real_space_first][stog.gr_ft_title], self.gofr_ff_target[0], places=places)
def test_stog_plot_flag_exception(self): stog = StoG() with self.assertRaises(TypeError): stog.plot_flag = 1.0