Skip to content

da.asarray(x, dtype=..., like=...) disregards dtype when x is already a Dask Array #11732

Closed

Description

@crusaderky
>>> a = da.array([1, 2], dtype=np.int32)
>>> b = da.asarray(0.)
>>> c = da.asarray(b, dtype=a.dtype, like=a)
>>> c.dtype
dtype('int32')
>>> c.compute().dtype
dtype('float64')

da.asanyarray has the same issue. da.array is unaffected. The copy parameter seems inconsequential.

Workaround

>>> d = da.asarray(b, like=a).astype(a.dtype)
>>> d.dtype
dtype('int32')
>>> d.compute().dtype
dtype('int32')

Related

Activity

  1. added
    needs triage
    on Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions