Ticket #610 (closed enhancement: fixed)

Opened 3 years ago

Last modified 2 years ago

Let numpy.interp accept scalar values as first argument

Reported by: Elby Owned by: somebody
Priority: normal Milestone: 1.1.0
Component: numpy.lib Version: none
Keywords: Cc:

Description

The current version of numpy.interp does not accept a single value as first argument, so it is not possible to make a single interpolation :

>>> import numpy as n
>>> n.__version__
'1.0.5.dev4420'
>>> xp = n.arange(10)
>>> yp = 2.5 + xp**2 -xp
>>> x = 3.2
>>> n.interp(x, xp, yp)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: object of too small depth for desired array

It would be a lot more nice to let x be a float, an int or another numpy scalar object, as the attached patch does.

Attachments

numpy.interp.patch (2.2 KB) - added by Elby 3 years ago.

Change History

Changed 3 years ago by Elby

Changed 2 years ago by oliphant

  • status changed from new to closed
  • resolution set to fixed

Fixed in r4942.

Note: See TracTickets for help on using tickets.