Luxio

25 Reputation

One Badge

3 years, 110 days

MaplePrimes Activity


These are replies submitted by Luxio

@acer 

Ok thank you, the list thing works and I can always redefine the type of the output matrix directly in maple.

The thing with the expression was basically that my two lists contained x and y values to insert in the expression, like this:

lists: pointsx, pointsy

expression: f(x, y)

-----

import numpy as np
def polygon_extrema_finder(f, pointsx, pointsy):
    linx = np.array([np.linspace(pointsx[0], pointsx[-1], 1000)])
    for index in range(len(pointsx)-1):
        linx = np.append(linx, np.linspace(pointsx[index], pointsx[index+1], 1000))
    linx = np.reshape(linx, (len(pointsx), 1000))
    liny = np.array([np.linspace(pointsy[0], pointsy[-1], 1000)])
    for index in range(len(pointsy)-1):
        liny = np.append(liny, np.linspace(pointsy[index], pointsy[index+1], 1000))
    liny = np.reshape(liny, (len(pointsy), 1000))
    extrema = np.array([])
    for i in range(len(pointsx)):
        for j in range(1000-2):
            if (f(linx[i, j+1], liny[i, j+1])>f(linx[i, j], liny[i, j]) and f(linx[i, j+1], liny[i, j+1])>f(linx[i, j+2], liny[i, j+2]) or f(linx[i, j+1], liny[i, j+1])<f(linx[i, j], liny[i, j]) and f(linx[i, j+1], liny[i, j+1])<f(linx[i, j+2], liny[i, j+2])):
                extrema = np.append(extrema, [linx[i,j], liny[i,j]])
    extrema = np.reshape(extrema, (2, extrema.size/2))

-----

(the real code is longer, but the rest of the python procedures defined there are all somewhat similar to this one and use the expression in the same way)

So I basically need the expression to have a "values can be input" format in python. Maybe sympy has something that could convert cmdstr to a procedure, I'll look it up

In any case, thank you, this helped a lot

@Carl Love 

After checking out said page, I think the best way would be to use define function for the procedure inside Blue.py and use Set variable/Get variable for the input/output arrays. That leaves the equation, for which I still don't have a good conversion...
I'm also unsure if I can use python packages, like numpy, that way.

@tomleslie 

... I would do everything in python if I was allowed to, but the person who instructed me to write the program basically said it had to be done that way. I don't make the rules...

Page 1 of 1