Skip to content

Clear sheet before removing - #1160

Merged
sequba merged 12 commits into
developfrom
feature/issue-1121
Mar 1, 2023
Merged

sequba merged 12 commits into
developfrom
feature/issue-1121

Conversation

@sequba

@sequba sequba commented Feb 16, 2023 •

Copy link
Copy Markdown
Contributor

How did you test your changes?

  • unit tests pass
  • new unit test that demonstrates this issue

Types of changes

  • Breaking change (a fix or a feature because of which an existing functionality doesn't work as expected anymore)
  • New feature or improvement (a non-breaking change that adds functionality)
  • Bug fix (a non-breaking change that fixes an issue)
  • Additional language file, or a change to an existing language file (translations)
  • Change to the documentation

Related issues:

Fixes #1121

Checklist:

  • My change is compliant with the OpenDocument standard.
  • My change is compatible with Microsoft Excel.
  • My change is compatible with Google Sheets.
  • My code follows the code style of this project.
  • I described my changes in the CHANGELOG.md file.
  • My changes require a documentation update.
  • My changes require a migration guide.

@github-actions

github-actions Bot commented Feb 16, 2023 •

Copy link
Copy Markdown

Performance comparison of head (0499db9) vs base (8e0c945)

                                     testName |  base |  head |  change
-----------------------------------------------------------------------
                                      Sheet A | 500.8 | 500.4 |  -0.08%
                                      Sheet B | 208.6 |   213 |  +2.11%
                                      Sheet T | 250.8 | 269.1 |  +7.30%
                                Column ranges | 554.6 | 592.1 |  +6.76%
Sheet A:  change value, add/remove row/column |    40 |    35 | -12.50%
 Sheet B: change value, add/remove row/column |   336 |   298 | -11.31%
                   Column ranges - add column |   199 |   227 | +14.07%
                Column ranges - without batch |   606 |   532 | -12.21%
                        Column ranges - batch |   121 |   149 | +23.14%

@sequba sequba self-assigned this Feb 16, 2023
@sequba sequba linked an issue Feb 16, 2023 that may be closed by this pull request
Comment on lines -310 to -315
this.stats.measure(StatType.ADJUSTING_ARRAY_MAPPING, () => {
for (const array of arrays.values()) {
this.arrayMapping.removeArray(array.getRange())
}
})

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.

This code is no longer necessary because clearSheet also removes array vertices.

@adamu-handsontable adamu-handsontable 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.

There are small potential improvements that we could discuss.

Comment thread src/DependencyGraph/DependencyGraph.ts Resolved
expect(Array.from(engine.addressMapping.entries())).toEqual([])
})

it('should remove a sheet with a cell reference to a value in the same sheet', () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think it could be a good idea to check if by removing one sheet, we're not affecting values in another sheet which is referenced. This does not have to be a scope of this PR, but maybe it's worth checking if it makes sense:

  it('should not remove data from cell referenced in another sheet', () => {
    const engine = HyperFormula.buildFromSheets({
      Sheet1: [
        ['=Sheet2!A1)'],
      ],
      Sheet2: [
        ['1'],
      ],
    })

    engine.removeSheet(0)

    expect(Array.from(engine.sheetMapping.displayNames())).toEqual(['Sheet2'])
    expect(engine.getCellValue(adr('A1', 1))).toBe(1)
  })

  it('should not remove data from cell range referenced in another sheet', () => {
    const engine = HyperFormula.buildFromSheets({
      Sheet1: [
        ['=SUM(Sheet2!A1:A2)'],
      ],
      Sheet2: [
        ['1'],
        ['5'],
      ],
    })

    engine.removeSheet(0)

    expect(Array.from(engine.sheetMapping.displayNames())).toEqual(['Sheet2'])
    expect(engine.getCellValue(adr('A1', 1))).toBe(1)
    expect(engine.getCellValue(adr('A2', 1))).toBe(5)
  })

Let me know what you think.

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.

Sure, these test cases are absolutely valid. I added an it that covers both of them

@codecov

codecov Bot commented Feb 28, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1160 (0499db9) into develop (8e0c945) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1160      +/-   ##
===========================================
- Coverage    95.84%   95.84%   -0.01%     
===========================================
  Files          165      165              
  Lines        14144    14135       -9     
  Branches      3007     3004       -3     
===========================================
- Hits         13556    13547       -9     
  Misses         588      588              
Impacted Files Coverage Δ
src/DependencyGraph/DependencyGraph.ts 97.91% <100.00%> (-0.03%) ⬇️

@adamu-handsontable adamu-handsontable 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.

Everything is good. Thank you

@sequba
sequba merged commit 558442c into develop Mar 1, 2023
@sequba
sequba deleted the feature/issue-1121 branch March 1, 2023 08:00
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.

Removing Sheet Errors With Vertex for address missing in AddressMapping

2 participants