Skip to content

Commit def2977

Browse files
committed
feat: rename reverse methods to split
1 parent 7730b2d commit def2977

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

matrix.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ declare module 'ml-matrix' {
166166
mmulStrassen(y: Matrix): Matrix;
167167
scaleRows(min?: number, max?: number): Matrix;
168168
scaleColumns(min?: number, max?: number): Matrix;
169-
reverseRows(): this;
170-
reverseColumns(): this;
169+
flipRows(): this;
170+
flipColumns(): this;
171171
kroneckerProduct(other: Matrix): Matrix;
172172
tensorProduct(other: Matrix): Matrix;
173173
transpose(): Matrix;

src/__tests__/matrix/flip.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Matrix } from '../..';
2+
3+
test('flip rows', () => {
4+
const matrix = new Matrix([[1, 2, 3], [4, 5, 6]]);
5+
const result = matrix.flipRows();
6+
expect(result).toBe(matrix);
7+
expect(result.to2DArray()).toStrictEqual([[3, 2, 1], [6, 5, 4]]);
8+
});
9+
10+
test('flip columns', () => {
11+
const matrix = new Matrix([[1, 2, 3], [4, 5, 6]]);
12+
const result = matrix.flipColumns();
13+
expect(result).toBe(matrix);
14+
expect(result.to2DArray()).toStrictEqual([[4, 5, 6], [1, 2, 3]]);
15+
});

src/__tests__/matrix/reverse.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/abstractMatrix.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ export default class AbstractMatrix {
13631363
return newMatrix;
13641364
}
13651365

1366-
reverseRows() {
1366+
flipRows() {
13671367
const middle = Math.ceil(this.columns / 2);
13681368
for (var i = 0; i < this.rows; i++) {
13691369
for (var j = 0; j < middle; j++) {
@@ -1376,7 +1376,7 @@ export default class AbstractMatrix {
13761376
return this;
13771377
}
13781378

1379-
reverseColumns() {
1379+
flipColumns() {
13801380
const middle = Math.ceil(this.rows / 2);
13811381
for (var j = 0; j < this.columns; j++) {
13821382
for (var i = 0; i < middle; i++) {

0 commit comments

Comments
 (0)