Skip to content

Commit

Permalink
manual ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Feb 11, 2024
1 parent 02e3245 commit 48c8eaa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
8 changes: 2 additions & 6 deletions src/dls_pmac_control/gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ def gatherConfig(self):
return True

def gatherSetup(self, numberOfSamples=1):

# Run through the bitmasks i5050 and i5051 to see which of the
# 48 channels should be sampled.
bitOffset = 1
Expand Down Expand Up @@ -223,10 +222,8 @@ def gatherSetup(self, numberOfSamples=1):

# Run through all the channels to sample from
self.oddNumberOfWords = False
for chIndex, ch in enumerate(self.lstChannels):

for _, ch in enumerate(self.lstChannels):
# Get the data info
# print "channel: %d"%chIndex
ch.getDataInfo()

# Figure out the data width and odd/even number of data words
Expand Down Expand Up @@ -312,7 +309,6 @@ def parseData(self, lstDataStrings):
ch.rawToScaled()

def plotData(self):

# xAxisData = range(self.numberOfSamples)
for _chIndex, ch in enumerate(self.lstChannels):
data = ch.scaledData
Expand Down Expand Up @@ -430,7 +426,7 @@ def saveClicked(self):
QMessageBox.information(
self,
"Error",
"Could not open file for writing."
"Could not open file for writing.",
# buttons=1,
# p_str_1="OK",
)
Expand Down
22 changes: 14 additions & 8 deletions src/dls_pmac_control/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ def addToTxtShell(self, command, retStr=None, chkShowAll=True):
# Called when an event comes out of the polling thread
# and the jog ribbon.
def updateMotors(self):

under_voltage = False
over_voltage = False
over_temperature = False
Expand All @@ -647,7 +646,7 @@ def updateMotors(self):
try:
motorRow = value[6]
# check for special cases
if type(motorRow) == str:
if isinstance(motorRow, str):
if isinstance(self.pmac, PPmacSshInterface):
if motorRow == "G":
self.PpmacGlobalStatusScreen.updateStatus(
Expand Down Expand Up @@ -702,14 +701,13 @@ def updateMotors(self):
over_current = False

if motorRow < 8:

if isinstance(self.pmac, PPmacSshInterface):
if int(value[4]) > 0:
i2t_fault = True
if int(value[5]) > 0:
over_current = True
elif isinstance(self.pmac, PmacEthernetInterface):
amp_status = ((int(value[4])&448)>>6)
amp_status = (int(value[4]) & 448) >> 6
if amp_status == 5:
i2t_fault = True
elif amp_status == 6:
Expand All @@ -732,13 +730,21 @@ def updateMotors(self):
if isinstance(self.pmac, PPmacSshInterface):
loLim = bool(statusWord & 0x2000000000000000) # MinusLimit
hiLim = bool(statusWord & 0x1000000000000000) # PlusLimit
loLimSoft = bool(statusWord & 0x0080000000000000) # SoftMinusLimit
hiLimSoft = bool(statusWord & 0x0040000000000000) # SoftPlusLimit
loLimSoft = bool(
statusWord & 0x0080000000000000
) # SoftMinusLimit
hiLimSoft = bool(
statusWord & 0x0040000000000000
) # SoftPlusLimit

# define high and low limits for pmac
else:
loLim = bool(statusWord & 0x400000000000) # negative end limit set
hiLim = bool(statusWord & 0x200000000000) # positive end limit set
loLim = bool(
statusWord & 0x400000000000
) # negative end limit set
hiLim = bool(
statusWord & 0x200000000000
) # positive end limit set
loLimSoft = False
hiLimSoft = False

Expand Down
13 changes: 6 additions & 7 deletions src/dls_pmac_control/watches.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import re

from PyQt5.QtWidgets import QDialog, QMessageBox, QTableWidgetItem
Expand All @@ -23,7 +22,7 @@ def __init__(self, parent):
def addWatch(self):
varName = str(self.lneVariableName.text())
try:
assert type(varName) is str
assert isinstance(varName, str)
varName = varName.lower()
if varName in unsafeCommands:
raise ValueError("%s is an unsafe command" % varName)
Expand All @@ -50,8 +49,8 @@ def getWatch(self, varName):
varName = varName.lower()
try:
watch = self._watches[varName]
except KeyError:
raise ValueError('There is no watch for variable "%s"' % varName)
except KeyError as e:
raise ValueError(msg='There is no watch for variable "%s"' % varName) from e
return watch

def updateWatch(self, row):
Expand All @@ -70,13 +69,13 @@ def removeWatch(self):
row = self.table.currentRow()
if row == -1:
return None
assert type(row) is int
assert isinstance(row, int)
varName = self.table.item(row, 0).text()
try:
del self._watches[varName]
self.parent.commsThread.remove_watch(varName)
except KeyError:
raise ValueError('There is no watch for variable "%s"' % varName)
except KeyError as e:
raise ValueError(msg='There is no watch for variable "%s"' % varName) from e
try:
self.table.removeRow(row)
# self.updateEditWatchPanel()
Expand Down

0 comments on commit 48c8eaa

Please sign in to comment.