Skip to content

Commit 7595940

Browse files
Merge pull request #96 from dragonyanglong/fix_sgconstrain
Fix sgconstrain
2 parents 3a3d3e9 + 5e4a520 commit 7595940

16 files changed

+458
-333
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Notable differences from version 1.1.2.
44

5-
## Version 2.0.1 – 2023-05-11
5+
## Version 2.0.2 – 2023-05-14
66

77
### Added
88

@@ -12,6 +12,7 @@ Notable differences from version 1.1.2.
1212
### Changed
1313

1414
- Update wxpython to 4.1.1 and remove incompatible align flags.
15+
- Update configparser use strict as False.
1516
- Update tutorial project files for py3.
1617

1718
### Deprecated

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# Use this version when git data are not available, like in git zip archive.
1717
# Update when tagging a new release.
18-
FALLBACK_VERSION = '2.0.1'
18+
FALLBACK_VERSION = '2.0.2'
1919

2020
# determine if we run with Python 3.
2121
PY3 = (sys.version_info[0] == 3)

src/diffpy/pdfgui/control/fitstructure.py

+2-2
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/bondlengthdialog.py

+58-45
Original file line numberDiff line numberDiff line change
@@ -27,76 +27,89 @@ def __init__(self, *args, **kwds):
2727
# begin wxGlade: BondLengthDialog.__init__
2828
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_DIALOG_STYLE
2929
wx.Dialog.__init__(self, *args, **kwds)
30+
self.SetTitle("Calculate Bond Lengths")
31+
32+
sizer_2 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, ""), wx.VERTICAL)
33+
3034
self.instructionsLabel = wx.StaticText(self, wx.ID_ANY, "Enter the indices of two atoms.")
35+
sizer_2.Add(self.instructionsLabel, 0, wx.ALL, 5)
36+
37+
sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
38+
sizer_2.Add(sizer_3, 0, wx.EXPAND, 0)
39+
3140
self.indicesLabel = wx.StaticText(self, wx.ID_ANY, "Atom Indices")
41+
sizer_3.Add(self.indicesLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
42+
3243
self.aSpinCtrl = wx.SpinCtrl(self, wx.ID_ANY, "", min=0, max=100, style=0)
44+
self.aSpinCtrl.SetMinSize((80, 27))
45+
sizer_3.Add(self.aSpinCtrl, 0, wx.ALL, 5)
46+
3347
self.bSpinCtrl = wx.SpinCtrl(self, wx.ID_ANY, "", min=0, max=100, style=0)
48+
self.bSpinCtrl.SetMinSize((80, 27))
49+
sizer_3.Add(self.bSpinCtrl, 0, wx.ALL, 5)
50+
3451
self.static_line_2 = wx.StaticLine(self, wx.ID_ANY)
52+
sizer_2.Add(self.static_line_2, 0, wx.BOTTOM | wx.EXPAND, 5)
53+
3554
self.instructionsLabel2 = wx.StaticText(self, wx.ID_ANY, "Or enter the elemental symbols of two atoms and\nthe range over which to calculate the bond lengths.")
36-
self.elementLabel = wx.StaticText(self, wx.ID_ANY, "Elements")
37-
self.aComboBox = wx.ComboBox(self, wx.ID_ANY, choices=[], style=0)
38-
self.bComboBox = wx.ComboBox(self, wx.ID_ANY, choices=[], style=0)
39-
self.rangeLabel = wx.StaticText(self, wx.ID_ANY, "Range")
40-
self.lbTextCtrl = wx.TextCtrl(self, wx.ID_ANY, "")
41-
self.toLabel = wx.StaticText(self, wx.ID_ANY, "to")
42-
self.ubTextCtrl = wx.TextCtrl(self, wx.ID_ANY, "")
43-
self.static_line_1 = wx.StaticLine(self, wx.ID_ANY)
44-
self.cancelButton = wx.Button(self, wx.ID_CANCEL, "Cancel")
45-
self.okButton = wx.Button(self, wx.ID_OK, "OK")
55+
sizer_2.Add(self.instructionsLabel2, 0, wx.ALL, 5)
4656

47-
self.__set_properties()
48-
self.__do_layout()
57+
sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
58+
sizer_2.Add(sizer_4, 0, wx.EXPAND, 0)
4959

50-
self.Bind(wx.EVT_SPINCTRL, self.onSpin, self.aSpinCtrl)
51-
self.Bind(wx.EVT_SPINCTRL, self.onSpin, self.bSpinCtrl)
52-
self.Bind(wx.EVT_BUTTON, self.onCancel, self.cancelButton)
53-
self.Bind(wx.EVT_BUTTON, self.onOk, self.okButton)
54-
# end wxGlade
55-
self.__customProperties()
60+
self.elementLabel = wx.StaticText(self, wx.ID_ANY, "Elements")
61+
sizer_4.Add(self.elementLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
5662

57-
def __set_properties(self):
58-
# begin wxGlade: BondLengthDialog.__set_properties
59-
self.SetTitle("Calculate Bond Lengths")
60-
self.aSpinCtrl.SetMinSize((80, 27))
61-
self.bSpinCtrl.SetMinSize((80, 27))
63+
self.aComboBox = wx.ComboBox(self, wx.ID_ANY, choices=[], style=0)
6264
self.aComboBox.SetMinSize((80, 27))
65+
sizer_4.Add(self.aComboBox, 0, wx.ALL, 5)
66+
67+
self.bComboBox = wx.ComboBox(self, wx.ID_ANY, choices=[], style=0)
6368
self.bComboBox.SetMinSize((80, 27))
64-
self.lbTextCtrl.SetMinSize((80, 27))
65-
self.ubTextCtrl.SetMinSize((80, 27))
66-
# end wxGlade
69+
sizer_4.Add(self.bComboBox, 0, wx.ALL, 5)
6770

68-
def __do_layout(self):
69-
# begin wxGlade: BondLengthDialog.__do_layout
70-
sizer_2 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, ""), wx.VERTICAL)
71-
sizer_4_copy = wx.BoxSizer(wx.HORIZONTAL)
7271
sizer_4_copy_1 = wx.BoxSizer(wx.HORIZONTAL)
73-
sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
74-
sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
75-
sizer_2.Add(self.instructionsLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
76-
sizer_3.Add(self.indicesLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
77-
sizer_3.Add(self.aSpinCtrl, 0, wx.ALL, 5)
78-
sizer_3.Add(self.bSpinCtrl, 0, wx.ALL, 5)
79-
sizer_2.Add(sizer_3, 0, wx.EXPAND, 0)
80-
sizer_2.Add(self.static_line_2, 0, wx.BOTTOM | wx.EXPAND, 5)
81-
sizer_2.Add(self.instructionsLabel2, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
82-
sizer_4.Add(self.elementLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
83-
sizer_4.Add(self.aComboBox, 0, wx.ALL, 5)
84-
sizer_4.Add(self.bComboBox, 0, wx.ALL, 5)
85-
sizer_2.Add(sizer_4, 0, wx.EXPAND, 0)
72+
sizer_2.Add(sizer_4_copy_1, 0, wx.EXPAND, 0)
73+
74+
self.rangeLabel = wx.StaticText(self, wx.ID_ANY, "Range")
8675
sizer_4_copy_1.Add(self.rangeLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
76+
77+
self.lbTextCtrl = wx.TextCtrl(self, wx.ID_ANY, "")
78+
self.lbTextCtrl.SetMinSize((80, 27))
8779
sizer_4_copy_1.Add(self.lbTextCtrl, 0, wx.ALL, 5)
80+
81+
self.toLabel = wx.StaticText(self, wx.ID_ANY, "to")
8882
sizer_4_copy_1.Add(self.toLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
83+
84+
self.ubTextCtrl = wx.TextCtrl(self, wx.ID_ANY, "")
85+
self.ubTextCtrl.SetMinSize((80, 27))
8986
sizer_4_copy_1.Add(self.ubTextCtrl, 0, wx.ALL, 5)
90-
sizer_2.Add(sizer_4_copy_1, 0, wx.EXPAND, 0)
87+
88+
self.static_line_1 = wx.StaticLine(self, wx.ID_ANY)
9189
sizer_2.Add(self.static_line_1, 0, wx.EXPAND, 0)
90+
91+
sizer_4_copy = wx.BoxSizer(wx.HORIZONTAL)
92+
sizer_2.Add(sizer_4_copy, 0, wx.EXPAND, 0)
93+
9294
sizer_4_copy.Add((0, 0), 1, wx.EXPAND, 0)
95+
96+
self.cancelButton = wx.Button(self, wx.ID_CANCEL, "Cancel")
9397
sizer_4_copy.Add(self.cancelButton, 0, wx.ALL, 5)
98+
99+
self.okButton = wx.Button(self, wx.ID_OK, "OK")
94100
sizer_4_copy.Add(self.okButton, 0, wx.ALL, 5)
95-
sizer_2.Add(sizer_4_copy, 0, wx.EXPAND, 0)
101+
96102
self.SetSizer(sizer_2)
97103
sizer_2.Fit(self)
104+
98105
self.Layout()
106+
107+
self.Bind(wx.EVT_SPINCTRL, self.onSpin, self.aSpinCtrl)
108+
self.Bind(wx.EVT_SPINCTRL, self.onSpin, self.bSpinCtrl)
109+
self.Bind(wx.EVT_BUTTON, self.onCancel, self.cancelButton)
110+
self.Bind(wx.EVT_BUTTON, self.onOk, self.okButton)
99111
# end wxGlade
112+
self.__customProperties()
100113

101114
def __customProperties(self):
102115
"""Set the custom properties."""

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

+3-3
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:00:05 2019 -->
2+
<!-- generated by wxGlade 1.0.5 on Sun May 14 18:16:11 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="../bondlengthdialog.py" source_extension=".cpp" top_window="blenDialog" use_gettext="0" use_new_namespace="1">
55
<object class="BondLengthDialog" name="blenDialog" base="EditDialog">
@@ -10,7 +10,7 @@
1010
<object class="sizeritem">
1111
<option>0</option>
1212
<border>5</border>
13-
<flag>wxALL|wxALIGN_CENTER_VERTICAL</flag>
13+
<flag>wxALL</flag>
1414
<object class="wxStaticText" name="instructionsLabel" base="EditStaticText">
1515
<label>Enter the indices of two atoms.</label>
1616
<attribute>1</attribute>
@@ -69,7 +69,7 @@
6969
<object class="sizeritem">
7070
<option>0</option>
7171
<border>5</border>
72-
<flag>wxALL|wxALIGN_CENTER_VERTICAL</flag>
72+
<flag>wxALL</flag>
7373
<object class="wxStaticText" name="instructionsLabel2" base="EditStaticText">
7474
<label>Or enter the elemental symbols of two atoms and\nthe range over which to calculate the bond lengths.</label>
7575
<attribute>1</attribute>

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

+2-2
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 Tue Aug 13 11:58:16 2019 -->
2+
<!-- generated by wxGlade 1.0.5 on Sun May 14 18:20:37 2023 -->
33

44
<application encoding="UTF-8" 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="../phaseconfigurepanel.py" source_extension=".cpp" use_gettext="0" use_new_namespace="1">
55
<object class="PhaseConfigurePanel" name="configurePanel" base="EditTopLevelPanel">
@@ -338,7 +338,7 @@
338338
<object class="sizeritem">
339339
<option>0</option>
340340
<border>5</border>
341-
<flag>wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
341+
<flag>wxALL|wxALIGN_CENTER_VERTICAL</flag>
342342
<object class="wxStaticText" name="labelIncludedPairs" base="EditStaticText">
343343
<label>Included Pairs</label>
344344
<attribute>1</attribute>

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

+2-2
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 Tue Aug 13 12:46:41 2019 -->
2+
<!-- generated by wxGlade 1.0.5 on Sun May 14 18:20:28 2023 -->
33

44
<application encoding="UTF-8" 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="../phaseconstraintspanel.py" source_extension=".cpp" use_gettext="0" use_new_namespace="1">
55
<object class="PhaseConstraintsPanel" name="constraintsPanel" base="EditTopLevelPanel">
@@ -337,7 +337,7 @@
337337
<object class="sizeritem">
338338
<option>0</option>
339339
<border>5</border>
340-
<flag>wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
340+
<flag>wxALL|wxALIGN_CENTER_VERTICAL</flag>
341341
<object class="wxStaticText" name="labelIncludedPairs" base="EditStaticText">
342342
<label>Included Pairs</label>
343343
<attribute>1</attribute>

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

+2-2
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 Tue Aug 13 14:02:02 2019 -->
2+
<!-- generated by wxGlade 1.0.5 on Sun May 14 18:20:13 2023 -->
33

44
<application encoding="UTF-8" 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="../phaseresultspanel.py" source_extension=".cpp" use_gettext="0" use_new_namespace="1">
55
<object class="PhaseResultsPanel" name="resultsPanel" base="EditTopLevelPanel">
@@ -337,7 +337,7 @@
337337
<object class="sizeritem">
338338
<option>0</option>
339339
<border>5</border>
340-
<flag>wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
340+
<flag>wxALL|wxALIGN_CENTER_VERTICAL</flag>
341341
<object class="wxStaticText" name="labelIncludedPairs" base="EditStaticText">
342342
<label>Included Pairs</label>
343343
<attribute>1</attribute>

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

+3-3
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/design/sgstructuredialog.wxg

+2-2
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:15 2019 -->
2+
<!-- generated by wxGlade 1.0.5 on Sun May 14 18:17:46 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="../sgstructuredialog.py" source_extension=".cpp" top_window="" use_gettext="0" use_new_namespace="1">
55
<object class="SGStructureDialog" name="sgsDialog" base="EditDialog">
@@ -11,7 +11,7 @@
1111
<object class="sizeritem">
1212
<option>0</option>
1313
<border>5</border>
14-
<flag>wxALL|wxALIGN_CENTER_VERTICAL</flag>
14+
<flag>wxALL</flag>
1515
<object class="wxStaticText" name="numConstrainedLabel" base="EditStaticText">
1616
<attribute>1</attribute>
1717
</object>

src/diffpy/pdfgui/gui/mainframe.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ def __customProperties(self):
298298
self.runningDict = {}
299299

300300
# The configuration parser for getting configuration data.
301-
self.cP = QuotedConfigParser()
301+
# self.cP = QuotedConfigParser()
302+
self.cP = QuotedConfigParser(strict=False) #Long try this to avoid DuplicateSectionError
302303

303304
# Set the program mode
304305
self.mode = "fitting"

0 commit comments

Comments
 (0)