Skip to content
Merged
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
0a6a3e5
Tranpose works with any type
voodoo11 May 15, 2021
4cdf2e5
CHANGELOG
voodoo11 May 15, 2021
c9cf90f
Remove obsolete test
voodoo11 May 15, 2021
0b30d65
Allow to move cells in address mapping
voodoo11 May 8, 2021
4df502c
Compare matrices in graph comparator
voodoo11 May 8, 2021
73eda47
Adjust matrices address mapping after adding row
voodoo11 May 8, 2021
688bcf6
TODO
voodoo11 May 8, 2021
ae20930
Obsolete test
voodoo11 May 8, 2021
03cb6ce
Fix cherry-pick
voodoo11 May 15, 2021
ce743d5
Compare matrix mappings in graph comparator
voodoo11 May 21, 2021
55663ec
Remove unused code
voodoo11 May 21, 2021
fbd7ae6
Add simple tests
voodoo11 May 21, 2021
8028fa8
Move MatrixMapping entries when adding rows
voodoo11 May 21, 2021
37bd290
Spike
voodoo11 May 21, 2021
747caec
Exchanging matrix vertex works
voodoo11 May 21, 2021
555983f
Fix addres mapping for simple case of removing row
voodoo11 May 22, 2021
e68288b
Make matrix REF if no space after removing row
voodoo11 May 22, 2021
ea1690e
Tidy up
voodoo11 May 22, 2021
c541d73
Shrink matrix before swap
voodoo11 May 22, 2021
b5a5445
Fix gathering matrices related to ranges
voodoo11 May 22, 2021
a3b480d
Basic tests for removing rows works
voodoo11 May 23, 2021
35212d9
Test with potential CYCLE
voodoo11 May 23, 2021
0a4455b
Simplify condition by making use of MatrixSize function
voodoo11 May 23, 2021
cdad5c2
Reuse and simplify
voodoo11 May 23, 2021
48a88ca
Basic cases for setCellContent
voodoo11 May 23, 2021
edf3ffc
Set no space if writing over matrix
voodoo11 May 24, 2021
6c164a5
Shrink matrix during building graph if needed
voodoo11 May 28, 2021
5b3065a
Tests cleanup
voodoo11 May 28, 2021
e345ce2
Allow to setCellContent onto matrix
voodoo11 May 28, 2021
07bc372
Replacing matrix should work
voodoo11 May 28, 2021
47325c6
We do not forbid to change cell content any more when there is array
voodoo11 May 28, 2021
cf6dde9
Remove matrix when removing row with corner
voodoo11 May 28, 2021
8fccdbd
Do not change size of a REFed matrix
voodoo11 May 28, 2021
6ab5d19
Test for references
voodoo11 May 28, 2021
07f401a
Add test specially for dep correction
voodoo11 May 28, 2021
50677ca
Compare only ref flag
voodoo11 May 29, 2021
7f55fec
Fix adjusting edges
voodoo11 May 31, 2021
51894a9
Skipped test for later
voodoo11 Jun 4, 2021
6299050
just setNoSpace()
voodoo11 Jun 4, 2021
b3c8f8e
Test for undo redo and changes
voodoo11 Jun 4, 2021
b70c2d7
Keep changes with old content in map
voodoo11 Jun 4, 2021
5091a07
Ensure range content changes are properly exported
voodoo11 Jun 11, 2021
86f9e31
More specs
voodoo11 Jun 11, 2021
c5b456f
Use string key in ContentChanges
voodoo11 Jun 11, 2021
1d2527d
Gather changes from dependency graph
voodoo11 Jun 11, 2021
3ab8920
Do nothing when trying to set internal array cell empty
voodoo11 Jun 11, 2021
55ab673
Track SimpleRangeValue changes
voodoo11 Jun 11, 2021
f4d0a01
Compare raw input of parsing errors
voodoo11 Jun 11, 2021
036ab8f
Handle ParsingError case
voodoo11 Jun 11, 2021
2dfe388
Cleanup
voodoo11 Jun 11, 2021
48252d8
Working undo/redo
voodoo11 Jun 11, 2021
d1cde5e
Do not allow to move rows inside array
voodoo11 Jun 12, 2021
5ab2606
Update js docs
voodoo11 Jun 12, 2021
6190cef
Fix rebase
voodoo11 Jun 12, 2021
09bb4bd
Merge branch 'develop' into jk/matrices-take-2-cruds
izulin Jun 17, 2021
5c8efe5
Merge branch 'develop' into jk/matrices-take-2-cruds
izulin Jun 17, 2021
ec581ab
imports
izulin Jun 17, 2021
7d26afc
Enable tests
voodoo11 Jun 18, 2021
3152155
ColumnIndex specs for arrays
voodoo11 Jun 20, 2021
73b6950
Fix test
voodoo11 Jun 23, 2021
7d1df27
Ensure DependencyGraph changes are cleared after building graph
voodoo11 Jun 23, 2021
d9bf831
Ignore EmptyValue in columnIndex
voodoo11 Jun 25, 2021
b28ed81
Apply array changes in all cases
voodoo11 Jun 25, 2021
7070b5e
Gather changes when removing rows
voodoo11 Jun 25, 2021
346e5d4
Make sure range edges are adjusted properly
voodoo11 Jun 25, 2021
dc15310
Linter
voodoo11 Jun 26, 2021
aad74cd
Remove console.log
voodoo11 Jun 26, 2021
5a3ec5c
Cleanup
voodoo11 Jun 27, 2021
20ddf9f
Fix lgtm complaints
voodoo11 Jun 27, 2021
0a44540
Adjust adding columns by analogy
voodoo11 Jun 26, 2021
604b283
ColumnIndex needs to be adjusted
voodoo11 Jun 26, 2021
ebf8f9e
Adjust removing columns by analogy
voodoo11 Jun 26, 2021
3372639
ColumnIndex needs to be adjusted
voodoo11 Jun 26, 2021
8d6b95e
Do not allow to move columns inside array
voodoo11 Jun 27, 2021
c29f3ac
Cleanup
voodoo11 Jun 27, 2021
a4ba74d
Fix browser tests
voodoo11 Jun 27, 2021
ff6f3a1
Fix browser tests
voodoo11 Jun 27, 2021
48dc0b1
rename1
izulin Jul 1, 2021
db34608
renaming 2
izulin Jul 1, 2021
cdbc83c
renaming 3
izulin Jul 1, 2021
3e1b0db
rename + exports + docs
izulin Jul 1, 2021
0db85dc
imports
izulin Jul 1, 2021
9c40964
Adjust tsdoc
voodoo11 Jul 2, 2021
861737a
Apply suggestions from code review
voodoo11 Jul 2, 2021
57834fe
Adjust tsdocs
voodoo11 Jul 2, 2021
623c0c2
Merge branch 'develop' into jk/matrices-take-2-cruds
voodoo11 Jul 2, 2021
c027918
Update CHANGELOG
voodoo11 Jul 2, 2021
64932dd
Merge branch 'jk/matrices-take-2-cruds' into jk/matrices-take-2-cruds…
voodoo11 Jul 2, 2021
a895bf5
Adjust tsdocs
voodoo11 Jul 2, 2021
8fca663
Update changelog
voodoo11 Jul 2, 2021
92a04a2
Adjust tsdocs
voodoo11 Jul 2, 2021
12f7e55
Merge branch 'jk/matrices-take-2-cruds-part-2' into pu/matrixarray
izulin Jul 4, 2021
8920d0e
docs
izulin Jul 4, 2021
0168bdb
Merge branch 'pu/matrixarray' of https://github.com/handsontable/hype…
izulin Jul 4, 2021
e0749a1
lines?
izulin Jul 4, 2021
b355e1d
SPILL array error
voodoo11 Jul 5, 2021
c3cf3c2
SPILL instead of REF
voodoo11 Jul 5, 2021
519622d
CHANGELOG
voodoo11 Jul 5, 2021
9af813e
CHANGELOG
voodoo11 Jul 5, 2021
878265a
Merge branch 'develop' into jk/matrices-take-2-cruds
voodoo11 Jul 5, 2021
ebad033
Merge branch 'jk/matrices-take-2-cruds' into jk/matrices-take-2-cruds…
voodoo11 Jul 5, 2021
2012c31
Unused import
voodoo11 Jul 5, 2021
0108e11
Merge branch 'develop' into jk/matrices-take-2-cruds-part-2
voodoo11 Jul 5, 2021
814f54d
Merge branch 'jk/matrices-take-2-cruds-part-2' into pu/matrixarray
izulin Jul 5, 2021
e15355e
minor fix
izulin Jul 5, 2021
8337518
failing test
izulin Jul 5, 2021
64eff5c
oops
izulin Jul 5, 2021
bd41bb7
Merge branch 'develop' into pu/matrixarray
izulin Jul 5, 2021
9ab1672
Merge branch 'develop' into pu/matrixarray
izulin Jul 5, 2021
3c3be68
Update CHANGELOG.md
izulin Jul 5, 2021
a33f478
Update CHANGELOG.md
izulin Jul 5, 2021
8cabb84
Update CHANGELOG.md
izulin Jul 5, 2021
873f89d
Update CHANGELOG.md
izulin Jul 5, 2021
39c5fa6
order
izulin Jul 5, 2021
8fbf0ab
Update CHANGELOG.md
izulin Jul 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Breaking change**: Changed behaviour of `addRows/removeRows` so that it is possible to add/remove rows across spilled array without changing array size. (#708)
- **Breaking change**: Changed behaviour of `addColumns/removeColumns` so that it is possible to add/remove columns across spilled array without changing array size. (#732)
- Changed SWITCH function, so it takes array as its first argument.
- Changed TRANSPOSE function, so it works with data of any type. (#708)
- Changed TRANSPOSE function, so it works with data of any type. (#670)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please move the braking changes before those non-breaking changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍

- Changed config options (#747):
Comment thread
izulin marked this conversation as resolved.
Resolved

| before | after |
|-----------------------|----------------------|
| matrixColumnSeparator | arrayColumnSeparator |
| matrixRowSeparator | arrayRowSeparator |

- Changed CellType.MATRIX to CellType.ARRAY (#747)
Comment thread
izulin marked this conversation as resolved.
Resolved
- Changed API methods (#747):
Comment thread
izulin marked this conversation as resolved.
Resolved

| before | after |
|--------------------|-------------------|
| matrixMapping | arrrayMapping |
| isCellPartOfMatrix | isCellPartOfArray |

- Changed Exceptions (#747):
Comment thread
izulin marked this conversation as resolved.
Resolved

| before | after |
|------------------------------|-----------------------------|
| SourceLocationHasMatrixError | SourceLocationHasArrayError |
| TargetLocationHasMatrixError | TargetLocationHasArrayError |

### Added
- Added support for array arithmetic. (#628)
Expand All @@ -38,6 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added pretty print for detailedCellError. (#712)
- Added `simpleCellRangeFromString` and `simpleCellRangeToString` helpers. (#720)
- Added `CellError` to exports. (#736)
- Added mapping policies to the exports: `AlwaysDense`, `AlwaysSparse`, `DenseSparseChooseBasedOnThreshold`. (#747)
- Added `#SPILL!` error type. (#708)

### Fixed
Expand Down
13 changes: 0 additions & 13 deletions docs/guide/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,6 @@ cells filled, but located very far from each other.
the fill ratio of the sheet. Let the engine choose the best strategy
for you.

## Numeric matrix detection

HyperFormula is able to optimize underlying data structures when it
detects consistent areas of numerical data. It is especially useful
when dealing with calculations on huge numerical data sets. You may
consider disabling this option completely by setting `matrixDetection`
to false or adjusting the `matrixDetectionThreshold` option to customize
the size of the numerical areas to better fit your use case.

It is worth mentioning that some of the CRUD operations, like
inserting non-numerical data, may lead to disabling optimization
for affected areas.

## Suspending automatic recalculations

By default, HyperFormula recalculates formulas after every change.
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/types-of-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Cells have types that can be retrieved by using the `getCellType`
method. Cell content is not calculated and the method returns only
the type, so, for example, you can check if there is a formula inside
a cell. Here is the list of possible cell types: `'FORMULA'`, `'VALUE'`,
`'MATRIX'`, `'EMPTY`.
`'ARRAY'`, `'EMPTY`.

## Getting cell value type

Expand Down
126 changes: 63 additions & 63 deletions src/MatrixSize.ts → src/ArraySize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import {InterpreterState} from './interpreter/InterpreterState'
import {ArgumentTypes} from './interpreter/plugin/FunctionPlugin'
import {Ast, AstNodeType, ProcedureAst} from './parser'

export class MatrixSize {
public static fromMatrix<T>(matrix: T[][]): MatrixSize {
return new MatrixSize(matrix.length > 0 ? matrix[0].length : 0, matrix.length)
export class ArraySize {
public static fromArray<T>(array: T[][]): ArraySize {
return new ArraySize(array.length > 0 ? array[0].length : 0, array.length)
}

public static error() {
return new MatrixSize(1, 1, true)
return new ArraySize(1, 1, true)
}

public static scalar() {
return new MatrixSize(1, 1, false)
return new ArraySize(1, 1, false)
}

constructor(
Expand All @@ -30,7 +30,7 @@ export class MatrixSize {
public isRef: boolean = false,
) {
if (width <= 0 || height <= 0) {
throw Error('Incorrect matrix size')
throw Error('Incorrect array size')
}
}

Expand All @@ -39,60 +39,60 @@ export class MatrixSize {
}
}

export function matrixSizeForTranspose(inputSize: MatrixSize): MatrixSize {
return new MatrixSize(inputSize.height, inputSize.width)
export function arraySizeForTranspose(inputSize: ArraySize): ArraySize {
return new ArraySize(inputSize.height, inputSize.width)
}

export function matrixSizeForMultiplication(leftMatrixSize: MatrixSize, rightMatrixSize: MatrixSize): MatrixSize {
return new MatrixSize(rightMatrixSize.width, leftMatrixSize.height)
export function arraySizeForMultiplication(leftArraySize: ArraySize, rightArraySize: ArraySize): ArraySize {
return new ArraySize(rightArraySize.width, leftArraySize.height)
}

export function matrixSizeForPoolFunction(inputMatrix: MatrixSize, windowSize: number, stride: number): MatrixSize {
return new MatrixSize(
1 + (inputMatrix.width - windowSize) / stride,
1 + (inputMatrix.height - windowSize) / stride,
export function arraySizeForPoolFunction(inputArray: ArraySize, windowSize: number, stride: number): ArraySize {
return new ArraySize(
1 + (inputArray.width - windowSize) / stride,
1 + (inputArray.height - windowSize) / stride,
)
}

function matrixSizeForBinaryOp(leftMatrixSize: MatrixSize, rightMatrixSize: MatrixSize): MatrixSize {
return new MatrixSize(Math.max(leftMatrixSize.width, rightMatrixSize.width), Math.max(leftMatrixSize.height, rightMatrixSize.height))
function arraySizeForBinaryOp(leftArraySize: ArraySize, rightArraySize: ArraySize): ArraySize {
return new ArraySize(Math.max(leftArraySize.width, rightArraySize.width), Math.max(leftArraySize.height, rightArraySize.height))
}

function matrixSizeForUnaryOp(matrixSize: MatrixSize): MatrixSize {
return new MatrixSize(matrixSize.width, matrixSize.height)
function arraySizeForUnaryOp(arraySize: ArraySize): ArraySize {
return new ArraySize(arraySize.width, arraySize.height)
}

export class MatrixSizePredictor {
export class ArraySizePredictor {
constructor(
private config: Config,
private functionRegistry: FunctionRegistry,
) {
}

public checkMatrixSize(ast: Ast, formulaAddress: SimpleCellAddress): MatrixSize {
return this._checkMatrixSize(ast, {formulaAddress, arraysFlag: this.config.useArrayArithmetic})
public checkArraySize(ast: Ast, formulaAddress: SimpleCellAddress): ArraySize {
return this._checkArraySize(ast, {formulaAddress, arraysFlag: this.config.useArrayArithmetic})
}

private checkMatrixSizeForFunction(ast: ProcedureAst, state: InterpreterState): MatrixSize {
private checkArraySizeForFunction(ast: ProcedureAst, state: InterpreterState): ArraySize {
const metadata = this.functionRegistry.getMetadata(ast.procedureName)
const subChecks = ast.args.map((arg) => this._checkMatrixSize(arg, new InterpreterState(state.formulaAddress, state.arraysFlag || (metadata?.arrayFunction ?? false))))
const subChecks = ast.args.map((arg) => this._checkArraySize(arg, new InterpreterState(state.formulaAddress, state.arraysFlag || (metadata?.arrayFunction ?? false))))
switch (ast.procedureName) {
case 'MMULT': {
if (ast.args.length !== 2) {
return MatrixSize.error()
return ArraySize.error()
}

const [left, right] = subChecks

return matrixSizeForMultiplication(left, right)
return arraySizeForMultiplication(left, right)
}
case 'MEDIANPOOL':
case 'MAXPOOL': {
if (ast.args.length < 2 || ast.args.length > 3) {
return MatrixSize.error()
return ArraySize.error()
}

const matrix = subChecks[0]
const array = subChecks[0]
const windowArg = ast.args[1]
let window

Expand All @@ -113,47 +113,47 @@ export class MatrixSizePredictor {
}
}

if (window > matrix.width || window > matrix.height
if (window > array.width || window > array.height
|| stride > window
|| (matrix.width - window) % stride !== 0 || (matrix.height - window) % stride !== 0) {
return MatrixSize.error()
|| (array.width - window) % stride !== 0 || (array.height - window) % stride !== 0) {
return ArraySize.error()
}

return matrixSizeForPoolFunction(matrix, window, stride)
return arraySizeForPoolFunction(array, window, stride)
}
case 'TRANSPOSE': {
if (ast.args.length !== 1) {
return MatrixSize.error()
return ArraySize.error()
}

const [size] = subChecks

return matrixSizeForTranspose(size)
return arraySizeForTranspose(size)
}
case 'ARRAYFORMULA': {
if (ast.args.length !== 1) {
return MatrixSize.error()
return ArraySize.error()
}
return subChecks[0]
}
case 'FILTER': {
if (ast.args.length <= 1) {
return MatrixSize.error()
return ArraySize.error()
}
const width = Math.max(...(subChecks).map(val => val.width))
const height = Math.max(...(subChecks).map(val => val.height))
return new MatrixSize(width, height)
return new ArraySize(width, height)
}
case 'SWITCH': {
if (ast.args.length === 0) {
return MatrixSize.error()
return ArraySize.error()
}
const [{width, height}] = subChecks
return new MatrixSize(width, height)
return new ArraySize(width, height)
}
case 'ARRAY_CONSTRAIN': {
if (ast.args.length !== 3) {
return MatrixSize.error()
return ArraySize.error()
}
let {height, width} = subChecks[0]
if (ast.args[1].type === AstNodeType.NUMBER) {
Expand All @@ -163,21 +163,21 @@ export class MatrixSizePredictor {
width = Math.min(width, ast.args[2].value)
}
if (height < 1 || width < 1 || !Number.isInteger(height) || !Number.isInteger(width)) {
return MatrixSize.error()
return ArraySize.error()
}
return new MatrixSize(width, height)
return new ArraySize(width, height)
}
default: {
if(metadata === undefined || metadata.expandRanges || !state.arraysFlag || metadata.vectorizationForbidden || metadata.parameters === undefined) {
return new MatrixSize(1, 1)
return new ArraySize(1, 1)
}
const argumentDefinitions = [...metadata.parameters]
if (metadata.repeatLastArgs === undefined && argumentDefinitions.length < subChecks.length) {
return MatrixSize.error()
return ArraySize.error()
}
if (metadata.repeatLastArgs !== undefined && argumentDefinitions.length < subChecks.length &&
(subChecks.length - argumentDefinitions.length) % metadata.repeatLastArgs !== 0) {
return MatrixSize.error()
return ArraySize.error()
}

while(argumentDefinitions.length < subChecks.length) {
Expand All @@ -192,44 +192,44 @@ export class MatrixSizePredictor {
maxWidth = Math.max(maxWidth, subChecks[i].width)
}
}
return new MatrixSize(maxWidth, maxHeight)
return new ArraySize(maxWidth, maxHeight)
}
}

}

private _checkMatrixSize(ast: Ast, state: InterpreterState): MatrixSize {
private _checkArraySize(ast: Ast, state: InterpreterState): ArraySize {
switch (ast.type) {
case AstNodeType.FUNCTION_CALL: {
return this.checkMatrixSizeForFunction(ast, state)
return this.checkArraySizeForFunction(ast, state)
}
case AstNodeType.CELL_RANGE: {
const range = AbsoluteCellRange.fromCellRangeOrUndef(ast, state.formulaAddress)
if (range === undefined) {
return MatrixSize.error()
return ArraySize.error()
} else {
return new MatrixSize(range.width(), range.height(), true)
return new ArraySize(range.width(), range.height(), true)
}
}
case AstNodeType.MATRIX: {
case AstNodeType.ARRAY: {
const heights = []
const widths = []
for(const row of ast.args) {
const sizes = row.map(ast => this._checkMatrixSize(ast, state))
const sizes = row.map(ast => this._checkArraySize(ast, state))
const h = Math.min(...sizes.map(size => size.height))
const w = sizes.reduce((total, size) => total+size.width, 0)
heights.push(h)
widths.push(w)
}
const height = heights.reduce((total, h) => total+h, 0)
const width = Math.min(...widths)
return new MatrixSize(width, height)
return new ArraySize(width, height)
}
case AstNodeType.STRING:
case AstNodeType.NUMBER:
return MatrixSize.scalar()
return ArraySize.scalar()
case AstNodeType.CELL_REFERENCE:
return new MatrixSize(1, 1, true)
return new ArraySize(1, 1, true)
case AstNodeType.DIV_OP:
case AstNodeType.CONCATENATE_OP:
case AstNodeType.EQUALS_OP:
Expand All @@ -242,26 +242,26 @@ export class MatrixSizePredictor {
case AstNodeType.PLUS_OP:
case AstNodeType.POWER_OP:
case AstNodeType.TIMES_OP: {
const left = this._checkMatrixSize(ast.left, state)
const right = this._checkMatrixSize(ast.right, state)
const left = this._checkArraySize(ast.left, state)
const right = this._checkArraySize(ast.right, state)
if (!state.arraysFlag && (left.height > 1 || left.width > 1 || right.height > 1 || right.width > 1)) {
return MatrixSize.error()
return ArraySize.error()
}
return matrixSizeForBinaryOp(left, right)
return arraySizeForBinaryOp(left, right)
}
case AstNodeType.MINUS_UNARY_OP:
case AstNodeType.PLUS_UNARY_OP:
case AstNodeType.PERCENT_OP: {
const val = this._checkMatrixSize(ast.value, state)
const val = this._checkArraySize(ast.value, state)
if (!state.arraysFlag && (val.height > 1 || val.width > 1)) {
return MatrixSize.error()
return ArraySize.error()
}
return matrixSizeForUnaryOp(val)
return arraySizeForUnaryOp(val)
}
case AstNodeType.EMPTY:
return MatrixSize.error()
return ArraySize.error()
default:
return MatrixSize.error()
return ArraySize.error()
}
}
}
Expand Down
Loading