Skip to content

Commit 5917bf7

Browse files
author
Martin Glesser
authored
Merge pull request #43 from wantysal/plt_suppress
matpltolib dependency made optional
2 parents 85086da + 3144b41 commit 5917bf7

23 files changed

+189
-124
lines changed

mosqito/functions/loudness_ecma/comp_loudness.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
@author: Daniel Jiménez-Caminero Costa
44
"""
55
import numpy as np
6-
import matplotlib.pyplot as plt
76

87
# Project Imports
98
from mosqito.functions.loudness_ecma.rectified_band_pass_signals import (

mosqito/functions/loudness_ecma/equal_loudness_contours.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
"""
55

66
import numpy as np
7-
import math
8-
import scipy as sp
9-
import matplotlib.pyplot as plt
10-
from scipy.signal import welch
117

128

139
def equal_loudness_contours(phones):

mosqito/functions/loudness_ecma/gammatone.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
try:
2+
import matplotlib.pyplot as plt
3+
except ImportError:
4+
raise RuntimeError(
5+
"In order to perform this validation you need the 'matplotlib' package."
6+
)
7+
8+
19
from scipy.special import comb
210
from scipy.signal import freqz
3-
import matplotlib.pyplot as plt
411
from numpy import (
512
abs as np_abs,
613
arange,

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
numpy
22
scipy
3-
matplotlib

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
requirements
1717
).splitlines() # remove endline in each element
1818

19-
tests_require = ["pytest>=5.4.1", "pandas", "openpyxl", "SciDataTool"]
19+
tests_require = ["pytest>=5.4.1", "pandas", "openpyxl", "SciDataTool", "matplotlib"]
2020
uff_require = ["pyuff"]
2121
scidatatool_require = ["SciDataTool"]
2222
all_require = tests_require + uff_require

validations/loudness_ecma/hearing_model_validation.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# -*- coding: utf-8 -*-
2+
# Optional package import
3+
try:
4+
import matplotlib.pyplot as plt
5+
except ImportError:
6+
plt = None
7+
28

39
import numpy as np
4-
import matplotlib.pyplot as plt
510
from scipy.optimize import root_scalar
611

712
# Project Imports
@@ -55,6 +60,10 @@ def hearing_model_validation():
5560
"""Validation of the ECMA loudness implementation according
5661
to ECMA-418-2 annex A
5762
"""
63+
if plt is None:
64+
raise RuntimeError(
65+
"In order to make this validation plot you need the 'matplotlib' package."
66+
)
5867

5968
phons = [80, 60, 40, 20]
6069

-622 Bytes
Loading
-67 Bytes
Loading
101 Bytes
Loading

validations/loudness_ecma/valid_ear_filter_design.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# -*- coding: utf-8 -*-
2+
try:
3+
import matplotlib.pyplot as plt
4+
except ImportError:
5+
raise RuntimeError(
6+
"In order to perform this validation you need the 'matplotlib' package."
7+
)
8+
29

310
import scipy.signal as sp_signal
411
from numpy import (
@@ -8,7 +15,7 @@
815
sqrt,
916
mean,
1017
)
11-
import matplotlib.pyplot as plt
18+
1219

1320
from mosqito.functions.loudness_ecma.ear_filter_design import ear_filter_design
1421
from mosqito.functions.shared.sine_wave_generator import (
@@ -64,6 +71,7 @@
6471
plt.semilogx(freq, level, "o", label="Filtered sine signal")
6572
plt.legend()
6673
plt.savefig(
67-
"./validations/loudness_ecma/output/" + "validation_ear_filter_design.png",
74+
"./output/" + "validation_ear_filter_design.png",
6875
format="png",
69-
)
76+
)
77+
plt.clf()

0 commit comments

Comments
 (0)