class _BaseTest(): def setup_method(self): self.mock_ubcalc = createMockUbcalc(None) self.mock_geometry = createMockDiffractometerGeometry() self.mock_hardware = SimpleHardwareAdapter( ['delta', 'gamma', 'omegah', 'phi']) self.constraints = Mock() settings.geometry = self.mock_geometry settings.hardware = self.mock_hardware self.calc = WillmottHorizontalCalculator(self.mock_ubcalc, self.constraints) self.places = 12 def _check_hkl_to_angles(self, testname, zrot, yrot, hkl, pos_expected, wavelength, virtual_expected={}): print('_check_hkl_to_angles(%s, %.1f, %.1f, %s, %s, %.2f, %s)' % (testname, zrot, yrot, hkl, pos_expected, wavelength, virtual_expected)) self.zrot, self.yrot = zrot, yrot self._configure_ub() pos, virtual = self.calc.hklToAngles(hkl[0], hkl[1], hkl[2], wavelength) assert_array_almost_equal(pos.totuple(), pos_expected.totuple(), self.places) assert_second_dict_almost_in_first(virtual, virtual_expected) def _check_angles_to_hkl(self, testname, zrot, yrot, hkl_expected, pos, wavelength, virtual_expected={}): print('_check_angles_to_hkl(%s, %.1f, %.1f, %s, %s, %.2f, %s)' % (testname, zrot, yrot, hkl_expected, pos, wavelength, virtual_expected)) self.zrot, self.yrot = zrot, yrot self._configure_ub() hkl, virtual = self.calc.anglesToHkl(pos, wavelength) assert_array_almost_equal(hkl, hkl_expected, self.places) assert_second_dict_almost_in_first(virtual, virtual_expected) @raises(DiffcalcException) def _check_hkl_to_angles_fails(self, *args): self._check_hkl_to_angles(*args)
def setup_method(self): self.mock_ubcalc = createMockUbcalc(None) self.mock_geometry = createMockDiffractometerGeometry() self.mock_hardware = SimpleHardwareAdapter( ['delta', 'gamma', 'omegah', 'phi']) self.constraints = Mock() self.calc = WillmottHorizontalCalculator(self.mock_ubcalc, self.mock_geometry, self.mock_hardware, self.constraints) self.places = 12
def setup(self): self.mock_ubcalc = createMockUbcalc(None) self.mock_geometry = createMockDiffractometerGeometry() self.mock_hardware = SimpleHardwareAdapter( ['delta', 'gamma', 'omegah', 'phi']) self.constraints = Mock() self.calc = WillmottHorizontalCalculator(self.mock_ubcalc, self.mock_geometry, self.mock_hardware, self.constraints) self.places = 12
class _BaseTest(): def setup(self): self.mock_ubcalc = createMockUbcalc(None) self.mock_geometry = createMockDiffractometerGeometry() self.mock_hardware = SimpleHardwareAdapter( ['delta', 'gamma', 'omegah', 'phi']) self.constraints = Mock() self.calc = WillmottHorizontalCalculator(self.mock_ubcalc, self.mock_geometry, self.mock_hardware, self.constraints) self.places = 12 def _check_hkl_to_angles(self, testname, zrot, yrot, hkl, pos_expected, wavelength, virtual_expected={}): print ('_check_hkl_to_angles(%s, %.1f, %.1f, %s, %s, %.2f, %s)' % (testname, zrot, yrot, hkl, pos_expected, wavelength, virtual_expected)) self.zrot, self.yrot = zrot, yrot self._configure_ub() pos, virtual = self.calc.hklToAngles(hkl[0], hkl[1], hkl[2], wavelength) assert_array_almost_equal(pos.totuple(), pos_expected.totuple(), self.places) assert_second_dict_almost_in_first(virtual, virtual_expected) def _check_angles_to_hkl(self, testname, zrot, yrot, hkl_expected, pos, wavelength, virtual_expected={}): print ('_check_angles_to_hkl(%s, %.1f, %.1f, %s, %s, %.2f, %s)' % (testname, zrot, yrot, hkl_expected, pos, wavelength, virtual_expected)) self.zrot, self.yrot = zrot, yrot self._configure_ub() hkl, virtual = self.calc.anglesToHkl(pos, wavelength) assert_array_almost_equal(hkl, hkl_expected, self.places) assert_second_dict_almost_in_first(virtual, virtual_expected) @raises(DiffcalcException) def _check_hkl_to_angles_fails(self, *args): self._check_hkl_to_angles(*args)