Skip to content

Commit

Permalink
remove import, remove lambda, and line length error
Browse files Browse the repository at this point in the history
  • Loading branch information
cadenmyers13 committed Jul 29, 2024
1 parent 277cadb commit 40e7fef
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 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 @@ -29,6 +28,10 @@
from diffpy.pdfgui.utils import numericStringSort


def temperature_sortkey(tf):
return float(tf[0])


class TemperatureSeriesPanel(wx.Panel, PDFPanel):
def __init__(self, *args, **kwds):
PDFPanel.__init__(self)
Expand All @@ -41,7 +44,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 +206,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 @@ -288,18 +300,26 @@ def onDelete(self, event): # wxGlade: TemperatureSeriesPanel.<event_handler>
self.fillList()
return

def create_filename_order(self):
filenames = [f for t, f in self.datasets]
numericStringSort(filenames)
self.filename_order = dict(zip(filenames, range(len(filenames))))
return

def filename_sortkey(self, tf):
return self.filename_order[tf[1]]

def onColClick(self, event): # wxGlade: TemperatureSeriesPanel.<event_handler>
"""Sort by temperature."""
column = event.GetColumn()
# sort by temperature
if column == 0:
sortkey = lambda tf: float(tf[0])
sortkey = temperature_sortkey()
# 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]]
self.create_filename_order()
sortkey = self.filename_sortkey()

# ignore unhandled columns
else:
return
Expand All @@ -308,7 +328,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 +345,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 +354,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

0 comments on commit 40e7fef

Please sign in to comment.