def setUpClass(cls): f = 'data/amset_data_85x85x47.json' cls.qs = [ 'doping', 'conductivity', 'electronic_thermal_conductivity', 'seebeck', 'temperature' ] cls.d = load.amset(f, cls.qs) cls.ts = len(cls.d['temperature']) cls.ds = len(cls.d['doping'])
def test_electronic_thermal_conductivity(self, mock_opens, mock_json): q = 'electronic_thermal_conductivity' data = {q: np.zeros((2, 2, 3, 3)), 'temperatures': [0, 1], 'doping': [1, 2]} data[q][0,1,0,0] = 1 mock_json.return_value = data data2 = load.amset('mock', q) mock_opens.assert_called_once() mock_json.assert_called_once() for q2 in [q, 'temperature', 'doping', 'meta']: self.assertIn(q2, data2) self.assertEqual(data2[q][1,0,0,0], 1)
def test_mobility(self, mock_opens, mock_json): q = 'mobility' data = {q: {'test': np.zeros((2, 2, 3, 3))}, 'temperatures': [0, 1], 'doping': [1, 2]} data[q]['test'][0,1,0,0] = 1 mock_json.return_value = data data2 = load.amset('mock', q) mock_opens.assert_called_once() mock_json.assert_called_once() for q2 in [q, 'temperature', 'doping', 'meta']: self.assertIn(q2, data2) self.assertEqual(np.array(data2[q])[0,1,0,0,0], 1) self.assertEqual(list(data2['scattering_labels']), ['test'])
def test_fermi_levels(self, mock_opens, mock_json): aq = 'fermi_levels' tq = 'fermi_level' data = {aq: np.zeros((2, 2)), 'temperatures': [0, 1], 'doping': [1, 2]} data[aq][0,1] = 1 mock_json.return_value = data data2 = load.amset('mock', aq) mock_opens.assert_called_once() mock_json.assert_called_once() for q2 in [tq, 'temperature', 'doping', 'meta']: self.assertIn(q2, data2) self.assertEqual(data2[tq][1,0], 1)