Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8646181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:44:14+00:00 2026-06-12T12:44:14+00:00

I’m trying to get started with scipy and can’t seem to get the example

  • 0

I’m trying to get started with scipy and can’t seem to get the example from interpolation.interp1d to work when using a kind other than ‘linear’ (I tried ‘zero’ and ‘cubic’).

I couldn’t find someone having the same problem while searching in Google, so I guess it’s something stupid on my part.

I use scipy 0.11 on python 2.73 with OSX 10.8

The code not working:

from scipy import interpolate
import numpy as np

x = np.arange(0, 10)
y = np.exp(-x/3.0)
f = interpolate.interp1d(x, y, kind="zero")
xnew = np.arange(0,9, 0.1)
ynew = f(xnew)   # use interpolation function returned by `interp1d`
plt.plot(x, y, 'o', xnew, ynew, '-')
plt.show()

IndexError                                Traceback (most recent call last)
<ipython-input-1-23bb96a1589b> in <module>()
  4 f = interpolate.interp1d(x, y, kind="zero")
  5 xnew = np.arange(0,9, 0.1)
----> 6 ynew = f(xnew)   # use interpolation function returned by `interp1d`
  7 plt.plot(x, y, 'o', xnew, ynew, '-')
  8 plt.show()

/usr/local/lib/python2.7/site-packages/scipy/interpolate/interpolate.pyc in __call__(self, x_new)
394         out_of_bounds = self._check_bounds(x_new)
395 
--> 396         y_new = self._call(x_new)
397 
398         # Rotate the values of y_new back so that they correspond to the

/usr/local/lib/python2.7/site-packages/scipy/interpolate/interpolate.pyc in _call_spline(self, x_new)
370     def _call_spline(self, x_new):
371         x_new =np.asarray(x_new)
--> 372         result = spleval(self._spline,x_new.ravel())
373         return result.reshape(x_new.shape+result.shape[1:])
374 

/usr/local/lib/python2.7/site-packages/scipy/interpolate/interpolate.pyc in spleval((xj, cvals, k), xnew, deriv)
833             res[sl].imag = _fitpack._bspleval(xx,xj,cvals.imag[sl],k,deriv)
834         else:
--> 835             res[sl] = _fitpack._bspleval(xx,xj,cvals[sl],k,deriv)
836     res.shape = oldshape + sh
837     return res

IndexError: too many indices

When starting the debug console here i can narrow it down to cvals[sl] causing the error with

sl = (slice(None, None, None), 0) # <-- I don't really get the slice part here...
cvals = array([ 1.        ,  0.71653131,  0.51341712,  0.36787944,  0.26359714,
    0.1888756 ,  0.13533528,  0.09697197,  0.06948345])

Can someone reproduce this or is something wrong on my machine?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:44:16+00:00Added an answer on June 12, 2026 at 12:44 pm

    It seems, that while following along an installation instruction for scipy on OSX I installed a non-release version of numpy without realizing it.

    Reinstalling numpy, scipy and matplotlib with pip solved the problem.

    Many thanks to unutbu for pointing out a the source of the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.