-
Notifications
You must be signed in to change notification settings - Fork 65
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
[MNT] - Update filter type checks & inference #322
Conversation
Forgot to tag people who might be interested in this update: @QuirinevEngen, @mwprestonjr, & @voytek - does this make sense / look good in terms of an update related to the filter type discussion that started on slack and described in #321 |
This looks totally reasonable to me. If Q and MJ don't seen any issue, then please merge. |
@QuirinevEngen & @mwprestonjr - just following up here on whether you have any thoughts / suggestions on this suggested update about filter specification? if it looks good to y'all, I think we can merge this in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @TomDonoghue, a couple small suggestions relating to 'n_cycles':
- I like the addition of _fir_checks(); one idea would be to add an additional warning if both 'n_cycles' and 'n_seconds' are set, to explicitly warn about the overwriting behavior.
- 'n_cycles' is only applicable to the FIR filter so _iir_checks() could raise a ValueError if this is not None, similar to the current behavior for 'n_seconds'.
Hey @mwprestonjr - thanks for checking in, and for the suggestions! I do like both suggestions, but they are both complicated by the current default definition of Because of this, I think the main options for better management of
Also cc'ing @ryanhammonds for any thoughts on this |
It does feel odd that n_cycles defaults to 3, but n_seconds can be passed to implicitly overwrite. Defaulting to n_cyles=None and then defaulting to n_cycles=3 within the func seems logical without breaking much. The mixing of these fir and iir kwargs seems tricky. Next time a breaking release is made, it may be worth considering something like: def filter_signal(sig, fs, pass_type, f_range, fir_params=None, iir_params=None,
print_transitions=False, plot_properties=False, return_filter=False): This would explicitly separate the two sets of kwargs and maybe simplify the checks a bit, but comes at the cost of breaking things. |
Yeh, I totally agree with Ryan - and missed this option in thinking through this before: by defaulting n_cycles to None in the function call, but checking and setting it to 3 if nothing else is defined lets us do the checks we want, without changing any current behavior. I pushed a commit to do this! Note that we do now check that not both |
I was thinking about @ryanhammonds other point about separating the arguments in separate dictionaries, and I agree - and I think we can do a version of this without it (really) being breaking. In thinking of this, I was thinking that In the latest commit, I dropped all arguments in This all works in a way that is almost non-breaking. Notably, I didn't have to change any tests to work, and because of how the inputs / defaults are managed in the sub-functions, none of the default values for non-explicitly passed in arguments should change. The almost part of the non-breaking part is that the API for For example, the following would have previously given valid FIR filter with n_cycles of 5: For IIR, it's even more tenious - this is the simplest inputs that would previously work but now fail: I don't think I ever use So - what do we think of the updated organization? Sidenote: if we like it, it's not quite finished - the docs might need cleaning up a bit to render nicely, and we should probably add a test for If we don't like this - I'll revert the last commit, and we can go back to keeping all the other updates in the PR |
I like the latest changes! |
Looks good! I wouldn’t worry too much about about the almost not breaking part - I’d argue named kwargs should be used instead of inferring args as kwargs based on order. I like the kwarg checking too - my one complaint with **kwargs is accidentally misspelling a kwarg and the func silently accepting. But since there are checks on them, this avoids the issue. |
Responds to #321
Previously, one could end up with an inconsistent set of input parameters to the general
filter_signal
function - for example, passing inbutterworth_order
without explicitly setting IIRfilter_type
. This update switchesfilter_type
to default to None, an if not explicitly set, it is inferred from the given parameters, with additional updates to check that the given set of parameters are consistent.