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

Type hinting and general code review #46

Merged
merged 14 commits into from Dec 30, 2022

Conversation

hadware
Copy link
Contributor

@hadware hadware commented Sep 30, 2022

Reference Issue

This is part of the code review for JOSS: openjournals/joss-reviews#4739

This PR is based on the edits from #44 . That other PR should probably be merged before this one.

What does this implement/fix? Explain your changes.

This PR has has three aims:

  • I'll add type hints to the function signatures (I hope you don't mind, but I really do love type hints, @hbredin might testify on this)
  • Adding type hints sort of forces me to comb through the code and get a better understanding it of it
  • If I see fishy things I might :
    • either add a # TODO or # WARNING comment for you to solve. You can probably solve them by directly pushing in this PR if you wish
    • correct them myself if they're extremely obvious. In this case you might want to check that I haven't done anything bad.

@SuperKogito SuperKogito self-requested a review October 24, 2022 01:41
)


# TODO: the mel conversion approaches are only ["Oshaghnessy", "Lindsay"]
Copy link
Owner

Choose a reason for hiding this comment

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

Some conversion approaches were not very stable so I restricted the choices to the ones I deemed stable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well then maybe you should remove references to the Beranek approach then? (If I understand everything correctly).

Copy link
Owner

Choose a reason for hiding this comment

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

I would rather not delete things and leave it to the user to decide :) so I will mention the Beranek appraoch too.

@@ -132,6 +141,9 @@ def windowing(frames, frame_len, win_type="hamming"):
https://superkogito.github.io/blog/2020/03/13/spectral_leakage_and_windowing.html

"""
# WARNING : I would argue that defaulting to hamming is good,
# but defaulting _silently_ is bad (any spelling mistake made would result
# in a silent usage of hamming)
Copy link
Owner

Choose a reason for hiding this comment

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

What do you recommend to do here instead? I am a bit confused by your point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two possible behaviors IMHO:

  1. since there's already a default argument in the function, remove the get and straight up use a regular window_fn[window_type] (getitem) syntax. Any badly written window type will raise a KeyError and it's a very quick fix for the user.
  2. keep the same behavior and fallback to hamming, but issue a warnings.warn to notify the user that this window type is being used.

I'd rather go for behavior 1, but it's your call on this one.

Copy link
Owner

Choose a reason for hiding this comment

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

Option 1 seems better so I went with that. Thank you :))

Copy link
Owner

@SuperKogito SuperKogito left a comment

Choose a reason for hiding this comment

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

Great remarks @hadware 👏 I already attempted to include type-hinting too but some scripts made it so hard (converters.py). However, you solved this elegantly in the code. I tried to implement all you remarks and notes and I will go over this again later today in case I missed something :)

@SuperKogito
Copy link
Owner

my latest changes on hadware#1 should close #47

@hadware
Copy link
Contributor Author

hadware commented Nov 3, 2022

Sorry, i've been quite busy, i'll review the PR this week end if I get the time to do so

@SuperKogito
Copy link
Owner

@hadware any update on this :) ?

@hadware
Copy link
Contributor Author

hadware commented Dec 29, 2022

Alright, sorry for the extreme delay: I merged the commits from your PR at hadware#1 into this branch. I think I'm out of nitpicking regarding the code, so this is a :shipit:

@SuperKogito SuperKogito merged commit 378d194 into SuperKogito:master Dec 30, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants