Skip to content

Commit

Permalink
Merge pull request #101 from ev-br/astype_complex_prohibit
Browse files Browse the repository at this point in the history
ENH: prohibit astype(complex, not complex)
  • Loading branch information
ev-br authored Dec 4, 2024
2 parents d086c61 + 8457354 commit 94febbc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions array_api_strict/_data_type_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def astype(

if not copy and dtype == x.dtype:
return x

if isdtype(x.dtype, 'complex floating') and not isdtype(dtype, 'complex floating'):
raise TypeError(
f'The Array API standard stipulates that casting {x.dtype} to {dtype} should not be permitted. '
'array-api-strict thus prohibits this conversion.'
)

return Array._new(x._array.astype(dtype=dtype._np_dtype, copy=copy), device=device)


Expand Down

0 comments on commit 94febbc

Please sign in to comment.