Skip to content

An Unknown type is returned from array-api-extra #1071

@paddyroddy

Description

@paddyroddy

Add your issue here

If the # ty: ignore[invalid-return-type] comment is removed from the following code

glass/glass/shells.py

Lines 520 to 529 in 7e620f7

zr = xpx.union1d(w.za, z_)
fr = glass.arraytools.ndinterp(
zr,
z,
f,
left=0.0,
right=0.0,
) * glass.arraytools.ndinterp(zr, w.za, w.wa)
return zr, fr # ty: ignore[invalid-return-type]

then we get this error upon running ty check

error[invalid-return-type]: Return type does not match returned value
   --> glass/shells.py:529:12
    |
529 |     return zr, fr
    |            ^^^^^^ expected `tuple[ndarray[tuple[Any, ...], dtype[float64]] | jax._src.basearray.Array | array_api_strict._array_object.Array, ndarray[tuple[Any, ...], dtype[float64]] | jax._src.basearray.Array | array_api_strict._array_object.Array]`, found `tuple[array_api_extra._lib._utils._typing.Array, Unknown]`
    |
   ::: glass/shells.py:482:6
    |
482 | ) -> tuple[FloatArray, FloatArray]:
    |      ----------------------------- Expected `tuple[ndarray[tuple[Any, ...], dtype[float64]] | jax._src.basearray.Array | array_api_strict._array_object.Array, ndarray[tuple[Any, ...], dtype[float64]] | jax._src.basearray.Array | array_api_strict._array_object.Array]` because of return type
    |
info: the first tuple element is not compatible: `Array` is not assignable to `ndarray[tuple[Any, ...], dtype[float64]] | jax._src.basearray.Array | array_api_strict._array_object.Array`

The Unknown type is coming from the xpx.union1d call. This could be "fixed" by changing line 520 to zr = xp.asarray(xpx.union1d(w.za, z_)).

Metadata

Metadata

Assignees

Labels

array-apiWork is related to the Array APIbugSomething isn't workingmaintenanceMaintenance: refactoring, typos, etc.typingStatic typing

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions