public distro 2.1.0
This commit is contained in:
@ -20,14 +20,71 @@ Licensed under the Apache License, Version 2.0 (the "License"); @n
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
import numpy as np
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import pmsco.data as data
|
||||
import pmsco.dispatch as dispatch
|
||||
import pmsco.project as project
|
||||
|
||||
|
||||
class TestScan(unittest.TestCase):
|
||||
"""
|
||||
test case for @ref pmsco.project.Scan class
|
||||
|
||||
"""
|
||||
def test_import_scan_file(self):
|
||||
base_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
test_file = os.path.join(base_dir, "..", "projects", "twoatom", "twoatom_energy_alpha.etpai")
|
||||
|
||||
scan = project.Scan()
|
||||
scan.import_scan_file(test_file, "C", "1s")
|
||||
|
||||
mode = ['e', 'a']
|
||||
self.assertEqual(scan.mode, mode)
|
||||
|
||||
ae = np.arange(10, 1005, 5)
|
||||
at = np.asarray([0])
|
||||
ap = np.asarray([0])
|
||||
aa = np.arange(-90, 91, 1)
|
||||
|
||||
np.testing.assert_array_almost_equal(scan.energies, ae)
|
||||
np.testing.assert_array_almost_equal(scan.thetas, at)
|
||||
np.testing.assert_array_almost_equal(scan.phis, ap)
|
||||
np.testing.assert_array_almost_equal(scan.alphas, aa)
|
||||
|
||||
def test_define_scan(self):
|
||||
scan = project.Scan()
|
||||
p0 = np.asarray([20])
|
||||
p1 = np.linspace(1, 4, 4)
|
||||
p2 = np.linspace(11, 13, 3)
|
||||
d = {'t': p1, 'e': p0, 'p': p2}
|
||||
scan.define_scan(d, "C", "1s")
|
||||
|
||||
ae = np.asarray([20])
|
||||
at = np.asarray([1, 2, 3, 4])
|
||||
ap = np.asarray([11, 12, 13])
|
||||
aa = np.asarray([0])
|
||||
|
||||
np.testing.assert_array_almost_equal(scan.energies, ae)
|
||||
np.testing.assert_array_almost_equal(scan.thetas, at)
|
||||
np.testing.assert_array_almost_equal(scan.phis, ap)
|
||||
np.testing.assert_array_almost_equal(scan.alphas, aa)
|
||||
|
||||
re = np.ones(12) * 20
|
||||
rt = np.asarray([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4])
|
||||
rp = np.asarray([11, 12, 13, 11, 12, 13, 11, 12, 13, 11, 12, 13])
|
||||
ra = np.ones(12) * 0
|
||||
|
||||
np.testing.assert_array_almost_equal(scan.raw_data['e'], re)
|
||||
np.testing.assert_array_almost_equal(scan.raw_data['t'], rt)
|
||||
np.testing.assert_array_almost_equal(scan.raw_data['p'], rp)
|
||||
np.testing.assert_array_almost_equal(scan.raw_data['a'], ra)
|
||||
|
||||
|
||||
class TestProject(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# before each test method
|
||||
|
Reference in New Issue
Block a user