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

Relax arithmetic rules in case only one audio object is involved #606

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

f-brinkmann
Copy link
Member

@f-brinkmann f-brinkmann commented May 12, 2024

Which issue(s) are closed by this pull request?

Closes #587

Changes proposed in this pull request:

  • Bypass rules for fft norm if only one audio object is involved in the opeeration
  • Add and update tests
  • Update docstrings

For discussion

I discovered that we had a test that explicitly does not allow 1/signal if the FFT norm is not 'none'. I did not remove this test yet. Do we want to stay hard?

@f-brinkmann f-brinkmann self-assigned this May 12, 2024
@f-brinkmann f-brinkmann added hot For bugs on the master branch audio Classes pyfar.classes.audio labels May 12, 2024
Copy link
Member

@ahms5 ahms5 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 fixing! How about testing if its really working, to make sure it will work in future as well.

@f-brinkmann
Copy link
Member Author

Thank you for fixing! How about testing if its really working, to make sure it will work in future as well.

I did a quick check locally, and everything works. I'll add it if we decide to change the behaviour - I added a todo in the PR description to make sure we dont forget. Just didn't want to do too much work that might be discarded :)

Copy link
Member

@ahms5 ahms5 left a comment

Choose a reason for hiding this comment

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

I would suggest not to change the behaviour of _match_fft_norm instead jsut call it if we have more then 1 Audio object

found_audio_data = False
for n, d in enumerate(data):
n_audio_objects = 0
for d in enumerate(data):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for d in enumerate(data):
for _, d in enumerate(data):

otherwise sth breaks

Comment on lines 1395 to 1396
fft_norm = _match_fft_norm(
fft_norm, d.fft_norm, division, n_audio_objects)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fft_norm = _match_fft_norm(
fft_norm, d.fft_norm, division, n_audio_objects)
fft_norm = d.fft_norm if n_audio_objects < 2 else \
_match_fft_norm(fft_norm, d.fft_norm, division)

I would not change the behaviour of _match_fft_norm, instead i would just call it, if we have more then 1 audio object.

@@ -1501,7 +1503,7 @@ def _matrix_multiplication(a, b, axes, audio_type):
return np.matmul(a, b, axes=axes)


def _match_fft_norm(fft_norm_1, fft_norm_2, division=False):
def _match_fft_norm(fft_norm_1, fft_norm_2, division=False, n_audio_objects=2):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def _match_fft_norm(fft_norm_1, fft_norm_2, division=False, n_audio_objects=2):
def _match_fft_norm(fft_norm_1, fft_norm_2, division=False):

then there would be no need to change the behaviour here.

@f-brinkmann
Copy link
Member Author

@ahms5 implemented your changes as suggested. Now I'm waiting for the weekly before changing any tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.6.6 audio Classes pyfar.classes.audio hot For bugs on the master branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inverting signal with division operator throws error when using fft normalization
3 participants