Skip to content

Commit

Permalink
Recognize no-op in reshape
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Feb 16, 2014
1 parent 98c59ef commit a039598
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pyopencl/array.py
Expand Up @@ -1173,6 +1173,10 @@ def reshape(self, *shape, **kwargs):
# TODO: add more error-checking, perhaps
if isinstance(shape[0], tuple) or isinstance(shape[0], list):
shape = tuple(shape[0])

if shape == self.shape:
return self

size = reduce(lambda x, y: x * y, shape, 1)
if size != self.size:
raise ValueError("total size of new array must be unchanged")
Expand Down

0 comments on commit a039598

Please sign in to comment.