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

Fix trim_zeros_frames to trim zeros from the end #87

Merged
merged 12 commits into from
Jun 22, 2019

Conversation

yamachu
Copy link
Contributor

@yamachu yamachu commented Jun 19, 2019

Docs of trim_zeros_frames says Remove trailing zeros frames.
But it behaves removing both front and back zero frames because of lack of np.trim_zeros 's trim option.

expected

arr = np.array(((0, 0), (1, 1), (2, 2), (0, 0)))
actual = trim_zeros_frames(arr)
# np.array(((0, 0), (1, 1), (2, 2)))

actual

arr = np.array(((0, 0), (1, 1), (2, 2), (0, 0)))
actual = trim_zeros_frames(arr)
# np.array(((0, 0), (1, 1)))

So I thought that it's better to set option trim='b'.

@codecov-io
Copy link

codecov-io commented Jun 19, 2019

Codecov Report

Merging #87 into master will increase coverage by 0.13%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #87      +/-   ##
==========================================
+ Coverage   83.85%   83.98%   +0.13%     
==========================================
  Files          31       31              
  Lines        1697     1711      +14     
==========================================
+ Hits         1423     1437      +14     
  Misses        274      274
Impacted Files Coverage Δ
nnmnkwii/preprocessing/generic.py 99.47% <100%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1649b3c...fbf98a8. Read the comment docs.

Copy link
Owner

@r9y9 r9y9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for raising the issue. To keep compatibility, could you make trim an option to the trim_zeros_frames and defaults to 'fb'' and fix docstring accordingly?

def trim_zeros_frames(x, eps=1e-7, trim="fb"):
   '''Remove leading and/or trailing zeros frames

   ...

@yamachu
Copy link
Contributor Author

yamachu commented Jun 21, 2019

Thank you for your review.

7874393
This commit fixed commit that follow your review.

But still trimming issue remains...
What do you think about my following suggestion.

  • Making default value None
  • If passed trim option f, b, or fb then trim_zeros_frames trims zeros frames from front, back, or front and back

These behaviors can be confirmed from these commits.
80a4a36
493487b

Thanks.

@r9y9
Copy link
Owner

r9y9 commented Jun 22, 2019

Could you put a change log in https://github.com/r9y9/nnmnkwii/blob/1649b3caba671ad203c4d599b5b8b95c168e03ac/docs/changelog.rst#v0019-2019-xx-xx? Thanks!

Copy link
Owner

@r9y9 r9y9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'll merge when CI succeeded.

@r9y9 r9y9 added the bug fix label Jun 22, 2019
@r9y9 r9y9 merged commit 52e8ecb into r9y9:master Jun 22, 2019
@yamachu yamachu deleted the fix/trim_zero_fb2b branch June 22, 2019 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants