fix(python): fix comparison to None (#211)
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. Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
Tento commit je obsažen v:
odevzdal
GitHub
rodič
39ea16e544
revize
bfdb3bc636
@@ -476,7 +476,7 @@ def getAllocatedMemoryPercent(device):
|
||||
mem_use_pct = 0
|
||||
if vram_used is None:
|
||||
return allocated_memory_vram
|
||||
if vram_used != None and vram_total != None and float(vram_total) != 0:
|
||||
if vram_used is not None and vram_total is not None and float(vram_total) != 0:
|
||||
# take floor of result (round down to nearest integer)
|
||||
mem_use_pct = (100 * (float(vram_used) / float(vram_total))) // 1
|
||||
allocated_memory_vram['value'] = mem_use_pct
|
||||
@@ -531,7 +531,7 @@ def getProcessName(pid):
|
||||
except subprocess.CalledProcessError as e:
|
||||
pName = 'UNKNOWN'
|
||||
|
||||
if pName == None:
|
||||
if pName is None:
|
||||
pName = 'UNKNOWN'
|
||||
|
||||
# Remove the substrings surrounding from process name (b' and \n')
|
||||
@@ -2382,7 +2382,7 @@ def getCoarseGrainUtil(device, typeName=None):
|
||||
"""
|
||||
timestamp = c_uint64(0)
|
||||
|
||||
if typeName != None:
|
||||
if typeName is not None:
|
||||
|
||||
try:
|
||||
i = utilization_counter_name.index(typeName)
|
||||
@@ -3329,7 +3329,7 @@ def showWeightTopology(deviceList):
|
||||
for gpu2 in deviceList:
|
||||
if (gpu1 == gpu2):
|
||||
printTableRow('%-12s', '0')
|
||||
elif (gpu_links_weight[gpu1][gpu2] == None):
|
||||
elif (gpu_links_weight[gpu1][gpu2] is None):
|
||||
printTableRow('%-12s', 'N/A')
|
||||
else:
|
||||
printTableRow('%-12s', gpu_links_weight[gpu1][gpu2].value)
|
||||
@@ -3375,7 +3375,7 @@ def showHopsTopology(deviceList):
|
||||
for gpu2 in deviceList:
|
||||
if (gpu1 == gpu2):
|
||||
printTableRow('%-12s', '0')
|
||||
elif (gpu_links_hops[gpu1][gpu2] == None):
|
||||
elif (gpu_links_hops[gpu1][gpu2] is None):
|
||||
printTableRow('%-12s', 'N/A')
|
||||
else:
|
||||
printTableRow('%-12s', gpu_links_hops[gpu1][gpu2].value)
|
||||
@@ -4612,7 +4612,7 @@ if __name__ == '__main__':
|
||||
showPcieReplayCount(deviceList)
|
||||
if args.showserial:
|
||||
showSerialNumber(deviceList)
|
||||
if args.showpids != None:
|
||||
if args.showpids is not None:
|
||||
showPids(args.showpids)
|
||||
if args.showpidgpus or str(args.showpidgpus) == '[]':
|
||||
showGpusByPid(args.showpidgpus)
|
||||
|
||||
@@ -23,7 +23,7 @@ def initRsmiBindings(silent=False):
|
||||
print(args)
|
||||
|
||||
rocm_smi_lib_path = os.getenv('ROCM_SMI_LIB_PATH')
|
||||
if (rocm_smi_lib_path != None):
|
||||
if (rocm_smi_lib_path is not None):
|
||||
path_librocm = rocm_smi_lib_path
|
||||
else:
|
||||
path_librocm = os.path.dirname(os.path.realpath(__file__)) + '/../../@CMAKE_INSTALL_LIBDIR@/librocm_smi64.so.@VERSION_MAJOR@'
|
||||
|
||||
@@ -23,7 +23,7 @@ def initRsmiBindings(silent=False):
|
||||
print(args)
|
||||
|
||||
rocm_smi_lib_path = os.getenv('ROCM_SMI_LIB_PATH')
|
||||
if (rocm_smi_lib_path != None):
|
||||
if (rocm_smi_lib_path is not None):
|
||||
path_librocm = rocm_smi_lib_path
|
||||
else:
|
||||
path_librocm = os.path.dirname(os.path.realpath(__file__)) + '/../../@CMAKE_INSTALL_LIBDIR@/librocm_smi64.so.@VERSION_MAJOR@'
|
||||
|
||||
Odkázat v novém úkolu
Zablokovat Uživatele