diff --git a/src/diffpy/pdfgui/control/fitstructure.py b/src/diffpy/pdfgui/control/fitstructure.py index f643c994..515fdec5 100644 --- a/src/diffpy/pdfgui/control/fitstructure.py +++ b/src/diffpy/pdfgui/control/fitstructure.py @@ -252,7 +252,7 @@ def _restoreAtomConstraints(self, acd): acd -- dictionary obtained from _popAtomConstraints() """ for i, a in enumerate(self.initial): - if not a in acd: + if a not in acd: continue # there are some constraints for atom a siteindex = i + 1 diff --git a/src/diffpy/pdfgui/control/organizer.py b/src/diffpy/pdfgui/control/organizer.py index 31a5a095..e5c74d37 100644 --- a/src/diffpy/pdfgui/control/organizer.py +++ b/src/diffpy/pdfgui/control/organizer.py @@ -20,6 +20,15 @@ from diffpy.pdfgui.control.pdfcomponent import PDFComponent +# Search datasets for spdiameter and its constraints +def spd_assigned(ds): + return bool(ds.spdiameter) + + +def spd_constrained(ds): + return "spdiameter" in ds.constraints + + class Organizer(PDFComponent): """Base class for Fitting. It holds separate lists of datasets, strucs and calculations @@ -241,9 +250,7 @@ def __forward_spdiameter(self): for stru in self.strucs: if stru.getvar("spdiameter"): return - # Search datasets for spdiameter and its constraints - spd_assigned = lambda ds: bool(ds.spdiameter) - spd_constrained = lambda ds: "spdiameter" in ds.constraints + # Figure out the value and constraint for spdiameter. # The highest priority is for a dataset with constrained spdiameter, # then for dataset with assigned spdiameter and finally from diff --git a/src/diffpy/pdfgui/control/pdfguicontrol.py b/src/diffpy/pdfgui/control/pdfguicontrol.py index bb39baa8..15632a0d 100644 --- a/src/diffpy/pdfgui/control/pdfguicontrol.py +++ b/src/diffpy/pdfgui/control/pdfguicontrol.py @@ -58,7 +58,7 @@ def __init__(self, gui=None): self.fittingQueue = [] self.currentFitting = None self.queueManager = PDFGuiControl.QueueManager(self) - ##self.startQueue() + # self.startQueue() def reset(self): """clean up for a new project""" diff --git a/src/diffpy/pdfgui/control/plotter.py b/src/diffpy/pdfgui/control/plotter.py index 77134fb1..39359cbd 100644 --- a/src/diffpy/pdfgui/control/plotter.py +++ b/src/diffpy/pdfgui/control/plotter.py @@ -129,6 +129,11 @@ def _buildStyle(plotter, name, group, yNames): return style +def deblank(s): + """Remove all whitespace from the given string.""" + return "".join(s.split()) + + class Plotter(PDFComponent): """Plots a single graph. It can have multiple curves.""" @@ -622,7 +627,6 @@ def export(self, filename): header = "# Generated on %s by %s.\n" % (time.ctime(), getpass.getuser()) header += "# This file was created by PDFgui.\n" outfile.write(header) - deblank = lambda s: "".join(s.split()) xylist = [(c.x, c.y) for c in self.curves] xynames = [(_transName(c.xStr), deblank(c.name)) for c in self.curves] _exportCompactData(outfile, xylist, xynames) diff --git a/src/diffpy/pdfgui/doc/manual/extractEquations.py b/src/diffpy/pdfgui/doc/manual/extractEquations.py index 4c32814e..ce3a9819 100644 --- a/src/diffpy/pdfgui/doc/manual/extractEquations.py +++ b/src/diffpy/pdfgui/doc/manual/extractEquations.py @@ -1,4 +1,7 @@ #!/usr/bin/python +import os +import shutil +import sys """Read one or more texinfo files and extract any equations marked in the code with '@EquationMark' macro as PNG files to the images @@ -31,10 +34,6 @@ ############################################################################## # business -import os -import shutil -import sys - def loadEquations(): """Search for equation codes preceded by @EquationMark macro. diff --git a/src/diffpy/pdfgui/doc/tutorial/tui_mno_bond_lengths.py b/src/diffpy/pdfgui/doc/tutorial/tui_mno_bond_lengths.py index 79c1b527..1f43d196 100755 --- a/src/diffpy/pdfgui/doc/tutorial/tui_mno_bond_lengths.py +++ b/src/diffpy/pdfgui/doc/tutorial/tui_mno_bond_lengths.py @@ -7,12 +7,17 @@ are plotted versus temperature and saved to "mno-bond-lengths.dat" file. """ +import pylab + +from diffpy.pdffit2 import PdfFit + +# Import tui (Text User Interface) functions from diffpy.pdfgui +from diffpy.pdfgui import tui + # PDFgui project file project_file = "lmo-template.ddp3" output_file = "mno-bond-lengths.dat" -# Import tui (Text User Interface) functions from diffpy.pdfgui -from diffpy.pdfgui import tui # load project file prj = tui.LoadProject(project_file) @@ -21,7 +26,7 @@ # using diffpy.pdffit2 # Create a PDF calculator object that will be used in that function. -from diffpy.pdffit2 import PdfFit + pf = PdfFit() @@ -69,7 +74,6 @@ def shortestBond_MnO(stru): # Plot results using matplotlib; pylab is a part of matplotlib that # provides MATLAB-like plotting functions. -import pylab pylab.plot(temperatures, MnO_bond_lengths, "o--") pylab.title("Data from refined phases in PDFgui project %s" % project_file) diff --git a/src/diffpy/pdfgui/gui/dopingseriespanel.py b/src/diffpy/pdfgui/gui/dopingseriespanel.py index 211e2f8e..fd60c1bf 100644 --- a/src/diffpy/pdfgui/gui/dopingseriespanel.py +++ b/src/diffpy/pdfgui/gui/dopingseriespanel.py @@ -18,7 +18,6 @@ import os.path import re -import sys import wx @@ -41,7 +40,10 @@ def __init__(self, *args, **kwds): self.instructionsLabel = wx.StaticText( self, wx.ID_ANY, - "Select a fit from the tree on the left then add datasets and assign\ndoping elements and values below. If you have not set up a fit to be\nthe template for the series, hit cancel and rerun this macro once a\nfit has been created.", + "Select a fit from the tree on the left then add datasets and " + + "assign\ndoping elements and values below. " + + "If you have not set up a fit to be\nthe template for the series, " + + "hit cancel and rerun this macro once a\nfit has been created.", ) self.instructionsLabel.SetFont( wx.Font( @@ -210,7 +212,11 @@ def onAdd(self, event): # wxGlade: DopingSeriesPanel. if not dir: dir = self.mainFrame.workpath - matchstring = "PDF data files (*.gr)|*.gr|PDF fit files (*.fgr)|*.fgr|PDF fit files (*.fit)|*.fit|PDF calculation files (*.cgr)|*.cgr|PDF calculation files (*.calc)|*.calc|All Files|*" + matchstring = ( + "PDF data files (*.gr)|*.gr|PDF fit files (*.fgr)|*.fgr|PDF fit files (*.fit)|" + "*.fit|PDF calculation files (*.cgr)|*.cgr|PDF calculation files (*.calc)|*.calc|" + "All Files|*" + ) d = wx.FileDialog( None, "Choose files", @@ -304,7 +310,7 @@ def onCancel(self, event): # wxGlade: DopingSeriesPanel. self.mainFrame.switchRightPanel("blank") return - ## Utility functions + # Utility functions def checkConfiguration(self): """Verify that the dopant and base are elements. @@ -340,7 +346,7 @@ def fillList(self): self.listCtrlFiles.SetItem(index, 1, shortname) return - ## Needed by mainframe + # Needed by mainframe def treeSelectionUpdate(self, node): """Set the current fit when the tree selection changes.""" nodetype = self.treeCtrlMain.GetNodeType(node) @@ -349,7 +355,7 @@ def treeSelectionUpdate(self, node): self.refresh() return - ## Required by PDFPanel + # Required by PDFPanel def refresh(self): """Block out OK button if there is no fit. diff --git a/src/diffpy/pdfgui/gui/errorreportdialog.py b/src/diffpy/pdfgui/gui/errorreportdialog.py index b93cca76..308954c0 100644 --- a/src/diffpy/pdfgui/gui/errorreportdialog.py +++ b/src/diffpy/pdfgui/gui/errorreportdialog.py @@ -207,15 +207,18 @@ def _extractSearchTerms(tbtext): return rv -##### testing code ############################################################ +# testing code ############################################################ _EXAMPLE_TRACEBACK = r""" Traceback (most recent call last): - File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\diffpy\pdfgui\gui\errorwrapper.py", line 60, in _f + File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\ +diffpy\pdfgui\gui\errorwrapper.py", line 60, in _f return func(*args, **kwargs) - File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\diffpy\pdfgui\gui\mainframe.py", line 2176, in onSave + File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\ +diffpy\pdfgui\gui\mainframe.py", line 2176, in onSave self.control.save(self.fullpath) - File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\diffpy\pdfgui\control\pdfguicontrol.py", line 507, in save + File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\ +diffpy\pdfgui\control\pdfguicontrol.py", line 507, in save self.projfile = projfile.encode('ascii') UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 115: ordinal not in range(128) """.strip() @@ -242,4 +245,4 @@ def test(self): app = MyApp(0) app.MainLoop() -##### end of testing code ##################################################### +# end of testing code ##################################################### diff --git a/src/diffpy/pdfgui/gui/errorreportdialog_control_fix.py b/src/diffpy/pdfgui/gui/errorreportdialog_control_fix.py index 71e239ca..11a8681b 100644 --- a/src/diffpy/pdfgui/gui/errorreportdialog_control_fix.py +++ b/src/diffpy/pdfgui/gui/errorreportdialog_control_fix.py @@ -17,7 +17,6 @@ # generated by wxGlade 0.9.3 on Fri Jul 19 16:01:37 2019 import re -import webbrowser # # "Bug report" Dialog @@ -25,6 +24,8 @@ import wx import wx.html +from .errorreportdialog import ErrorReportDialog + # Constants ------------------------------------------------------------------ ISSUESTRACKER = "https://github.com/diffpy/diffpy.pdfgui/issues" @@ -77,7 +78,7 @@ def __do_layout(self): # begin wxGlade: ErrorReportDialog.__do_layout sizer_main = wx.BoxSizer(wx.VERTICAL) sizer_buttons = wx.BoxSizer(wx.HORIZONTAL) - sizer_log = wx.BoxSizer(wx.VERTICAL) + # sizer_log = wx.BoxSizer(wx.VERTICAL) sizer_label = wx.BoxSizer(wx.HORIZONTAL) sizer_label.Add(self.label_header, 1, wx.EXPAND, 5) sizer_main.Add(sizer_label, 1, wx.ALL | wx.EXPAND, 5) @@ -141,17 +142,21 @@ def _extractSearchTerms(tbtext): return rv -##### testing code ############################################################ +# testing code ############################################################ _EXAMPLE_TRACEBACK = r""" Traceback (most recent call last): - File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\diffpy\pdfgui\gui\errorwrapper.py", line 60, in _f + File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\ +\diffpy\pdfgui\gui\errorwrapper.py", line 60, in _f return func(*args, **kwargs) - File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\diffpy\pdfgui\gui\mainframe.py", line 2176, in onSave + File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\ +\diffpy\pdfgui\gui\mainframe.py", line 2176, in onSave self.control.save(self.fullpath) - File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\diffpy\pdfgui\control\pdfguicontrol.py", line 507, in save + File "C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg\ +\diffpy\pdfgui\control\pdfguicontrol.py", line 507, in save self.projfile = projfile.encode('ascii') -UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 115: ordinal not in range(128) +UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 115: \ +ordinal not in range(128) """.strip() @@ -176,4 +181,4 @@ def test(self): app = MyApp(0) app.MainLoop() -##### end of testing code ##################################################### +# end of testing code ##################################################### diff --git a/src/diffpy/pdfgui/gui/extendedplotframe.py b/src/diffpy/pdfgui/gui/extendedplotframe.py index 848b54d6..297a7670 100644 --- a/src/diffpy/pdfgui/gui/extendedplotframe.py +++ b/src/diffpy/pdfgui/gui/extendedplotframe.py @@ -20,8 +20,6 @@ import os.path import matplotlib - -matplotlib.use("WXAgg") import wx from matplotlib.artist import setp from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas @@ -32,6 +30,8 @@ from diffpy.pdfgui.gui.pdfguiglobals import iconpath from diffpy.pdfgui.gui.wxextensions import wx12 +matplotlib.use("WXAgg") + DATA_SAVE_ID = wx12.NewIdRef() @@ -303,7 +303,7 @@ def __translateStyles(self, style): symbolSize = style["symbolSize"] symbolColor = colorDict.get(style["symbolColor"], "k") properties.update( - { #'linewidth':0.0, # doesn't affect any + { # 'linewidth':0.0, # doesn't affect any "markerfacecolor": symbolColor, "markeredgecolor": color, "marker": symbol,