You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be nice if Dask Array's diag supported the k value to allow selection of the diagonal as NumPy's implementation does. It seems like Dask Array's API docs suggest diag does support k, but the code does not allow for this option.
It might make sense to rewrite diag to use diagonal after PR ( #4431 ) is accepted. This would be a way to solve this problem and cutdown on code as well.
It's worth pointing out this feature is broken in both directions. You also can't make a dask 2-D array from a vector on k!=0 diagonal. Support for da.diagonal doesn't help at all in this case as da.diagonal only extracts diagonals from 2-D arrays. Here's a use case to reproduce the problem:
import dask.array as da v = da.random.uniform(size=100,chunks=50) A = da.diag(v,k=1)
which yields the following error:
TypeError: diag() got an unexpected keyword argument 'k'
I am working on a pull request on this using #4431 for the diagonal extraction case. WIP though, as I was surprised by the $(n+k)*(n+k)$ output of np.diag(np.ones(n), k).
I also want to have a look into cleaning up the shared but different code in da.triu, da.tril and da.diag.
Activity
jakirkham commentedon Feb 9, 2019
It might make sense to rewrite
diagto usediagonalafter PR ( #4431 ) is accepted. This would be a way to solve this problem and cutdown on code as well.lightsighter commentedon Mar 9, 2019
It's worth pointing out this feature is broken in both directions. You also can't make a dask 2-D array from a vector on k!=0 diagonal. Support for da.diagonal doesn't help at all in this case as da.diagonal only extracts diagonals from 2-D arrays. Here's a use case to reproduce the problem:
import dask.array as dav = da.random.uniform(size=100,chunks=50)A = da.diag(v,k=1)which yields the following error:
TypeError: diag() got an unexpected keyword argument 'k'At a minimum the documentation should be updated to reflect that you don't support the 'k' keyword argument. Currently the documentation says that it is supported.
http://docs.dask.org/en/latest/array-api.html#dask.array.diag
mrocklin commentedon Mar 9, 2019
TAdeJong commentedon May 20, 2019
I am working on a pull request on this using #4431 for the diagonal extraction case. WIP though, as I was surprised by the$(n+k)*(n+k)$ output of
np.diag(np.ones(n), k).I also want to have a look into cleaning up the shared but different code in
da.triu,da.trilandda.diag.jakirkham commentedon May 20, 2019
Cool, thanks for working on this. Please let us know if you need pointers or would like someone to take a look.