Skip to content

Commit 6182ac4

Browse files
committed
Merge branch 'fix-crash-on-occupancy-int64'
* accept diffpy.structure.Atom occupancy of np.int64 type Resolve #18.
2 parents f478e0c + eef86ce commit 6182ac4

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/diffpy/srreal/structureconverters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def _fetchDiffPyStructureData(adpt, stru):
142142
aa = AdapterAtom()
143143
for a0 in stru:
144144
aa.atomtype = a0.element
145-
aa.occupancy = a0.occupancy
145+
aa.occupancy = float(a0.occupancy)
146146
aa.anisotropy = a0.anisotropy
147147
# copy fractional coordinates
148148
aa.xyz_cartn = a0.xyz

src/diffpy/srreal/tests/teststructureadapter.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ def test_createStructureAdapterTypes(self):
6060
self.assertTrue(type(adpt3) is DiffPyStructureAtomicAdapter)
6161
return
6262

63+
def test_createStructureAdapter_int64_occupancy(self):
64+
"""Check Structure conversion when occupany is of numpy.int64 type.
65+
"""
66+
self.nickel[0].occupancy = numpy.int64(0)
67+
self.nickel[1].occupancy = numpy.int64(1)
68+
adpt = createStructureAdapter(self.nickel)
69+
self.assertEqual(0.0, adpt.siteOccupancy(0))
70+
self.assertEqual(1.0, adpt.siteOccupancy(1))
71+
return
72+
6373
def test_pickling(self):
6474
'''check pickling of StructureAdapter instances.
6575
'''

0 commit comments

Comments
 (0)