Skip to content

Commit

Permalink
minor cleanup with autopep8
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 11, 2023
1 parent 0901d75 commit df41b58
Show file tree
Hide file tree
Showing 28 changed files with 170 additions and 154 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ tests/data
.pytest_cache
htmlcov
docs/_build

# pycharm
.idea
16 changes: 8 additions & 8 deletions pycorrfit/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ def compute_weights(correlation, verbose=0, uselatex=False):
ival = corr.fit_ival
weight_data = corr.fit_weight_data
weight_type = corr.fit_weight_type
#parameters = corr.fit_parameters
#parameters_range = corr.fit_parameters_range
#parameters_variable = corr.fit_parameters_variable
# parameters = corr.fit_parameters
# parameters_range = corr.fit_parameters_range
# parameters_variable = corr.fit_parameters_variable

cdat = corr.correlation
if cdat is None:
Expand All @@ -503,7 +503,7 @@ def compute_weights(correlation, verbose=0, uselatex=False):
x_full = cdat[:, 0]
y_full = cdat[:, 1]
x_fit = cdatfit[:, 0]
#y_fit = cdatfit[:,1]
# y_fit = cdatfit[:,1]

dataweights = np.ones_like(x_fit)

Expand Down Expand Up @@ -555,7 +555,7 @@ def compute_weights(correlation, verbose=0, uselatex=False):
return
if verbose > 0:
# If plotting module is available:
#name = "spline fit: "+str(knotnumber)+" knots"
# name = "spline fit: "+str(knotnumber)+" knots"
# plotting.savePlotSingle(name, 1*x, 1*y, 1*ys,
# dirname=".",
# uselatex=uselatex)
Expand Down Expand Up @@ -641,8 +641,8 @@ def compute_weights(correlation, verbose=0, uselatex=False):
# start: counter on correlation array
start = i - weight_spread + offsetstart + ival[0] - offsetcrop
end = start + 2*weight_spread + 1 - offsetstart
#start = ival[0] - weight_spread + i
#end = ival[0] + weight_spread + i + 1
# start = ival[0] - weight_spread + i
# end = ival[0] + weight_spread + i + 1
diff = y - model(model_parms, x)
dataweights[i] = diff[start:end].std()
# The standard deviation at the end and the start of the
Expand Down Expand Up @@ -696,7 +696,7 @@ def fit_function(self, params, x, y, weights=1):
tominimize = np.where(weights != 0,
tominimize/weights, 0)
# There might be NaN values because of zero weights:
#tominimize = tominimize[~np.isinf(tominimize)]
# tominimize = tominimize[~np.isinf(tominimize)]
return tominimize

