Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible shape for array on vector function #4580

Open
2 tasks done
TomMaullin opened this issue Sep 17, 2019 · 1 comment
Open
2 tasks done

Incompatible shape for array on vector function #4580

TomMaullin opened this issue Sep 17, 2019 · 1 comment
Labels
bug - failure to compile Bugs: failed to compile valid code

Comments

@TomMaullin
Copy link

TomMaullin commented Sep 17, 2019

Reporting a bug

Bug

I have the following helper function to vectorize a 2D matrix. If I run it without numba it works well.

def mat2vec(matrix):
  
  #Return vectorised matrix
  return(matrix.transpose().reshape(matrix.shape[0]*matrix.shape[1],1))

# Example:
matrix = np.random.randn(3,3)
print(matrix)
print(mat2vec(matrix))

If I run it with @numba.jit(nopython=True) prepended to the function I get:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-46-bce81c0a0a5c> in <module>()
      8 matrix = np.random.randn(3,3)
      9 print(matrix)
---> 10 print(mat2vec(matrix))

NotImplementedError: incompatible shape for array

Apologies if this is documented behaviour/a non-issue and I have misunderstood but I cannot work out why this happens.

@sklam sklam added the bug label Sep 17, 2019
@sklam
Copy link
Member

sklam commented Sep 17, 2019

Confirmed bug. The reshape on the original non-transposed matrix works fine. Seems to be a logic error when the layout is changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - failure to compile Bugs: failed to compile valid code
Projects
None yet
Development

No branches or pull requests

3 participants