Repository navigation
test: cover MLXArray reads, indexing forms, nested structures, eval/grad, memory and errors - #46
Merged
Merged
Conversation
The job summary now shows one table with Lines, Regions and Functions for all of Source/MLX* and for MLX, MLXNN and MLXOptimizers, each against the 80% target. The target is reported only. The text under the table names what is not measured: the Cmlx core and the targets that the test bundle does not link. The step reads each value from the TOTAL row by its column name and fails when a value is missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MLXFast, MLXFFT, MLXLinalg and MLXRandom are deprecated shims that forward to APIs in Source/MLX. Those APIs are counted in the Source/MLX row, so the text no longer reads as if FFT, linalg and random were unmeasured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…grad, memory and errors Add six test files for code that had low coverage: - ArrayAccessorTests: item() for each dtype, shape tuples, strides, asType, complex parts, description. - IndexingFormsTests: each subscript form (deprecated axis forms, newAxis, ellipsis, strides, negative and array indices, setters), compared with values from plain Swift loops. - NestedStructureTests: NestedItem and NestedDictionary map, reduce, flatten, unflatten and description. - EvalGradOverloadTests: eval, asyncEval and checkedEval overloads and the grad and valueAndGrad overloads. - MemoryLimitTests: snapshots and the cache and memory limits. Each test restores the limits it changes. - ErrorHandlerScopeTests: withError, withErrorHandler (sync and async), ErrorBox, MLXError and the global handler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gajesh2007
approved these changes
Oct 2, 2026
Gajesh2007
left a comment
Member
There was a problem hiding this comment.
Reviewed test-only scope and additive fork.yaml resolution at head 50272a3. Signed normal main integration retains every previously landed test and the #35 coverage workflow. Runtime Source is unchanged; original utility tests retain global-state restoration. User explicitly authorizes merging without waiting for refreshed pending CI.
8 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Seven files in
Source/MLXhad low line coverage in run 36587565184:MLXArray.swift(56.2%),MLXArray+Indexing.swift(79.8%),Nested.swift(78.7%),Transforms+Eval.swift(60.5%),Transforms+Grad.swift(42.3%),Memory.swift(55.4%) andErrorHandler.swift(61.2%). This PR adds tests only. It does not change library code.New test files in
Tests/MLXTests:ArrayAccessorTests.swift:item()for each integer and float dtype and each Swift type (theitemInt,itemUInt,itemFloatanditemDoublepaths), reads that convert first, complexitem(),shape2/shape3/shape4,dim, strides, bothasTypeoverloads,asImaginary/realPart/imaginaryPart,_updateInternal,copyContext,innerStateanddescription.IndexingFormsTests.swift: each subscript form on a [2, 3, 4] array: the deprecatedrange, axis:,index, axis:andfrom:to:stride:axis:forms (get and set), the[any MLXArrayIndex]subscript,.newAxisand.ellipsisreads, strided and negative reads, array index reads, and writes with negative indices,.newAxisand strided slices with array indices. Each result is compared with values from plain Swift loops. AlsoMLXArrayIndexOperationandMLXSlicedescriptions and bounds.NestedStructureTests.swift:NestedItemandNestedDictionary: initializers, theunwrapping:subscript, collection indices,unwrap/asDictionary,description,mapValueswith a path,reduce,compactMapValues, the two- and three-itemmapValuesforms for each combination of value, array, dictionary and.none, flatten with a prefix and each unflatten form.EvalGradOverloadTests.swift:eval,asyncEvalandcheckedEvalwith arrays, collections,[Any], dictionaries, 3/4/5-tuples, ignored scalars andNestedDictionary;checkedEvalthat throwsMLXError; eachgradoverload andvalueAndGradwithargumentNumbers, checked against hand-computed derivatives.MemoryLimitTests.swift:Snapshot.delta,description(K and M forms), Codable round trip, live snapshot, and thecacheLimitandmemoryLimitgetters and setters. Each test restores every limit it changes in adefer.ErrorHandlerScopeTests.swift:MLXError,ErrorBox, sync and asyncwithErrorandwithErrorHandler, and the deprecated global handler (its data destructor runs when the handler is replaced). The global handler is reset in adefer.fork.yaml: the Tests section text now names the new test files.Base and merge order. This PR is based on
ci/coverage-scope(#35). It merges after #35. It does not depend on #36, #37, #38, #41 or the other coverage PRs. If a sibling test PR merges first, the only overlap is one line of text at the end of the Tests section infork.yaml. Keep both lines.Checklist
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes (ranswift format format --in-place --configuration .swift-formaton the changed files;swift format lintis clean)fork.yaml;check_forkdiff.pypasses)🤖 Generated with Claude Code