def test_stog_transform_merged_default(self): # Number of decimal places for precision places = 2 # Load S(Q) for Argon from test data stog = StoG(**self.kwargs_for_stog_input) stog.files = self.kwargs_for_files['Files'] stog.read_all_data() stog.merge_data() stog.transform_merged() # 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_title], self.gofr_target[0], places=places) # Test if no dr defined stog.dr = None stog.transform_merged() # 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_title], self.gofr_target[0], places=places)
def test_stog_read_all_data_assertion(self): stog = StoG() with self.assertRaises(AssertionError): stog.read_all_data() stog.files = list() with self.assertRaises(AssertionError): stog.read_all_data()
def test_stog_read_all_data_for_files_length(self): # Load S(Q) for Argon from test data stog = StoG() stog.files = self.kwargs_for_files['Files'] stog.read_all_data() # Check S(Q) data against targets self.assertEqual(len(stog.files), len(self.kwargs_for_files['Files']))
def setUp(self): super(TestStogPlottingDataFrameMethods, self).setUp() stog = StoG(**self.kwargs_for_stog_input) stog.files = self.kwargs_for_files['Files'] stog.read_all_data() stog.merge_data() stog.transform_merged() self.stog = stog
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_add_keen_gr_GKofR(self): stog = StoG(**self.kwargs_for_stog_input) stog.real_space_function = "GK(r)" stog.files = self.kwargs_for_files['Files'] stog.read_all_data() stog.merge_data() stog.transform_merged() r = stog.df_gr_master[stog.gr_title].index.values gr = stog.df_gr_master[stog.gr_title].values stog._add_keen_gr(r, gr) self.assertTrue(stog.GKofR_title in stog.df_gr_master.columns)
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_transform_merged_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.real_space_function = "GK(r)" stog.read_all_data() stog.merge_data() stog.transform_merged() self.assertFalse( np.isnan(stog.df_sq_master[stog.sq_title].values).any()) self.assertFalse( np.isnan(stog.df_gr_master[stog.gr_title].values).any())
def test_stog_merge_data_qsq_opts_offset(self): # Number of decimal places for precision places = 5 # Load S(Q) for Argon from test data stog = StoG() stog.files = self.kwargs_for_files['Files'] stog.read_all_data() qsq_opts = {'Y': {'Offset': 1.0}} # Test Q[S(Q)-1] scale stog.merged_opts['Q[S(Q)-1]'] = qsq_opts stog.merge_data() self.assertAlmostEqual( stog.df_sq_master.iloc[self.first][stog.qsq_minus_one_title], qsq_opts['Y']['Offset'] + self.fq_target[0], places=places)
def test_stog_merge_data(self): # Number of decimal places for precision places = 5 # Load S(Q) for Argon from test data stog = StoG() stog.files = self.kwargs_for_files['Files'] stog.read_all_data() stog.merge_data() # Check S(Q) data against targets self.assertEqual(stog.df_sq_master.iloc[self.first].name, self.reciprocal_xtarget) self.assertAlmostEqual( stog.df_sq_master.iloc[self.first][stog.sq_title], self.sq_target[0], places=places)
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_read_all_data(self): # Number of decimal places for precision places = 5 # Load S(Q) for Argon from test data stog = StoG() stog.files = self.kwargs_for_files['Files'] stog.read_all_data() # Check S(Q) data against targets self.assertEqual(stog.df_individuals.iloc[self.first].name, self.reciprocal_xtarget) for index in range(len(stog.files)): self.assertAlmostEqual( stog.df_individuals.iloc[self.first]['S(Q)_%d' % index], self.sq_target[0], places=places) self.assertAlmostEqual( stog.df_sq_individuals.iloc[self.first]['S(Q)_%d' % index], self.sq_target[0], places=places)