Skip to content

Commit 552fb59

Browse files
committed
Fix: DTypeLike can no longer be None in numpy 2.4+
1 parent bfb2b4c commit 552fb59

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

arraycontext/fake_numpy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def linspace(self,
186186
num: int = 50,
187187
*, endpoint: bool = True,
188188
retstep: Literal[False] = False,
189-
dtype: DTypeLike = None,
189+
dtype: DTypeLike | None = None,
190190
axis: int = 0
191191
) -> Array: ...
192192

@@ -197,7 +197,7 @@ def linspace(self,
197197
num: int = 50,
198198
*, endpoint: bool = True,
199199
retstep: Literal[True],
200-
dtype: DTypeLike = None,
200+
dtype: DTypeLike | None = None,
201201
axis: int = 0
202202
) -> tuple[Array, NDArray[Any] | float] | Array: ...
203203

@@ -207,7 +207,7 @@ def linspace(self,
207207
num: int = 50,
208208
*, endpoint: bool = True,
209209
retstep: bool = False,
210-
dtype: DTypeLike = None,
210+
dtype: DTypeLike | None = None,
211211
axis: int = 0
212212
) -> tuple[Array, NDArray[Any] | float] | Array:
213213
num = operator.index(num)
@@ -446,19 +446,19 @@ def where(self,
446446
def sum(self,
447447
a: ArrayOrContainer, /,
448448
axis: int | tuple[int, ...] | None = None,
449-
dtype: DTypeLike = None,
449+
dtype: DTypeLike | None = None,
450450
) -> Array: ...
451451
@overload
452452
def sum(self,
453453
a: ScalarLike, /,
454454
axis: int | tuple[int, ...] | None = None,
455-
dtype: DTypeLike = None,
455+
dtype: DTypeLike | None = None,
456456
) -> ScalarLike: ...
457457

458458
def sum(self,
459459
a: ArrayOrContainerOrScalar, /,
460460
axis: int | tuple[int, ...] | None = None,
461-
dtype: DTypeLike = None,
461+
dtype: DTypeLike | None = None,
462462
) -> ArrayOrScalar: ...
463463

464464
@overload

arraycontext/impl/jax/fake_numpy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,20 @@ def rec_equal(x, y):
209209
def sum(self,
210210
a: ArrayOrContainer,
211211
axis: int | tuple[int, ...] | None = None,
212-
dtype: DTypeLike = None,
212+
dtype: DTypeLike | None = None,
213213
) -> Array: ...
214214
@overload
215215
def sum(self,
216216
a: Scalar,
217217
axis: int | tuple[int, ...] | None = None,
218-
dtype: DTypeLike = None,
218+
dtype: DTypeLike | None = None,
219219
) -> Scalar: ...
220220

221221
@override
222222
def sum(self,
223223
a: ArrayOrContainerOrScalar,
224224
axis: int | tuple[int, ...] | None = None,
225-
dtype: DTypeLike = None,
225+
dtype: DTypeLike | None = None,
226226
) -> ArrayOrScalar:
227227
return rec_map_reduce_array_container(
228228
sum,

arraycontext/impl/numpy/fake_numpy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,20 @@ def __getattr__(self, name: str):
100100
def sum(self,
101101
a: ArrayOrContainer,
102102
axis: int | tuple[int, ...] | None = None,
103-
dtype: DTypeLike = None,
103+
dtype: DTypeLike | None = None,
104104
) -> Array: ...
105105
@overload
106106
def sum(self,
107107
a: Scalar,
108108
axis: int | tuple[int, ...] | None = None,
109-
dtype: DTypeLike = None,
109+
dtype: DTypeLike | None = None,
110110
) -> Scalar: ...
111111

112112
@override
113113
def sum(self,
114114
a: ArrayOrContainerOrScalar,
115115
axis: int | tuple[int, ...] | None = None,
116-
dtype: DTypeLike = None,
116+
dtype: DTypeLike | None = None,
117117
) -> ArrayOrScalar:
118118
return rec_map_reduce_array_container(sum, partial(np.sum,
119119
axis=axis,
@@ -273,7 +273,7 @@ def array_equal(self,
273273

274274
@override
275275
def arange(self, *args, **kwargs):
276-
return np.arange(*args, **kwargs)
276+
return cast("Array", cast("object", np.arange(*args, **kwargs)))
277277

278278
@override
279279
def linspace(self, *args, **kwargs):

arraycontext/impl/pyopencl/fake_numpy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,20 +345,20 @@ def inner(ary: ArrayOrScalar) -> ArrayOrScalar:
345345
def sum(self,
346346
a: ArrayOrContainer,
347347
axis: int | tuple[int, ...] | None = None,
348-
dtype: DTypeLike = None,
348+
dtype: DTypeLike | None = None,
349349
) -> Array: ...
350350
@overload
351351
def sum(self,
352352
a: ScalarLike,
353353
axis: int | tuple[int, ...] | None = None,
354-
dtype: DTypeLike = None,
354+
dtype: DTypeLike | None = None,
355355
) -> ScalarLike: ...
356356

357357
@override
358358
def sum(self,
359359
a: ArrayOrContainerOrScalar,
360360
axis: int | tuple[int, ...] | None = None,
361-
dtype: DTypeLike = None,
361+
dtype: DTypeLike | None = None,
362362
) -> ArrayOrScalar:
363363
if isinstance(axis, int):
364364
axis = axis,

arraycontext/impl/pyopencl/taggable_cl_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def to_tagged_cl_array(ary: cla.Array,
185185
def empty(
186186
queue: cl.CommandQueue,
187187
shape: tuple[int, ...] | int,
188-
dtype: DTypeLike = float,
188+
dtype: DTypeLike | None = None,
189189
*, axes: tuple[Axis, ...] | None = None,
190190
tags: frozenset[Tag] = _EMPTY_TAG_SET,
191191
order: Literal["C"] | Literal["F"] = "C",

arraycontext/impl/pytato/fake_numpy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,20 +234,20 @@ def rec_equal(
234234
def sum(self,
235235
a: ArrayOrContainer,
236236
axis: int | tuple[int, ...] | None = None,
237-
dtype: DTypeLike = None,
237+
dtype: DTypeLike | None = None,
238238
) -> Array: ...
239239
@overload
240240
def sum(self,
241241
a: Scalar,
242242
axis: int | tuple[int, ...] | None = None,
243-
dtype: DTypeLike = None,
243+
dtype: DTypeLike | None = None,
244244
) -> Scalar: ...
245245

246246
@override
247247
def sum(self,
248248
a: ArrayOrContainerOrScalar,
249249
axis: int | tuple[int, ...] | None = None,
250-
dtype: DTypeLike = None,
250+
dtype: DTypeLike | None = None,
251251
) -> ArrayOrScalar:
252252
def _pt_sum(ary):
253253
if dtype not in [ary.dtype, None]:

0 commit comments

Comments
 (0)