Skip to content

Commit d7e8ffd

Browse files
committed
Closes #5225: Resolve N806 errors
1 parent 270ed41 commit d7e8ffd

Some content is hidden

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

49 files changed

+827
-805
lines changed

arkouda/apply.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,18 @@ def apply(
175175
if result_type != arr.dtype:
176176
raise TypeError("result_dtype must match the dtype of the input")
177177

178-
repMsg = generic_msg(
178+
rep_msg = generic_msg(
179179
cmd=f"applyStr<{arr.dtype},{arr.ndim}>",
180180
args={"x": arr, "funcStr": func},
181181
)
182-
return create_pdarray(repMsg)
182+
return create_pdarray(rep_msg)
183183
elif callable(func):
184-
pickleData = cloudpickle.dumps(func)
185-
pickleDataStr = base64.b64encode(pickleData).decode("utf-8")
186-
repMsg = generic_msg(
184+
pickle_data = cloudpickle.dumps(func)
185+
pickle_data_str = base64.b64encode(pickle_data).decode("utf-8")
186+
rep_msg = generic_msg(
187187
cmd=f"applyPickle<{arr.dtype},{arr.ndim},{result_type}>",
188-
args={"x": arr, "pickleData": pickleDataStr},
188+
args={"x": arr, "pickleData": pickle_data_str},
189189
)
190-
return create_pdarray(repMsg)
190+
return create_pdarray(rep_msg)
191191
else:
192192
raise TypeError("func must be a string or a callable function")

arkouda/array_api/_dtypes.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import numpy as np
2+
13
import arkouda as ak
24

35
from arkouda import dtype as akdtype
46

7+
from ._typing import Dtype
8+
59

610
__all__: list[str] = []
711

@@ -22,21 +26,23 @@
2226
complex128 = ak.complex128
2327
bool_ = ak.bool_
2428

25-
_all_dtypes = (
26-
int8,
27-
int16,
28-
int32,
29-
int64,
30-
uint8,
31-
uint16,
32-
uint32,
33-
uint64,
34-
float32,
35-
float64,
36-
complex64,
37-
complex128,
38-
bool,
29+
30+
_all_dtypes: tuple[Dtype, ...] = (
31+
np.dtype(np.int8),
32+
np.dtype(np.int16),
33+
np.dtype(np.int32),
34+
np.dtype(np.int64),
35+
np.dtype(np.uint8),
36+
np.dtype(np.uint16),
37+
np.dtype(np.uint32),
38+
np.dtype(np.uint64),
39+
np.dtype(np.float32),
40+
np.dtype(np.float64),
41+
np.dtype(np.complex64),
42+
np.dtype(np.complex128),
43+
np.dtype(np.bool_),
3944
)
45+
4046
_boolean_dtypes = (bool,)
4147
_real_floating_dtypes = (float32, float64)
4248
_floating_dtypes = (float32, float64, complex64, complex128)

arkouda/array_api/_typing.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
from __future__ import annotations
1010

11-
from typing import Any, Literal, Protocol, TypeVar, Union
11+
from typing import TYPE_CHECKING, Any, Literal, Protocol, TypeAlias, TypeVar, Union
1212

13-
from numpy import dtype, float32, float64, int8, int16, int32, int64, uint8, uint16, uint32, uint64
13+
import numpy as np
1414

15-
from .array_object import Array
15+
16+
if TYPE_CHECKING:
17+
from .array_object import Array
1618

1719

1820
__all__ = [
@@ -37,19 +39,20 @@ def __len__(self, /) -> int: ...
3739
Device = Literal["cpu"]
3840

3941

40-
Dtype = dtype[
41-
Union[
42-
int8,
43-
int16,
44-
int32,
45-
int64,
46-
uint8,
47-
uint16,
48-
uint32,
49-
uint64,
50-
float32,
51-
float64,
52-
]
42+
Dtype: TypeAlias = Union[
43+
np.dtype[np.int8],
44+
np.dtype[np.int16],
45+
np.dtype[np.int32],
46+
np.dtype[np.int64],
47+
np.dtype[np.uint8],
48+
np.dtype[np.uint16],
49+
np.dtype[np.uint32],
50+
np.dtype[np.uint64],
51+
np.dtype[np.float32],
52+
np.dtype[np.float64],
53+
np.dtype[np.complex64],
54+
np.dtype[np.complex128],
55+
np.dtype[np.bool_],
5356
]
5457

5558

arkouda/array_api/creation_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def eye(
218218
raise ValueError(f"Unsupported device {device!r}")
219219

220220
if M is None:
221-
M = N
221+
M = N # noqa: N806
222222

223223
from arkouda import dtype as akdtype
224224

arkouda/array_api/data_type_functions.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,28 @@ def isdtype(dtype: Dtype, kind: Union[Dtype, str, Tuple[Union[Dtype, str], ...]]
133133
@implements_numpy(np.result_type)
134134
def result_type(*arrays_and_dtypes: Union[Array, Dtype]) -> Dtype:
135135
"""Compute the result dtype for a group of arrays and/or dtypes."""
136-
A = []
137-
for a in arrays_and_dtypes:
138-
if isinstance(a, Array):
139-
a = a.dtype
140-
elif isinstance(a, np.ndarray):
141-
a = a.dtype
142-
elif a not in _all_dtypes:
143-
raise TypeError("result_type() inputs must be array_api arrays or dtypes")
144-
A.append(a)
145-
146-
if len(A) == 0:
136+
dtypes: list[Dtype] = []
137+
138+
for obj in arrays_and_dtypes:
139+
if isinstance(obj, Array):
140+
dt: Dtype = obj.dtype
141+
elif isinstance(obj, np.ndarray):
142+
# If you truly allow numpy arrays here, you may need a mapping step.
143+
# If Array.dtype already returns a numpy dtype, this may be fine.
144+
dt = obj.dtype # type: ignore[assignment]
145+
else:
146+
dt = obj
147+
if dt not in _all_dtypes:
148+
raise TypeError("result_type() inputs must be array_api arrays or dtypes")
149+
150+
dtypes.append(dt)
151+
152+
if len(dtypes) == 0:
147153
raise ValueError("at least one array or dtype is required")
148-
elif len(A) == 1:
149-
return A[0]
150-
else:
151-
t = A[0]
152-
for t2 in A[1:]:
153-
t = _result_type(t, t2)
154-
return t
154+
if len(dtypes) == 1:
155+
return dtypes[0]
156+
157+
t = dtypes[0]
158+
for t2 in dtypes[1:]:
159+
t = _result_type(t, t2)
160+
return t

arkouda/array_api/manipulation_functions.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ def broadcast_arrays(*arrays: Array) -> List[Array]:
7070
from arkouda.numpy.util import broadcast_shapes
7171

7272
shapes = [a.shape for a in arrays]
73-
bcShape = broadcast_shapes(*shapes)
73+
bc_shape = broadcast_shapes(*shapes)
7474

75-
return [broadcast_to(a, shape=bcShape) for a in arrays]
75+
return [broadcast_to(a, shape=bc_shape) for a in arrays]
7676

7777

7878
@implements_numpy(np.broadcast_to)
@@ -293,9 +293,9 @@ def flip(x: Array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) ->
293293
from arkouda.client import generic_msg
294294
from arkouda.numpy.util import _axis_validation
295295

296-
axisList = []
296+
axis_list = []
297297
if axis is not None:
298-
valid, axisList = _axis_validation(axis, x.ndim)
298+
valid, axis_list = _axis_validation(axis, x.ndim)
299299
if not valid:
300300
raise IndexError(f"{axis} is not a valid axis/axes for array of rank {x.ndim}")
301301

@@ -312,8 +312,8 @@ def flip(x: Array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) ->
312312
),
313313
args={
314314
"name": x._array,
315-
"nAxes": len(axisList),
316-
"axis": axisList,
315+
"nAxes": len(axis_list),
316+
"axis": axis_list,
317317
},
318318
),
319319
)
@@ -610,9 +610,9 @@ def roll(
610610
if isinstance(shift, tuple) and isinstance(axis, tuple) and (len(axis) != len(shift)):
611611
raise IndexError("When shift and axis are both tuples, they must have the same length.")
612612

613-
axisList = []
613+
axis_list = []
614614
if axis is not None:
615-
valid, axisList = _axis_validation(axis, x.ndim)
615+
valid, axis_list = _axis_validation(axis, x.ndim)
616616
if not valid:
617617
raise IndexError(f"{axis} is not a valid axis/axes for array of rank {x.ndim}")
618618

@@ -631,8 +631,8 @@ def roll(
631631
"name": x._array,
632632
"nShifts": len(shift) if isinstance(shift, tuple) else 1,
633633
"shift": (list(shift) if isinstance(shift, tuple) else [shift]),
634-
"nAxes": len(axisList),
635-
"axis": axisList,
634+
"nAxes": len(axis_list),
635+
"axis": axis_list,
636636
},
637637
),
638638
)

arkouda/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ def _mem_get_factor(unit: str) -> int:
172172
)
173173

174174

175-
logger = getArkoudaLogger(name="Arkouda Client", logLevel=LogLevel.INFO)
176-
clientLogger = getArkoudaLogger(name="Arkouda User Logger", logFormat="%(message)s")
175+
logger = getArkoudaLogger(name="Arkouda Client", log_level=LogLevel.INFO)
176+
clientLogger = getArkoudaLogger(name="Arkouda User Logger", log_format="%(message)s")
177177

178178

179179
class ClientMode(Enum):
@@ -1452,8 +1452,8 @@ def get_server_commands() -> Mapping[str, str]:
14521452

14531453
def print_server_commands():
14541454
"""Print the list of available server commands."""
1455-
cmdMap = get_server_commands()
1456-
cmds = [k for k in sorted(cmdMap.keys())]
1455+
cmd_map = get_server_commands()
1456+
cmds = [k for k in sorted(cmd_map.keys())]
14571457
sys.stdout.write(f"Total available server commands: {len(cmds)}")
14581458
for cmd in cmds:
14591459
sys.stdout.write(f"\t{cmd}")

0 commit comments

Comments
 (0)