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

Why choose to not use numpy? #4

Open
jonasvdd opened this issue Jul 28, 2022 · 3 comments
Open

Why choose to not use numpy? #4

jonasvdd opened this issue Jul 28, 2022 · 3 comments

Comments

@jonasvdd
Copy link

Hi really cool repo 🚀

I am 100% sure that this this code can be significantly sped up by using numpy vectorisation.

I was able to write a pure numpy-python implementation which could downsample 50,000,000->2,000 data points in ~300ms (on a consumer pc).

If interested; I can quickly make a PR where I put the numpy-python version of that algorithm next to yours.

Cheers,
Jonas

@sfc-gh-puneet-lakhanpal

Hi @jonasvdd , are you able to submit the PR for the numpy vectorized version ?

Thank you.

@jonasvdd
Copy link
Author

Sure!

@jonasvdd
Copy link
Author

Just a few questions:

def largest_triangle_three_buckets(data, threshold):
    """
    Return a downsampled version of data.
    Parameters
    ----------
    data: list of lists/tuples
        data must be formated this way: [[x,y], [x,y], [x,y], ...]
                                    or: [(x,y), (x,y), (x,y), ...]
    threshold: int
        threshold must be >= 2 and <= to the len of data
    Returns
    -------
    data, but downsampled using threshold
  • Why did you opt of a list of tuples as datatype? (not really performant when operating on large arrays). If you are considering numpy support, I would opt to just allow an array-alike type argument (and thus splitting up the data argument into x and y), e.g.:
def largest_triangle_three_buckets(x, y, threshold):
   """
   ....
   
   Parameters:
   ------------------
    x: list | np.ndarray
       ....

How should I add the numpy dependency? (via requirements.txt / pyproject.toml)

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

2 participants