-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve conversion to sparse arrays (#289)
* sparse conversion * map sparse over components * move tests up * Move to package extension and extend issparse * formatting * use createinstance --------- Co-authored-by: Jishnu Bhattacharya <jishnub.github@gmail.com>
- Loading branch information
Showing
4 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module StructArraysSparseArraysExt | ||
|
||
using StructArrays: StructArray, components, createinstance | ||
import SparseArrays: sparse, issparse | ||
|
||
function sparse(S::StructArray{T}) where {T} | ||
sparse_components = map(sparse, components(S)) | ||
return createinstance.(T, sparse_components...) | ||
end | ||
|
||
issparse(S::StructArray) = all(issparse, components(S)) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters