Feature: time-slicing function for pyfar.Signal objects#849
Conversation
ahms5
left a comment
There was a problem hiding this comment.
nice, thank you. a few minor comments on the doc and testing
|
I added TimeData as a data type for the parameter |
ahms5
left a comment
There was a problem hiding this comment.
Thank you hanna, Looks fine, just one main point about the error handling, see below.
jf-som
left a comment
There was a problem hiding this comment.
Thanks for implementing these changes. I found a small corrention and an unusual empty line, but otherwise all looks good to me
sikersten
left a comment
There was a problem hiding this comment.
Thank you! Already looks quite good. Some minor comments and one more important on the function's behavior if interval is out of the boundaries.
mberz
left a comment
There was a problem hiding this comment.
Thanks for the implementation.
Apart from the interval checking issue missing for samples already mentioned by Simon I have only minor comments. Functionality wise I think this is good to go.
Additionally I found a couple of indenting issue which do not comply with PEP8. You can have a look at the guidelines for PEP8 here:
https://peps.python.org/pep-0008/#indentation
pyfar/dsp/dsp.py
Outdated
| np.ndarray], | ||
| unit: Literal["samples", "s"]='samples'): | ||
| """This function can be used to crop a pf.Signal or pf.TimeData object. | ||
| """Crop a pf.Signal or pf.TimeData object in time. |
There was a problem hiding this comment.
I would suggest to add a sentence on the definition of the crop interval used by the function, i.e. that the function crops to the inside of the interval.
|
Thanks for implementing the changes. In terms of the actual code, this looks ready to me. I have two general design thoughts though:
I see you added TimeData as a an alternative input to Signal. In my opinion, it's unusual to allow different types of inputs and return types, when the behavior of the function is different depending on the type. In this case, cropping TimeData seems to keep timestamps while Signal changes them to start at 0, as you show in the examples. croppedTimeData = someTimeData.time_crop(interval, unit)
croppedSignal = someSignal.time_crop(interval, unit)This version would be similar to the Perhaps we can discuss this in the weekly meeting in 7 days. |
Thank you very much for such a comprehensive review! I appreciate your opinion. Regarding the first point: I don't use pyfar myself, so it's always difficult for me to evaluate the context in which the implemented functions will be used. If the majority agrees that the end of the interval should not be included in the new signal, I will of course apply these changes. Regarding the second point: I would like to note that the idea of adding TimeData to this function as alternative data type for the parameter And I agree that this is a topic for discussion at the weekly meeting :) |
|
Your are right in that it's pretty late for structure changes like this, though the thought only came to me now that I saw the different examples in practice... Sorry! For now I just think it's something worth discussing. If we decide to make it instance methods instead, I don't think it will be too much work. But I'm also open to implement that change myself if it comes to it, I'm not trying to offload extra work onto you ^^ |
It's fine, don't worry, I also think that implementing this change won't take long. And it's certainly better to mention possible improvements belatedly than not to mention them at all. |
jf-som
left a comment
There was a problem hiding this comment.
As discussed in the weekly, I consider this ready for merge. 🙌
As a last minor edit, it would be nice if you could add a short hint to the different signal.times behavior between Signal and TimeData input types before the merge, like we discussed in the weekly.
Thanks for implementation!
ahms5
left a comment
There was a problem hiding this comment.
approved, execpt hint about the interval, feel free to ajust my recommendation.
Thank you Hanna.
Which issue(s) are closed by this pull request?
Closes #751
This is my implementation of the pyfar.dsp.time_crop function, which can be used to crop a signal in the time domain. I have also written some test functions, most of which are similar to the existing test functions for pyfar.dsp.time_window.