feat: enhance mlx.core.full() TypeScript interface and add comprehensive tests - #548
feat: enhance mlx.core.full() TypeScript interface and add comprehensive tests#548sydneyrenee with Copilot wants to merge 5 commits into
Conversation
Co-authored-by: sydneyrenee <188732394+sydneyrenee@users.noreply.github.com>
…ive tests Co-authored-by: sydneyrenee <188732394+sydneyrenee@users.noreply.github.com>
Co-authored-by: sydneyrenee <188732394+sydneyrenee@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the TypeScript interface for mlx.core.full() to support MLXArray and TypedArray values in addition to scalar numbers, bringing it to parity with the underlying C++ implementation and Python MLX API. The dtype parameter is now optional with automatic inference, and comprehensive test coverage has been added.
Key Changes:
- Extended
full()signature to acceptnumber | SupportedTypedArray | MLXArrayvalues with optional dtype inference - Added 8 comprehensive test cases covering scalar values, explicit dtypes, automatic inference, and array broadcasting
- Applied code formatting improvements across test files
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| node/src/core/array.ts | Enhanced full() function signature and implementation to support MLXArray/TypedArray values with optional dtype; added JSDoc documentation |
| node/test/core/array.test.ts | Added comprehensive test suite for full() function and applied prettier formatting to existing tests |
| node/package.json | Added devDependencies for TypeScript type definitions and formatted keywords array |
Files not reviewed (1)
- node/package-lock.json: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@copilot Address this issue: When dtype is undefined and value is an MLXArray or TypedArray, the addon.full function receives undefined as the dtype parameter. Consider documenting whether the C++ implementation handles dtype inference correctly for array values, or add explicit dtype inference logic in TypeScript before calling addon.full to ensure consistent behavior. |
Co-authored-by: sydneyrenee <188732394+sydneyrenee@users.noreply.github.com>
Fixed in commit 7b4a8c9. The TypeScript wrapper now conditionally passes the dtype parameter only when explicitly provided, avoiding undefined values. The C++ implementation correctly handles dtype inference for all value types:
Enhanced JSDoc documentation now clearly describes this behavior. |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- node/package-lock.json: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@copilot help fix conflicts |
I checked the repository and there are currently no merge conflicts. The working tree is clean and all changes have been committed successfully. If you're seeing conflicts on the GitHub PR page, please let me know:
I'll be happy to help resolve any conflicts once I know more details. |
|
Closing in favor of manual integration on main: reworked TypeScript wrapper/tests for mlx.core.full() without the noise. |
✅ Implementation Complete: mlx.core.full() is fully functional
Summary: The
mlx.core.full()function was already implemented at the C++ level. This PR enhances the TypeScript interface and adds comprehensive test coverage.Checklist
What Was Already Implemented
✅ C++ Native Binding - Full implementation with:
✅ TypeScript Wrapper - Basic wrapper existed
✅ Module Exports - Properly exported throughout
✅ Basic Tests - One test case existed
Enhancements Made
1. Enhanced TypeScript Wrapper (
node/src/core/array.ts)number | SupportedTypedArray | MLXArray2. Comprehensive Test Suite (
node/test/core/array.test.ts)Added 8 new test cases covering:
3. Documentation
4. Code Quality
API Compatibility
Fully compatible with Python MLX:
DType Inference Behavior
The C++ implementation handles dtype inference correctly:
TypeScript now conditionally passes dtype parameter to avoid undefined values.
Verification
All features match Python MLX API:
Files Changed
node/src/core/array.ts- Enhanced wrapper + JSDoc + dtype handling fixnode/test/core/array.test.ts- Added 8 comprehensive testsnode/package.json- Updated dev dependenciesnode/package-lock.json- Dependency updatesOriginal prompt
Fixes #505
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.