Skip to content

Commit

Permalink
fix(python): fix comparison to True/False
Browse files Browse the repository at this point in the history
from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or
> is not, never the equality operators.
  • Loading branch information
e-kwsm committed Aug 20, 2024
1 parent 78373cb commit 41fef74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions amdsmi_cli/amdsmi_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3686,9 +3686,9 @@ def set_value(self, args, multiple_devices=False, gpu=None, fan=None, perf_level
break

# Only allow one device's arguments to be set at a time
if gpu_args_enabled == cpu_args_enabled == core_args_enabled == False:
if not (gpu_args_enabled == cpu_args_enabled == core_args_enabled):
raise ValueError('No GPU, CPU, or CORE arguments provided, specific arguments are needed')
elif gpu_args_enabled == cpu_args_enabled == core_args_enabled == True:
elif gpu_args_enabled == cpu_args_enabled == core_args_enabled:
raise ValueError('Cannot set GPU, CPU, and CORE arguments at the same time')
elif not (gpu_args_enabled ^ cpu_args_enabled ^ core_args_enabled):
raise ValueError('Cannot set GPU, CPU, or CORE arguments at the same time')
Expand Down
8 changes: 4 additions & 4 deletions rocm_smi/python_smi_tools/rocm_smi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ def setClocks(deviceList, clktype, clk):
# Validate frequency bitmask
freq = rsmi_frequencies_t()
ret = rocmsmi.rsmi_dev_gpu_clk_freq_get(device, rsmi_clk_names_dict[clktype], byref(freq))
if rsmi_ret_ok(ret, device, 'get_gpu_clk_freq_' + str(clktype)) == False:
if not rsmi_ret_ok(ret, device, 'get_gpu_clk_freq_' + str(clktype)):
RETCODE = 1
return
# The freq_bitmask should be less than 2^(freqs.num_supported)
Expand All @@ -1257,7 +1257,7 @@ def setClocks(deviceList, clktype, clk):
# Validate the bandwidth bitmask
bw = rsmi_pcie_bandwidth_t()
ret = rocmsmi.rsmi_dev_pci_bandwidth_get(device, byref(bw))
if rsmi_ret_ok(ret, device, 'get_PCIe_bandwidth') == False:
if not rsmi_ret_ok(ret, device, 'get_PCIe_bandwidth'):
RETCODE = 1
return
# The freq_bitmask should be less than 2^(bw.transfer_rate.num_supported)
Expand Down Expand Up @@ -1492,7 +1492,7 @@ def setPowerOverDrive(deviceList, value, autoRespond):
new_power_cap.value = int(value) * 1000000

ret = rocmsmi.rsmi_dev_power_cap_range_get(device, 0, byref(power_cap_max), byref(power_cap_min))
if rsmi_ret_ok(ret, device, 'get_power_cap_range') == False:
if not rsmi_ret_ok(ret, device, 'get_power_cap_range'):
printErrLog(device, 'Unable to parse Power OverDrive range')
RETCODE = 1
continue
Expand Down Expand Up @@ -4119,7 +4119,7 @@ def isConciseInfoRequested(args):
devCsv = ''
sysCsv = ''
# JSON won't have any 'system' data without one of these flags
if args.showdriverversion and args.showallinfo == False:
if args.showdriverversion and not args.showallinfo:
sysCsv = formatCsv(['system'])
print('%s' % (sysCsv))
elif args.showallinfo is True:
Expand Down

0 comments on commit 41fef74

Please sign in to comment.