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

Create functional style api #2

Closed
andgoldschmidt opened this issue May 5, 2020 · 1 comment
Closed

Create functional style api #2

andgoldschmidt opened this issue May 5, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@andgoldschmidt
Copy link
Owner

To add backwards compatibility with derivative.py, a function-style api should be implemented on top of this project's derivative interface.

E.g. from derivative.py/derivative/derivative.py on 05/04/2020:

methods = {}


def register(name=""):
    def inner(f):
        n = name or f.__name__
        methods[n] = f
        return f
    return inner

from .loc import *
from .glob import *

def derivative(x, y, kind="finitediff", **kwargs):
    method = methods.get(kind)
    f = lambda y: method(x, y, **kwargs)
    if len(y.shape) > 1:
        return np.apply_along_axis(f, 0, y)
    else:
        return f(y)
@andgoldschmidt andgoldschmidt added the enhancement New feature or request label May 5, 2020
@andgoldschmidt andgoldschmidt self-assigned this May 5, 2020
@andgoldschmidt
Copy link
Owner Author

feature added in version 0.1.1, see commit #70f89f9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant