Skip to content

Commit a0d2dbb

Browse files
edwinsolisfsyurkevi
authored andcommitted
Linting fixes
1 parent 8f047f5 commit a0d2dbb

14 files changed

+197
-190
lines changed

.flake8

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ max-line-length = 119
88
exclude =
99
.venv/**
1010
build/**
11-
benchmarks/**
11+
benchmarks/**
12+
docs/*
13+
tests/test_documentation/test_documentation.py

arrayfire/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@
103103

104104
from arrayfire.library.array_functions import (
105105
constant,
106-
zeros,
107-
ones,
108106
copy_array,
109107
diag,
110108
eval,
@@ -119,17 +117,19 @@
119117
lookup,
120118
lower,
121119
moddims,
122-
reshape,
120+
ones,
123121
pad,
124122
range,
125123
reorder,
126124
replace,
125+
reshape,
127126
select,
128127
set_manual_eval_flag,
129128
shift,
130129
tile,
131130
transpose,
132131
upper,
132+
zeros,
133133
)
134134

135135
__all__ += ["gloh", "orb", "sift", "dog", "fast", "harris", "susan", "hamming_matcher", "nearest_neighbour"]

arrayfire/array_object.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -758,10 +758,10 @@ def __getitem__(self, key: IndexKey, /) -> Array:
758758
ndims = self.ndim
759759

760760
indexing = key
761-
762-
if isinstance(key, int | float | slice): # when indexing with one dimension, treat it as indexing a flat array
761+
762+
if isinstance(key, int | float | slice): # when indexing with one dimension, treat it as indexing a flat array
763763
ndims = 1
764-
elif isinstance(key, Array): # when indexing with one array, treat it as indexing a flat array
764+
elif isinstance(key, Array): # when indexing with one array, treat it as indexing a flat array
765765
ndims = 1
766766
if key.is_bool:
767767
indexing = wrapper.where(key.arr)
@@ -836,9 +836,9 @@ def __setitem__(self, key: IndexKey, value: int | float | bool | Array, /) -> No
836836
del_other = False
837837

838838
indexing = key
839-
if isinstance(key, int | float | slice): # when indexing with one dimension, treat it as indexing a flat array
839+
if isinstance(key, int | float | slice): # when indexing with one dimension, treat it as indexing a flat array
840840
ndims = 1
841-
elif isinstance(key, Array): # when indexing with one array, treat it as indexing a flat array
841+
elif isinstance(key, Array): # when indexing with one array, treat it as indexing a flat array
842842
ndims = 1
843843
if key.is_bool:
844844
indexing = wrapper.where(key.arr)
@@ -930,7 +930,8 @@ def T(self) -> Array:
930930
931931
Note
932932
----
933-
- The array instance must be two-dimensional. If the array instance is not two-dimensional, an error should be raised.
933+
- The array instance must be two-dimensional. If the array instance is not two-dimensional,
934+
| an error should be raised.
934935
935936
"""
936937
if self.ndim < 2:
@@ -949,11 +950,13 @@ def H(self) -> Array:
949950
-------
950951
Array
951952
Two-dimensional array whose first and last dimensions (axes) are permuted in reverse order relative to
952-
original array with its elements complex conjugated. The returned array must have the same data type as the original array.
953+
| original array with its elements complex conjugated.
954+
| The returned array must have the same data type as the original array.
953955
954956
Note
955957
----
956-
- The array instance must be two-dimensional. If the array instance is not two-dimensional, an error should be raised.
958+
- The array instance must be two-dimensional. If the array instance is not two-dimensional,
959+
| an error should be raised.
957960
958961
"""
959962
if self.ndim < 2:
@@ -1191,7 +1194,8 @@ def reshape(self, shape) -> Array:
11911194
-------
11921195
out : af.Array
11931196
- An array containing the same data as `array` with the specified shape.
1194-
- The total number of elements in `array` must match the product of the dimensions specified in the `shape` tuple.
1197+
- The total number of elements in `array` must match the product of the dimensions
1198+
| specified in the `shape` tuple.
11951199
11961200
Raises
11971201
------

arrayfire/library/array_functions.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def constant(scalar: int | float | complex, shape: tuple[int, ...] = (1,), dtype
7373
"""
7474
return cast(Array, wrapper.create_constant_array(scalar, shape, dtype))
7575

76+
7677
def zeros(shape: tuple[int, ...], dtype: Dtype = float32) -> Array:
7778
"""
7879
Create a multi-dimensional array filled with zeros
@@ -100,6 +101,7 @@ def zeros(shape: tuple[int, ...], dtype: Dtype = float32) -> Array:
100101
"""
101102
return constant(0, shape, dtype)
102103

104+
103105
def ones(shape: tuple[int, ...], dtype: Dtype = float32) -> Array:
104106
"""
105107
Create a multi-dimensional array filled with ones
@@ -127,6 +129,7 @@ def ones(shape: tuple[int, ...], dtype: Dtype = float32) -> Array:
127129
"""
128130
return constant(1, shape, dtype)
129131

132+
130133
@afarray_as_array
131134
def diag(array: Array, /, *, diag_index: int = 0, extract: bool = True) -> Array:
132135
"""
@@ -311,7 +314,8 @@ def lower(array: Array, /, *, is_unit_diag: bool = False) -> Array:
311314
Notes
312315
-----
313316
- The function does not alter the elements above the main diagonal; it simply does not include them in the output.
314-
- This function can be useful for mathematical operations that require lower triangular matrices, such as certain types of matrix factorizations.
317+
- This function can be useful for mathematical operations that require lower triangular matrices,
318+
| such as certain types of matrix factorizations.
315319
316320
Examples
317321
--------
@@ -367,7 +371,8 @@ def upper(array: Array, /, *, is_unit_diag: bool = False) -> Array:
367371
Notes
368372
-----
369373
- The function does not alter the elements below the main diagonal; it simply does not include them in the output.
370-
- This function can be useful for mathematical operations that require upper triangular matrices, such as certain types of matrix factorizations.
374+
- This function can be useful for mathematical operations that require upper triangular matrices,
375+
| such as certain types of matrix factorizations.
371376
372377
Examples
373378
--------
@@ -872,6 +877,7 @@ def moddims(array: Array, shape: tuple[int, ...], /) -> Array:
872877
# TODO add examples to doc
873878
return cast(Array, wrapper.moddims(array.arr, shape))
874879

880+
875881
def reshape(array: Array, shape: tuple[int, ...], /) -> Array:
876882
"""
877883
Modify the shape of the array without changing the data layout.
@@ -907,6 +913,7 @@ def reshape(array: Array, shape: tuple[int, ...], /) -> Array:
907913
"""
908914
return moddims(array, shape)
909915

916+
910917
@afarray_as_array
911918
def reorder(array: Array, /, *, shape: tuple[int, ...] = (1, 0, 2, 3)) -> Array:
912919
"""

arrayfire/library/computer_vision.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ def sift(
164164
tuple[Features, Array]
165165
A tuple containing:
166166
- An ArrayFire Features object encapsulating the detected keypoints.
167-
- An ArrayFire Array containing the corresponding descriptors for each keypoint. The descriptors are 128-dimensional vectors describing the local appearance around each keypoint.
167+
- An ArrayFire Array containing the corresponding descriptors for each keypoint.
168+
| The descriptors are 128-dimensional vectors describing the local appearance around each keypoint.
168169
169170
Note
170171
----

arrayfire/library/linear_algebra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def gemm(
9292
rhs_opts: MatProp = MatProp.NONE,
9393
alpha: int | float = 1.0,
9494
beta: int | float = 0.0,
95-
accum: Array = None
95+
accum: Array = None,
9696
) -> Array:
9797
"""
9898
Performs BLAS general matrix multiplication (GEMM) on two Array instances.

docs/afjit.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
# removed, then the execution of this code would be equivalent to the
66
# following function.
77

8-
import arrayfire as af
98
import time
109

10+
import arrayfire as af
11+
1112
samples = int(9e8)
1213
x = af.randu((samples))
1314
y = af.randu((samples))
1415

16+
1517
def pi_no_jit(x, y, samples):
1618
temp = x * x
1719
af.eval(temp)
@@ -23,11 +25,13 @@ def pi_no_jit(x, y, samples):
2325
af.eval(temp)
2426
return 4.0 * af.sum(temp) / samples
2527

28+
2629
def pi_jit(x, y, samples):
2730
temp = af.sqrt(x * x + y * y) < 1
2831
af.eval(temp)
2932
return 4.0 * af.sum(temp) / samples
3033

34+
3135
# Print device info
3236
af.info()
3337

@@ -47,4 +51,4 @@ def pi_jit(x, y, samples):
4751
end = time.perf_counter()
4852
print("no jit:", end - start, res)
4953

50-
# [jit-endsnippet]
54+
# [jit-endsnippet]

docs/arrayandmatrixmanipulation.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464

6565
print(a)
6666

67-
moddims_a = af.moddims(a,(2,4))
67+
moddims_a = af.moddims(a, (2, 4))
6868

6969
print(moddims_a)
7070

71-
moddims_b = af.moddims(a,(len(a),))
71+
moddims_b = af.moddims(a, (len(a),))
7272
print(moddims_b)
7373

7474
# [manipulation4-endsnippet]
@@ -79,24 +79,24 @@
7979

8080
import arrayfire as af
8181

82-
a = af.randu((2,2,3,1))
82+
a = af.randu((2, 2, 3, 1))
8383

8484
print(a)
8585

86-
a_reorder = af.reorder(a,())
86+
a_reorder = af.reorder(a, ())
8787
# [manipulation5-endsnippet]
8888

8989
# [manipulation6-snippet]
9090

9191
import arrayfire as af
9292

93-
a = af.randu((3,5))
93+
a = af.randu((3, 5))
9494
print(a)
9595

96-
a_shift = af.shift(a,(0,2))
96+
a_shift = af.shift(a, (0, 2))
9797
print(a_shift)
9898

99-
a_shift1 = af.shift(a,(-1,2))
99+
a_shift1 = af.shift(a, (-1, 2))
100100
print(a_shift1)
101101

102102
# [manipulation6-endsnippet]
@@ -106,17 +106,17 @@
106106

107107
import arrayfire as af
108108

109-
a = af.randu((3,)) #[3,1,1,1]
109+
a = af.randu((3,)) # [3,1,1,1]
110110

111-
print (a)
111+
print(a)
112112

113-
a_tile = af.tile(a,(2,))
113+
a_tile = af.tile(a, (2,))
114114
print(a_tile)
115115

116-
a_tile1 = af.tile(a,(2,2))
116+
a_tile1 = af.tile(a, (2, 2))
117117
print(a_tile1)
118118

119-
a_tile2 = af.tile(a,(1,2,3))
119+
a_tile2 = af.tile(a, (1, 2, 3))
120120
print(a_tile2)
121121
# [manipulation7-endsnippet]
122122

@@ -125,18 +125,18 @@
125125

126126
import arrayfire as af
127127

128-
a = af.randu((3,3))
129-
print(a) #[3 3 1 1]
128+
a = af.randu((3, 3))
129+
print(a) # [3 3 1 1]
130130

131-
''' 0.3949 0.8465 0.3709
131+
""" 0.3949 0.8465 0.3709
132132
0.3561 0.9399 0.2751
133-
0.6097 0.6802 0.2720'''
134-
133+
0.6097 0.6802 0.2720"""
134+
135135

136136
a_transpose = af.transpose(a)
137-
print(a_transpose) #[3 3 1 1]
137+
print(a_transpose) # [3 3 1 1]
138138

139-
''' 0.3949 0.3561 0.6097
139+
""" 0.3949 0.3561 0.6097
140140
0.8465 0.9399 0.6802
141-
0.3709 0.2751 0.2720'''
141+
0.3709 0.2751 0.2720"""
142142
# [manipulation8-endsnippet]

docs/conf.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,47 @@
22
#
33
# For the full list of built-in configuration values, see the documentation:
44
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5-
import sys
65
import os
7-
sys.path.insert(0, os.path.abspath('..'))
6+
import sys
7+
8+
sys.path.insert(0, os.path.abspath(".."))
89

910
# -- Project information -----------------------------------------------------
1011
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
1112

12-
project = 'ArrayFire'
13-
copyright = '2025, ArrayFire'
14-
author = 'ArrayFire'
15-
release = ''
13+
project = "ArrayFire"
14+
copyright = "2025, ArrayFire"
15+
author = "ArrayFire"
16+
release = ""
1617

1718
# -- General configuration ---------------------------------------------------
1819
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
1920

2021
extensions = [
21-
'sphinx.ext.duration',
22-
'sphinx.ext.doctest',
23-
'sphinx.ext.autodoc',
24-
'sphinx.ext.mathjax',
25-
'sphinx_collapse',
22+
"sphinx.ext.duration",
23+
"sphinx.ext.doctest",
24+
"sphinx.ext.autodoc",
25+
"sphinx.ext.mathjax",
26+
"sphinx_collapse",
2627
]
2728

28-
templates_path = ['_templates']
29+
templates_path = ["_templates"]
2930
exclude_patterns = []
3031

3132

32-
3333
# -- Options for HTML output -------------------------------------------------
3434
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
3535

36-
html_theme = 'sphinxawesome_theme'
37-
html_static_path = ['_static']
36+
html_theme = "sphinxawesome_theme"
37+
html_static_path = ["_static"]
3838
html_permalinks = False
3939
html_theme_options = {
4040
"logo_light": "_static/../images/arrayfire_icon.png",
41-
"logo_dark": "_static/../images/arrayfire_icon.png"
41+
"logo_dark": "_static/../images/arrayfire_icon.png",
4242
}
4343

4444
# -- Suppress specific warnings --------------------------------------------
4545

4646
suppress_warnings = [
47-
'ref.include_missing',
47+
"ref.include_missing",
4848
]

0 commit comments

Comments
 (0)