numba for scipy, specifically cdist Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!What is the most efficient way to compute the square euclidean distance between N samples and clusters centroids?Installing SciPy with pipRelationship between SciPy and NumPyDoes Python SciPy need BLAS?Pairwise cdist in scipy instead of zipUse numba on classes?Is scipy cdist() efficient?python numba fingerprint errorSparse Matrix-Matrix Multiplication Using SciPy and NumbaNumba giving error for NumPyPrime number factorization with numba

Table formatting with tabularx?

How to make triangles with rounded sides and corners? (squircle with 3 sides)

Why not use the yoke to control yaw, as well as pitch and roll?

Does the Rock Gnome trait Artificer's Lore apply when you aren't proficient in History?

Why complex landing gears are used instead of simple, reliable and light weight muscle wire or shape memory alloys?

The Nth Gryphon Number

How do I say "this must not happen"?

Keep at all times, the minus sign above aligned with minus sign below

malloc in main() or malloc in another function: allocating memory for a struct and its members

What is "Lambda" in Heston's original paper on stochastic volatility models?

Plotting a Maclaurin series

Is a copyright notice with a non-existent name be invalid?

Is the time—manner—place ordering of adverbials an oversimplification?

First paper to introduce the "principal-agent problem"

"Destructive power" carried by a B-52?

How to name indistinguishable henchmen in a screenplay?

Are there any irrational/transcendental numbers for which the distribution of decimal digits is not uniform?

What was the last profitable war?

Pointing to problems without suggesting solutions

How to infer difference of population proportion between two groups when proportion is small?

French equivalents of おしゃれは足元から (Every good outfit starts with the shoes)

What is a more techy Technical Writer job title that isn't cutesy or confusing?

Was the pager message from Nick Fury to Captain Marvel unnecessary?

What did Turing mean when saying that "machines cannot give rise to surprises" is due to a fallacy?



numba for scipy, specifically cdist



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!What is the most efficient way to compute the square euclidean distance between N samples and clusters centroids?Installing SciPy with pipRelationship between SciPy and NumPyDoes Python SciPy need BLAS?Pairwise cdist in scipy instead of zipUse numba on classes?Is scipy cdist() efficient?python numba fingerprint errorSparse Matrix-Matrix Multiplication Using SciPy and NumbaNumba giving error for NumPyPrime number factorization with numba



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm trying to speed up a comparison between two pointclouds, I have some code which took up to an hour to complete. I've butchered it to this and tried to implement numba. The code works with the exception of the scipy cdist function. It's my first test of using numba, where am I going wrong?



from numba import jit

@jit(nopython=True)
def near_dist_top(T, B):
xi = [i[0] for i in T]
yi = [i[1] for i in T]
zi = [i[2] for i in T]
XB = B

insert_params = []

for i in range(len(T)):
XA = [T[i]]
disti = cdist(XA, XB, metric='euclidean').min()
insert_params.append((xi[i], yi[i], zi[i], disti))
# print("Top: " + str(i) + " of " + str(len(T)))
print(i)
return insert_params
print(XB)


@@@ Edits @@@



Both T and B are lists of coordinates



(580992.507, 4275268.8321, 192.4599), (580992.507, 4275268.8391, 192.4209), (580992.507, 4275268.8391, 192.4209)


hmmm, does numba handle lists, does it need to be a numpy array, would cdist handle a numpy array...?



The error



numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'cdist': cannot determine Numba type of <class 'function'>

File "scratch_28.py", line 132:
def near_dist_top(T, B):
<source elided>
XA = [T[i]]
disti = cdist(XA, XB, metric='euclidean').min()
^









share|improve this question
























  • Can you please post the stack trace ? Also, what does the argument T and B contain ?

    – Gambit
    Mar 9 at 5:25











  • What sor t of error? LIke something about not being able to implement cdist? How, by the way, are you importing or defining cdist? It's not 'native' numpy.

    – hpaulj
    Mar 9 at 7:03











  • ok, I've updated the question

    – Gary Nobles
    Mar 9 at 8:54











  • cdist is brought in using from scipy.spatial.distance import cdist

    – Gary Nobles
    Mar 9 at 8:55











  • Is cdist in the list of of functions that can be handled with 'nopython'?

    – hpaulj
    Mar 9 at 15:20

















0















I'm trying to speed up a comparison between two pointclouds, I have some code which took up to an hour to complete. I've butchered it to this and tried to implement numba. The code works with the exception of the scipy cdist function. It's my first test of using numba, where am I going wrong?



from numba import jit

@jit(nopython=True)
def near_dist_top(T, B):
xi = [i[0] for i in T]
yi = [i[1] for i in T]
zi = [i[2] for i in T]
XB = B

insert_params = []

for i in range(len(T)):
XA = [T[i]]
disti = cdist(XA, XB, metric='euclidean').min()
insert_params.append((xi[i], yi[i], zi[i], disti))
# print("Top: " + str(i) + " of " + str(len(T)))
print(i)
return insert_params
print(XB)


@@@ Edits @@@



Both T and B are lists of coordinates



(580992.507, 4275268.8321, 192.4599), (580992.507, 4275268.8391, 192.4209), (580992.507, 4275268.8391, 192.4209)


hmmm, does numba handle lists, does it need to be a numpy array, would cdist handle a numpy array...?



The error



numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'cdist': cannot determine Numba type of <class 'function'>

File "scratch_28.py", line 132:
def near_dist_top(T, B):
<source elided>
XA = [T[i]]
disti = cdist(XA, XB, metric='euclidean').min()
^









