Add 0-d NDArray support#84
Merged
Merged
Conversation
Closed
…n-place/comparison op 0-d guards, tests Agent-Logs-Url: https://github.com/Quafadas/vecxt/sessions/34025804-0357-4276-a13e-a022f28af110 Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for 0-dimensional NDArray
Add 0-d NDArray support
Apr 10, 2026
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.
NDArray[A]previously rejected empty shapes, precluding 0-dimensional arrays needed for scalar-tensor bridge patterns (e.g.,MathTrig[NDArray[Double]]wherezero/one/fromDoublemust produce shape-agnostic values that broadcast universally).Core changes
NDArrayCheck.scala: Remove theshape.length == 0rejection fromshapeCheck. 0-d arrays are now valid; the dimension loop simply doesn't execute.ndarray.scala: AddisScalar: Booleanproperty; addNDArray.scalar[A](value)factory producingshape=[], strides=[], numel=1.ndarrayOps.scala: Addscalar(0-arity read) andsetScalar(0-arity write) extension methods.ndarrayDoubleOps.scala/ndarrayFloatOps.scala: Add 0-d guards to all binary ops, in-place ops, and comparison ops. A 0-d operand is auto-promoted by delegating to the existing scalar extension — this is the only implicit broadcast relaxation; all other shape mismatches still require explicitbroadcastTo/broadcastPair.Semantics (NumPy-aligned)
All existing broadcast machinery (
broadcastShape,broadcastTo,broadcastPair) already handles 0-d correctly without modification.