def fit_function_scalar(self, parms, x, y, weights=1):
Expand Down
2 changes: 1 addition & 1 deletion pycorrfit/gui/contribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ def on_button(self, event):
"https://dx.doi.org/10.1093/bioinformatics/btu328",
"https://github.com/sponsors/paulmueller",
"https://liberapay.com/paulmueller",
]
]
4 changes: 2 additions & 2 deletions pycorrfit/gui/edclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def save_figure(self, evt=None):
if not filename.endswith(wildcard):
filename += "."+wildcard
dirname = dlg.GetDirectory()
#savename = os.path.join(dirname, filename)
# savename = os.path.join(dirname, filename)
savename = filename
try:
self.canvas.figure.savefig(savename)
Expand Down Expand Up @@ -166,7 +166,7 @@ def __init__(self, parent, text, title):
sizer = wx.BoxSizer(wx.VERTICAL)
btnsizer = wx.BoxSizer()
btn1 = wx.Button(self, wx.ID_YES)
#btn1.Bind(wx.EVT_BTN, self.YES)
# btn1.Bind(wx.EVT_BTN, self.YES)
btnsizer.Add(btn1, 0, wx.ALL, 5)
btnsizer.Add((1, -1), 0, wx.ALL, 5)
btn2 = wx.Button(self, wx.ID_NO)
Expand Down
18 changes: 9 additions & 9 deletions pycorrfit/gui/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def add_fitting_tab(self, event=None, modelid=None, counter=None,
# window is open.
# Find Tool Statistics
# Get open tools
#toolkeys = self.ToolsOpen.keys()
# toolkeys = self.ToolsOpen.keys()
# for key in toolkeys:
# tool = self.ToolsOpen[key]
# try:
Expand Down Expand Up @@ -401,7 +401,7 @@ def MakeMenu(self):
self.EnableToolCurrent(False)
# Set events
# File
#self.Bind(wx.EVT_MENU, self.OnLoadSingle, menuLoadSingle)
# self.Bind(wx.EVT_MENU, self.OnLoadSingle, menuLoadSingle)
self.Bind(wx.EVT_MENU, self.OnLoadBatch, menuLoadBatch)
self.Bind(wx.EVT_MENU, self.OnAddModel, menuAddModel)
self.Bind(wx.EVT_MENU, self.OnCommSession, self.menuComm)
Expand Down Expand Up @@ -494,8 +494,8 @@ def OnAddModel(self, event=None, modfile=None):
if dlg.ShowModal() == wx.ID_OK:
# Workaround since 0.7.5
(dirname, filename) = os.path.split(dlg.GetPath())
#filename = dlg.GetFilename()
#dirname = dlg.GetDirectory()
# filename = dlg.GetFilename()
# dirname = dlg.GetDirectory()
self.dirname = dirname
# Try to import a selected .txt file
else:
Expand Down Expand Up @@ -764,8 +764,8 @@ def OnImportData(self, e=None):
# The filename the page will get
path = dlg.GetPath() # Workaround since 0.7.5
(self.dirname, self.filename) = os.path.split(path)
#self.filename = dlg.GetFilename()
#self.dirname = dlg.GetDirectory()
# self.filename = dlg.GetFilename()
# self.dirname = dlg.GetDirectory()
try:
Stuff = readfiles.open_any(self.dirname, self.filename)
except:
Expand Down Expand Up @@ -1076,7 +1076,7 @@ def OnLoadBatch(self, e=None, dataname=None):
if dlgi.Update(j, "Loading data: "+afile)[0] == False:
dlgi.Destroy()
return
#Stuff = readfiles.openAny(self.dirname, afile)
# Stuff = readfiles.openAny(self.dirname, afile)
try:
Stuff = readfiles.open_any(self.dirname, afile)
except Exception as excpt:
Expand Down Expand Up @@ -1178,7 +1178,7 @@ def OnLoadBatch(self, e=None, dataname=None):
coords[k] = WorkType.index(keys[k])
WorkType[coords[k]] = None
Run[coords] = i + 1
#del WorkType
# del WorkType
else:
Run = [""] * len(Curveid)
# Now we have a dictionary curvetypes with keys that name
Expand Down Expand Up @@ -1867,7 +1867,7 @@ def UnpackParameters(self, Parms, Page, init=False):
Page.corr.fit_parameters_range = np.array(Parms[9])
# If we want to add more stuff, we should do something like:
# if len(Parms) >= 11:
## nextvalue = Parms[10]
# nextvalue = Parms[10]
# Such that we are compatible to earlier versions of
# PyCorrFit sessions.

Expand Down
4 changes: 2 additions & 2 deletions pycorrfit/gui/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, parent, counter, modelid, active_parms, tau=None):
# This is necessary to prevent "Unsplit" of the SplitterWindow:
self.sp.SetMinimumPaneSize(1)
# Settings Section (left side)
#self.panelsettings = wx.Panel(self.sp, size=sizepanel)
# self.panelsettings = wx.Panel(self.sp, size=sizepanel)
self.panelsettings = scrolled.ScrolledPanel(self.sp, size=sizepanel)
self.panelsettings.SetupScrolling(scroll_x=False)
# Setting up Plot (correlation + chi**2)
Expand Down Expand Up @@ -620,7 +620,7 @@ def PlotAll(self, event=None, trigger=None):
# if weights are from average or other, make sure that the
# dimensions are correct
if weights.shape[0] == self.corr.correlation.shape[0]:
weights = weights[self.corr.fit_ival[0] :self.corr.fit_ival[1]]
weights = weights[self.corr.fit_ival[0]:self.corr.fit_ival[1]]

# perform some checks
if np.allclose(weights, np.ones_like(weights)):
Expand Down
16 changes: 8 additions & 8 deletions pycorrfit/gui/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

def greek2tex(char):
""" Converts greek UTF-8 letters to latex """
#decchar = codecs.decode(char, "UTF-8")
# decchar = codecs.decode(char, "UTF-8")
decchar = char
repres = unicodedata.name(decchar).split(" ")
# GREEK SMALL LETTER ALPHA
Expand All @@ -42,7 +42,7 @@ def greek2tex(char):

