Skip to content

Conversation

@Anri-Lombard
Copy link

Summary

  • Add asarray function to mlx.core module
  • Makes xp.asarray() available via the Array API namespace

Test plan

  • Added test_array_namespace_asarray test

Fixes #2945

Adds the asarray function to the mlx.core module, making it available
via the Array API namespace.

Fixes ml-explore#2945
Copy link
Member

@awni awni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an incomplete fix. mx.asarray should be able to handle any input types that the array constructor can. Please update it and add more tests as appropriate.

Use ArrayInitType and create_array() to handle lists, tuples,
and nested sequences in addition to scalars and arrays.
@Anri-Lombard
Copy link
Author

Anri-Lombard commented Jan 7, 2026

Updated asarray to use ArrayInitType and create_array() - the same type and function used by the array constructor. Also added more tests.

@Anri-Lombard Anri-Lombard requested a review from awni January 7, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] __array_namespace__ missing asarray

2 participants