Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chaquopy with Scipy.Griddata bugs

See original GitHub issue


So i tried to use Scipy Griddata function in a small app with the following code. import numpy as np from scipy.interpolate import griddata

    X = np.array([.......])
    Y = np.array([.......])
    Z = np.array([.......])
    D = np.array([.......])
    points = np.array((X.flatten(), Y.flatten(), Z.flatten())).T
    values = D.flatten()
    D0 =  griddata(points, values, (X0,Y0,Z0))`

I inserted this code inside the Chaquopy Demo app, in exactly. Inside “def onCreate(self, state):” function.

The app takes about 5 mins to open the screen, sometimes never. Ofc the app works perfectly without this chunk of code.

Is there a way i could use to speedup the code. It’s really a small code and i intend to develop a small app that interpolate a small set of data thanks to Python Numpy and Scipy capabilities. No plotting, just that specific small of code that returns a float value.

Just for info this is what i intend to achieve: I have a set of data for example: X Y Z 1 3 7 2 5 8 1 4 9 3 6 10 I would like to interpolate Z for X=2.5 and Y=3.5.

I can use interp2.griddata from Scipy in Python or ScatteredInterpolant in Matlab like this:

z = griddata( [1 2 1 3], [3 5 4 6], [7 8 9 10], 2.5, 3.5, 'nearest' ) or

S = scatteredInterpolant(x,y,z,d); Is there a way i could use something similar in Swift/Objective-c or any other compatible language to develop a small app for iOS (as well as for Android if possible) where i insert scattered data and when the user enter a value for a given X and Y he gets an interpolated value for Z (i intend to use this with 4D dimension).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

mhsmithcommented, Dec 3, 2018

I can confirm that griddata hangs forever on a physical device even for simple examples, and crashes on the emulator.

Your simple X=2.5 and Y=3.5 example would never actually work with griddata because those coordinates are outside the convex hull of the dataset. In this case Rbf might be more appropriate, but unfortunately that crashes or hangs in the same way.

We’ll try updating SciPy and NumPy to the newest versions as soon as possible. Meanwhile, if your data is 2-dimensional, interp2d does work, though it may give extreme results for coordinates which are far away from the dataset.

KacemRostomcommented, Dec 22, 2018

It worked! Very much appreciated sir!

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Scipy griddata doesn't work inside a loop / memory leak
It's a bug in Cython, should be worked around in Scipy's final 0.12.0 release.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found