Skip to content

fix: use absolute values for max norm - #223

Merged
targos merged 1 commit into
mljs:mainfrom
vera-rubin:fix/max-norm
Oct 19, 2026
Merged

targos merged 1 commit into
mljs:mainfrom
vera-rubin:fix/max-norm

Conversation

@vera-rubin

@vera-rubin vera-rubin commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

norm('max') (6.15.0) returns -1 for [[-2, -1]], but the max norm definition calls for the largest absolute entry, 2.

const { Matrix } = require('ml-matrix');
new Matrix([[-2, -1]]).norm('max'); // -1 before this change

We now take absolute values on a copy before finding the maximum, leaving the input matrix unchanged. We've added a regression test for negative and mixed-sign entries and checked it alongside the full test suite, lint, formatting and build.

@codecov

codecov Bot commented Oct 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.88%. Comparing base (1a4a05a) to head (a252b72).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #223   +/-   ##
=======================================
  Coverage   68.88%   68.88%           
=======================================
  Files          49       49           
  Lines        5904     5904           
  Branches     1060     1060           
=======================================
  Hits         4067     4067           
  Misses       1824     1824           
  Partials       13       13           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@targos
targos merged commit b64306c into mljs:main Oct 19, 2026
10 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.

2 participants