Skip to content

Commit

Permalink
Merge 12af4b6 into 1d072d0
Browse files Browse the repository at this point in the history
  • Loading branch information
kmaehashi committed Mar 16, 2018
2 parents 1d072d0 + 12af4b6 commit dfe1f74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cupy/creation/matrix.py
Expand Up @@ -48,7 +48,7 @@ def diagflat(v, k=0):
if isinstance(v, cupy.ndarray):
return cupy.diag(v.ravel(), k)
else:
return cupy.diag(numpy.ndarray(v).ravel(), k)
return cupy.diag(numpy.asarray(v).ravel(), k)


# TODO(okuta): Implement tri
Expand Down
10 changes: 10 additions & 0 deletions tests/cupy_tests/creation_tests/test_matrix.py
@@ -1,5 +1,7 @@
import unittest

import numpy

from cupy import testing


Expand Down Expand Up @@ -37,3 +39,11 @@ def test_diagflat2(self, xp):
def test_diagflat3(self, xp):
a = testing.shaped_arange((3, 3), xp)
return xp.diagflat(a, -2)

@testing.numpy_cupy_array_equal()
def test_diagflat_from_numpy(self, xp):
return xp.diagflat(numpy.ones((3, 3)))

@testing.numpy_cupy_array_equal()
def test_diagflat_from_range(self, xp):
return xp.diagflat(range(10))

0 comments on commit dfe1f74

Please sign in to comment.