willow-ahrens / finch-tensor

Sparse Tensors in Python and more! Datastructure-Driven Array Programming Language
MIT License
8 stars 3 forks source link

Verify SciPy canonical input #43

Closed mtsokol closed 4 months ago

mtsokol commented 4 months ago

Hi @hameerabbasi,

When consuming SciPy sparse object, Finch expects it to be in a canonical format. When it's not true then array isn't loaded properly.

Here I verify that input is in canonical format and raise a proper warning.

willow-ahrens commented 4 months ago

does "canonical" mean "sorted"? just curious. thanks!

mtsokol commented 4 months ago

does "canonical" mean "sorted"? just curious. thanks!

Yes! finch-tensor requires it. I realized that creating SparseCOO with coords arrays that aren't sorted results in a broken Tensor (e.g. when densifying (copying to a dense Tensor) the resulting tensor is incorrect).

hameerabbasi commented 4 months ago

does "canonical" mean "sorted"? just curious. thanks!

Almost, sorted + no duplicate entries. 😄