File tree Expand file tree Collapse file tree 4 files changed +11
-7
lines changed
Expand file tree Collapse file tree 4 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ def setUp(self):
1111 cif_content = CrystalExamples .get_cif_content (num = 1 )
1212 self .empty_experiment : PowderExperiment = PowderExperiment .make_empty ()
1313 self .full_experiment : PowderExperiment = PowderExperiment .from_cif (cif_content = cif_content )
14- self .full_experiment .primary_phase .calculate_properties ()
14+ self .full_experiment .phases [ 0 ] .calculate_properties ()
1515
1616 def test_is_empty (self ):
1717 empty_experiment = PowderExperiment .make_empty ()
Original file line number Diff line number Diff line change 99import numpy as np
1010from numpy .typing import NDArray
1111from scipy .interpolate import CubicSpline
12- from xrdpattern .crystal import CrystalStructure
1312
1413from xrdpattern .parsing import MasterParser , Formats
1514from xrdpattern .xrd import XrdData
Original file line number Diff line number Diff line change 33import json
44from dataclasses import dataclass , field
55from dataclasses import fields
6+ from typing import Optional
67
78import numpy as np
89from numpy .typing import NDArray
@@ -84,8 +85,12 @@ def num_entries(self) -> int:
8485 return len (self .two_theta_values )
8586
8687 @property
87- def primary_phase (self ) -> CrystalStructure :
88- return self .powder_experiment .phases [0 ]
88+ def primary_phase (self ) -> Optional [CrystalStructure ]:
89+ phases = self .powder_experiment .phases
90+ if len (phases ) > 0 :
91+ return phases [0 ]
92+ else :
93+ return None
8994
9095 @property
9196 def startval (self ):
Original file line number Diff line number Diff line change @@ -81,15 +81,15 @@ def has_label(self, label_type: LabelType) -> bool:
8181 if label_type == LabelType .lattice :
8282 return True
8383 elif label_type == LabelType .spg :
84- return self .primary_phase .spacegroup is not None
84+ return self .phases [ 0 ] .spacegroup is not None
8585 elif label_type == LabelType .composition :
86- return self .primary_phase .chemical_composition is not None
86+ return self .phases [ 0 ] .chemical_composition is not None
8787 elif label_type == LabelType .temperature :
8888 return self .temp_K is not None
8989 elif label_type == LabelType .crystallite_size :
9090 return self .crystallite_size_nm is not None
9191 elif label_type == LabelType .atom_coords :
92- return len (self .primary_phase .basis .atom_sites ) > 0
92+ return len (self .phases [ 0 ] .basis .atom_sites ) > 0
9393 else :
9494 raise ValueError (f'Label type { label_type } is not supported.' )
9595
You can’t perform that action at this time.
0 commit comments