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

Flake8 fixes pt3 #126

Closed
wants to merge 16 commits into from
4 changes: 2 additions & 2 deletions devutils/makesdist
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import subprocess
import sys
import tarfile

from setup import FALLBACK_VERSION, versiondata

BASEDIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.insert(0, BASEDIR)

from setup import FALLBACK_VERSION, versiondata

timestamp = versiondata.getint("DEFAULT", "timestamp")

vfb = versiondata.get("DEFAULT", "version").split(".post")[0] + ".post0"
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfgui/gui/bondangledialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def onSpin(self, event):
loop = True
while loop:
loop = False
for l in letters:
if newval == getattr(self, l):
for letter in letters:
if newval == getattr(self, letter):
loop = True
if increasing:
newval += 1
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfgui/gui/bondlengthdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ def onSpin(self, event): # wxGlade: BondLengthDialog.<event_handler>
loop = True
while loop:
loop = False
for l in letters:
if newval == getattr(self, l):
for letter in letters:
if newval == getattr(self, letter):
loop = True
if increasing:
newval += 1
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfgui/gui/phaseconfigurepanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def restrictConstrainedParameters(self):
"""Set 'read-only' boxes that correspond to constrained parameters."""

self.setToolTips(tooltips.phasepanel)
txtbg = self.textCtrlA.DefaultStyle.BackgroundColour
# txtbg = self.textCtrlA.DefaultStyle.BackgroundColour
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will change behavior. If flake8 is complaining about txtbg not being used, just remove the txtbg = from the beginning of the line.


# First the TextCtrls
for key, var in self.lConstraintsMap.items():
Expand Down Expand Up @@ -393,7 +393,7 @@ def applyTextCtrlChange(self, id, value):

return value

except:
except ValueError:
return None

def applyCellChange(self, i, j, value):
Expand Down
12 changes: 6 additions & 6 deletions src/diffpy/pdfgui/gui/phaseconstraintspanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# PDFgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2006 trustees of the Michigan State University.
# (c) 2006-2025 trustees of the Michigan State University.
# All rights reserved.
#
# File coded by: Chris Farrow, Dmitriy Bryndin
Expand Down Expand Up @@ -314,7 +314,7 @@ def refresh(self):

self.refreshTextCtrls()

### update the grid ###
# update the grid ##########
natoms = len(self.structure)
nrows = self.gridAtoms.GetNumberRows()
self.gridAtoms.BeginBatch()
Expand All @@ -339,7 +339,7 @@ def refresh(self):
if not m:
continue
barevar = m.group(1)
if not barevar in bareAtomVarColumn:
if barevar not in bareAtomVarColumn:
continue
column = bareAtomVarColumn[barevar]
row = int(m.group(2)) - 1
Expand All @@ -348,7 +348,7 @@ def refresh(self):
raise ControlValueError(emsg)
self.gridAtoms.SetCellValue(row, column, con.formula)
barevar = re.sub(r"\(\d+\)$", "", var)
if not barevar in bareAtomVarColumn:
if barevar not in bareAtomVarColumn:
continue

self.gridAtoms.AutosizeLabels()
Expand Down Expand Up @@ -554,12 +554,12 @@ def onKey(self, event):
self.mainFrame.needsSave()

# Can't get these to work. Maybe later.
## Copy - Ctrl+C / Ctrl+Insert
# Copy - Ctrl+C / Ctrl+Insert
# if event.ControlDown() and (key == 67 or key == wx.WXK_INSERT):
# if phasepanelutils.canCopySelectedCells(self):
# phasepanelutils.copySelectedCells(self)

## Paste - Ctrl+V / Shift+Insert
# Paste - Ctrl+V / Shift+Insert
# if (event.ControlDown() and key == 86) or\
# (event.ShiftDown() and key == wx.WXK_INSERT):
# if phasepanelutils.canPasteIntoCells(self):
Expand Down
5 changes: 4 additions & 1 deletion src/diffpy/pdfgui/gui/rseriespanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def __init__(self, *args, **kwds):
self.instructionsLabel = wx.StaticText(
self,
wx.ID_ANY,
"Select a fit from the tree on the left and set the first value, last value, \nand the step size of the maximum and/or minimum of the fit range\nbelow. If you have not set up a fit to be the template for the series, hit\ncancel and rerun this macro once a fit has been created.",
"Select a fit from the tree on the left and set the first value, last value, "
+ "\nand the step size of the maximum and/or minimum of the fit range\nbelow. "
+ "If you have not set up a fit to be the template for the series, hit\ncancel and "
+ "rerun this macro once a fit has been created.",
)
self.maxFirstLabel = wx.StaticText(self, wx.ID_ANY, "first")
self.maxFirstTextCtrl = wx.TextCtrl(self, wx.ID_ANY, "")
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/gui/sgconstraindialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def updateWidgets(self):
raise ControlValueError(error)
return

### Events
# Events

def onKillFocus(self, event):
"""Check value of widgets and update the dialog message."""
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/gui/sgstructuredialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def updateWidgets(self):
raise ControlValueError(error)
return

### Events
# Events
def onKillFocus(self, event):
"""Check value of widgets and update the dialog message."""
self.updateWidgets()
Expand Down
30 changes: 22 additions & 8 deletions src/diffpy/pdfgui/gui/temperatureseriespanel.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,9 @@ 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\ntemperatues below. If you have not set up a fit to be the template\nfor the series, hit cancel and rerun this macro once a fit has been\ncreated.",
"Select a fit from the tree on the left then add datasets and assign\ntemperatues below. "
+ "If you have not set up a fit to be the template\nfor the series, hit cancel and rerun this "
+ "macro once a fit has been\ncreated.",
)
self.instructionsLabel.SetFont(
wx.Font(
Expand Down Expand Up @@ -201,7 +202,14 @@ def onAdd(self, event): # wxGlade: TemperatureSeriesPanel.<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 @@ -293,13 +301,19 @@ def onColClick(self, event): # wxGlade: TemperatureSeriesPanel.<event_handler>
column = event.GetColumn()
# sort by temperature
if column == 0:
sortkey = lambda tf: float(tf[0])

def sortkey(tf):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define the function elsewhere then use it here

return float(tf[0])

# sort by filename with numerical comparison of digits
elif column == 1:
filenames = [f for t, f in self.datasets]
numericStringSort(filenames)
order = dict(zip(filenames, range(len(filenames))))
sortkey = lambda tf: order[tf[1]]

def sortkey(tf):
return order[tf[1]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above


# ignore unhandled columns
else:
return
Expand All @@ -308,7 +322,7 @@ def onColClick(self, event): # wxGlade: TemperatureSeriesPanel.<event_handler>
self.fillList()
return

## Utility functions
# Utility functions
def fillList(self):
"""Fill the list with the datasets."""
self.listCtrlFiles.DeleteAllItems()
Expand All @@ -325,7 +339,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 @@ -334,7 +348,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
Loading