willow-ahrens / Finch.jl

Sparse tensors in Julia and more! Datastructure-driven array programing language.
http://willowahrens.io/Finch.jl/
MIT License
158 stars 15 forks source link

API: Add list indexing for 1D Tensors #429

Closed mtsokol closed 6 months ago

mtsokol commented 6 months ago

Addressing #427

Hi @willow-ahrens,

This PR adds specialized getindex and to_indices for Tensor and SwizzleArray, to enable list indexing for 1D objects. There's no need to check whether Tensor/SwizzleArray is 1D here, because indexing +2D Tensor with a list/vector results in AssertionError: ndims(arr) == length(inds).

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (25afb3f) 75.84% compared to head (2d2e61b) 75.88%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #429 +/- ## ========================================== + Coverage 75.84% 75.88% +0.03% ========================================== Files 87 87 Lines 7710 7712 +2 ========================================== + Hits 5848 5852 +4 + Misses 1862 1860 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

willow-ahrens commented 6 months ago

LGTM! @mtsokol I'll push a release too