Refactor the parametric energy decay curve function#74
Conversation
ahms5
left a comment
There was a problem hiding this comment.
why is this PR called refactor if a new method is added?
This PR was not ready for review, yet ;) When it's ready it will replace the function |
f-brinkmann
left a comment
There was a problem hiding this comment.
Made a suggestion to improve the docs and simplify the computation (not tested if the latter works)
pyrato/parametric.py
Outdated
| shape = np.broadcast_shapes(energy.shape, reverberation_time.shape) | ||
| try: | ||
| energy = np.broadcast_to(energy, shape) | ||
| except ValueError as error: | ||
| raise ValueError( | ||
| "Reverberation time and energy must have the same shape.", | ||
| ) from error |
There was a problem hiding this comment.
I think this only works one way. How about using
| shape = np.broadcast_shapes(energy.shape, reverberation_time.shape) | |
| try: | |
| energy = np.broadcast_to(energy, shape) | |
| except ValueError as error: | |
| raise ValueError( | |
| "Reverberation time and energy must have the same shape.", | |
| ) from error | |
| try: | |
| shape = np.broadcast_shapes(energy.shape, reverberation_time.shape) | |
| except ValueError as error: | |
| raise ValueError( | |
| "Reverberation time and energy must be broadcastable to the same shape.", | |
| ) from error |
If we then do
times = np.broadcast_to(times, shape + (times.size, ))the reshaping and transposing below might not be requried anymore because of exploting automatic broadcasting.
There was a problem hiding this comment.
Seems to not work like that.
There was a problem hiding this comment.
I've adapted your suggestion, though
pyrato/parametric.py
Outdated
| reverberation_time : float | numpy.ndarray[float] | ||
| The reverberation time in seconds. | ||
| energy : float | numpy.ndarray[float], optional | ||
| The initial energy of the sound field, by default 1. |
There was a problem hiding this comment.
It took me a little while to figure out
- that mulriple EDCs will be computed if one of these is array like and
- that they must be broadcastable (I also made a note below that might make things more flexible)
Can you please add a note on this here?
f-brinkmann
left a comment
There was a problem hiding this comment.
Thanks. Only docstring suggestions left. Approved otherwise.
pyrato/parametric.py
Outdated
| times : numpy.ndarray[float] | ||
| The times at which the energy decay curve is evaluated. | ||
| reverberation_time : float | numpy.ndarray[float] | ||
| The reverberation time in seconds. If an array is passed, a energy |
There was a problem hiding this comment.
teeny tiny typo
| The reverberation time in seconds. If an array is passed, a energy | |
| The reverberation time in seconds. If an array is passed, an energy |
pyrato/parametric.py
Outdated
| ``reverberation_time`` is an array, the shape of ``energy`` is required | ||
| to match the shape or be broadcastable to the shape of | ||
| ``reverberation_time``. |
There was a problem hiding this comment.
I think we agreed to have parameters in italics:
| ``reverberation_time`` is an array, the shape of ``energy`` is required | |
| to match the shape or be broadcastable to the shape of | |
| ``reverberation_time``. | |
| `reverberation_time` is an array, the shape of `energy` is required | |
| to match the shape or be broadcastable to the shape of | |
| `reverberation_time`. |
d9f11b5 to
7f72db0
Compare
- uses reverbation time as input instead of geometry - returns pf.TimeData object - independent of sabine/eyring equations
Co-authored-by: Anton Hoyer <156099087+hoyer-a@users.noreply.github.com>
7f72db0 to
f6ce872
Compare
Changes to the function
We should also remove support for Python < 3.11 in a different PR