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

Created on 12 Aug 2017  路  4Comments  路  Source: numpy/numpy

Most helpful comment

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.

All 4 comments

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?

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!

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.

Hi Nathaniel,

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

Was this page helpful?
0 / 5 - 0 ratings