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

Pull request to fix issue #12 for 0 values in np.log10() #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions timbral_models/Timbral_Warmth.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ def timbral_warmth(fname, dev_output=False, phase_correction=False, clip_output=
HF decay
- linear regression of the values above the warmth region
'''
above_WR_spec = np.log10(spec[WR_upper_f_limit_idx:])
# Sometimes when there are zero values in the spec array (the intensity is null),
# the np.log10 raises a warning.
# Because the log10 is used to reduce the range of the values,
# when a value is zero, zero should be returned :
above_WR_spec = np.array([value if value == 0 else np.log10(value) for value in spec[WR_upper_f_limit_idx:]])
above_WR_freq = np.log10(freq[WR_upper_f_limit_idx:])
np.ones_like(above_WR_freq)
metrics = np.array([above_WR_freq, np.ones_like(above_WR_freq)])
Expand All @@ -225,7 +229,6 @@ def timbral_warmth(fname, dev_output=False, phase_correction=False, clip_output=
decay_score = model.score(metrics.transpose(), above_WR_spec)
all_decay_score.append(decay_score)


'''
get mean values
'''
Expand Down