Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sympy_to_scipy More efficient #10

Closed
tBuLi opened this issue Dec 17, 2014 · 1 comment
Closed

Make sympy_to_scipy More efficient #10

tBuLi opened this issue Dec 17, 2014 · 1 comment

Comments

@tBuLi
Copy link
Owner

tBuLi commented Dec 17, 2014

def sympy_to_scipy(func, vars, params):
    """
    Convert a symbolic expression to one scipy digs.
    :param func: sympy expression
    :param vars: variables
    :param params: parameters
    """
    lambda_func = sympy_to_py(func, vars, params)
    def f(x, p):
        """
        Scipy style function.
        :param x: list of arrays, NxM
        :param p: tuple of parameter values.
        """
        x = np.atleast_2d(x)
        y = [x[i] for i in range(len(x))]
        return lambda_func(*(y + list(p)))

    return f

The current definition of f will do the list comprehension every time it is called, which can be a lot of a lot of iterations are needed for the fit to converge. Therefore a more efficient function is desirable.

@tBuLi tBuLi changed the title sympy_to_scipy More efficient sympy_to_scipy More efficient Dec 17, 2014
@tBuLi tBuLi changed the title sympy_to_scipy More efficient Make sympy_to_scipy More efficient Dec 17, 2014
@tBuLi
Copy link
Owner Author

tBuLi commented Dec 6, 2015

No longer relevant due to the internal API changes

@tBuLi tBuLi closed this as completed Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant