Skip to content

Commit 74a5ff3

Browse files
committed
FIX: handling of CIF with unknown space group
Raise StructureFormatError as appropriate. Resolves #21
1 parent b124623 commit 74a5ff3

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

src/diffpy/Structure/Parsers/P_cif.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ def _parse_space_group_symop_operation_xyz(self, block):
479479
short_name=new_short_name,
480480
crystal_system=new_crystal_system,
481481
symop_list=symop_list)
482+
if self.spacegroup is None:
483+
emsg = "CIF file has unknown space group identifier {!r}."
484+
raise StructureFormatError(emsg.format(sgid))
482485
self._expandAsymmetricUnit()
483486
return
484487

src/diffpy/Structure/tests/TestP_cif.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,14 @@ def test_nosites_cif(self):
244244
self.assertEqual(10.413, stru.lattice.c)
245245
return
246246

247+
def test_badspacegroup_cif(self):
248+
"""Test reading of CIF file with unrecognized space group.
249+
"""
250+
ptest = self.ptest
251+
filename = datafile('badspacegroup.cif')
252+
self.assertRaises(StructureFormatError, ptest.parseFile, filename)
253+
return
254+
247255
def test_getParser(self):
248256
"""Test passing of eps keyword argument by getParser function.
249257
"""
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#------------------------------------------------------------------------------
2+
#$Date: 2015-01-27 21:58:39 +0200 (Tue, 27 Jan 2015) $
3+
#$Revision: 130149 $
4+
#$URL: svn://www.crystallography.net/cod/cif/1/10/01/1100106.cif $
5+
#------------------------------------------------------------------------------
6+
#
7+
# This file is available in the Crystallography Open Database (COD),
8+
# http://www.crystallography.net/
9+
#
10+
# All data on this site have been placed in the public domain by the
11+
# contributors.
12+
#
13+
data_1100106
14+
_publ_section_title 'Clay Montmorillonite'
15+
_chemical_name_common Montmorillonite
16+
_symmetry_cell_setting monoclinic
17+
_symmetry_space_group_name_H-M C2:b1
18+
_audit_update_record 'Last update Thu Dec 18 14:12:16 CET 2003'
19+
_cell_angle_alpha 90
20+
_cell_angle_beta 100.3(1)
21+
_cell_angle_gamma 90
22+
_cell_formula_units_Z 1
23+
_cell_length_a 5.411(4)
24+
_cell_length_b 9.0(5)
25+
_cell_length_c 10.25(2)
26+
_refine_ls_goodness_of_fit_all 1.1109964
27+
_refine_ls_R_factor_all 0.04240644
28+
_refine_ls_wR_factor_all 0.06303699
29+
_cod_database_code 1100106
30+
loop_
31+
_atom_site_label
32+
_atom_site_type_symbol
33+
_atom_site_occupancy
34+
_atom_site_fract_x
35+
_atom_site_fract_y
36+
_atom_site_fract_z
37+
_atom_site_B_iso_or_equiv
38+
Al1 Al3+ 1.00000 0 0 0 0.5
39+
Al2 Al3+ 1.00000 0 0.321 0 0.5
40+
Mg1 Mg2+ 1.00000 0 0.654 0 0.5
41+
Si1 Si4+ 1.00000 0.432 0.333 0.27 0.5
42+
Si2 Si4+ 1.00000 0.432 0.662 0.27 0.5
43+
K1 K1+ 1.00000 0.5 0 0.5 0.5
44+
O1 O2- 1.00000 0.489 0.496 0.335 0.8
45+
O2 O2- 1.00000 0.173 0.725 0.335 0.8
46+
O3 O2- 1.00000 0.17 0.268 0.32 0.8
47+
O4 O2- 1.00000 0.334 -0.024 0.105 0.8
48+
O5 O2- 1.00000 0.417 0.656 0.109 0.8
49+
O6 O2- 1.00000 0.343 0.347 0.109 0.8

0 commit comments

Comments
 (0)