Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copyright updates #133

Closed
wants to merge 13 commits into from
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/applications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2009 Trustees of the Columbia University
# (c) 2009-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/control/fitstructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 23 additions & 17 deletions src/diffpy/pdfgui/control/organizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,44 +230,50 @@ def organization(self):

return org

def __forward_spdiameter(self):
def __forward_spdiameter(strucs, datasets, calcs):
"""Copy spdiameter value loaded from fit or calculation to phase.

This method takes care of loading old PDFgui projects where
This function handles loading old PDFgui projects where
spdiameter belonged to FitDataSet or Calculation classes.
It should be called only from the Organizer.load method.
"""
# Jump out if any of structures has spdiameter set
for stru in self.strucs:
for stru in 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

# Helper function to check if spdiameter is assigned
def spd_assigned(ds):
return bool(ds.spdiameter)

# Helper function to check if spdiameter is constrained
def spd_constrained(ds):
return "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
# a calculation.
spd_val = spd_cns = None
constrained_datas = list(filter(spd_constrained, self.datasets))
assigned_datas = list(filter(spd_assigned, self.datasets))
assigned_calcs = list(filter(spd_assigned, self.calcs))
constrained_datas = list(filter(spd_constrained, datasets))
assigned_datas = list(filter(spd_assigned, datasets))
assigned_calcs = list(filter(spd_assigned, calcs))

if constrained_datas:
spd_val = constrained_datas[0].spdiameter
spd_cns = constrained_datas[0].constraints["spdiameter"]
elif assigned_datas:
spd_val = assigned_datas[0].spdiameter
elif assigned_calcs:
spd_val = assigned_calcs[0].spdiameter
# assign spd_val to all structures that don't have it set
for stru in self.strucs:

# Assign spd_val to all structures that don't have it set
for stru in strucs:
if spd_val and not stru.getvar("spdiameter"):
stru.setvar("spdiameter", spd_val)
if spd_cns:
stru.constraints.setdefault("spdiameter", spd_cns)
# finally remove any spdiameter constraints from all datasets
for ds in self.datasets:

# Finally remove any spdiameter constraints from all datasets
for ds in datasets:
ds.constraints.pop("spdiameter", None)

return


Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/control/pdfguicontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
6 changes: 5 additions & 1 deletion src/diffpy/pdfgui/control/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,11 @@ 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())

def deblank(s):
"""Removes all whitespace from string s"""
return "".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)
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/control/structureviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2009 Trustees of the Columbia University
# (c) 2009-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
7 changes: 3 additions & 4 deletions src/diffpy/pdfgui/doc/manual/extractEquations.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -31,10 +34,6 @@
##############################################################################
# business

import os
import shutil
import sys


def loadEquations():
"""Search for equation codes preceded by @EquationMark macro.
Expand Down
11 changes: 7 additions & 4 deletions src/diffpy/pdfgui/doc/tutorial/tui_mno_bond_lengths.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/usr/bin/env python

import pylab

from diffpy.pdffit2 import PdfFit

# Import tui (Text User Interface) functions from diffpy.pdfgui
from diffpy.pdfgui import tui

"""Extract the shortest Mn-O bond lengths from all fits in PDFgui project.

This script loops through all refined phases in PDFgui project and calculates
Expand All @@ -11,8 +18,6 @@
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)
Expand All @@ -21,7 +26,6 @@
# using diffpy.pdffit2

# Create a PDF calculator object that will be used in that function.
from diffpy.pdffit2 import PdfFit

pf = PdfFit()

Expand Down Expand Up @@ -69,7 +73,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)
Expand Down
18 changes: 12 additions & 6 deletions src/diffpy/pdfgui/gui/dopingseriespanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import os.path
import re
import sys

import wx

Expand All @@ -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(
Expand Down Expand Up @@ -210,7 +212,11 @@ def onAdd(self, event): # wxGlade: DopingSeriesPanel.<event_handler>
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",
Expand Down Expand Up @@ -304,7 +310,7 @@ def onCancel(self, event): # wxGlade: DopingSeriesPanel.<event_handler>
self.mainFrame.switchRightPanel("blank")
return

## Utility functions
# Utility functions
def checkConfiguration(self):
"""Verify that the dopant and base are elements.

Expand Down Expand Up @@ -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)
Expand All @@ -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.

Expand Down
10 changes: 5 additions & 5 deletions src/diffpy/pdfgui/gui/errorreportdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ 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 "...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 "...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 "...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()
Expand All @@ -242,4 +242,4 @@ def test(self):
app = MyApp(0)
app.MainLoop()

##### end of testing code #####################################################
# end of testing code #####################################################
33 changes: 19 additions & 14 deletions src/diffpy/pdfgui/gui/errorreportdialog_control_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
# generated by wxGlade 0.9.3 on Fri Jul 19 16:01:37 2019

import re
import webbrowser

#
# "Bug report" Dialog
#
import wx
import wx.html

from .errorreportdialog import ErrorReportDialog

# Constants ------------------------------------------------------------------

ISSUESTRACKER = "https://github.com/diffpy/diffpy.pdfgui/issues"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -141,18 +142,22 @@ 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
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
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
self.projfile = projfile.encode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 115: ordinal not in range(128)
""".strip()
_EXAMPLE_TRACEBACK = (
r"""Traceback (most recent call last): """
r"""File 'C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg"""
r"""\diffpy\pdfgui\gui\errorwrapper.py', line 60, in _f """
r"""return func(*args, **kwargs) """
r"""File 'C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg"""
r"""\diffpy\pdfgui\gui\mainframe.py', line 2176, in onSave """
r"""self.control.save(self.fullpath) """
r"""File 'C:\DiffPy\Python25\lib\site-packages\diffpy.pdfgui-1.0_r3067_20090410-py2.5.egg"""
r"""\diffpy\pdfgui\control\pdfguicontrol.py', line 507, in save """
r"""self.projfile = projfile.encode('ascii') """
r"""UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position """
r"""115: ordinal not in range(128)"""
).strip()


class MyApp(wx.App):
Expand All @@ -176,4 +181,4 @@ def test(self):
app = MyApp(0)
app.MainLoop()

##### end of testing code #####################################################
# end of testing code #####################################################
6 changes: 3 additions & 3 deletions src/diffpy/pdfgui/gui/extendedplotframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()


Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2012 Trustees of the Columbia University
# (c) 2012-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/tests/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2012 Trustees of the Columbia University
# (c) 2012-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/tests/rundeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2012 Trustees of the Columbia University
# (c) 2012-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/tests/showphasenotebookpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2016 Trustees of the Columbia University
# (c) 2016-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2016 Trustees of the Columbia University
# (c) 2016-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
Loading