[SciPy-Dev] maybe a bug into scipy.interpolate.Rbf?

Scott Sinclair scott.sinclair.za at gmail.com
Tue May 17 10:19:45 EDT 2011


On 17 May 2011 17:12, Luca Penasa <luca.penasa at gmail.com> wrote:
> I see the Rbf class permits to use a callable function as radial basis
> function, but gives me an error, see below:
>
>
> My self defined rbf:
>
> def ElasticDeformationRBF(this, r):
>        ratio = ((r**2) / this.epsilon)
>        out = ratio * np.log(ratio) + 1 - ratio
>        return out
>
> interpolator = scipy.interpolate.Rbf(somex, somey,
> function=ElasticDeformationRBF)
>
> The error is:
>
>  /usr/lib64/python2.6/site-packages/scipy/interpolate/rbf.pyc in
> __init__(self, *args, **kwargs)
>    195             setattr(self, item, value)
>    196
> --> 197         self.A = self._init_function(r) -
> eye(self.N)*self.smooth
>    198         self.nodes = linalg.solve(self.A, self.di)
>    199
>
> /usr/lib64/python2.6/site-packages/scipy/interpolate/rbf.pyc in
> _init_function(self, r)
>    159                 self._function = self.function
>    160             elif argcount == 2:
> --> 161                 if sys.version_info[0] >= 3:
>    162                     self._function = function.__get__(self, Rbf)
>    163                 else:
>
> NameError: global name 'sys' is not defined

Looks like a bug accidentally introduced here
https://github.com/scipy/scipy/commit/4e8e22983786de5150a510af6d2e12c8081898db.
You can work around the bug by adding an 'import sys' to your
/usr/lib64/python2.6/site-packages/scipy/interpolate/rbf.py

There's a pull request with a fix here https://github.com/scipy/scipy/pull/22

Cheers,
Scott



More information about the SciPy-Dev mailing list