def escapechars(string):
""" For latex output, some characters have to be escaped with a "\\" """
#string = codecs.decode(string, "UTF-8")
# string = codecs.decode(string, "UTF-8")
escapechars = ["#", "$", "%", "&", "~", "_", "\\", "{", "}"]
retstr = r""
for char in string:
Expand All @@ -64,20 +64,20 @@ def latexmath(string):
return r"\mathrm{offset}"
elif string == "SP":
return r"\mathrm{SP}"
#string = codecs.decode(string, "UTF-8")
# string = codecs.decode(string, "UTF-8")
unicodechars = dict()
#unicodechars["τ"] = r"\tau"
#unicodechars["µ"] = r"\mu"
# unicodechars["τ"] = r"\tau"
# unicodechars["µ"] = r"\mu"
unicodechars["²"] = r"^2"
unicodechars["³"] = r"^3"
unicodechars["₁"] = r"_1"
unicodechars["₂"] = r"_2"
unicodechars["₃"] = r"_3"
unicodechars["₀"] = r"_0"
#unicodechars["α"] = r"\alpha"
# unicodechars["α"] = r"\alpha"
# We need lambda in here, because unicode names it lamda sometimes.
unicodechars["λ"] = r"\lambda"
#unicodechars["η"] = r'\eta'
# unicodechars["η"] = r'\eta'
unitchars = dict()
unitchars["µ"] = r"\micro "
items = string.split(" ", 1)
Expand Down Expand Up @@ -269,7 +269,7 @@ def savePlotCorrelation(parent, dirname, Page, uselatex=False,
plt.text(xt, yt, text, size=12)
if resid is not None:
ax2 = plt.subplot(gs[1])
#ax2 = plt.axes()
# ax2 = plt.axes()
ax2.semilogx()
if Page.corr.is_weighted_fit:
if uselatex == True:
Expand Down
2 changes: 1 addition & 1 deletion pycorrfit/gui/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
ImpB[i][0], globals(), locals(), [ImpB[i][1]], 1))
ToolsPassive.append(getattr(ModulePassive[i], ImpB[i][1]))
# ModulePassive.append(importlib.import_module("tools."+ImpB[i][0]))
#ToolsPassive.append(getattr(ModulePassive[i], ImpB[i][1]))
# ToolsPassive.append(getattr(ModulePassive[i], ImpB[i][1]))

ToolDict = dict()
ToolDict["A"] = ToolsActive
Expand Down
4 changes: 2 additions & 2 deletions pycorrfit/gui/tools/average.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def OnPageChanged(self, page, trigger=None):
self.panel.Disable()
return

