Skip to content

Pu/minmax - #711

Merged
izulin merged 4 commits into
developfrom
pu/minmax
Jun 14, 2021
Merged

izulin merged 4 commits into
developfrom
pu/minmax

Conversation

@izulin

@izulin izulin commented Jun 14, 2021

Copy link
Copy Markdown
Contributor

Context

MIN and MAX were using the same function cache.

    const engine = HyperFormula.buildFromArray([[1, 2, 3], ['=MIN(A1:C1)', '=MAX(A1:C1)']])
    expect(engine.getCellValue({col: 1, row: 1, sheet: 0})).toEqual(3) //returns 1

How has this been tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature or improvement (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Additional language file or change to the existing one (translations)

Related issue(s):

Checklist:

  • My code follows the code style of this project,
  • My change requires a change to the documentation,
  • I described the modification in the CHANGELOG.md file.

@izulin
izulin changed the base branch from master to develop June 14, 2021 18:06
@izulin
izulin requested a review from wojciechczerniak June 14, 2021 18:06
@codecov

codecov Bot commented Jun 14, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #711 (325275d) into develop (d828fc8) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #711   +/-   ##
========================================
  Coverage    92.27%   92.27%           
========================================
  Files          166      166           
  Lines        39400    39400           
  Branches      5364     5364           
========================================
  Hits         36358    36358           
  Misses        3003     3003           
  Partials        39       39           
Impacted Files Coverage Δ
src/interpreter/plugin/NumericAggregationPlugin.ts 92.16% <100.00%> (ø)

@wojciechczerniak wojciechczerniak left a comment

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.

LGTM 👍

Comment on lines +7 to +15
[1, 2, 5, 10, 20],
['=MIN(A1:E1)', '=MAX(A1:E1)', '=SUM(A1:E1)', '=SUMSQ(A1:E1)', '=AVERAGE(A1:E1)'],
['=MIN(A1:E1)', '=MAX(A1:E1)', '=SUM(A1:E1)', '=SUMSQ(A1:E1)', '=AVERAGE(A1:E1)'],
])
expect(engine.getCellValue(adr('A3'))).toEqual(1)
expect(engine.getCellValue(adr('B3'))).toEqual(20)
expect(engine.getCellValue(adr('C3'))).toEqual(38)
expect(engine.getCellValue(adr('D3'))).toEqual(530)
expect(engine.getCellValue(adr('E3'))).toEqual(7.6)

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.

Can similar problem occur when functions are the same but ranges differ? Looks like one row is unused, so I have a suggestion:

Suggested change
[1, 2, 5, 10, 20],
['=MIN(A1:E1)', '=MAX(A1:E1)', '=SUM(A1:E1)', '=SUMSQ(A1:E1)', '=AVERAGE(A1:E1)'],
['=MIN(A1:E1)', '=MAX(A1:E1)', '=SUM(A1:E1)', '=SUMSQ(A1:E1)', '=AVERAGE(A1:E1)'],
])
expect(engine.getCellValue(adr('A3'))).toEqual(1)
expect(engine.getCellValue(adr('B3'))).toEqual(20)
expect(engine.getCellValue(adr('C3'))).toEqual(38)
expect(engine.getCellValue(adr('D3'))).toEqual(530)
expect(engine.getCellValue(adr('E3'))).toEqual(7.6)
[1, 2, 5, 10, 20],
['=MIN(B1:E1)', '=MAX(A1:D1)', '=SUM(B1:E1)', '=SUMSQ(A1:D1)', '=AVERAGE(A1:D1)'],
['=MIN(A1:E1)', '=MAX(A1:E1)', '=SUM(A1:E1)', '=SUMSQ(A1:E1)', '=AVERAGE(A1:E1)'],
])
expect(engine.getCellValue(adr('A2'))).toEqual(2)
expect(engine.getCellValue(adr('B2'))).toEqual(10)
expect(engine.getCellValue(adr('C2'))).toEqual(37)
expect(engine.getCellValue(adr('D2'))).toEqual( ?? )
expect(engine.getCellValue(adr('E2'))).toEqual( ?? )
expect(engine.getCellValue(adr('A3'))).toEqual(1)
expect(engine.getCellValue(adr('B3'))).toEqual(20)
expect(engine.getCellValue(adr('C3'))).toEqual(38)
expect(engine.getCellValue(adr('D3'))).toEqual(530)
expect(engine.getCellValue(adr('E3'))).toEqual(7.6)

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.

The reason why I copied the row is to have it so each function is called once on exactly one particular range, before we try to call them second time, (so we check possible cache pollution for every combination).

@izulin izulin Jun 14, 2021 •

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.

Can similar problem occur when functions are the same but ranges differ? Looks like one row is unused, so I have a suggestion:

If it could, it would also occur with identical ranges.

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.

ok then 👍

@izulin
izulin merged commit 30abc3b into develop Jun 14, 2021
@izulin
izulin deleted the pu/minmax branch June 14, 2021 21:11
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