예제 #1
0
    def testSetlat(self):
        # "Exception should result if no UBCalculation started")
        with pytest.raises(DiffcalcException):
            self.ub.setlat('HCl', 2)

        self.ub.newub('testing_setlat')
        with pytest.raises(TypeError):
            self.ub.setlat(1)
        with pytest.raises(TypeError):
            self.ub.setlat(1, 2)
        with pytest.raises(TypeError):
            self.ub.setlat('HCl')
        self.ub.setlat('NaCl', 1.1)
        ubcalc = self.ub.ubcalc
        eq_(('NaCl', 1.1, 1.1, 1.1, 90, 90, 90),
            ubcalc._state.crystal.getLattice())
        self.ub.setlat('NaCl', 1.1, 2.2)
        eq_(('NaCl', 1.1, 1.1, 2.2, 90, 90, 90),
            ubcalc._state.crystal.getLattice())
        self.ub.setlat('NaCl', 1.1, 2.2, 3.3)
        eq_(('NaCl', 1.1, 2.2, 3.3, 90, 90, 90),
            ubcalc._state.crystal.getLattice())
        self.ub.setlat('NaCl', 1.1, 2.2, 3.3, 91)
        eq_(('NaCl', 1.1, 2.2, 3.3, 90, 90, 91),
            ubcalc._state.crystal.getLattice())
        with pytest.raises(TypeError):
            self.ub.setlat(('NaCl', 1.1, 2.2, 3.3, 91, 92))
        self.ub.setlat('NaCl', 1.1, 2.2, 3.3, 91, 92, 93)
        assert_iterable_almost_equal(
            ('NaCl', 1.1, 2.2, 3.3, 91, 92, 92.99999999999999),
            ubcalc._state.crystal.getLattice())
예제 #2
0
    def testSetlat(self):
        # "Exception should result if no UBCalculation started")
        with pytest.raises(DiffcalcException):
            self.ub.setlat('HCl', 2)

        self.ub.newub('testing_setlat')
        with pytest.raises(TypeError):
            self.ub.setlat(1)
        with pytest.raises(TypeError):
            self.ub.setlat(1, 2)
        with pytest.raises(TypeError):
            self.ub.setlat('HCl')
        self.ub.setlat('NaCl', 1.1)
        ubcalc = self.ub.ubcalc
        eq_(('NaCl', 1.1, 1.1, 1.1, 90, 90, 90), ubcalc._state.crystal.getLattice())
        self.ub.setlat('NaCl', 1.1, 2.2)
        eq_(('NaCl', 1.1, 1.1, 2.2, 90, 90, 90), ubcalc._state.crystal.getLattice())
        self.ub.setlat('NaCl', 1.1, 2.2, 3.3)
        eq_(('NaCl', 1.1, 2.2, 3.3, 90, 90, 90), ubcalc._state.crystal.getLattice())
        self.ub.setlat('NaCl', 1.1, 2.2, 3.3, 91)
        eq_(('NaCl', 1.1, 2.2, 3.3, 90, 90, 91), ubcalc._state.crystal.getLattice())
        with pytest.raises(TypeError):
            self.ub.setlat(('NaCl', 1.1, 2.2, 3.3, 91, 92))
        self.ub.setlat('NaCl', 1.1, 2.2, 3.3, 91, 92, 93)
        assert_iterable_almost_equal(
            ('NaCl', 1.1, 2.2, 3.3, 91, 92, 92.99999999999999),
             ubcalc._state.crystal.getLattice())
예제 #3
0
    def testSetlatInteractive(self):
        self.ub.newub('testing_setlatinteractive')
        prepareRawInput(['xtal', '1', '2', '3', '91', '92', '93'])
        self.ub.setlat()
        getLattice = self.ub.ubcalc._state.crystal.getLattice
        assert_iterable_almost_equal(
            getLattice(), ('xtal', 1., 2., 3., 91, 92, 92.999999999999986))

        #Defaults:
        prepareRawInput(['xtal', '', '', '', '', '', ''])
        self.ub.setlat()
        getLattice = self.ub.ubcalc._state.crystal.getLattice
        eq_(getLattice(), ('xtal', 1., 1., 1., 90, 90, 90))
예제 #4
0
    def testSetlatInteractive(self):
        self.ubcommands.newub('testing_setlatinteractive')
        prepareRawInput(['xtal', '1', '2', '3', '91', '92', '93'])
        self.ubcommands.setlat()
        getLattice = self.ubcommands._ubcalc._state.crystal.getLattice
        assert_iterable_almost_equal(getLattice(),
                         ('xtal', 1., 2., 3., 91, 92, 92.999999999999986))

        #Defaults:
        prepareRawInput(['xtal', '', '', '', '', '', ''])
        self.ubcommands.setlat()
        getLattice = self.ubcommands._ubcalc._state.crystal.getLattice
        eq_(getLattice(), ('xtal', 1., 1., 1., 90, 90, 90))
예제 #5
0
    def testSetlat(self):
        # "Exception should result if no UBCalculation started")
        self.assertRaises(DiffcalcException, self.ubcommands.setlat, 'HCl', 2)

        self.ubcommands.newub('testing_setlat')
        self.assertRaises(TypeError, self.ubcommands.setlat, 1)
        self.assertRaises(TypeError, self.ubcommands.setlat, 1, 2)
        self.assertRaises(TypeError, self.ubcommands.setlat, 'HCl')
        self.ubcommands.setlat('NaCl', 1.1)
        ubcalc = self.ubcommands._ubcalc
        eq_(('NaCl', 1.1, 1.1, 1.1, 90, 90, 90), ubcalc._state.crystal.getLattice())
        self.ubcommands.setlat('NaCl', 1.1, 2.2)
        eq_(('NaCl', 1.1, 1.1, 2.2, 90, 90, 90), ubcalc._state.crystal.getLattice())
        self.ubcommands.setlat('NaCl', 1.1, 2.2, 3.3)
        eq_(('NaCl', 1.1, 2.2, 3.3, 90, 90, 90), ubcalc._state.crystal.getLattice())
        self.ubcommands.setlat('NaCl', 1.1, 2.2, 3.3, 91)
        eq_(('NaCl', 1.1, 2.2, 3.3, 90, 90, 91), ubcalc._state.crystal.getLattice())
        self.assertRaises(
            TypeError, self.ubcommands.setlat, ('NaCl', 1.1, 2.2, 3.3, 91, 92))
        self.ubcommands.setlat('NaCl', 1.1, 2.2, 3.3, 91, 92, 93)
        assert_iterable_almost_equal(
            ('NaCl', 1.1, 2.2, 3.3, 91, 92, 92.99999999999999),
             ubcalc._state.crystal.getLattice())