Skip to content

Commit c8448dc

Browse files
committed
Update config, fix lints for ruff 0.15.2
1 parent 624be71 commit c8448dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+87
-110
lines changed

aksetup_helper.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def count_down_delay(delay):
2525
sys.stdout.flush()
2626
delay -= 1
2727
sleep(1)
28-
print("")
28+
print()
2929

3030

3131
DASH_SEPARATOR = 75 * "-"
@@ -297,7 +297,6 @@ def get_default_config(self):
297297
return dict((opt.name, opt.default) for opt in self.options)
298298

299299
def read_config_from_pyfile(self, filename):
300-
result = {}
301300
filevars = {}
302301
infile = open(filename)
303302
try:
@@ -307,11 +306,7 @@ def read_config_from_pyfile(self, filename):
307306

308307
exec(compile(contents, filename, "exec"), filevars)
309308

310-
for key, value in filevars.items():
311-
if key in self.optdict:
312-
result[key] = value
313-
314-
return result
309+
return {key: value for key, value in filevars.items() if key in self.optdict}
315310

316311
def update_conf_file(self, filename, config):
317312
result = {}
@@ -324,16 +319,13 @@ def update_conf_file(self, filename, config):
324319

325320
filevars.pop("__builtins__", None)
326321

327-
for key, value in config.items():
328-
if value is not None:
329-
filevars[key] = value
322+
filevars.update({key: value for key, value in config.items() if value is not None})
330323

331324
keys = list(filevars.keys())
332325
keys.sort()
333326

334327
outf = open(filename, "w")
335-
for key in keys:
336-
outf.write("%s = %s\n" % (key, repr(filevars[key])))
328+
outf.writelines("%s = %s\n" % (key, repr(filevars[key])) for key in keys)
337329
outf.close()
338330

339331
return result
@@ -520,8 +512,7 @@ def take_from_configparser(self, options):
520512
import re
521513
sep = re.compile(r"(?<!\\),")
522514
result = sep.split(opt)
523-
result = [i.replace(r"\,", ",") for i in result]
524-
return result
515+
return [i.replace(r"\,", ",") for i in result]
525516
else:
526517
return []
527518

@@ -588,9 +579,9 @@ def set_up_shipped_boost_if_requested(project_name, conf, source_path=None,
588579
print("(The files should be under %s/.)" % source_path)
589580
print(DASH_SEPARATOR)
590581
print("If you got this package from git, you probably want to do")
591-
print("")
582+
print()
592583
print(" $ git submodule update --init")
593-
print("")
584+
print()
594585
print("to fetch what you are presently missing. If you got this from")
595586
print("a distributed package on the net, that package is broken and")
596587
print("should be fixed. For now, I will turn off 'USE_SHIPPED_BOOST'")
@@ -798,7 +789,7 @@ def _run_git_command(cmd):
798789
print(DASH_SEPARATOR)
799790
print("The package directory appears to be a git repository, but I could")
800791
print("not invoke git to check whether my submodules are up to date.")
801-
print("")
792+
print()
802793
print("The error was:")
803794
print(git_error)
804795
print("Hit Ctrl-C now if you'd like to think about the situation.")
@@ -855,20 +846,20 @@ def check_git_submodules():
855846
print("git submodules are not up-to-date or in odd state")
856847
print(DASH_SEPARATOR)
857848
print("If this makes no sense, you probably want to say")
858-
print("")
849+
print()
859850
print(" $ git submodule update --init")
860-
print("")
851+
print()
861852
print("to fetch what you are presently missing and "
862853
"move on with your life.")
863854
print("If you got this from a distributed package on the "
864855
"net, that package is")
865856
print("broken and should be fixed. Please inform whoever "
866857
"gave you this package.")
867-
print("")
858+
print()
868859
print("These issues were found:")
869860
for w in pkg_warnings:
870861
print(" %s" % w)
871-
print("")
862+
print()
872863
print("I will try to initialize the submodules for you "
873864
"after a short wait.")
874865
print(DASH_SEPARATOR)
@@ -898,12 +889,12 @@ def check_pybind11():
898889
print("Pybind11 is not installed.")
899890
print(DASH_SEPARATOR)
900891
print("Very likely, the build process after this message will fail.")
901-
print("")
892+
print()
902893
print("Simply press Ctrl+C and type")
903894
print("python -m pip install pybind11")
904895
print("to fix this. If you don't, the build will continue ")
905896
print("in a few seconds.")
906-
print("")
897+
print()
907898
print("[1] https://pybind11.readthedocs.io/en/stable/")
908899
print(DASH_SEPARATOR)
909900

examples/cai_numba.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# We use autoprimaryctx instead of autoinit because Numba can only operate on a
99
# primary context
10-
import pycuda.gpuarray as gpuarray
10+
from pycuda import gpuarray
1111

1212

1313
# Create a PyCUDA gpuarray

examples/demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
# part 2 ----------------------------------------------------------------------
4444

45-
import pycuda.gpuarray as gpuarray
45+
from pycuda import gpuarray
4646

4747

4848
a_gpu = gpuarray.to_gpu(numpy.random.randn(4, 4).astype(numpy.float32))

examples/demo_elementwise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import numpy
44

5-
import pycuda.gpuarray as gpuarray
5+
from pycuda import gpuarray
66
from pycuda.curandom import rand as curand
77

88

examples/fill_gpu_with_nans.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy
44

55
import pycuda.driver as cuda
6-
import pycuda.gpuarray as gpuarray
6+
from pycuda import gpuarray
77

88

99
free_bytes, total_bytes = cuda.mem_get_info()

examples/from-wiki/2d_fft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def run(self):
6868
num = 2 # I KNOW THIS IS A BAD PRACTISE, BUT I COUNDN'T FIND ANY OTHER WAY(INIT CANNOT BE USED HERE)
6969

7070
# THE TRANSPOSE-SPLIT ALGORITHM FOR FFT
71-
for _t in range(0, trans):
71+
for _t in range(trans):
7272
for i in range(m):
7373
a2_1[i, :] = a2[i*p/m:(i+1)*p/m, :].flatten() # DIVIDE AND RESHAPE THE INPUT IMAGE INTO 1D ARRAY
7474

examples/from-wiki/arithmetic_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66

77
import pycuda.driver as cuda
8-
import pycuda.gpuarray as gpuarray
8+
from pycuda import gpuarray
99
from pycuda.compiler import SourceModule
1010

1111

examples/from-wiki/c++_function_templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import numpy as np
55

6-
import pycuda.gpuarray as gpuarray
6+
from pycuda import gpuarray
77
from pycuda.compiler import SourceModule
88

99

examples/from-wiki/demo_complex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import numpy
55

6-
import pycuda.gpuarray as gpuarray
6+
from pycuda import gpuarray
77

88

99
a = (numpy.random.randn(400)

examples/from-wiki/distance_element_wise3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy
77

88
import pycuda.driver as cuda
9-
import pycuda.gpuarray as gpuarray
9+
from pycuda import gpuarray
1010
from pycuda.elementwise import ElementwiseKernel as Elementwise
1111

1212

0 commit comments

Comments
 (0)