Repository: Quasars/orange-spectroscopy (language: python)

Issue:
spectral 0.23 doesn't support data type complex256 on Windows
@stuart-cls, do you have any ideas where the following error came from? I know it is not from this PR, but did perhaps any dependency change?

```
======================================================================
ERROR: test_envi_comparison (test_readers.TestAgilentReader)
----------------------------------------------------------------------
TypeError: data type 'complex256' not understood
```

_Originally posted by @markotoplak in https://github.com/Quasars/orange-spectroscopy/issues/626#issuecomment-1255057523_

Found it, it was due to change in spectral:

https://github.com/spectralpython/spectral/issues/144
https://github.com/spectralpython/spectral/issues/135

I propose pinning to spectral < 0.23 until they fix it.


Discussion / hints:
I guess related issue is that the only test for the envi reader is my agilent comparison 😄 
Thanks for the find and so nice that your tests are so inclusive. :)

Fix patch:
diff --git a/conda/meta.yaml b/conda/meta.yaml
index f535d7ae7..d1f247794 100644
--- a/conda/meta.yaml
+++ b/conda/meta.yaml
@@ -29,7 +29,7 @@ requirements:
     - orange-widget-base >=4.16.1
     - scipy >=1.4.0
     - scikit-learn >0.23.0
-    - spectral >=0.18
+    - spectral >=0.18,!=0.23
     - serverfiles >=0.2
     - AnyQt >=0.0.6
     - pyqtgraph >=0.11.1,!=0.12.4
diff --git a/setup.py b/setup.py
index dfcd4f821..45711331a 100644
--- a/setup.py
+++ b/setup.py
@@ -133,7 +133,7 @@ def include_documentation(local_dir, install_dir):
             'orange-widget-base>=4.16.1',
             'scipy>=1.4.0',
             'scikit-learn>0.23.0',
-            'spectral>=0.18',
+            'spectral>=0.18,!=0.23',
             'serverfiles>=0.2',
             'AnyQt>=0.0.6',
             'pyqtgraph>=0.11.1,!=0.12.4',  # https://github.com/pyqtgraph/pyqtgraph/issues/2237


Test patch:
diff --git a/orangecontrib/spectroscopy/tests/test_readers.py b/orangecontrib/spectroscopy/tests/test_readers.py
index 4d8d4b4cd..1ab81f5c4 100644
--- a/orangecontrib/spectroscopy/tests/test_readers.py
+++ b/orangecontrib/spectroscopy/tests/test_readers.py
@@ -31,6 +31,7 @@ def initialize_reader(reader, fn):
     absolute_filename = FileFormat.locate(fn, Orange.data.table.dataset_dirs)
     return reader(absolute_filename)
 
+
 # pylint: disable=protected-access
 def check_attributes(table):
     """
@@ -80,7 +81,6 @@ def test_comma_delim(self):
             np.testing.assert_equal(d.X, [[500., 650.]])
 
 
-
 try:
     no_visible_image = FileFormat.locate("opus/no_visible_images.0",
                                          Orange.data.table.dataset_dirs)
@@ -404,6 +404,19 @@ def test_read(self):
         check_attributes(data)
 
 
+class TestEnvi(unittest.TestCase):
+
+    def test_read(self):
+        data = Orange.data.Table("agilent/4_noimage_agg256.hdr")
+        self.assertEqual(len(data), 64)
+        xs = getx(data)
+        np.testing.assert_almost_equal(xs[:3], [1990.178230, 2005.605960, 2021.033700])
+        self.assertAlmostEqual(data[0][2], 1.30845487)
+        self.assertAlmostEqual(data[-1][3], 1.35767233)
+        np.testing.assert_equal(data.metas[:3], [[0, 0], [1, 0], [2, 0]])
+        np.testing.assert_equal(data.metas[-3:], [[5, 7], [6, 7], [7, 7]])
+
+
 class TestSpa(unittest.TestCase):
 
     def test_open(self):
@@ -537,6 +550,7 @@ def test_select_column(self):
                                 [[0.91213142, 0.89539732, 0.87925428, 0.86225812]])
         np.testing.assert_equal(getx(d), [6870, 6880, 6890, 6900])
 
+
 class TestStxmHdrXim(unittest.TestCase):
 
     def test_read(self):