share|improve this question
























  • Can you please post the stack trace ? Also, what does the argument T and B contain ?

    – Gambit
    Mar 9 at 5:25











  • What sor t of error? LIke something about not being able to implement cdist? How, by the way, are you importing or defining cdist? It's not 'native' numpy.

    – hpaulj
    Mar 9 at 7:03











  • ok, I've updated the question

    – Gary Nobles
    Mar 9 at 8:54











  • cdist is brought in using from scipy.spatial.distance import cdist

    – Gary Nobles
    Mar 9 at 8:55











  • Is cdist in the list of of functions that can be handled with 'nopython'?

    – hpaulj
    Mar 9 at 15:20













0












0








0








I'm trying to speed up a comparison between two pointclouds, I have some code which took up to an hour to complete. I've butchered it to this and tried to implement numba. The code works with the exception of the scipy cdist function. It's my first test of using numba, where am I going wrong?



from numba import jit

@jit(nopython=True)
def near_dist_top(T, B):
xi = [i[0] for i in T]
yi = [i[1] for i in T]
zi = [i[2] for i in T]
XB = B

insert_params = []

for i in range(len(T)):
XA = [T[i]]
disti = cdist(XA, XB, metric='euclidean').min()
insert_params.append((xi[i], yi[i], zi[i], disti))
# print("Top: " + str(i) + " of " + str(len(T)))
print(i)
return insert_params
print(XB)


@@@ Edits @@@



Both T and B are lists of coordinates



(580992.507, 4275268.8321, 192.4599), (580992.507, 4275268.8391, 192.4209), (580992.507, 4275268.8391, 192.4209)


hmmm, does numba handle lists, does it need to be a numpy array, would cdist handle a numpy array...?



The error



numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'cdist': cannot determine Numba type of <class 'function'>

File "scratch_28.py", line 132:
def near_dist_top(T, B):
<source elided>
XA = [T[i]]
disti = cdist(XA, XB, metric='euclidean').min()
^









share|improve this question
















I'm trying to speed up a comparison between two pointclouds, I have some code which took up to an hour to complete. I've butchered it to this and tried to implement numba. The code works with the exception of the scipy cdist function. It's my first test of using numba, where am I going wrong?



from numba import jit

@jit(nopython=True)
def near_dist_top(T, B):
xi = [i[0] for i in T]
yi = [i[1] for i in T]
zi = [i[2] for i in T]
XB = B

insert_params = []

for i in range(len(T)):
XA = [T[i]]
disti = cdist(XA, XB, metric='euclidean').min()
insert_params.append((xi[i], yi[i], zi[i], disti))
# print("Top: " + str(i) + " of " + str(len(T)))
print(i)
return insert_params
print(XB)


@@@ Edits @@@



Both T and B are lists of coordinates



(580992.507, 4275268.8321, 192.4599), (580992.507, 4275268.8391, 192.4209), (580992.507, 4275268.8391, 192.4209)


hmmm, does numba handle lists, does it need to be a numpy array, would cdist handle a numpy array...?



The error



numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'cdist': cannot determine Numba type of <class 'function'>

File "scratch_28.py", line 132:
def near_dist_top(T, B):
<source elided>
XA = [T[i]]
disti = cdist(XA, XB, metric='euclidean').min()
^






python-3.x scipy numba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 8:54







Gary Nobles

















asked Mar 9 at 0:49









Gary NoblesGary Nobles

394317




394317












  • Can you please post the stack trace ? Also, what does the argument T and B contain ?

    – Gambit
    Mar 9 at 5:25











  • What sor t of error? LIke something about not being able to implement cdist? How, by the way, are you importing or defining cdist? It's not 'native' numpy.

    – hpaulj
    Mar 9 at 7:03











  • ok, I've updated the question

    – Gary Nobles
    Mar 9 at 8:54











  • cdist is brought in using from scipy.spatial.distance import cdist

    – Gary Nobles
    Mar 9 at 8:55











  • Is cdist in the list of of functions that can be handled with 'nopython'?

    – hpaulj
    Mar 9 at 15:20

















  • Can you please post the stack trace ? Also, what does the argument T and B contain ?

    – Gambit
    Mar 9 at 5:25











  • What sor t of error? LIke something about not being able to implement cdist? How, by the way, are you importing or defining cdist? It's not 'native' numpy.

    – hpaulj
    Mar 9 at 7:03











  • ok, I've updated the question

    – Gary Nobles
    Mar 9 at 8:54











  • cdist is brought in using from scipy.spatial.distance import cdist

    – Gary Nobles
    Mar 9 at 8:55











  • Is cdist in the list of of functions that can be handled with 'nopython'?

    – hpaulj
    Mar 9 at 15:20
















Can you please post the stack trace ? Also, what does the argument T and B contain ?

– Gambit
Mar 9 at 5:25





Can you please post the stack trace ? Also, what does the argument T and B contain ?

– Gambit
Mar 9 at 5:25













What sor t of error? LIke something about not being able to implement cdist? How, by the way, are you importing or defining cdist? It's not 'native' numpy.

– hpaulj
Mar 9 at 7:03





What sor t of error? LIke something about not being able to implement cdist? How, by the way, are you importing or defining cdist? It's not 'native' numpy.

– hpaulj
Mar 9 at 7:03













ok, I've updated the question

– Gary Nobles
Mar 9 at 8:54





ok, I've updated the question

– Gary Nobles
Mar 9 at 8:54













cdist is brought in using from scipy.spatial.distance import cdist

– Gary Nobles
Mar 9 at 8:55





cdist is brought in using from scipy.spatial.distance import cdist

– Gary Nobles
Mar 9 at 8:55













Is cdist in the list of of functions that can be handled with 'nopython'?

– hpaulj
Mar 9 at 15:20





Is cdist in the list of of functions that can be handled with 'nopython'?

– hpaulj
Mar 9 at 15:20












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072904%2fnumba-for-scipy-specifically-cdist%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072904%2fnumba-for-scipy-specifically-cdist%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко