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

block_stream might drop up to n_jobs - 1 complete frames #2

Open
beasteers opened this issue Feb 7, 2020 · 2 comments
Open

block_stream might drop up to n_jobs - 1 complete frames #2

beasteers opened this issue Feb 7, 2020 · 2 comments

Comments

@beasteers
Copy link
Collaborator

The offending line is here:

y_blocks = (y for y in y_blocks if y.size == block_length)

This line is meant to drop blocks that don't have enough samples. But since we're working with multiprocessing and are loading block_size * n_jobs, if we have block_size * (n_jobs - 1) + 3, it would drop that entire block instead of just the +3.

Another issue with that line is that it assumes a mono signal, so that's not good either.

A solution could be:

single_block_length = block_length // n_blocks
y_blocks = (
    y[:(y.shape[0] // single_block_length) * single_block_length] 
    for y in y_blocks)

This just makes sure that y.shape[0] is divisible by block_length / n_jobs

@lostanlen
Copy link
Member

yes, but now what if y.shape[0] < single_block_length ?

@beasteers
Copy link
Collaborator Author

Right, good point. How bout this?

single_block_length = block_length // n_blocks
y_blocks = (
    y[:(y.shape[0] // single_block_length) * single_block_length] 
    for y in y_blocks)

# +
y_blocks = (y for y in y_blocks if y.shape[0])

Not sure how many nested generators is too many lol 🤷🏼‍♀️

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