Repository: spectrochempy/spectrochempy

Issue:
Error in Travis Build for a PR
**Describe the bug**
The following error occured while travis built for py 3.7, 3.8 and 3.9  (it passed for py 3.6). No change has been made to setup.py and to any configuration script since the last PR one month ago. Any idea ? 
  
```
$ python setup.py install;
/home/travis/miniconda/envs/scpy3.7/lib/python3.7/site-packages/setuptools_scm/git.py:88: UserWarning: "/home/travis/build/spectrochempy/spectrochempy" is shallow and may cause errors
  warnings.warn(f'"{wd.path}" is shallow and may cause errors')
/home/travis/miniconda/envs/scpy3.7/lib/python3.7/site-packages/setuptools_scm/git.py:88: UserWarning: "/home/travis/build/spectrochempy/spectrochempy" is shallow and may cause errors
  warnings.warn(f'"{wd.path}" is shallow and may cause errors')
running install
Stylesheets installed in /home/travis/.config/matplotlib/stylelib/notebook.mplstyle
Traceback (most recent call last):
  File "setup.py", line 142, in <module>
    setup(**setup_args)
  File "/home/travis/miniconda/envs/scpy3.7/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/home/travis/miniconda/envs/scpy3.7/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/home/travis/miniconda/envs/scpy3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/home/travis/miniconda/envs/scpy3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 87, in run
    _install_mpl()
  File "setup.py", line 58, in _install_mpl
    _dir_data = Path(mpl.rcParams['datapath'])
  File "/home/travis/miniconda/envs/scpy3.7/lib/python3.7/site-packages/matplotlib/__init__.py", line 621, in __getitem__
    return dict.__getitem__(self, key)
KeyError: 'datapath'

The command "python setup.py install;" failed and exited with 1 during .
```



Discussion:
Hi Arnaud
I have seen this some time ago... as the error is a key error in RcParams (Matplotlib) I suspect that it is due to a recent new version of Matplotlib. I will have a look at this as soon as possible.

Thanks christian,
There is no emergency for this :-)

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -55,8 +55,9 @@ def _install_mpl():
 
     # Copy files over
     # _dir_data = Path(matplotlib_fname()).parent
-    _dir_data = Path(mpl.rcParams['datapath'])
-
+    #_dir_data = Path(mpl.rcParams['datapath'])
+    _dir_data = Path(mpl.get_data_path())
+    
     dir_source = Path("scp_data") / 'fonts'
     if not dir_source.exists():
         raise IOError(f'directory {dir_source} not found!')
diff --git a/spectrochempy/core/analysis/iris.py b/spectrochempy/core/analysis/iris.py
--- a/spectrochempy/core/analysis/iris.py
+++ b/spectrochempy/core/analysis/iris.py
@@ -222,7 +222,7 @@ def solve_lambda(X, K, G0, lamda, S, verbose):
                 # The following line is to avoid ValueError: 'matrix G is not
                 # positive definite'
                 # SEE: https://github.com/facebookresearch/GradientEpisodicMemory/issues/2#issuecomment-431826393
-                G += G * 0.00001
+                G +=  np.eye(G.shape[0]).__mul__(1e-3)
 
                 for j, freq in enumerate(coord_x.data):
                     fi[:, j] = quadprog.solve_qp(G, a[j].squeeze(), C, b)[0]
@@ -543,9 +543,9 @@ def nearestPD(A):
 
 
 def isPD(B):
-    """Returns true when input is positive-definite, via Cholesky
+    """Returns true when input is positive-definite,
+     copyright: see https://gist.github.com/fasiha/fdb5cec2054e6f1c6ae35476045a0bbd"""
 
-    copyright: see https://gist.github.com/fasiha/fdb5cec2054e6f1c6ae35476045a0bbd"""
     try:
         _ = np.linalg.cholesky(B)
         return True
diff --git a/spectrochempy/plot_preferences.py b/spectrochempy/plot_preferences.py
--- a/spectrochempy/plot_preferences.py
+++ b/spectrochempy/plot_preferences.py
@@ -65,13 +65,13 @@ class PlotPreferences(MetaConfigurable):
     lines_markeredgecolor = Unicode('auto', help=r'''the default markeredgecolor''').tag(config=True, kind='color')
     lines_markeredgewidth = Float(0.0, help=r'''the line width around the marker symbol''').tag(config=True, kind='')
     lines_markersize = Float(7.0, help=r'''markersize, in points''').tag(config=True, kind='')
-    lines_dash_joinstyle = Enum(['miter', 'round', 'bevel'], default_value='round', help=r'''miter|round|bevel''').tag(
+    lines_dash_joinstyle = Enum(['miter', 'JoinStyle.miter','round', 'JoinStyle.round', 'bevel', 'JoinStyle.bevel'], default_value='round', help=r'''miter|round|bevel''').tag(
             config=True, kind='')
-    lines_dash_capstyle = Enum(['butt', 'round', 'projecting'], default_value='butt',
+    lines_dash_capstyle = Enum(['CapStyle.butt', 'butt', 'CapStyle.round', 'round', 'CapStyle.projecting', 'projecting'], default_value='butt',
                                help=r'''butt|round|projecting''').tag(config=True, kind='')
-    lines_solid_joinstyle = Enum(['miter', 'round', 'bevel'], default_value='round',
+    lines_solid_joinstyle = Enum(['miter', 'JoinStyle.miter', 'round', 'JoinStyle.round', 'bevel', 'JoinStyle.bevel'], default_value='round',
                                  help=r'''miter|round|bevel''').tag(config=True, kind='')
-    lines_solid_capstyle = Enum(['butt', 'round', 'projecting'], default_value='round',
+    lines_solid_capstyle = Enum(['CapStyle.butt', 'butt', 'CapStyle.round', 'round', 'CapStyle.projecting', 'projecting'], default_value='round',
                                 help=r'''butt|round|projecting''').tag(config=True, kind='')
     lines_antialiased = Bool(True, help=r'''render lines in antialiased (no jaggies)''').tag(config=True, kind='')
     lines_dashed_pattern = Tuple((6.0, 6.0), help=r'''''').tag(config=True, kind='')


Test patch: