-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify show implementation #31
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #31 +/- ##
==========================================
- Coverage 72.46% 71.36% -1.11%
==========================================
Files 7 7
Lines 454 433 -21
==========================================
- Hits 329 309 -20
+ Misses 125 124 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Does this work for higher dimensional arrays as well? |
Yes, they recursively make views that they call julia> A = SparseArraysBase.sprand(Float64, (3,3,3), 0.2)
3×3×3 SparseArrayDOK{Float64, 3, typeof(SparseArraysBase.default_getunstoredindex)}:
[:, :, 1] =
⋅ 0.884028 ⋅
⋅ ⋅ ⋅
⋅ ⋅ ⋅
[:, :, 2] =
⋅ ⋅ ⋅
⋅ ⋅ ⋅
⋅ 0.859288 ⋅
[:, :, 3] =
⋅ 0.716633 0.826796
⋅ ⋅ ⋅
⋅ ⋅ ⋅ |
Great, I think I tried to dig into |
Honestly, I still think we should use the |
I like the idea of switching over to just listing the stored values after a certain size (say once Julia would start to not show all of the values anyway). |
This breaks a downstream BlockSparseArrays test, I didn't realize that the structure was being explicitly used there. Let me fix that first |
Oh yeah, thanks. |
I bumped to v0.3.0, but since #33 is also breaking, we might want to bundle these together |
Can be merged after #33 |
This PR simplifies a bit of the code used for defining show by leveraging the built-in Base functionality of replacing values for printing.
This shouldn't change the functionality, although it does change a bit of the exact alignment properties.
In particular, here, the zero-value print is used to determine things like alignment, and only afterwards is this replaced with a centered dot, while I think the previous implementation first replaced the entries with dots, and only then computed alignments.