Spaces within python function input arguments because it's a cython function?

90 Views Asked by At

I know nothing about cython, only python.

The function emd_c below (from the pot optimal transport package) has a header whose argument formats I've never seen before, or which I don't think would work under stand-alone python/numpy, but perhaps only if cython is loaded as well.

def emd_c(np.ndarray[double, ndim=1, mode="c"] a, np.ndarray[double, ndim=1, mode="c"] b, np.ndarray[double, ndim=2, mode="c"] M, int max_iter):

As you can see, there are spaces in the arguments themselves ([] a, [] b, [] M) which would normally be illegal.

I wanted to use this function stand-alone rather than installing the entire package it comes from:

Copying the function out of the package it came from, and pasting the function by itself in my own script, Spyder instantly gave me an invalid syntax error when I tried to run my script, even though I was only expecting errors having to do with missing dependencies. My questions here only have to do with trying to understand this strange-looking function.

  1. What explains the strange formatting for the input arguments in this function? Is it because it is not python-in-isolation compliant and requires cython additionally?
  2. How to make this sort of function run properly?
0

There are 0 best solutions below