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

_read32 TypeError: only integer scalar arrays can be converted to a scalar index #9549

Closed
ghost opened this issue Aug 12, 2017 · 4 comments
Closed

Comments

@ghost
Copy link

ghost commented Aug 12, 2017

This seems to be a bug.

For me, array concatenation is not working as expected. Doing a little searching, I found these:

llSourcell/tensorflow_demo#4

https://stackoverflow.com/questions/42128830/typeerror-only-integer-scalar-arrays-can-be-converted-to-a-scalar-index

https://github.com/Paradigm4/SciDB-Py/issues/96

@njsmith
Copy link
Member

njsmith commented Aug 12, 2017

Those links show projects adapting to an intentional change of behavior that happened back in numpy 1.12, after a deprecation period. As far as I can tell, though, none of them have anything to do with array concatenation.

Can you give an example of what you're doing and what you're getting and what you were expecting instead?

@ghost
Copy link
Author

ghost commented Aug 13, 2017

Sure. This is the whole script:

import numpy as np
import scipy.io.wavfile as wf
(fs, x) = wf.read('wave.wav')
zrs = np.zeros(int(x.size / 2))
x = np.concatenate(x, zrs)

Thank you very much for the help!

@njsmith
Copy link
Member

njsmith commented Aug 13, 2017

Concatenate's signature is

def concatenate(arrays, axis=0):

i.e. it takes a single positional argument which is an iterable of arrays to be concatenated. So you want np.concatenate((x, zrs)). Right now you're ending up saying np.concatenate(x, axis=zrs), and then numpy is getting confused when it tries to convert the zrs array into an axis index.

@njsmith njsmith closed this as completed Aug 13, 2017
@ghost
Copy link
Author

ghost commented Aug 13, 2017

Hi Nathaniel,

Thank you for that. Sorry to waste your time on a silly syntax mistake. You are very kind to have answered. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant