Repository: spectrochempy/spectrochempy

Issue:
improve lgtm grade (errors+warnings)
Author: @atravert (Arnaud TRAVERT)

Redmine Issue: 71, https://redmine.spectrochempy.fr/issues/71

---

Correct code to fix detected errors (7 minus at least one false positive) et 23 warnings.

see https://lgtm.com/projects/g/spectrochempy/spectrochempy?mode=list




Discussion:

Resolving patch:
diff --git a/spectrochempy/core/analysis/efa.py b/spectrochempy/core/analysis/efa.py
--- a/spectrochempy/core/analysis/efa.py
+++ b/spectrochempy/core/analysis/efa.py
@@ -150,9 +150,9 @@ def cut_f(self, n_pc=None, cutoff=None):
         -------
 
         """
-        M, K = self.f.shape
-        if n_pc is None:
-            n_pc = K
+        # M, K = self.f.shape
+        # if n_pc is None:
+        #    n_pc = K
         # n_pc = min(K, n_pc)
 
         f = self.f
@@ -172,9 +172,9 @@ def cut_b(self, n_pc=None, cutoff=None):
         -------
 
         """
-        M, K = self.b.shape
-        if n_pc is None:
-            n_pc = K
+        # M, K = self.b.shape
+        # if n_pc is None:
+        #    n_pc = K
         # n_pc = min(K, n_pc)
 
         b = self.b
diff --git a/spectrochempy/core/dataset/ndarray.py b/spectrochempy/core/dataset/ndarray.py
--- a/spectrochempy/core/dataset/ndarray.py
+++ b/spectrochempy/core/dataset/ndarray.py
@@ -1739,15 +1739,17 @@ def _repr_value(self):
 
         if not self.is_empty:
 
-            if self._data is not None:
-                data = self.umasked_data
-            else:
-                # no data but labels
-                data = self.get_labels()
+            # if self._data is not None:
+            #    data = self.umasked_data
+            # else:
+            #    # no data but labels
+            #    data = self.get_labels()
+
+            if self._data is None:
                 print_unit = False
 
-            if isinstance(data, Quantity):
-                data = data.magnitude                   # TODO:   Check why it is not used???
+            # if isinstance(data, Quantity):
+            #    data = data.magnitude                   # TODO:   Check why it is not used???
 
             if print_unit:
                 units = ' {:~K}'.format(self.units) if self.has_units else ' unitless'
diff --git a/spectrochempy/core/processors/concatenate.py b/spectrochempy/core/processors/concatenate.py
--- a/spectrochempy/core/processors/concatenate.py
+++ b/spectrochempy/core/processors/concatenate.py
@@ -148,34 +148,34 @@ def concatenate(*datasets, **kwargs):
     # get the coordss
     coordss = [dataset.coords for dataset in datasets]
 
-    def check_coordinates(coordss, force_stack):
-
-        # We will call this only in case of problems because it takes a lot of time
-
-        # how many different coordss
-        coordss = set(coordss)
-        if len(coordss) == 1 and force_stack:
-            # nothing to do (all datasets have the same coords and so are
-            # perfectly compatibles for stacking)
-            pass
-
-        else:
-            for i, cs in enumerate(zip(*coordss)):
-
-                axs = set(cs)
-                axref = axs.pop()
-                for ax in axs:
-                    # we expect compatible units
-                    if not ax.is_units_compatible(axref):
-                        raise ValueError(
-                            "units of the dataset's axis are not compatible"
-                        )
-                    if i != axis and ax.size != axref.size:
-                        # and same size for the non-concatenated axis
-                        raise ValueError(
-                            "size of the non-concatenated dimension must be "
-                            "identical"
-                        )
+    # def check_coordinates(coordss, force_stack):
+    #
+    #     # We will call this only in case of problems because it takes a lot of time
+    #
+    #     # how many different coordss
+    #     coordss = set(coordss)
+    #     if len(coordss) == 1 and force_stack:
+    #         # nothing to do (all datasets have the same coords and so are
+    #         # perfectly compatibles for stacking)
+    #         pass
+    #
+    #     else:
+    #         for i, cs in enumerate(zip(*coordss)):
+    #
+    #             axs = set(cs)
+    #             axref = axs.pop()
+    #             for ax in axs:
+    #                 # we expect compatible units
+    #                 if not ax.is_units_compatible(axref):
+    #                     raise ValueError(
+    #                         "units of the dataset's axis are not compatible"
+    #                     )
+    #                 if i != axis and ax.size != axref.size:
+    #                     # and same size for the non-concatenated axis
+    #                     raise ValueError(
+    #                         "size of the non-concatenated dimension must be "
+    #                         "identical"
+    #                     )
 
     # concatenate or stack the data array + mask
     # ------------------------------------------------------------------------------------------------------------------


Test patch: