Repository: wright-group/WrightTools

Issue:
add Tensor 27 dataset for testing



Discussion:

Resolving patch:
diff --git a/WrightTools/data.py b/WrightTools/data.py
--- a/WrightTools/data.py
+++ b/WrightTools/data.py
@@ -1956,10 +1956,19 @@ def zoom(self, factor, order=1, verbose=True):
 def from_Cary50(filepath, verbose=True):
     """Create a data object from a Cary 50 UV VIS absorbance file.
 
+    .. plot::
+
+        >>> import WrightTools as wt
+        >>> from WrightTools import datasets
+        >>> p = datasets.Cary50.CuPCtS_H2O_vis
+        >>> data = wt.data.from_Cary50(p)[0]
+        >>> artist = wt.artists.mpl_1D(data)
+        >>> artist.plot()
+
     Parameters
     ----------
     filepath : string
-        Path to Tensor27 output file (.dpt).
+        Path to Cary50 output file (.csv).
     verbose : boolean (optional)
         Toggle talkback. Default is True.
 
@@ -1987,6 +1996,7 @@ def from_Cary50(filepath, verbose=True):
                 clean = line[:-2]  # lines end with ',/n'
                 lines.append(np.fromstring(clean, sep=','))
     header = header.split(',')
+    lines = [i for i in lines if len(i)>0]
     arr = np.array(lines).T
     # chew through all scans
     datas = []
@@ -2862,6 +2872,18 @@ def from_shimadzu(filepath, name=None, verbose=True):
 def from_Tensor27(filepath, name=None, verbose=True):
     """Create a data object from a Tensor27 FTIR file.
 
+    .. plot::
+
+        >>> import WrightTools as wt
+        >>> import matplotlib
+        >>> from WrightTools import datasets
+        >>> p = datasets.Tensor27.CuPCtS_powder_ATR
+        >>> data = wt.data.from_Tensor27(p)
+        >>> artist = wt.artists.mpl_1D(data)
+        >>> artist.plot()
+        >>> matplotlib.pyplot.xlim(1300,1700)
+        >>> matplotlib.pyplot.ylim(-0.005,.02)
+
     Parameters
     ----------
     filepath : string
diff --git a/WrightTools/datasets/__init__.py b/WrightTools/datasets/__init__.py
--- a/WrightTools/datasets/__init__.py
+++ b/WrightTools/datasets/__init__.py
@@ -71,8 +71,14 @@ def from_directory(self, dirname, prefix=''):
 PyCMDS = DatasetContainer()
 PyCMDS.from_files('PyCMDS')
 
+Cary50 = DatasetContainer()
+Cary50.from_files('Cary50')
+
+Tensor27 = DatasetContainer()
+Tensor27.from_files('Tensor27')
+
 
 # --- pretty namespace ----------------------------------------------------------------------------
 
 
-__all__ = ['COLORS', 'JASCO', 'KENT', 'BrunoldrRaman']
+__all__ = ['COLORS', 'JASCO', 'KENT', 'BrunoldrRaman', 'Cary50', 'Tensor27']


Test patch:
diff --git a/tests/data/from_Cary50.py b/tests/data/from_Cary50.py
new file mode 100644
--- /dev/null
+++ b/tests/data/from_Cary50.py
@@ -0,0 +1,23 @@
+"""test from_Cary50"""
+
+
+# --- import --------------------------------------------------------------------------------------
+
+
+import WrightTools as wt
+from WrightTools import datasets
+
+
+# --- test ----------------------------------------------------------------------------------------
+
+
+def test_CuPCtS_H2O_vis():
+    p = datasets.Cary50.CuPCtS_H2O_vis
+    datas = wt.data.from_Cary50(p)
+
+    assert isinstance(datas, list)
+    assert len(datas) == 1
+
+    data = datas[0]
+    assert data.shape == (141,)
+    assert data.axis_names == ['wm']
diff --git a/tests/data/from_Tensor27.py b/tests/data/from_Tensor27.py
new file mode 100644
--- /dev/null
+++ b/tests/data/from_Tensor27.py
@@ -0,0 +1,18 @@
+"""test from_Tensor27"""
+
+
+# --- import --------------------------------------------------------------------------------------
+
+
+import WrightTools as wt
+from WrightTools import datasets
+
+
+# --- test ----------------------------------------------------------------------------------------
+
+
+def test_CuPCtS_powder_ATR():
+    p = datasets.Tensor27.CuPCtS_powder_ATR
+    data = wt.data.from_Tensor27(p)
+    assert data.shape == (7259,)
+    assert data.axis_names == ['w']