Skip to content

Commit c165196

Browse files
MNT: fix sgconstrain parameters
1 parent 1f28f1f commit c165196

File tree

3 files changed

+50
-42
lines changed

3 files changed

+50
-42
lines changed

src/diffpy/pdfgui/control/fitstructure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def getSpaceGroupList(self):
383383
existing_names[sg.short_name] = True
384384
# sort by International Tables number, stay compatible with 2.3
385385
n_sg = [(sg.number % 1000, sg) for sg in unique_named_list]
386-
n_sg.sort()
386+
n_sg = sorted(n_sg, key=lambda x: x[0]) #sort by the first element of tuple.
387387
FitStructure.sorted_standard_space_groups = [sg for n, sg in n_sg]
388388
sglist = list(FitStructure.sorted_standard_space_groups)
389389
if self.custom_spacegroup:
@@ -491,7 +491,7 @@ def applySymmetryConstraints(self, spacegroup, indices, posflag, Uijflag,
491491
# find the largest used parameter index; pidxused must have an element
492492
pidxused = [i for i in self.owner.updateParameters()] + [0]
493493
# new parameters will start at the next decade
494-
parzeroidx = 10*(max(pidxused)/10) + 10
494+
parzeroidx = 10*(int(max(pidxused)/10)) + 10
495495
# dictionary of parameter indices and their values
496496
newparvalues = {}
497497
selatoms = [self.initial[i] for i in uindices]

src/diffpy/pdfgui/gui/design/sgconstraindialog.wxg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<!-- generated by wxGlade 0.9.3 on Fri Jul 19 16:06:06 2019 -->
2+
<!-- generated by wxGlade 1.0.5 on Sun May 14 18:17:55 2023 -->
33

44
<application encoding="ISO-8859-1" for_version="3.0" header_extension=".h" indent_amount="4" indent_symbol="space" is_template="0" language="python" mark_blocks="1" option="0" overwrite="0" path="../sgconstraindialog.py" source_extension=".cpp" top_window="" use_gettext="0" use_new_namespace="1">
55
<object class="SGConstrainDialog" name="sgcDialog" base="EditDialog">
@@ -11,7 +11,7 @@
1111
<object class="sizeritem">
1212
<option>0</option>
1313
<border>5</border>
14-
<flag>wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
14+
<flag>wxALL|wxALIGN_CENTER_HORIZONTAL</flag>
1515
<object class="wxStaticText" name="numConstrainedLabel" base="EditStaticText">
1616
<attribute>1</attribute>
1717
</object>
@@ -113,7 +113,7 @@
113113
<object class="sizeritem">
114114
<option>0</option>
115115
<border>5</border>
116-
<flag>wxALL|wxALIGN_CENTER_VERTICAL</flag>
116+
<flag>wxALL</flag>
117117
<object class="wxCheckBox" name="tfCheckBox" base="EditCheckBox">
118118
<events>
119119
<handler event="EVT_CHECKBOX">onTempFlag</handler>

src/diffpy/pdfgui/gui/sgconstraindialog.py

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,64 @@ def __init__(self, *args, **kwds):
2727
# begin wxGlade: SGConstrainDialog.__init__
2828
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_DIALOG_STYLE
2929
wx.Dialog.__init__(self, *args, **kwds)
30+
self.SetTitle("Space Group Constraints")
31+
32+
sizer_2 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Space Group Constraints"), wx.VERTICAL)
33+
3034
self.numConstrainedLabel = wx.StaticText(self, wx.ID_ANY, "")
35+
sizer_2.Add(self.numConstrainedLabel, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5)
36+
37+
sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
38+
sizer_2.Add(sizer_3, 0, wx.EXPAND, 0)
39+
3140
self.sgLabel = wx.StaticText(self, wx.ID_ANY, "Space Group")
41+
sizer_3.Add(self.sgLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
42+
3243
self.sgComboBox = wx.ComboBox(self, wx.ID_ANY, choices=["P1"], style=0)
44+
self.sgComboBox.SetSelection(0)
45+
sizer_3.Add(self.sgComboBox, 0, wx.ALL, 5)
46+
47+
sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
48+
sizer_2.Add(sizer_4, 0, wx.EXPAND, 0)
49+
3350
self.offsetLabel = wx.StaticText(self, wx.ID_ANY, "Origin Offset")
51+
sizer_4.Add(self.offsetLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
52+
3453
self.offsetTextCtrlX = wx.TextCtrl(self, wx.ID_ANY, "0")
54+
sizer_4.Add(self.offsetTextCtrlX, 0, wx.ALL, 5)
55+
3556
self.offsetTextCtrlY = wx.TextCtrl(self, wx.ID_ANY, "0")
57+
sizer_4.Add(self.offsetTextCtrlY, 0, wx.ALL, 5)
58+
3659
self.offsetTextCtrlZ = wx.TextCtrl(self, wx.ID_ANY, "0")
60+
sizer_4.Add(self.offsetTextCtrlZ, 0, wx.ALL, 5)
61+
3762
self.positionCheckBox = wx.CheckBox(self, wx.ID_ANY, "constrain positions")
63+
self.positionCheckBox.SetValue(1)
64+
sizer_2.Add(self.positionCheckBox, 0, wx.ALL, 5)
65+
3866
self.tfCheckBox = wx.CheckBox(self, wx.ID_ANY, "constrain temperature factors")
67+
self.tfCheckBox.SetValue(1)
68+
sizer_2.Add(self.tfCheckBox, 0, wx.ALL, 5)
69+
3970
self.static_line_1 = wx.StaticLine(self, wx.ID_ANY)
71+
sizer_2.Add(self.static_line_1, 0, wx.EXPAND, 0)
72+
73+
sizer_4_copy = wx.BoxSizer(wx.HORIZONTAL)
74+
sizer_2.Add(sizer_4_copy, 0, wx.EXPAND, 0)
75+
76+
sizer_4_copy.Add((0, 0), 1, wx.EXPAND, 0)
77+
4078
self.cancelButton = wx.Button(self, wx.ID_CANCEL, "Cancel")
79+
sizer_4_copy.Add(self.cancelButton, 0, wx.ALL, 5)
80+
4181
self.okButton = wx.Button(self, wx.ID_OK, "OK")
82+
sizer_4_copy.Add(self.okButton, 0, wx.ALL, 5)
4283

43-
self.__set_properties()
44-
self.__do_layout()
84+
self.SetSizer(sizer_2)
85+
sizer_2.Fit(self)
86+
87+
self.Layout()
4588

4689
self.Bind(wx.EVT_COMBOBOX, self.onSGSelect, self.sgComboBox)
4790
self.Bind(wx.EVT_TEXT_ENTER, self.onSGTextEnter, self.sgComboBox)
@@ -55,41 +98,6 @@ def __init__(self, *args, **kwds):
5598
# end wxGlade
5699
self.__customProperties()
57100

58-
def __set_properties(self):
59-
# begin wxGlade: SGConstrainDialog.__set_properties
60-
self.SetTitle("Space Group Constraints")
61-
self.sgComboBox.SetSelection(0)
62-
self.positionCheckBox.SetValue(1)
63-
self.tfCheckBox.SetValue(1)
64-
# end wxGlade
65-
66-
def __do_layout(self):
67-
# begin wxGlade: SGConstrainDialog.__do_layout
68-
sizer_2 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Space Group Constraints"), wx.VERTICAL)
69-
sizer_4_copy = wx.BoxSizer(wx.HORIZONTAL)
70-
sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
71-
sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
72-
sizer_2.Add(self.numConstrainedLabel, 0, wx.ALIGN_CENTER | wx.ALL, 5)
73-
sizer_3.Add(self.sgLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
74-
sizer_3.Add(self.sgComboBox, 0, wx.ALL, 5)
75-
sizer_2.Add(sizer_3, 0, wx.EXPAND, 0)
76-
sizer_4.Add(self.offsetLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
77-
sizer_4.Add(self.offsetTextCtrlX, 0, wx.ALL, 5)
78-
sizer_4.Add(self.offsetTextCtrlY, 0, wx.ALL, 5)
79-
sizer_4.Add(self.offsetTextCtrlZ, 0, wx.ALL, 5)
80-
sizer_2.Add(sizer_4, 0, wx.EXPAND, 0)
81-
sizer_2.Add(self.positionCheckBox, 0, wx.ALL, 5)
82-
sizer_2.Add(self.tfCheckBox, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
83-
sizer_2.Add(self.static_line_1, 0, wx.EXPAND, 0)
84-
sizer_4_copy.Add((0, 0), 1, wx.EXPAND, 0)
85-
sizer_4_copy.Add(self.cancelButton, 0, wx.ALL, 5)
86-
sizer_4_copy.Add(self.okButton, 0, wx.ALL, 5)
87-
sizer_2.Add(sizer_4_copy, 0, wx.EXPAND, 0)
88-
self.SetSizer(sizer_2)
89-
sizer_2.Fit(self)
90-
self.Layout()
91-
# end wxGlade
92-
93101
###########################################################################
94102

95103
def __customProperties(self):

0 commit comments

Comments
 (0)