Skip to content

Commit efb45d4

Browse files
committed
TST: setting Atom attributes to numpy types
Expose failed conversion.
1 parent f05127a commit efb45d4

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

src/diffpy/srreal/tests/teststructureadapter.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,42 @@ def test_uij_cartn(self):
599599
self.assertEqual(0.023, a.uc23)
600600
return
601601

602+
def test_xc_yc_zc(self):
603+
'check Atom properties xc, yc, zc.'
604+
a = self.a
605+
a.xc, a.yc, a.zc = numpy.arange(1, 4)
606+
self.assertEqual(1.0, a.xc)
607+
self.assertEqual(2.0, a.yc)
608+
self.assertEqual(3.0, a.zc)
609+
return
610+
611+
def test_occupancy(self):
612+
'check Atom.occupancy'
613+
a = self.a
614+
a.occupancy, = numpy.arange(1)
615+
self.assertEqual(0.0, a.occupancy)
616+
a.occupancy = numpy.float32(0.5)
617+
self.assertEqual(0.5, a.occupancy)
618+
return
619+
620+
def test_anisotropy(self):
621+
'check Atom.anisotropy'
622+
a = self.a
623+
nptrue, npfalse = (numpy.arange(2) < 1)
624+
a.anisotropy = nptrue
625+
self.assertTrue(a.anisotropy)
626+
a.anisotropy = npfalse
627+
self.assertFalse(a.anisotropy)
628+
return
629+
630+
def test_ucij(self):
631+
'check Atom attributes u11, u22, etc.'
632+
a = self.a
633+
a.uc11, a.uc22, a.uc33, a.uc12, a.uc13, a.uc23 = numpy.arange(1, 7)
634+
uijexp = [[1, 4, 5], [4, 2, 6], [5, 6, 3]]
635+
self.assertTrue(numpy.array_equal(uijexp, a.uij_cartn))
636+
return
637+
602638
# End of class TestAtom
603639

604640
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)