pydata / sparse

Sparse multi-dimensional arrays for the PyData ecosystem
https://sparse.pydata.org
BSD 3-Clause "New" or "Revised" License
602 stars 126 forks source link

ENH: Implement `reshape` function #776

Closed mtsokol closed 2 months ago

mtsokol commented 2 months ago

Hi @hameerabbasi,

This PR adds Array API reshape function (without copy keyword for now).

Unfortunately calling sparse.reshape(...) gives a segmentation fault (on exit) - I haven't figured out it yet.

codspeed-hq[bot] commented 2 months ago

CodSpeed Performance Report

Merging #776 will improve performances by 19.89%

Comparing reshape-func (9325477) with main (373f29f)

Summary

⚡ 5 improvements ✅ 335 untouched benchmarks

Benchmarks breakdown

Benchmark main reshape-func Change
test_elemwise[f=<built-in function add>-backend='Finch'-side=100] 862.4 µs 719.4 µs +19.89%
test_elemwise[f=<built-in function add>-backend='Finch'-side=500] 1,027.2 µs 884.4 µs +16.15%
test_elemwise[f=<built-in function mul>-backend='Finch'-side=1000] 828 µs 735.2 µs +12.62%
test_elemwise[f=<built-in function mul>-backend='Finch'-side=100] 788.5 µs 694.8 µs +13.48%
test_elemwise[f=<built-in function mul>-backend='Finch'-side=500] 811.1 µs 711.2 µs +14.05%
mtsokol commented 2 months ago

@hameerabbasi The PR is ready from my side. For now reshape only works on CSF and CSR formats. For other ones it's broken (there are skips in the test with relevant links pointing to issues).