OtagoHarbour
OtagoHarbour

Reputation: 4183

scipy.convolve gives "ValueError: object too deep for desired array" with 3D array and 3D kernel

I am using Python 3 on Anacona Spyder on CentOS 7.

The following call

scipy.convolve(nda, box)

gives the following error message.

ValueError: object too deep for desired array

nda and box have the same type and dimensions.

np.shape(nda)
Out[51]: (70, 70, 70)

np.shape(box)
Out[52]: (3, 3, 3)

type(nda)
Out[53]: numpy.ndarray

type(box)
Out[54]: numpy.ndarray

It is my understanding that scipy.convolve can handles multidimensional objects. I cannot understand this error message.

Upvotes: 0

Views: 1661

Answers (1)

Warren Weckesser
Warren Weckesser

Reputation: 114781

The name scipy.convolve is an alias for numpy.convolve, and the NumPy version accepts only one-dimensional input. (This potential confusion is one of the reasons SciPy is deprecating the use of the NumPy names in the scipy namespace.)

You probably want scipy.ndimage.convolve or scipy.signal.convolve. (Why SciPy has independent implementations of convolve in two subpackages is a whole 'nother topic.)

Upvotes: 2

Related Questions