Items tagged with python

how to use python to call maple and scroll up or down scrollbar

I was trying to call a C shared library which calls a Python function. I got the following error:

Error, external linking: error loading external library

/directory/of/my/library/libbe.so: libpython2.7.so.1.0: cannot open shared object

file: No such file or directory

 

Since I was running this using a pbs file, I made sure that I exported LD_LIBRARY_PATH (to libpython.so) inside the specific node. Does anyone have ideas on why this happens? Thank you!

how to translate python code which use scipy, numpy to maple code

 

 

import numpy as np
from scipy.sparse.linalg import svds
from functools import partial


def emsvd(Y, k=None, tol=1E-3, maxiter=None):
    """
    Approximate SVD on data with missing values via expectation-maximization

    Inputs:
    -----------
    Y:          (nobs, ndim) data matrix, missing values denoted by NaN/Inf
    k:          number of singular values/vectors to find (default: k=ndim)
    tol:        convergence tolerance on change in trace norm
    maxiter:    maximum number of EM steps to perform (default: no limit)

    Returns:
    -----------
    Y_hat:      (nobs, ndim) reconstructed data matrix
    mu_hat:     (ndim,) estimated column means for reconstructed data
    U, s, Vt:   singular values and vectors (see np.linalg.svd and 
                scipy.sparse.linalg.svds for details)
    """

    if k is None:
        svdmethod = partial(np.linalg.svd, full_matrices=False)
    else:
        svdmethod = partial(svds, k=k)
    if maxiter is None:
        maxiter = np.inf

    # initialize the missing values to their respective column means
    mu_hat = np.nanmean(Y, axis=0, keepdims=1)
    valid = np.isfinite(Y)
    Y_hat = np.where(valid, Y, mu_hat)

    halt = False
    ii = 1
    v_prev = 0

    while not halt:

        # SVD on filled-in data
        U, s, Vt = svdmethod(Y_hat - mu_hat)

        # impute missing values
        Y_hat[~valid] = (U.dot(np.diag(s)).dot(Vt) + mu_hat)[~valid]

        # update bias parameter
        mu_hat = Y_hat.mean(axis=0, keepdims=1)

        # test convergence using relative change in trace norm
        v = s.sum()
        if ii >= maxiter or ((v - v_prev) / v_prev) < tol:
            halt = True
        ii += 1
        v_prev = v

    return Y_hat, mu_hat, U, s, Vt

hi,

 

having some issue using the codegeneration function in maple. I have a script written in Maple that I would like to do in Python 2.7. I knew to maple and not sure if my syntax is incorrect or if the program doesnt support the conversion, as an example,

 

q[Fick] := proc (t) options operator, arrow; -hm0(t)*(ps(T[C5](t))-p[inf]) end proceq2 := m[C5](t)*Cp[C5l](T[C5](t))*(diff(T[C5](t), t)) = q[heat](t)

 

thanks

There seems to be a bug in the CodeGeneration package for Python which leads to a deletion of braces in some cases.

# E.g.

CodeGeneration[Python](Pi*(a+2));

# leads to

cg5 = math.pi * a + 2

which is obviously wrong.

I would like to know if it is possible in an external program (C or Python) to create a Maple function ( Not a one liner, maybe a number of lines of Maple code ). Then call Maple to execute a separate Maple function and get the result back.

how can i call python code in maple like external call for C++/Java/C#...

i have a text parser written in python and want to use it

can someone help me?

I am looking to use MapleSim in my MSEE Thesis project. I need to capture input from a hardware system, then use that data to drive a model in MapleSim, using MapleSim as a 3D kinematic model.

I have been using Python for most of my work so far, so that would be a preferred language, but I am also comfortable with C++, it just takes longer.

I am brand new to MapleSim (I have not even received it yet), so if there are some documents you could point me to, then that would be just great!

This guy Giorges is using Python and wget inorder to do parrallel downloading
and he is arguing that it is very fast.

http://keramida.wordpress.com/2010/01/19/parallel-downloads-with-python-and-gnu-wget/


Now my questions become

1) Does there exist a simple way that I can use wget without installing it ?
I dont want to bother users of my Maple application with installing a 3:rd party software.
A simple file in a specific location would be ok though

Page 1 of 1