#idsel = self.WXDropSelMod.GetSelection()
# idsel = self.WXDropSelMod.GetSelection()
self.SetValues()
# Set back user selection:
# self.WXDropSelMod.SetSelection(idsel)
Expand All @@ -116,7 +116,7 @@ def OnAverage(self, evt=None):
pages = list()
UsedPagenumbers = list()
# Reference page is the first page of the selection!
#referencePage = self.parent.notebook.GetCurrentPage()
# referencePage = self.parent.notebook.GetCurrentPage()
referencePage = None
for i in np.arange(self.parent.notebook.GetPageCount()):
Page = self.parent.notebook.GetPage(i)
Expand Down
8 changes: 4 additions & 4 deletions pycorrfit/gui/tools/background.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ def OnBrowse(self, event):
if dlg.ShowModal() == wx.ID_OK:
# Workaround since 0.7.5
(dirname, filename) = os.path.split(dlg.GetPath())
#filename = dlg.GetFilename()
#dirname = dlg.GetDirectory()
# filename = dlg.GetFilename()
# dirname = dlg.GetDirectory()
# Set parent dirname for user comfort
self.parent.dirname = dirname
try:
Expand Down Expand Up @@ -368,7 +368,7 @@ def OnImport(self, event):
self.parent.Background.append(
Trace(trace=self.trace, name=self.bgname.GetValue()))
# Next two lines are taken care of by UpdateDropdown
#name = "{} ({:.2f} kHz)".format(self.bgname.GetValue(), self.average)
# name = "{} ({:.2f} kHz)".format(self.bgname.GetValue(), self.average)
# self.BGlist.append(name)
self.UpdateDropdown()
self.btnremyall.Enable(True)
Expand Down Expand Up @@ -465,7 +465,7 @@ def OnRemove(self, event):
# an error message.
return
# BG number
#item = self.dropdown.GetSelection()
# item = self.dropdown.GetSelection()
# Apply to corresponding pages
for i in np.arange(self.parent.notebook.GetPageCount()):
Page = self.parent.notebook.GetPage(i)
Expand Down
4 changes: 2 additions & 2 deletions pycorrfit/gui/tools/chooseimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ def OnSelected(self, keep, remove):
# Set new button label
for i in np.arange(len(keep)):
keep[i] = int(keep[i])
#button = self.Buttons[self.buttonindex]
# button = self.Buttons[self.buttonindex]
label = " ("+str(len(keep))+" curves)"
# button.SetLabel(label)
# Add new content to selected key
SelectedKey = self.curvekeys[self.buttonindex]
#self.kept_curvedict[SelectedKey] = keep
# self.kept_curvedict[SelectedKey] = keep
# If there are keys with the same amount of correlations,
# these are assumed to be AC2, CC12, CC21 etc., so we will remove
# items from them accordingly.
Expand Down
2 changes: 1 addition & 1 deletion pycorrfit/gui/tools/overlaycurves.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def __init__(self, parent, curvedict, wrapper=None, selkeys=None,
np.array((300, 30)))
self.SetMinSize(minsize)
# self.SetSize(minsize)
#self.SetMaxSize((9999, self.boxSizer.GetMinSize()[1]))
# self.SetMaxSize((9999, self.boxSizer.GetMinSize()[1]))
# Canvas
self.canvas = plot.PlotCanvas(self.bottom_sp)
self.canvas.logScale = (True, False)
Expand Down
2 changes: 1 addition & 1 deletion pycorrfit/gui/tools/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def SetValues(self, event=None):
self.valueB = ParmValues[idB]
# Operator
idop = self.dropop.GetSelection()
#keys = self.opdict.keys()
# keys = self.opdict.keys()
opkey = self.oplist[idop]
self.opfunc = self.opdict[opkey]
# Parameter A
Expand Down
18 changes: 9 additions & 9 deletions pycorrfit/gui/tools/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ def __init__(self, parent):
GridAll.Add(self.WXavg)
GridAll.Add(textsd)
GridAll.Add(self.WXsd)
#Psizer = wx.BoxSizer(wx.HORIZONTAL)
# Psizer = wx.BoxSizer(wx.HORIZONTAL)
# Psizer.Add(Pagetext)
# Psizer.Add(self.WXTextPages)
#DDsizer = wx.BoxSizer(wx.HORIZONTAL)
# DDsizer = wx.BoxSizer(wx.HORIZONTAL)
# DDsizer.Add(DDtext)
# DDsizer.Add(self.WXDropdown)
# self.topSizer.Add(Psizer)
Expand Down Expand Up @@ -344,8 +344,8 @@ def OnChooseValues(self, event=None):
"""
Info, checked = self.GetListOfAllParameters(
return_std_checked=True)
#headcounter = 0
#headlen = len(head)
# headcounter = 0
# headlen = len(head)
# We will sort the checkboxes in more than one column if there
# are more than *maxitemsincolumn*
maxitemsincolumn = np.float64(19)
Expand All @@ -354,10 +354,10 @@ def OnChooseValues(self, event=None):
for i in np.arange(Sizernumber):
self.boxsizerlist.append(wx.BoxSizer(wx.VERTICAL))
# Start at -1 so the indexes will start at 0 (see below).
#itemcount = -1
# itemcount = -1
for i in range(len(Info)):
#itemcount += 1
#headcounter += 1
# itemcount += 1
# headcounter += 1
checkbox = wx.CheckBox(self.panel, label=Info[i][0])
# if headcounter <= headlen:
# checkbox.SetValue(True)
Expand Down Expand Up @@ -405,7 +405,7 @@ def OnDropDown(self, e=None):

# Get plot parameters
DDselid = self.WXDropdown.GetSelection()
#[label, key] = self.PlotParms[DDselid]
# [label, key] = self.PlotParms[DDselid]
label = self.PlotParms[DDselid]
# Get potential pages
pages = list()
Expand Down Expand Up @@ -450,7 +450,7 @@ def OnDropDown(self, e=None):
else:
# Plot data
plotavg = [[0.5, avg], [maxpage+.5, avg]]
#lineclear = plot.PolyLine(plotavg, colour="black")
# lineclear = plot.PolyLine(plotavg, colour="black")
lineclear = plot.PolyMarker(plotavg, colour="black")
plotlist.append(lineclear)
# Update Text control
Expand Down
4 changes: 2 additions & 2 deletions pycorrfit/gui/wxutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ def GetValue(self):
string = wx.TextCtrl.GetValue(self)
if string == PCFFloatTextCtrl.float2string(self._PCFvalue):
# use internal value: more accurate
#print("internal", self._PCFvalue)
# print("internal", self._PCFvalue)
return self._PCFvalue
else:
# new value
#print("external", string)
# print("external", string)
return PCFFloatTextCtrl.string2float(string)

@staticmethod
Expand Down
6 changes: 3 additions & 3 deletions pycorrfit/models/MODEL_TIRF_1C.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def MoreInfo_6000(parms, countrate=None):
Effective particle number in detection area:
[6] N_eff = A_eff * C_2D
"""
#D = parms[0]
#sigma = parms[1]
# D = parms[0]
# sigma = parms[1]
a = parms[2]
Conc = parms[3]
Info = list()
Expand Down Expand Up @@ -158,7 +158,7 @@ def MoreInfo_6010(parms, countrate):
# 3D Model TIR square
# 3D TIR (□xσ/exp),Simple 3D diffusion w/ TIR, fct.CF_Gxyz_square_tir
# D [10 µm²/s],σ [100 nm],a [100 nm],d_eva [100 nm],[conc.] [1000 /µm³]
#sigma = parms[1]
# sigma = parms[1]
a = parms[2]
d_eva = parms[3]
conc = parms[4]
Expand Down

0 comments on commit df41b58

Please sign in to comment.