diff --git a/.travis.yml b/.travis.yml index 3c7b10f..da1afa8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,12 @@ language: python python: - "2.7" - - "3.2" - - "3.3" - "3.4" - "3.5" - - "3.5-dev" # 3.5 development branch - - "nightly" # currently points to 3.6-dev + - "3.6" # command to install dependencies -install: "pip install -r requirements.txt" +install: + - pip install -r requirements.txt + - pip install pytest pytest-cov pandas # command to run tests -script: ./test.py +script: py.test --cov=spc tests diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test_data/4d_map.spc b/tests/data/4d_map.spc similarity index 100% rename from test_data/4d_map.spc rename to tests/data/4d_map.spc diff --git a/test_data/BC408_5mmHorizontal.spc b/tests/data/BC408_5mmHorizontal.spc similarity index 100% rename from test_data/BC408_5mmHorizontal.spc rename to tests/data/BC408_5mmHorizontal.spc diff --git a/test_data/CAthickyellow_try4_17_ZSCAN.spc b/tests/data/CAthickyellow_try4_17_ZSCAN.spc similarity index 100% rename from test_data/CAthickyellow_try4_17_ZSCAN.spc rename to tests/data/CAthickyellow_try4_17_ZSCAN.spc diff --git a/test_data/CAthickyellow_try4_18.spc b/tests/data/CAthickyellow_try4_18.spc similarity index 100% rename from test_data/CAthickyellow_try4_18.spc rename to tests/data/CAthickyellow_try4_18.spc diff --git a/test_data/DERt3_1.spc b/tests/data/DERt3_1.spc similarity index 100% rename from test_data/DERt3_1.spc rename to tests/data/DERt3_1.spc diff --git a/test_data/DOERNER.spc b/tests/data/DOERNER.spc similarity index 100% rename from test_data/DOERNER.spc rename to tests/data/DOERNER.spc diff --git a/test_data/Ft-ir.spc b/tests/data/Ft-ir.spc similarity index 100% rename from test_data/Ft-ir.spc rename to tests/data/Ft-ir.spc diff --git a/test_data/HENE25.SPC b/tests/data/HENE25.SPC similarity index 100% rename from test_data/HENE25.SPC rename to tests/data/HENE25.SPC diff --git a/test_data/HENE27.SPC b/tests/data/HENE27.SPC similarity index 100% rename from test_data/HENE27.SPC rename to tests/data/HENE27.SPC diff --git a/test_data/KRY3.SPC b/tests/data/KRY3.SPC similarity index 100% rename from test_data/KRY3.SPC rename to tests/data/KRY3.SPC diff --git a/test_data/KRY4.SPC b/tests/data/KRY4.SPC similarity index 100% rename from test_data/KRY4.SPC rename to tests/data/KRY4.SPC diff --git a/test_data/KRY5.SPC b/tests/data/KRY5.SPC similarity index 100% rename from test_data/KRY5.SPC rename to tests/data/KRY5.SPC diff --git a/test_data/MERC.SPC b/tests/data/MERC.SPC similarity index 100% rename from test_data/MERC.SPC rename to tests/data/MERC.SPC diff --git a/test_data/NMR_FID.SPC b/tests/data/NMR_FID.SPC similarity index 100% rename from test_data/NMR_FID.SPC rename to tests/data/NMR_FID.SPC diff --git a/test_data/NMR_SPC.SPC b/tests/data/NMR_SPC.SPC similarity index 100% rename from test_data/NMR_SPC.SPC rename to tests/data/NMR_SPC.SPC diff --git a/test_data/RAMAN.SPC b/tests/data/RAMAN.SPC similarity index 100% rename from test_data/RAMAN.SPC rename to tests/data/RAMAN.SPC diff --git a/test_data/RUBY18.SPC b/tests/data/RUBY18.SPC similarity index 100% rename from test_data/RUBY18.SPC rename to tests/data/RUBY18.SPC diff --git a/test_data/TS01.SPC b/tests/data/TS01.SPC similarity index 100% rename from test_data/TS01.SPC rename to tests/data/TS01.SPC diff --git a/tests/data/__init__.py b/tests/data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test_data/kry2.spc b/tests/data/kry2.spc similarity index 100% rename from test_data/kry2.spc rename to tests/data/kry2.spc diff --git a/test_data/m_evenz.spc b/tests/data/m_evenz.spc similarity index 100% rename from test_data/m_evenz.spc rename to tests/data/m_evenz.spc diff --git a/test_data/m_ordz.spc b/tests/data/m_ordz.spc similarity index 100% rename from test_data/m_ordz.spc rename to tests/data/m_ordz.spc diff --git a/test_data/m_xyxy.spc b/tests/data/m_xyxy.spc similarity index 100% rename from test_data/m_xyxy.spc rename to tests/data/m_xyxy.spc diff --git a/test_data/ms.spc b/tests/data/ms.spc similarity index 100% rename from test_data/ms.spc rename to tests/data/ms.spc diff --git a/test_data/nir.spc b/tests/data/nir.spc similarity index 100% rename from test_data/nir.spc rename to tests/data/nir.spc diff --git a/test_data/plots2/4d_map.spc.png b/tests/data/plots2/4d_map.spc.png similarity index 100% rename from test_data/plots2/4d_map.spc.png rename to tests/data/plots2/4d_map.spc.png diff --git a/test_data/plots2/BC408_5mmHorizontal.spc.png b/tests/data/plots2/BC408_5mmHorizontal.spc.png similarity index 100% rename from test_data/plots2/BC408_5mmHorizontal.spc.png rename to tests/data/plots2/BC408_5mmHorizontal.spc.png diff --git a/test_data/plots2/CAthickyellow_try4_17_ZSCAN.spc.png b/tests/data/plots2/CAthickyellow_try4_17_ZSCAN.spc.png similarity index 100% rename from test_data/plots2/CAthickyellow_try4_17_ZSCAN.spc.png rename to tests/data/plots2/CAthickyellow_try4_17_ZSCAN.spc.png diff --git a/test_data/plots2/CAthickyellow_try4_18.spc.png b/tests/data/plots2/CAthickyellow_try4_18.spc.png similarity index 100% rename from test_data/plots2/CAthickyellow_try4_18.spc.png rename to tests/data/plots2/CAthickyellow_try4_18.spc.png diff --git a/test_data/plots2/DERt3_1.spc.png b/tests/data/plots2/DERt3_1.spc.png similarity index 100% rename from test_data/plots2/DERt3_1.spc.png rename to tests/data/plots2/DERt3_1.spc.png diff --git a/test_data/plots2/DOERNER.spc.png b/tests/data/plots2/DOERNER.spc.png similarity index 100% rename from test_data/plots2/DOERNER.spc.png rename to tests/data/plots2/DOERNER.spc.png diff --git a/test_data/plots2/Ft-ir.spc.png b/tests/data/plots2/Ft-ir.spc.png similarity index 100% rename from test_data/plots2/Ft-ir.spc.png rename to tests/data/plots2/Ft-ir.spc.png diff --git a/test_data/plots2/HENE25.SPC.png b/tests/data/plots2/HENE25.SPC.png similarity index 100% rename from test_data/plots2/HENE25.SPC.png rename to tests/data/plots2/HENE25.SPC.png diff --git a/test_data/plots2/HENE27.SPC.png b/tests/data/plots2/HENE27.SPC.png similarity index 100% rename from test_data/plots2/HENE27.SPC.png rename to tests/data/plots2/HENE27.SPC.png diff --git a/test_data/plots2/KRY3.SPC.png b/tests/data/plots2/KRY3.SPC.png similarity index 100% rename from test_data/plots2/KRY3.SPC.png rename to tests/data/plots2/KRY3.SPC.png diff --git a/test_data/plots2/KRY4.SPC.png b/tests/data/plots2/KRY4.SPC.png similarity index 100% rename from test_data/plots2/KRY4.SPC.png rename to tests/data/plots2/KRY4.SPC.png diff --git a/test_data/plots2/KRY5.SPC.png b/tests/data/plots2/KRY5.SPC.png similarity index 100% rename from test_data/plots2/KRY5.SPC.png rename to tests/data/plots2/KRY5.SPC.png diff --git a/test_data/plots2/MERC.SPC.png b/tests/data/plots2/MERC.SPC.png similarity index 100% rename from test_data/plots2/MERC.SPC.png rename to tests/data/plots2/MERC.SPC.png diff --git a/test_data/plots2/NMR_FID.SPC.png b/tests/data/plots2/NMR_FID.SPC.png similarity index 100% rename from test_data/plots2/NMR_FID.SPC.png rename to tests/data/plots2/NMR_FID.SPC.png diff --git a/test_data/plots2/NMR_SPC.SPC.png b/tests/data/plots2/NMR_SPC.SPC.png similarity index 100% rename from test_data/plots2/NMR_SPC.SPC.png rename to tests/data/plots2/NMR_SPC.SPC.png diff --git a/test_data/plots2/RAMAN.SPC.png b/tests/data/plots2/RAMAN.SPC.png similarity index 100% rename from test_data/plots2/RAMAN.SPC.png rename to tests/data/plots2/RAMAN.SPC.png diff --git a/test_data/plots2/RUBY18.SPC.png b/tests/data/plots2/RUBY18.SPC.png similarity index 100% rename from test_data/plots2/RUBY18.SPC.png rename to tests/data/plots2/RUBY18.SPC.png diff --git a/test_data/plots2/TS01.SPC.png b/tests/data/plots2/TS01.SPC.png similarity index 100% rename from test_data/plots2/TS01.SPC.png rename to tests/data/plots2/TS01.SPC.png diff --git a/tests/data/plots2/__init__.py b/tests/data/plots2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test_data/plots2/kry2.spc.png b/tests/data/plots2/kry2.spc.png similarity index 100% rename from test_data/plots2/kry2.spc.png rename to tests/data/plots2/kry2.spc.png diff --git a/test_data/plots2/m_evenz.spc.png b/tests/data/plots2/m_evenz.spc.png similarity index 100% rename from test_data/plots2/m_evenz.spc.png rename to tests/data/plots2/m_evenz.spc.png diff --git a/test_data/plots2/m_ordz.spc.png b/tests/data/plots2/m_ordz.spc.png similarity index 100% rename from test_data/plots2/m_ordz.spc.png rename to tests/data/plots2/m_ordz.spc.png diff --git a/test_data/plots2/m_xyxy.spc.png b/tests/data/plots2/m_xyxy.spc.png similarity index 100% rename from test_data/plots2/m_xyxy.spc.png rename to tests/data/plots2/m_xyxy.spc.png diff --git a/test_data/plots2/ms.spc.png b/tests/data/plots2/ms.spc.png similarity index 100% rename from test_data/plots2/ms.spc.png rename to tests/data/plots2/ms.spc.png diff --git a/test_data/plots2/nir.spc.png b/tests/data/plots2/nir.spc.png similarity index 100% rename from test_data/plots2/nir.spc.png rename to tests/data/plots2/nir.spc.png diff --git a/test_data/plots2/s_evenx.spc.png b/tests/data/plots2/s_evenx.spc.png similarity index 100% rename from test_data/plots2/s_evenx.spc.png rename to tests/data/plots2/s_evenx.spc.png diff --git a/test_data/plots2/s_xy.spc.png b/tests/data/plots2/s_xy.spc.png similarity index 100% rename from test_data/plots2/s_xy.spc.png rename to tests/data/plots2/s_xy.spc.png diff --git a/test_data/plots3/4d_map.spc.png b/tests/data/plots3/4d_map.spc.png similarity index 100% rename from test_data/plots3/4d_map.spc.png rename to tests/data/plots3/4d_map.spc.png diff --git a/test_data/plots3/BC408_5mmHorizontal.spc.png b/tests/data/plots3/BC408_5mmHorizontal.spc.png similarity index 100% rename from test_data/plots3/BC408_5mmHorizontal.spc.png rename to tests/data/plots3/BC408_5mmHorizontal.spc.png diff --git a/test_data/plots3/CAthickyellow_try4_17_ZSCAN.spc.png b/tests/data/plots3/CAthickyellow_try4_17_ZSCAN.spc.png similarity index 100% rename from test_data/plots3/CAthickyellow_try4_17_ZSCAN.spc.png rename to tests/data/plots3/CAthickyellow_try4_17_ZSCAN.spc.png diff --git a/test_data/plots3/CAthickyellow_try4_18.spc.png b/tests/data/plots3/CAthickyellow_try4_18.spc.png similarity index 100% rename from test_data/plots3/CAthickyellow_try4_18.spc.png rename to tests/data/plots3/CAthickyellow_try4_18.spc.png diff --git a/test_data/plots3/DERt3_1.spc.png b/tests/data/plots3/DERt3_1.spc.png similarity index 100% rename from test_data/plots3/DERt3_1.spc.png rename to tests/data/plots3/DERt3_1.spc.png diff --git a/test_data/plots3/DOERNER.spc.png b/tests/data/plots3/DOERNER.spc.png similarity index 100% rename from test_data/plots3/DOERNER.spc.png rename to tests/data/plots3/DOERNER.spc.png diff --git a/test_data/plots3/Ft-ir.spc.png b/tests/data/plots3/Ft-ir.spc.png similarity index 100% rename from test_data/plots3/Ft-ir.spc.png rename to tests/data/plots3/Ft-ir.spc.png diff --git a/test_data/plots3/HENE25.SPC.png b/tests/data/plots3/HENE25.SPC.png similarity index 100% rename from test_data/plots3/HENE25.SPC.png rename to tests/data/plots3/HENE25.SPC.png diff --git a/test_data/plots3/HENE27.SPC.png b/tests/data/plots3/HENE27.SPC.png similarity index 100% rename from test_data/plots3/HENE27.SPC.png rename to tests/data/plots3/HENE27.SPC.png diff --git a/test_data/plots3/KRY3.SPC.png b/tests/data/plots3/KRY3.SPC.png similarity index 100% rename from test_data/plots3/KRY3.SPC.png rename to tests/data/plots3/KRY3.SPC.png diff --git a/test_data/plots3/KRY4.SPC.png b/tests/data/plots3/KRY4.SPC.png similarity index 100% rename from test_data/plots3/KRY4.SPC.png rename to tests/data/plots3/KRY4.SPC.png diff --git a/test_data/plots3/KRY5.SPC.png b/tests/data/plots3/KRY5.SPC.png similarity index 100% rename from test_data/plots3/KRY5.SPC.png rename to tests/data/plots3/KRY5.SPC.png diff --git a/test_data/plots3/MERC.SPC.png b/tests/data/plots3/MERC.SPC.png similarity index 100% rename from test_data/plots3/MERC.SPC.png rename to tests/data/plots3/MERC.SPC.png diff --git a/test_data/plots3/NMR_FID.SPC.png b/tests/data/plots3/NMR_FID.SPC.png similarity index 100% rename from test_data/plots3/NMR_FID.SPC.png rename to tests/data/plots3/NMR_FID.SPC.png diff --git a/test_data/plots3/NMR_SPC.SPC.png b/tests/data/plots3/NMR_SPC.SPC.png similarity index 100% rename from test_data/plots3/NMR_SPC.SPC.png rename to tests/data/plots3/NMR_SPC.SPC.png diff --git a/test_data/plots3/RAMAN.SPC.png b/tests/data/plots3/RAMAN.SPC.png similarity index 100% rename from test_data/plots3/RAMAN.SPC.png rename to tests/data/plots3/RAMAN.SPC.png diff --git a/test_data/plots3/RUBY18.SPC.png b/tests/data/plots3/RUBY18.SPC.png similarity index 100% rename from test_data/plots3/RUBY18.SPC.png rename to tests/data/plots3/RUBY18.SPC.png diff --git a/test_data/plots3/TS01.SPC.png b/tests/data/plots3/TS01.SPC.png similarity index 100% rename from test_data/plots3/TS01.SPC.png rename to tests/data/plots3/TS01.SPC.png diff --git a/tests/data/plots3/__init__.py b/tests/data/plots3/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test_data/plots3/kry2.spc.png b/tests/data/plots3/kry2.spc.png similarity index 100% rename from test_data/plots3/kry2.spc.png rename to tests/data/plots3/kry2.spc.png diff --git a/test_data/plots3/m_evenz.spc.png b/tests/data/plots3/m_evenz.spc.png similarity index 100% rename from test_data/plots3/m_evenz.spc.png rename to tests/data/plots3/m_evenz.spc.png diff --git a/test_data/plots3/m_ordz.spc.png b/tests/data/plots3/m_ordz.spc.png similarity index 100% rename from test_data/plots3/m_ordz.spc.png rename to tests/data/plots3/m_ordz.spc.png diff --git a/test_data/plots3/m_xyxy.spc.png b/tests/data/plots3/m_xyxy.spc.png similarity index 100% rename from test_data/plots3/m_xyxy.spc.png rename to tests/data/plots3/m_xyxy.spc.png diff --git a/test_data/plots3/ms.spc.png b/tests/data/plots3/ms.spc.png similarity index 100% rename from test_data/plots3/ms.spc.png rename to tests/data/plots3/ms.spc.png diff --git a/test_data/plots3/nir.spc.png b/tests/data/plots3/nir.spc.png similarity index 100% rename from test_data/plots3/nir.spc.png rename to tests/data/plots3/nir.spc.png diff --git a/test_data/plots3/s_evenx.spc.png b/tests/data/plots3/s_evenx.spc.png similarity index 100% rename from test_data/plots3/s_evenx.spc.png rename to tests/data/plots3/s_evenx.spc.png diff --git a/test_data/plots3/s_xy.spc.png b/tests/data/plots3/s_xy.spc.png similarity index 100% rename from test_data/plots3/s_xy.spc.png rename to tests/data/plots3/s_xy.spc.png diff --git a/test_data/s_evenx.spc b/tests/data/s_evenx.spc similarity index 100% rename from test_data/s_evenx.spc rename to tests/data/s_evenx.spc diff --git a/test_data/s_xy.spc b/tests/data/s_xy.spc similarity index 100% rename from test_data/s_xy.spc rename to tests/data/s_xy.spc diff --git a/test_data/test_input.spc b/tests/data/test_input.spc similarity index 100% rename from test_data/test_input.spc rename to tests/data/test_input.spc diff --git a/test_data/txt/4d_map.spc.txt b/tests/data/txt/4d_map.spc.txt similarity index 100% rename from test_data/txt/4d_map.spc.txt rename to tests/data/txt/4d_map.spc.txt diff --git a/test_data/txt/CAthickyellow_try4_17_ZSCAN.spc.txt b/tests/data/txt/CAthickyellow_try4_17_ZSCAN.spc.txt similarity index 100% rename from test_data/txt/CAthickyellow_try4_17_ZSCAN.spc.txt rename to tests/data/txt/CAthickyellow_try4_17_ZSCAN.spc.txt diff --git a/test_data/txt/CAthickyellow_try4_18.spc.txt b/tests/data/txt/CAthickyellow_try4_18.spc.txt similarity index 100% rename from test_data/txt/CAthickyellow_try4_18.spc.txt rename to tests/data/txt/CAthickyellow_try4_18.spc.txt diff --git a/test_data/txt/DERt3_1.spc.txt b/tests/data/txt/DERt3_1.spc.txt similarity index 100% rename from test_data/txt/DERt3_1.spc.txt rename to tests/data/txt/DERt3_1.spc.txt diff --git a/test_data/txt/DOERNER.spc.txt b/tests/data/txt/DOERNER.spc.txt similarity index 100% rename from test_data/txt/DOERNER.spc.txt rename to tests/data/txt/DOERNER.spc.txt diff --git a/test_data/txt/Ft-ir.spc.txt b/tests/data/txt/Ft-ir.spc.txt similarity index 100% rename from test_data/txt/Ft-ir.spc.txt rename to tests/data/txt/Ft-ir.spc.txt diff --git a/test_data/txt/HENE25.SPC.txt b/tests/data/txt/HENE25.SPC.txt similarity index 100% rename from test_data/txt/HENE25.SPC.txt rename to tests/data/txt/HENE25.SPC.txt diff --git a/test_data/txt/HENE27.SPC.txt b/tests/data/txt/HENE27.SPC.txt similarity index 100% rename from test_data/txt/HENE27.SPC.txt rename to tests/data/txt/HENE27.SPC.txt diff --git a/test_data/txt/KRY3.SPC.txt b/tests/data/txt/KRY3.SPC.txt similarity index 100% rename from test_data/txt/KRY3.SPC.txt rename to tests/data/txt/KRY3.SPC.txt diff --git a/test_data/txt/KRY4.SPC.txt b/tests/data/txt/KRY4.SPC.txt similarity index 100% rename from test_data/txt/KRY4.SPC.txt rename to tests/data/txt/KRY4.SPC.txt diff --git a/test_data/txt/KRY5.SPC.txt b/tests/data/txt/KRY5.SPC.txt similarity index 100% rename from test_data/txt/KRY5.SPC.txt rename to tests/data/txt/KRY5.SPC.txt diff --git a/test_data/txt/MERC.SPC.txt b/tests/data/txt/MERC.SPC.txt similarity index 100% rename from test_data/txt/MERC.SPC.txt rename to tests/data/txt/MERC.SPC.txt diff --git a/test_data/txt/NMR_FID.SPC.txt b/tests/data/txt/NMR_FID.SPC.txt similarity index 100% rename from test_data/txt/NMR_FID.SPC.txt rename to tests/data/txt/NMR_FID.SPC.txt diff --git a/test_data/txt/NMR_SPC.SPC.txt b/tests/data/txt/NMR_SPC.SPC.txt similarity index 100% rename from test_data/txt/NMR_SPC.SPC.txt rename to tests/data/txt/NMR_SPC.SPC.txt diff --git a/test_data/txt/RAMAN.SPC.txt b/tests/data/txt/RAMAN.SPC.txt similarity index 100% rename from test_data/txt/RAMAN.SPC.txt rename to tests/data/txt/RAMAN.SPC.txt diff --git a/test_data/txt/RUBY18.SPC.txt b/tests/data/txt/RUBY18.SPC.txt similarity index 100% rename from test_data/txt/RUBY18.SPC.txt rename to tests/data/txt/RUBY18.SPC.txt diff --git a/test_data/txt/TS01.SPC.txt b/tests/data/txt/TS01.SPC.txt similarity index 100% rename from test_data/txt/TS01.SPC.txt rename to tests/data/txt/TS01.SPC.txt diff --git a/tests/data/txt/__init__.py b/tests/data/txt/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test_data/txt/kry2.spc.txt b/tests/data/txt/kry2.spc.txt similarity index 100% rename from test_data/txt/kry2.spc.txt rename to tests/data/txt/kry2.spc.txt diff --git a/test_data/txt/m_evenz.spc.txt b/tests/data/txt/m_evenz.spc.txt similarity index 100% rename from test_data/txt/m_evenz.spc.txt rename to tests/data/txt/m_evenz.spc.txt diff --git a/test_data/txt/m_ordz.spc.txt b/tests/data/txt/m_ordz.spc.txt similarity index 100% rename from test_data/txt/m_ordz.spc.txt rename to tests/data/txt/m_ordz.spc.txt diff --git a/test_data/txt/m_xyxy.spc.txt b/tests/data/txt/m_xyxy.spc.txt similarity index 100% rename from test_data/txt/m_xyxy.spc.txt rename to tests/data/txt/m_xyxy.spc.txt diff --git a/test_data/txt/ms.spc.txt b/tests/data/txt/ms.spc.txt similarity index 100% rename from test_data/txt/ms.spc.txt rename to tests/data/txt/ms.spc.txt diff --git a/test_data/txt/nir.spc.txt b/tests/data/txt/nir.spc.txt similarity index 100% rename from test_data/txt/nir.spc.txt rename to tests/data/txt/nir.spc.txt diff --git a/test_data/txt/s_evenx.spc.txt b/tests/data/txt/s_evenx.spc.txt similarity index 100% rename from test_data/txt/s_evenx.spc.txt rename to tests/data/txt/s_evenx.spc.txt diff --git a/test_data/txt/s_xy.spc.txt b/tests/data/txt/s_xy.spc.txt similarity index 100% rename from test_data/txt/s_xy.spc.txt rename to tests/data/txt/s_xy.spc.txt diff --git a/test_data/txt2/4d_map.spc.txt b/tests/data/txt2/4d_map.spc.txt similarity index 100% rename from test_data/txt2/4d_map.spc.txt rename to tests/data/txt2/4d_map.spc.txt diff --git a/test_data/txt2/BC408_5mmHorizontal.spc.txt b/tests/data/txt2/BC408_5mmHorizontal.spc.txt similarity index 100% rename from test_data/txt2/BC408_5mmHorizontal.spc.txt rename to tests/data/txt2/BC408_5mmHorizontal.spc.txt diff --git a/test_data/txt2/CAthickyellow_try4_17_ZSCAN.spc.txt b/tests/data/txt2/CAthickyellow_try4_17_ZSCAN.spc.txt similarity index 100% rename from test_data/txt2/CAthickyellow_try4_17_ZSCAN.spc.txt rename to tests/data/txt2/CAthickyellow_try4_17_ZSCAN.spc.txt diff --git a/test_data/txt2/CAthickyellow_try4_18.spc.txt b/tests/data/txt2/CAthickyellow_try4_18.spc.txt similarity index 100% rename from test_data/txt2/CAthickyellow_try4_18.spc.txt rename to tests/data/txt2/CAthickyellow_try4_18.spc.txt diff --git a/test_data/txt2/DERt3_1.spc.txt b/tests/data/txt2/DERt3_1.spc.txt similarity index 100% rename from test_data/txt2/DERt3_1.spc.txt rename to tests/data/txt2/DERt3_1.spc.txt diff --git a/test_data/txt2/DOERNER.spc.txt b/tests/data/txt2/DOERNER.spc.txt similarity index 100% rename from test_data/txt2/DOERNER.spc.txt rename to tests/data/txt2/DOERNER.spc.txt diff --git a/test_data/txt2/Ft-ir.spc.txt b/tests/data/txt2/Ft-ir.spc.txt similarity index 100% rename from test_data/txt2/Ft-ir.spc.txt rename to tests/data/txt2/Ft-ir.spc.txt diff --git a/test_data/txt2/HENE25.SPC.txt b/tests/data/txt2/HENE25.SPC.txt similarity index 100% rename from test_data/txt2/HENE25.SPC.txt rename to tests/data/txt2/HENE25.SPC.txt diff --git a/test_data/txt2/HENE27.SPC.txt b/tests/data/txt2/HENE27.SPC.txt similarity index 100% rename from test_data/txt2/HENE27.SPC.txt rename to tests/data/txt2/HENE27.SPC.txt diff --git a/test_data/txt2/KRY3.SPC.txt b/tests/data/txt2/KRY3.SPC.txt similarity index 100% rename from test_data/txt2/KRY3.SPC.txt rename to tests/data/txt2/KRY3.SPC.txt diff --git a/test_data/txt2/KRY4.SPC.txt b/tests/data/txt2/KRY4.SPC.txt similarity index 100% rename from test_data/txt2/KRY4.SPC.txt rename to tests/data/txt2/KRY4.SPC.txt diff --git a/test_data/txt2/KRY5.SPC.txt b/tests/data/txt2/KRY5.SPC.txt similarity index 100% rename from test_data/txt2/KRY5.SPC.txt rename to tests/data/txt2/KRY5.SPC.txt diff --git a/test_data/txt2/MERC.SPC.txt b/tests/data/txt2/MERC.SPC.txt similarity index 100% rename from test_data/txt2/MERC.SPC.txt rename to tests/data/txt2/MERC.SPC.txt diff --git a/test_data/txt2/NMR_FID.SPC.txt b/tests/data/txt2/NMR_FID.SPC.txt similarity index 100% rename from test_data/txt2/NMR_FID.SPC.txt rename to tests/data/txt2/NMR_FID.SPC.txt diff --git a/test_data/txt2/NMR_SPC.SPC.txt b/tests/data/txt2/NMR_SPC.SPC.txt similarity index 100% rename from test_data/txt2/NMR_SPC.SPC.txt rename to tests/data/txt2/NMR_SPC.SPC.txt diff --git a/test_data/txt2/RAMAN.SPC.txt b/tests/data/txt2/RAMAN.SPC.txt similarity index 100% rename from test_data/txt2/RAMAN.SPC.txt rename to tests/data/txt2/RAMAN.SPC.txt diff --git a/test_data/txt2/RUBY18.SPC.txt b/tests/data/txt2/RUBY18.SPC.txt similarity index 100% rename from test_data/txt2/RUBY18.SPC.txt rename to tests/data/txt2/RUBY18.SPC.txt diff --git a/test_data/txt2/TS01.SPC.txt b/tests/data/txt2/TS01.SPC.txt similarity index 100% rename from test_data/txt2/TS01.SPC.txt rename to tests/data/txt2/TS01.SPC.txt diff --git a/tests/data/txt2/__init__.py b/tests/data/txt2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test_data/txt2/kry2.spc.txt b/tests/data/txt2/kry2.spc.txt similarity index 100% rename from test_data/txt2/kry2.spc.txt rename to tests/data/txt2/kry2.spc.txt diff --git a/test_data/txt2/m_evenz.spc.txt b/tests/data/txt2/m_evenz.spc.txt similarity index 100% rename from test_data/txt2/m_evenz.spc.txt rename to tests/data/txt2/m_evenz.spc.txt diff --git a/test_data/txt2/m_ordz.spc.txt b/tests/data/txt2/m_ordz.spc.txt similarity index 100% rename from test_data/txt2/m_ordz.spc.txt rename to tests/data/txt2/m_ordz.spc.txt diff --git a/test_data/txt2/m_xyxy.spc.txt b/tests/data/txt2/m_xyxy.spc.txt similarity index 100% rename from test_data/txt2/m_xyxy.spc.txt rename to tests/data/txt2/m_xyxy.spc.txt diff --git a/test_data/txt2/ms.spc.txt b/tests/data/txt2/ms.spc.txt similarity index 100% rename from test_data/txt2/ms.spc.txt rename to tests/data/txt2/ms.spc.txt diff --git a/test_data/txt2/nir.spc.txt b/tests/data/txt2/nir.spc.txt similarity index 100% rename from test_data/txt2/nir.spc.txt rename to tests/data/txt2/nir.spc.txt diff --git a/test_data/txt2/s_evenx.spc.txt b/tests/data/txt2/s_evenx.spc.txt similarity index 100% rename from test_data/txt2/s_evenx.spc.txt rename to tests/data/txt2/s_evenx.spc.txt diff --git a/test_data/txt2/s_xy.spc.txt b/tests/data/txt2/s_xy.spc.txt similarity index 100% rename from test_data/txt2/s_xy.spc.txt rename to tests/data/txt2/s_xy.spc.txt diff --git a/test_data/txt2/test_input.spc.txt b/tests/data/txt2/test_input.spc.txt similarity index 100% rename from test_data/txt2/test_input.spc.txt rename to tests/data/txt2/test_input.spc.txt diff --git a/test_data/txt3/4d_map.spc.txt b/tests/data/txt3/4d_map.spc.txt similarity index 100% rename from test_data/txt3/4d_map.spc.txt rename to tests/data/txt3/4d_map.spc.txt diff --git a/test_data/txt3/BC408_5mmHorizontal.spc.txt b/tests/data/txt3/BC408_5mmHorizontal.spc.txt similarity index 100% rename from test_data/txt3/BC408_5mmHorizontal.spc.txt rename to tests/data/txt3/BC408_5mmHorizontal.spc.txt diff --git a/test_data/txt3/CAthickyellow_try4_17_ZSCAN.spc.txt b/tests/data/txt3/CAthickyellow_try4_17_ZSCAN.spc.txt similarity index 100% rename from test_data/txt3/CAthickyellow_try4_17_ZSCAN.spc.txt rename to tests/data/txt3/CAthickyellow_try4_17_ZSCAN.spc.txt diff --git a/test_data/txt3/CAthickyellow_try4_18.spc.txt b/tests/data/txt3/CAthickyellow_try4_18.spc.txt similarity index 100% rename from test_data/txt3/CAthickyellow_try4_18.spc.txt rename to tests/data/txt3/CAthickyellow_try4_18.spc.txt diff --git a/test_data/txt3/DERt3_1.spc.txt b/tests/data/txt3/DERt3_1.spc.txt similarity index 100% rename from test_data/txt3/DERt3_1.spc.txt rename to tests/data/txt3/DERt3_1.spc.txt diff --git a/test_data/txt3/DOERNER.spc.txt b/tests/data/txt3/DOERNER.spc.txt similarity index 100% rename from test_data/txt3/DOERNER.spc.txt rename to tests/data/txt3/DOERNER.spc.txt diff --git a/test_data/txt3/Ft-ir.spc.txt b/tests/data/txt3/Ft-ir.spc.txt similarity index 100% rename from test_data/txt3/Ft-ir.spc.txt rename to tests/data/txt3/Ft-ir.spc.txt diff --git a/test_data/txt3/HENE25.SPC.txt b/tests/data/txt3/HENE25.SPC.txt similarity index 100% rename from test_data/txt3/HENE25.SPC.txt rename to tests/data/txt3/HENE25.SPC.txt diff --git a/test_data/txt3/HENE27.SPC.txt b/tests/data/txt3/HENE27.SPC.txt similarity index 100% rename from test_data/txt3/HENE27.SPC.txt rename to tests/data/txt3/HENE27.SPC.txt diff --git a/test_data/txt3/KRY3.SPC.txt b/tests/data/txt3/KRY3.SPC.txt similarity index 100% rename from test_data/txt3/KRY3.SPC.txt rename to tests/data/txt3/KRY3.SPC.txt diff --git a/test_data/txt3/KRY4.SPC.txt b/tests/data/txt3/KRY4.SPC.txt similarity index 100% rename from test_data/txt3/KRY4.SPC.txt rename to tests/data/txt3/KRY4.SPC.txt diff --git a/test_data/txt3/KRY5.SPC.txt b/tests/data/txt3/KRY5.SPC.txt similarity index 100% rename from test_data/txt3/KRY5.SPC.txt rename to tests/data/txt3/KRY5.SPC.txt diff --git a/test_data/txt3/MERC.SPC.txt b/tests/data/txt3/MERC.SPC.txt similarity index 100% rename from test_data/txt3/MERC.SPC.txt rename to tests/data/txt3/MERC.SPC.txt diff --git a/test_data/txt3/NMR_FID.SPC.txt b/tests/data/txt3/NMR_FID.SPC.txt similarity index 100% rename from test_data/txt3/NMR_FID.SPC.txt rename to tests/data/txt3/NMR_FID.SPC.txt diff --git a/test_data/txt3/NMR_SPC.SPC.txt b/tests/data/txt3/NMR_SPC.SPC.txt similarity index 100% rename from test_data/txt3/NMR_SPC.SPC.txt rename to tests/data/txt3/NMR_SPC.SPC.txt diff --git a/test_data/txt3/RAMAN.SPC.txt b/tests/data/txt3/RAMAN.SPC.txt similarity index 100% rename from test_data/txt3/RAMAN.SPC.txt rename to tests/data/txt3/RAMAN.SPC.txt diff --git a/test_data/txt3/RUBY18.SPC.txt b/tests/data/txt3/RUBY18.SPC.txt similarity index 100% rename from test_data/txt3/RUBY18.SPC.txt rename to tests/data/txt3/RUBY18.SPC.txt diff --git a/test_data/txt3/TS01.SPC.txt b/tests/data/txt3/TS01.SPC.txt similarity index 100% rename from test_data/txt3/TS01.SPC.txt rename to tests/data/txt3/TS01.SPC.txt diff --git a/tests/data/txt3/__init__.py b/tests/data/txt3/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test_data/txt3/kry2.spc.txt b/tests/data/txt3/kry2.spc.txt similarity index 100% rename from test_data/txt3/kry2.spc.txt rename to tests/data/txt3/kry2.spc.txt diff --git a/test_data/txt3/m_evenz.spc.txt b/tests/data/txt3/m_evenz.spc.txt similarity index 100% rename from test_data/txt3/m_evenz.spc.txt rename to tests/data/txt3/m_evenz.spc.txt diff --git a/test_data/txt3/m_ordz.spc.txt b/tests/data/txt3/m_ordz.spc.txt similarity index 100% rename from test_data/txt3/m_ordz.spc.txt rename to tests/data/txt3/m_ordz.spc.txt diff --git a/test_data/txt3/m_xyxy.spc.txt b/tests/data/txt3/m_xyxy.spc.txt similarity index 100% rename from test_data/txt3/m_xyxy.spc.txt rename to tests/data/txt3/m_xyxy.spc.txt diff --git a/test_data/txt3/ms.spc.txt b/tests/data/txt3/ms.spc.txt similarity index 100% rename from test_data/txt3/ms.spc.txt rename to tests/data/txt3/ms.spc.txt diff --git a/test_data/txt3/nir.spc.txt b/tests/data/txt3/nir.spc.txt similarity index 100% rename from test_data/txt3/nir.spc.txt rename to tests/data/txt3/nir.spc.txt diff --git a/test_data/txt3/s_evenx.spc.txt b/tests/data/txt3/s_evenx.spc.txt similarity index 100% rename from test_data/txt3/s_evenx.spc.txt rename to tests/data/txt3/s_evenx.spc.txt diff --git a/test_data/txt3/s_xy.spc.txt b/tests/data/txt3/s_xy.spc.txt similarity index 100% rename from test_data/txt3/s_xy.spc.txt rename to tests/data/txt3/s_xy.spc.txt diff --git a/tests/test_spc.py b/tests/test_spc.py new file mode 100644 index 0000000..8f76bf1 --- /dev/null +++ b/tests/test_spc.py @@ -0,0 +1,108 @@ +import os +from os.path import join, dirname + +import numpy as np +import pandas as pd +from numpy.testing import assert_allclose + +import spc + + +def _list_all_spc_files(): + """List the spc files in the data folders.""" + path_data = join(dirname(__file__), 'data') + filenames = [filename + for filename in os.listdir(path_data) + if filename.lower().endswith('spc')] + return filenames + + +def _split_data(spc_file): + """Reorganize into numpy format the data depending of the format. + + Parameters + ---------- + spc_file : spc.File + The spc.File object to be reorganized to ease the testing. + + Returns + ------- + X : ndarray, shape (n_spectra, n_frequency) or (n_frequency,) + The x axis. + + Y : ndarray shape (n_spectra, n_frequency) + The y axis. + + """ + if (spc_file.dat_fmt == 'gx-y' or + spc_file.dat_fmt == 'x-y'): + X = spc_file.x + elif spc_file.dat_fmt == '-xy': + X = np.array([f.x for f in spc_file.sub]) + Y = np.array([f.y for f in spc_file.sub]) + + return X, Y + + +def _read_expected_file(spc_filename, spc_file_format): + """Reorganize into numpy format the data depending of the format. + + Parameters + ---------- + spc_filename : str + The filename of the SPC file which will be checked. + + spc_file_format : str + The format of the SPC file: '-xy', 'x-y', or 'gx-y'. + + Returns + ------- + X : ndarray, shape (n_spectra, n_frequency) or (n_frequency,) + The x axis. + + Y : ndarray shape (n_spectra, n_frequency) + The y axis. + + """ + path_data = join(dirname(__file__), 'data', 'txt2') + data_expected = pd.read_csv(join(path_data, spc_filename + '.txt'), + sep='\t', header=None, skip_blank_lines=False) + if (spc_file_format == 'gx-y' or + spc_file_format == 'x-y'): + X = data_expected.iloc[:, 0].values.T + Y = data_expected.iloc[:, 1:].values.T + elif spc_file_format == '-xy': + data_expected['group_no'] = data_expected.isnull().all(axis=1).cumsum() + # split into a list of DataFrames + data_expected = [ + (data_expected.loc[data_expected['group_no'] == i, + [0, 1]]).dropna() + for i in range(data_expected['group_no'].iloc[-1])] + X, Y = [], [] + for df in data_expected: + X.append(df.iloc[:, 0].values.T) + Y.append(df.iloc[:, 1].values.T) + X = np.array(X) + Y = np.array(Y) + + return X, Y + + +def test_spc(): + filenames_spc = _list_all_spc_files() + + for filename in filenames_spc: + path_data = join(dirname(__file__), 'data') + file_spc = spc.File(join(path_data, filename)) + X, Y = _split_data(file_spc) + X_expected, Y_expected = _read_expected_file(filename, + file_spc.dat_fmt) + if file_spc.dat_fmt == '-xy': + for x, y, x_expected, y_expected in zip(X, Y, + X_expected, + Y_expected): + assert_allclose(x, x_expected) + assert_allclose(y, y_expected) + else: + assert_allclose(X, X_expected) + assert_allclose(Y, Y_expected)