Skip to content

feat: add scalar operations and sum reduction - #42

Merged
sMouaad merged 3 commits into
mainfrom
feature/optional-ndarray-extensions
Apr 6, 2026
Merged

feat: add scalar operations and sum reduction#42
sMouaad merged 3 commits into
mainfrom
feature/optional-ndarray-extensions

Conversation

@YassineSamirX

Copy link
Copy Markdown
Collaborator

I added two optional ndarray features: scalar addition and sum() reduction. I also updated unit tests, README updates, and a small demo showcase.

@sMouaad

sMouaad commented Apr 6, 2026

Copy link
Copy Markdown
Owner

for fun this time, try to ask copilot to review @YassineSamirX

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the NdArray API with two additional operations (scalar addition and full-array sum reduction), and updates tests, documentation, and the demo to showcase the new functionality.

Changes:

  • Add scalar overloads for add(...) and addInPlace(...) to apply a constant shift to all elements.
  • Introduce sum() reduction to compute the total of all elements.
  • Update unit tests, README usage/examples, and the demo showcase accordingly.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/main/java/org/sadisamir/ndarray/NdArray.java Adds scalar addition overloads and sum() reduction to the core ndarray API.
src/test/java/org/sadisamir/ndarray/NdArrayTest.java Adds unit tests covering scalar add/addInPlace behavior and sum() across shapes and empty arrays.
src/main/java/org/sadisamir/ndarray/demo/NdArrayDemo.java Adds a demo section showcasing scalar addition and sum reduction.
README.md Documents the new optional extensions and updates usage examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/org/sadisamir/ndarray/NdArray.java Outdated
Comment thread README.md
Comment on lines 26 to +32
Current snapshot date: 2026-04-04.

- 1D ndarray core with metadata (`ndim`, `shape`, `size`).
- 2D ndarray support with matrix validation.
- Creation helpers: `array`, `zeros`, `arange`.
- Addition operations: `add` and `addInPlace` with strict shape checks.
- Optional extensions: scalar addition and `sum()` reduction.

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

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

The README still states "Current snapshot date: 2026-04-04" even though this PR adds new user-facing functionality. Consider updating the snapshot date so the feature list and the stated snapshot date stay consistent.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

he's right

Comment thread src/main/java/org/sadisamir/ndarray/demo/NdArrayDemo.java Outdated
YassineSamirX and others added 2 commits April 6, 2026 12:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sMouaad
sMouaad self-requested a review April 6, 2026 10:55
@sMouaad sMouaad linked an issue Apr 6, 2026 that may be closed by this pull request
10 tasks

@sMouaad sMouaad left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

all good :)

@sMouaad
sMouaad merged commit f917d44 into main Apr 6, 2026
3 checks passed
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.

Add selected optional ndarray features (focused, high-value extensions)

4 participants