Zeros and OneElement addition/subtraction
This pull request alters some behaviour of addition/subtraction of the Zeros and OneElement types. It ensures that the sparsity of any array structure that undergoes addition or subtraction with one of these types preserves its sparsity by avoiding the materialisation of dense arrays where possible:
-Adding or subtracting a Zeros and any array v now preserves the type of v (while still obeying type promotion rules)
-Adding or subtracting a OneElement to any array v is now O(1) and preserves the type of v unless the underlying setindex! operation is invalid (e.g adding a OneElement with a nondiagonal entry to a Diagonal), in which case a dense array is materialised
-Adding or subtracting two OneElements now returns a OneElement if their indices are the same. Otherwise it materialises a dense vector. If SparseArrays is imported, it instead creates a SparseArray.
Changes have been covered with unit tests
Codecov Report
:x: Patch coverage is 62.85714% with 26 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 97.71%. Comparing base (0a58cd8) to head (33466e1).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/oneelement.jl | 48.83% | 22 Missing :warning: |
| ext/FillArraysSparseArraysExt.jl | 33.33% | 4 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #422 +/- ##
===========================================
+ Coverage 0.00% 97.71% +97.71%
===========================================
Files 8 9 +1
Lines 1152 1224 +72
===========================================
+ Hits 0 1196 +1196
+ Misses 1152 28 -1124
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Main suggestions:
- [ ] split off StaticArrays.jl extension into separate PR
- [ ] make SparseArrays.jl a hard dependency (others may have opinions about this...)
- [ ] make sure 100% of the diff is covered