Repository: claritychallenge/clarity
Issue: Deprecation warnings in tests

Several deprecation warnings appear when running the test suite.

 These should be dealt with

- [x] NumbaPendingDeprecationWarning:  'reflected list' in HAO_tools_cec2.py
- [x] DeprecationWarning: `np.int` is a deprecated alias for buildin 'int' in torch_msbg.py
- [x] FutureWarning: `rcond` parameter - in torch_msbg.py 

**NB** No need to make a branch for this issue as it is likely to be resolved by other issues but is being recorded here for tracking purposes, i.e.:

The torch_msbg.py issues may be fixed in issue #86 dealing with torch_msbg tests which will include some torch_msbg refactoring.  The Numba warnings issues may be fixed when dealing with the data/ dir tests in issue #81 


Changed files:
clarity/predictor/torch_msbg.py, tests/recipes/cpc2/test_evaluate_cpc2.py, clarity/enhancer/gha/audiogram.py

diff --git a/clarity/enhancer/gha/audiogram.py b/clarity/enhancer/gha/audiogram.py
index e9b0e10..ad2b84b 100644
--- a/clarity/enhancer/gha/audiogram.py
+++ b/clarity/enhancer/gha/audiogram.py
@@ -36,6 +36,10 @@ class Audiogram:
         """
         # calculate mean hearing loss between 2 & 8 kHz
         impairment_freqs = np.logical_and(2000 <= self.cfs, self.cfs <= 8000)
+
+        if not np.any(impairment_freqs):
+            return ["NOTHING", "NOTHING"]
+
         severity_levels = ["NOTHING", "NOTHING"]
         for i, levels in enumerate([self.levels_l, self.levels_r]):
             impairment_degree = np.mean(levels[impairment_freqs])
diff --git a/clarity/predictor/torch_msbg.py b/clarity/predictor/torch_msbg.py
index a18b0dc..2e613d5 100644
--- a/clarity/predictor/torch_msbg.py
+++ b/clarity/predictor/torch_msbg.py
@@ -100,6 +100,7 @@ class MSBGHearingModel(nn.Module):
         corrn_forward = 10 ** (0.05 * corrn_used)
         corrn_backward = 10 ** (0.05 * -1 * corrn_used)
         n_wdw = int(2 * np.floor((sr / 16e3) * 368 / 2))
+
         cochlea_filter_forward = firwin2(
             n_wdw + 1, hz_used / nyquist, corrn_forward, window=("kaiser", 4)
         )
diff --git a/tests/recipes/cpc2/test_evaluate_cpc2.py b/tests/recipes/cpc2/test_evaluate_cpc2.py
index cb6414e..d5d2150 100644
--- a/tests/recipes/cpc2/test_evaluate_cpc2.py
+++ b/tests/recipes/cpc2/test_evaluate_cpc2.py
@@ -1,10 +1,12 @@
 """Tests for the CPC2 evaluation functions."""
 
 import math
+import warnings
 
 import numpy as np
 import pytest
 
+# pylint: disable=import-error, no-name-in-module
 from recipes.cpc2.baseline.evaluate import (
     compute_scores,
     kt_score,
@@ -30,7 +32,10 @@ def test_rmse_score_ok(x, y, expected):
 def test_rmse_score_error(x, y, expected):
     """Test the function rmse_score for invalid inputs"""
     with pytest.raises(expected):
-        result = rmse_score(np.array(x), np.array(y))
+        np.seterr(all="ignore")
+        with warnings.catch_warnings():
+            warnings.simplefilter("ignore")  # <--- suppress mean of empty slice warning
+            result = rmse_score(np.array(x), np.array(y))
         if np.isnan(result):
             raise ValueError
 
@@ -99,6 +104,7 @@ def test_std_err_ok(x, y, expected):
 def test_std_err_error(x, y, expected):
     """Test the function std_err for invalid inputs"""
     with pytest.raises(expected):
+        warnings.simplefilter("ignore")
         result = std_err(np.array(x), np.array(y))
         if np.isnan(result):
             raise ValueError
@@ -111,6 +117,7 @@ def test_std_err_error(x, y, expected):
 def test_compute_scores_error(x, y, expected):
     """Test the function compute_scores for invalid inputs"""
     with pytest.raises(expected):
+        warnings.simplefilter("ignore")  # <--- suppress mean of empty slice warning
         compute_scores(np.array(x), np.array(y))