diff --git a/Pipfile b/Pipfile index 4eb535f3cea4a06f8911dba3c64abddd87b204a6..0f7a0d51e3d4020eef79b44ec5965c22d3f06d9a 100644 --- a/Pipfile +++ b/Pipfile @@ -5,6 +5,7 @@ verify_ssl = true [dev-packages] recommonmark = "*" +docutils = "!=0.16b0" sphinx-markdown-tables = "*" pytest = "*" pytest-cov = ">=2.5.1" @@ -12,7 +13,7 @@ sphinx-rtd-theme = "*" twine = "*" mypy = "*" pylint = "*" -Sphinx = "*" +sphinx = "*" pipenv = "*" black = "*" pre-commit = "*" @@ -42,6 +43,7 @@ six = ">=1.12.0" python-dateutil = ">=2.7.5" eml-parser = ">=1.11" DateTime = "*" +docutils = "==0.15.2" [pipenv] allow_prereleases = true diff --git a/Pipfile.lock b/Pipfile.lock index f03c74f0af000fdfe24c28173977dcce672330fd..3a12011d991b505f1e9de9df56ed21ac8926d4a8 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "1f9f4c79edffec103091153771441bcfc05f753e3d2956655047de304ded1095" + "sha256": "f299b4e9164a13ece2c350e6f4f89b382af1ee8ad67652e7d0689d61337fbc25" }, "pipfile-spec": 6, "requires": {}, @@ -78,6 +78,15 @@ "index": "pypi", "version": "==0.3.1.1" }, + "docutils": { + "hashes": [ + "sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0", + "sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827", + "sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99" + ], + "index": "pypi", + "version": "==0.15.2" + }, "eml-parser": { "hashes": [ "sha256:726a0b972c23c1ca44311abd22308684cc9f05744d426b8d127b2fae0f85e501", @@ -443,6 +452,14 @@ ], "version": "==1.4.3" }, + "appnope": { + "hashes": [ + "sha256:5b26757dc6f79a3b7dc9fab95359328d5747fcb2409d331ea66d0272b90ab2a0", + "sha256:8b995ffe925347a2138d7ac0fe77155e4311a0ea6d6da4f5128fe4b3cbe5ed71" + ], + "markers": "sys_platform == 'darwin'", + "version": "==0.1.0" + }, "aspy.refactor-imports": { "hashes": [ "sha256:6d465c18cadad7e5a87810ecf8e516cb6f78e91871f4f55d0f228c6c376bd16a", @@ -514,44 +531,6 @@ ], "version": "==2019.11.28" }, - "cffi": { - "hashes": [ - "sha256:0b49274afc941c626b605fb59b59c3485c17dc776dc3cc7cc14aca74cc19cc42", - "sha256:0e3ea92942cb1168e38c05c1d56b0527ce31f1a370f6117f1d490b8dcd6b3a04", - "sha256:135f69aecbf4517d5b3d6429207b2dff49c876be724ac0c8bf8e1ea99df3d7e5", - "sha256:19db0cdd6e516f13329cba4903368bff9bb5a9331d3410b1b448daaadc495e54", - "sha256:2781e9ad0e9d47173c0093321bb5435a9dfae0ed6a762aabafa13108f5f7b2ba", - "sha256:291f7c42e21d72144bb1c1b2e825ec60f46d0a7468f5346841860454c7aa8f57", - "sha256:2c5e309ec482556397cb21ede0350c5e82f0eb2621de04b2633588d118da4396", - "sha256:2e9c80a8c3344a92cb04661115898a9129c074f7ab82011ef4b612f645939f12", - "sha256:32a262e2b90ffcfdd97c7a5e24a6012a43c61f1f5a57789ad80af1d26c6acd97", - "sha256:3c9fff570f13480b201e9ab69453108f6d98244a7f495e91b6c654a47486ba43", - "sha256:415bdc7ca8c1c634a6d7163d43fb0ea885a07e9618a64bda407e04b04333b7db", - "sha256:42194f54c11abc8583417a7cf4eaff544ce0de8187abaf5d29029c91b1725ad3", - "sha256:4424e42199e86b21fc4db83bd76909a6fc2a2aefb352cb5414833c030f6ed71b", - "sha256:4a43c91840bda5f55249413037b7a9b79c90b1184ed504883b72c4df70778579", - "sha256:599a1e8ff057ac530c9ad1778293c665cb81a791421f46922d80a86473c13346", - "sha256:5c4fae4e9cdd18c82ba3a134be256e98dc0596af1e7285a3d2602c97dcfa5159", - "sha256:5ecfa867dea6fabe2a58f03ac9186ea64da1386af2159196da51c4904e11d652", - "sha256:62f2578358d3a92e4ab2d830cd1c2049c9c0d0e6d3c58322993cc341bdeac22e", - "sha256:6471a82d5abea994e38d2c2abc77164b4f7fbaaf80261cb98394d5793f11b12a", - "sha256:6d4f18483d040e18546108eb13b1dfa1000a089bcf8529e30346116ea6240506", - "sha256:71a608532ab3bd26223c8d841dde43f3516aa5d2bf37b50ac410bb5e99053e8f", - "sha256:74a1d8c85fb6ff0b30fbfa8ad0ac23cd601a138f7509dc617ebc65ef305bb98d", - "sha256:7b93a885bb13073afb0aa73ad82059a4c41f4b7d8eb8368980448b52d4c7dc2c", - "sha256:7d4751da932caaec419d514eaa4215eaf14b612cff66398dd51129ac22680b20", - "sha256:7f627141a26b551bdebbc4855c1157feeef18241b4b8366ed22a5c7d672ef858", - "sha256:8169cf44dd8f9071b2b9248c35fc35e8677451c52f795daa2bb4643f32a540bc", - "sha256:aa00d66c0fab27373ae44ae26a66a9e43ff2a678bf63a9c7c1a9a4d61172827a", - "sha256:ccb032fda0873254380aa2bfad2582aedc2959186cce61e3a17abc1a55ff89c3", - "sha256:d754f39e0d1603b5b24a7f8484b22d2904fa551fe865fd0d4c3332f078d20d4e", - "sha256:d75c461e20e29afc0aee7172a0950157c704ff0dd51613506bd7d82b718e7410", - "sha256:dcd65317dd15bc0451f3e01c80da2216a31916bdcffd6221ca1202d96584aa25", - "sha256:e570d3ab32e2c2861c4ebe6ffcad6a8abf9347432a37608fe1fbd157b3f0036b", - "sha256:fd43a88e045cf992ed09fa724b5315b790525f2676883a6ea64e3263bae6549d" - ], - "version": "==1.13.2" - }, "cfgv": { "hashes": [ "sha256:edb387943b665bf9c434f717bf630fa78aecd53d5900d2e05da6ad6048553144", @@ -616,32 +595,6 @@ ], "version": "==5.0" }, - "cryptography": { - "hashes": [ - "sha256:02079a6addc7b5140ba0825f542c0869ff4df9a69c360e339ecead5baefa843c", - "sha256:1df22371fbf2004c6f64e927668734070a8953362cd8370ddd336774d6743595", - "sha256:369d2346db5934345787451504853ad9d342d7f721ae82d098083e1f49a582ad", - "sha256:3cda1f0ed8747339bbdf71b9f38ca74c7b592f24f65cdb3ab3765e4b02871651", - "sha256:44ff04138935882fef7c686878e1c8fd80a723161ad6a98da31e14b7553170c2", - "sha256:4b1030728872c59687badcca1e225a9103440e467c17d6d1730ab3d2d64bfeff", - "sha256:58363dbd966afb4f89b3b11dfb8ff200058fbc3b947507675c19ceb46104b48d", - "sha256:6ec280fb24d27e3d97aa731e16207d58bd8ae94ef6eab97249a2afe4ba643d42", - "sha256:7270a6c29199adc1297776937a05b59720e8a782531f1f122f2eb8467f9aab4d", - "sha256:73fd30c57fa2d0a1d7a49c561c40c2f79c7d6c374cc7750e9ac7c99176f6428e", - "sha256:7f09806ed4fbea8f51585231ba742b58cbcfbfe823ea197d8c89a5e433c7e912", - "sha256:90df0cc93e1f8d2fba8365fb59a858f51a11a394d64dbf3ef844f783844cc793", - "sha256:971221ed40f058f5662a604bd1ae6e4521d84e6cad0b7b170564cc34169c8f13", - "sha256:a518c153a2b5ed6b8cc03f7ae79d5ffad7315ad4569b2d5333a13c38d64bd8d7", - "sha256:b0de590a8b0979649ebeef8bb9f54394d3a41f66c5584fff4220901739b6b2f0", - "sha256:b43f53f29816ba1db8525f006fa6f49292e9b029554b3eb56a189a70f2a40879", - "sha256:d31402aad60ed889c7e57934a03477b572a03af7794fa8fb1780f21ea8f6551f", - "sha256:de96157ec73458a7f14e3d26f17f8128c959084931e8997b9e655a39c8fde9f9", - "sha256:df6b4dca2e11865e6cfbfb708e800efb18370f5a46fd601d3755bc7f85b3a8a2", - "sha256:ecadccc7ba52193963c0475ac9f6fa28ac01e01349a2ca48509667ef41ffd2cf", - "sha256:fb81c17e0ebe3358486cd8cc3ad78adbae58af12fc2bf2bc0bb84e8090fa5ce8" - ], - "version": "==2.8" - }, "decorator": { "hashes": [ "sha256:54c38050039232e1db4ad7375cfce6748d7b41c29e95a081c8a6d2c30364a2ce", @@ -651,10 +604,12 @@ }, "docutils": { "hashes": [ - "sha256:7a6228589435302e421f5c473ce0180878b90f70227f7174cacde5efbd34275f", - "sha256:f1bad547016f945f7b35b28d8bead307821822ca3f8d4f87a1bd2ad1a8faab51" + "sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0", + "sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827", + "sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99" ], - "version": "==0.16b0.dev0" + "index": "pypi", + "version": "==0.15.2" }, "identify": { "hashes": [ @@ -677,6 +632,14 @@ ], "version": "==1.1.0" }, + "importlib-metadata": { + "hashes": [ + "sha256:073a852570f92da5f744a3472af1b61e28e9f78ccf0c9117658dc32b15de7b45", + "sha256:d95141fbfa7ef2ec65cfd945e2af7e5a6ddbd7c8d9a25e66ff3be8e3daf9f60f" + ], + "markers": "python_version < '3.8'", + "version": "==1.3.0" + }, "ipython": { "hashes": [ "sha256:190a279bd3d4fc585a611e9358a88f1048cc57fd688254a86f9461889ee152a6", @@ -707,13 +670,6 @@ ], "version": "==0.15.1" }, - "jeepney": { - "hashes": [ - "sha256:13806f91a96e9b2623fd2a81b950d763ee471454aafd9eb6d75dbe7afce428fb", - "sha256:f6a3f93464a0cf052f4e87da3c8b3ed1e27696758fb9739c63d3a74d9a1b6774" - ], - "version": "==0.4.1" - }, "jinja2": { "hashes": [ "sha256:74320bb91f31270f9551d46522e33af46a80c3d619f4a4bf42b3164d30b5911f", @@ -928,12 +884,6 @@ ], "version": "==1.8.0" }, - "pycparser": { - "hashes": [ - "sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3" - ], - "version": "==2.19" - }, "pydocstyle": { "hashes": [ "sha256:4167fe954b8f27ebbbef2fbcf73c6e8ad1e7bb31488fce44a69fdfc4b0cd0fae", @@ -1059,14 +1009,6 @@ "index": "pypi", "version": "==0.14.0" }, - "secretstorage": { - "hashes": [ - "sha256:20c797ae48a4419f66f8d28fc221623f11fc45b6828f96bdb1ad9990acb59f92", - "sha256:7a119fb52a88e398dbb22a4b3eb39b779bfbace7e4153b7bc6e5954d86282a8a" - ], - "markers": "sys_platform == 'linux'", - "version": "==3.1.1" - }, "seed-isort-config": { "hashes": [ "sha256:3e7c194d6322bfd15827640b85ddefbfcb205407530ebff5298700ae88d2397d", @@ -1208,6 +1150,7 @@ "sha256:fdc1c9bbf79510b76408840e009ed65958feba92a88833cdceecff93ae8fff66", "sha256:ffde2fbfad571af120fcbfbbc61c72469e72f550d676c3342492a9dfdefb8f12" ], + "markers": "implementation_name == 'cpython' and python_version < '3.8'", "version": "==1.4.0" }, "typing-extensions": { @@ -1258,6 +1201,13 @@ "sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1" ], "version": "==1.11.2" + }, + "zipp": { + "hashes": [ + "sha256:3718b1cbcd963c7d4c5511a8240812904164b7f381b647143a89d3b98f9bcd8e", + "sha256:f06903e9f1f43b12d371004b4ac7b06ab39a44adc747266928ae6debfa7b3335" + ], + "version": "==0.6.0" } } } diff --git a/src/openqlab/io/importers/ascii.py b/src/openqlab/io/importers/ascii.py index a0d5bbbfabe7fa9ee55b8fe47276bca86d6a0dd2..78912acdd7577e1642f7130e253010dbc0acfe7e 100644 --- a/src/openqlab/io/importers/ascii.py +++ b/src/openqlab/io/importers/ascii.py @@ -29,16 +29,11 @@ class ASCII(StreamImporter): raise utils.UnknownFileType( f"'{self.NAME}' importer: expected plain numeric ASCII" ) + self._stream.seek(0) def read(self): data = self._read_data() output = DataContainer(data) - if output.empty: - raise utils.ImportFailed( - f"'{self.NAME}' importer: \ - Did not find any valid data \ - in file '{self._stream.name}'" - ) return output def _read_data(self): diff --git a/src/openqlab/io/importers/ascii_header.py b/src/openqlab/io/importers/ascii_header.py index 89bf19a9a52ce616d3e6d666a2a9b56dbebd3eb0..e882b84e021cc449bbcf8b5fc6b8f4586750ea5c 100644 --- a/src/openqlab/io/importers/ascii_header.py +++ b/src/openqlab/io/importers/ascii_header.py @@ -6,7 +6,6 @@ import pandas as pd from openqlab.io.base_importer import StreamImporter from openqlab.io.data_container import DataContainer -from openqlab.io.importers import utils class ASCII_Header(StreamImporter): @@ -42,15 +41,9 @@ class ASCII_Header(StreamImporter): continue match = re.match(rf"^{self.HEADER_ESCAPE}\s*", line) if match: - try: - split = re.split(self.LINE_SPLIT, line[match.end() :], maxsplit=1) - keyword, value = re.split( - self.LINE_SPLIT, line[match.end() :], maxsplit=1 - ) - except ValueError: - raise utils.UnknownFileType( - f"'{self.NAME}' importer: Could not parse header in file '{self._stream.name}'" - ) + keyword, value = re.split( + self.LINE_SPLIT, line[match.end() :], maxsplit=1 + ) self._header[keyword] = value.strip() continue if not re.match(r"[-+]*\d+", line): diff --git a/src/openqlab/io/importers/data_container_csv.py b/src/openqlab/io/importers/data_container_csv.py index 5b7252e669a42cad7d840872a1480c881048284b..82bc14e1270e06ad1c44d7dc028b499a3659c569 100644 --- a/src/openqlab/io/importers/data_container_csv.py +++ b/src/openqlab/io/importers/data_container_csv.py @@ -1,6 +1,5 @@ from openqlab.io.base_importer import StreamImporter from openqlab.io.data_container import DataContainer -from openqlab.io.importers import utils class DataContainerCSV(StreamImporter): @@ -11,9 +10,4 @@ class DataContainerCSV(StreamImporter): def read(self): self._stream.seek(0) output = DataContainer.from_csv(self._stream, parse_dates=True) - if output.empty: - raise utils.ImportFailed( - f"'{self.NAME}' importer: Did not find any valid data\ - in file '{self._stream.name}'" - ) return output diff --git a/src/openqlab/io/importers/gwinstek.py b/src/openqlab/io/importers/gwinstek.py index ac4675b569ddae9a76609a4f152e334189d6769f..16068ea0f4892612e2fe42ff2dd7c1ad0a934ccb 100644 --- a/src/openqlab/io/importers/gwinstek.py +++ b/src/openqlab/io/importers/gwinstek.py @@ -79,7 +79,6 @@ class Gwinstek(StreamImporter): if mode == "Detail": index, data = self._data.iloc[:, 2 * ii : 2 * ii + 2].values.T - print(data) if mode == "Fast": x_offset = header["xOffset"] @@ -107,42 +106,3 @@ class Gwinstek(StreamImporter): traces = [self._read_trace(n) for n in range(self.num_traces)] return DataContainer.concat(traces, axis=1) - - # xlabel = 'Time' - # try: - # mode = self._header['Mode'] - # num_traces = self._header['NumTraces'] - # num_points = self._header['NumPoints'] - # x_offset = self._header['xOffset'] - # start = - self._header['xScale'] * 10 / 2 + x_offset - # stop = self._header['xScale'] * 10 / 2 + x_offset - # if self._header['xUnit'] == 'S': - # self._header['xUnit'] = 's' - # except KeyError: - # raise utils.ImportFailed( - # f"'{self.NAME}' importer: could not gather necessary information in file '{self._stream.name}'") - # - # ylabel = utils.get_file_basename(self._stream.name) - # ylabels = [f'{ylabel}_{trace_num}' for trace_num in range(1, num_traces + 1)] - # if mode == 'Detail': - # names = [xlabel] + ylabels - # usecols = [0, 1] + list(range(3, 2 * num_traces + 1, 2)) - # output = pd.read_csv(self._stream, sep=',', index_col=0, usecols=usecols, prefix=ylabel + '_', header=None) - # output.index.name = xlabel - # output.columns = ylabels - # elif mode == 'Fast': - # names = ylabels - # usecols = list(range(0, 2 * num_traces - 1, 2)) - # x = np.linspace(start, stop, endpoint=False, num=num_points) - # output = pd.read_csv(self._stream, sep=',', usecols=usecols, - # names=names, header=None, skipinitialspace=True) - # output = output * (self._header['yScale']) / 25 - # if output.empty: - # raise EmptyDataError( - # f"'{self.NAME}' importer: Did not find any valid data in file '{self._stream.name}'") - # output.index = x - # output.index.name = xlabel - # else: - # raise utils.ImportFailed( - # f"'{self.NAME}' importer: expected save modes {self.SAVEMODES} not found in file '{self._stream.name}'") - # return output diff --git a/src/openqlab/io/importers/gwinstek_lsf.py b/src/openqlab/io/importers/gwinstek_lsf.py index 317ac8d68f8d95ff2f539a3363603715e2670711..b303ee2d66c915e167c65296f5751d0ef78e0dee 100644 --- a/src/openqlab/io/importers/gwinstek_lsf.py +++ b/src/openqlab/io/importers/gwinstek_lsf.py @@ -75,7 +75,7 @@ class Gwinstek_LSF(StreamImporter): ) digits = int(struct.unpack("c", self._stream.read(1))[0]) - num_points = int(self._stream.read(digits)) // 2 + self._stream.read(digits) y_scale = self._header["yScale"] / 25 y_offset = self._header["yOffset"] / y_scale + 128 @@ -86,10 +86,4 @@ class Gwinstek_LSF(StreamImporter): data.index.name = xlabel data = (data - y_offset) * y_scale - if not len(data) == num_points: - raise utils.ImportFailed( - f"'{self.NAME}' importer: Data length should be {num_points}," - f" but the real length is {len(data)}.] in '{self._stream.name}'" - ) - return data diff --git a/src/openqlab/io/importers/hp4395a.py b/src/openqlab/io/importers/hp4395a.py index 87dad5e6c79a0fa4d4863e28951ff383c321fdd7..38dc63a7323ab9fd077a58bc9cc8a0807651a0f1 100644 --- a/src/openqlab/io/importers/hp4395a.py +++ b/src/openqlab/io/importers/hp4395a.py @@ -23,7 +23,6 @@ class HP4395A(StreamImporter): channel = 0 channels: List = [] filename = Path(self._stream.name).stem - print(filename) line = True while line: diff --git a/src/openqlab/io/importers/rhode_schwarz.py b/src/openqlab/io/importers/rhode_schwarz.py index d89877edbb45e1d0596c8e3a2fa9a8db882d41cb..ec129fde817841d736d463f14c57a242ce2ac609 100644 --- a/src/openqlab/io/importers/rhode_schwarz.py +++ b/src/openqlab/io/importers/rhode_schwarz.py @@ -61,7 +61,7 @@ class RhodeSchwarz(StreamImporter): elif x_unit == "Hz": xlabel = "Frequency" else: - xlabel = "x" + xlabel = "x" # pragma: no cover except KeyError: xlabel = "x" diff --git a/src/tests/test_analysis/test_cavity/test_finesse.py b/src/tests/test_analysis/test_cavity/test_finesse.py index 99069dd770e1552b13f5ba86e3200df7879ce7d5..b18819b727085078cdbb2194d18ae9cf34cffe68 100644 --- a/src/tests/test_analysis/test_cavity/test_finesse.py +++ b/src/tests/test_analysis/test_cavity/test_finesse.py @@ -21,3 +21,7 @@ class TestFinesse(unittest.TestCase): def test_finesse_plot(self): finesse(self.data["opo_scan_2"], plot=True) + + def test_finesse_two_columns(self): + with self.assertRaises(ValueError): + finesse(self.data[["opo_scan_1", "opo_scan_2"]], plot=True) diff --git a/src/tests/test_conversion/test_db/test_db.py b/src/tests/test_conversion/test_db/test_db.py index 35036e0691adf8a086652db42e50312d491bbe1c..6e4f204682d8cbe24619e7117f78e5afe5b344b4 100644 --- a/src/tests/test_conversion/test_db/test_db.py +++ b/src/tests/test_conversion/test_db/test_db.py @@ -54,3 +54,8 @@ class TestDB(unittest.TestCase): ) np.testing.assert_array_almost_equal(db.dBm2Vrms(dbm_data), dbv_data, decimal=3) + + def test_average_deprecated(self): + with self.assertWarns(DeprecationWarning): + lin_data = np.array([1, 2, 3, 4, 5, 6, 7]) + db.average(lin_data) diff --git a/src/tests/test_conversion/test_utils/test_human_readable.py b/src/tests/test_conversion/test_utils/test_human_readable.py index e62cf46f79564afb5e6d6006b4502681aca416d9..eb449ed690534e3663d2ecff288b722a2fe11a6f 100644 --- a/src/tests/test_conversion/test_utils/test_human_readable.py +++ b/src/tests/test_conversion/test_utils/test_human_readable.py @@ -3,7 +3,7 @@ import unittest from openqlab.conversion.utils import human_readable -class TestModematching(unittest.TestCase): +class TestHumanReadable(unittest.TestCase): def setUp(self): pass diff --git a/src/tests/test_io/test___init__/test_read.py b/src/tests/test_io/test___init__/test_read.py index c9cbec729e67fdb0926ba99449c9d4af7ef28c20..37fe0fc463ed4f2800eda644dbac65a3ee92eb8a 100644 --- a/src/tests/test_io/test___init__/test_read.py +++ b/src/tests/test_io/test___init__/test_read.py @@ -13,8 +13,8 @@ class TestRead(unittest.TestCase): Test files starting with a dot (".") will be ignored. """ - files_path = Path(fr"{filedir}/../test_importers/data_files") - gzip_files_path = Path(fr"{filedir}/gzip_data_files") + files_path = filedir / "../test_importers/data_files" + gzip_files_path = filedir / "gzip_data_files" @classmethod def setUpClass(cls): @@ -27,21 +27,13 @@ class TestRead(unittest.TestCase): cls.files = [file for file in cls.files if not file.stem.startswith(".")] cls.binary_files = [ - Path( - fr"{filedir}/../test_importers/data_files/KeysightBinary/keysight_binary.bin" - ), - Path( - fr"{filedir}/../test_importers/data_files/TektronixSpectrogram/test2.mat" - ), + filedir / "../test_importers/data_files/KeysightBinary/keysight_binary.bin", + filedir / "../test_importers/data_files/TektronixSpectrogram/test2.mat", ] cls.ignore_text_files = [ - Path( - fr"{filedir}/../test_importers/data_files/KeysightFRA/scope_0_comma.csv" - ), - Path( - fr"{filedir}/../test_importers/data_files/KeysightFRA/scope_1_semicolon.csv" - ), + filedir / "../test_importers/data_files/KeysightFRA/scope_0_comma.csv", + filedir / "../test_importers/data_files/KeysightFRA/scope_1_semicolon.csv", ] cls.text_files = [ file diff --git a/src/tests/test_io/test___init__/test_reads.py b/src/tests/test_io/test___init__/test_reads.py index d5ac0aa6ae3897c9fefa6bb70696c6b4ca598f36..8b23e4fdc94dcb7bcedc363dd08c7e548faa820e 100644 --- a/src/tests/test_io/test___init__/test_reads.py +++ b/src/tests/test_io/test___init__/test_reads.py @@ -12,7 +12,7 @@ class TestReads(unittest.TestCase): Test files starting with a dot (".") will be ignored. """ - files_path = Path(fr"{filedir}/../test_importers/data_files") + files_path = filedir / "../test_importers/data_files" @classmethod def setUpClass(cls): @@ -23,21 +23,13 @@ class TestReads(unittest.TestCase): cls.files = [file for file in cls.files if not file.stem.startswith(".")] cls.binary_files = [ - Path( - fr"{filedir}/../test_importers/data_files/KeysightBinary/keysight_binary.bin" - ), - Path( - fr"{filedir}/../test_importers/data_files/TektronixSpectrogram/test2.mat" - ), + filedir / "../test_importers/data_files/KeysightBinary/keysight_binary.bin", + filedir / "../test_importers/data_files/TektronixSpectrogram/test2.mat", ] + list((cls.files_path / "Gwinstek_LSF").glob("*")) cls.ignore_text_files = [ - Path( - fr"{filedir}/../test_importers/data_files/KeysightFRA/scope_0_comma.csv" - ), - Path( - fr"{filedir}/../test_importers/data_files/KeysightFRA/scope_1_semicolon.csv" - ), + filedir / "../test_importers/data_files/KeysightFRA/scope_0_comma.csv", + filedir / "../test_importers/data_files/KeysightFRA/scope_1_semicolon.csv", ] cls.text_files = [ file diff --git a/src/tests/test_io/test_data_container/test_data_container.py b/src/tests/test_io/test_data_container/test_data_container.py index 4c9aa0850a274667ae9fc2c1d90126513344a9ab..8dca345ba2cf55e576e03bcd6ab15f6f5562d638 100644 --- a/src/tests/test_io/test_data_container/test_data_container.py +++ b/src/tests/test_io/test_data_container/test_data_container.py @@ -79,6 +79,14 @@ class TestDataContainer(unittest.TestCase): dc.columns = ["impulse", "error", "amplitude"] dc.plot(subplots=True, figsize=(8, 8), grid=True) + def test___str__(self): + expected_string = ( + "------------------------------------------------------------\na : a\nab : " + "ab\n------------------------------------------------------------\n one two\n0 1 " + "4\n1 2 5\n2 3 6" + ) + self.assertEqual(str(self.base), expected_string) + # @print_wrapper def test_magic_methods(self, *args, **kwargs): funcs = MetaDataContainer.magic_methods @@ -109,7 +117,6 @@ class TestDataContainer(unittest.TestCase): def test_computations(self, *args, **kwargs): funcs = MetaDataContainer.computations_single for f in funcs: - # print(f) base = deepcopy(self.base) result = DataContainer.__dict__[f](base) self.assertIsInstance(result, DataContainer) @@ -168,7 +175,6 @@ class TestDataContainer(unittest.TestCase): @print_wrapper def test_append(self, method): result = self.base.__getattr__(method)(self.uneq) - print(result) self.assertIsInstance(result, DataContainer) self.assertEqual(result.header, self.header_combined) yield result diff --git a/src/tests/test_io/test_importers/test_ascii/empty.TXT b/src/tests/test_io/test_importers/test_ascii/empty.TXT new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/tests/test_io/test_importers/test_ascii/test_ascii.py b/src/tests/test_io/test_importers/test_ascii/test_ascii.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3d17dcd1ae7a5d31ff5164ed948fdf607ba4c468 100644 --- a/src/tests/test_io/test_importers/test_ascii/test_ascii.py +++ b/src/tests/test_io/test_importers/test_ascii/test_ascii.py @@ -0,0 +1,75 @@ +import unittest +from pathlib import Path + +import pandas as pd + +from openqlab.io.data_container import DataContainer +from openqlab.io.importers.ascii import ASCII +from openqlab.io.importers.utils import UnknownFileType + +filedir = Path(__file__).parent +datadir = filedir / "../data_files" + + +class TestASCII(unittest.TestCase): + importer = ASCII + files_path = datadir + supported_files_path = datadir / "ASCII" + multiline_comment = "This is a multiline comment.\nIt continues at the next line.\nAnd another line\nwith newline." + + def read_file(self, file): + try: + data = self.importer(file).read() + self.assertTrue(isinstance(data, DataContainer) and not data.empty) + self.assertTrue(data._is_numeric_mixed_type) + for column in data.columns: + self.assertFalse(data[column].isna().values.all()) + return data + except Exception as e: + print(f"{file}") + raise type(e)(f'"{file}" raised Exception: {e}') from e + + @classmethod + def setUpClass(cls): + cls.supported_files = list(cls.supported_files_path.glob("*")) + cls.supported_files = [ + file for file in cls.supported_files if not file.stem.startswith(".") + ] + cls.test_files = list(cls.files_path.glob("*/*")) + cls.unsupported_files = [ + file for file in cls.test_files if file not in cls.supported_files + ] + assert cls.supported_files + assert cls.unsupported_files + + def test_supported_files(self): + for file in self.supported_files: + self.read_file(file) + + # @unittest.skip("Importer cannot recognize unsupported files") + def test_unsupported_files(self): + for file in self.unsupported_files: + try: + with self.assertRaises(UnknownFileType): + self.read_file(file) + except AssertionError as e: + raise AssertionError(f"{file} did not raise {UnknownFileType}") from e + + def test_correct_rows(self): + file = self.supported_files_path / "dig0.TXT" + data = self.read_file(file) + + # columns and index + self.assertEqual(["dig0"], list(data.columns)) + self.assertEqual("x", data.index.name) + + # data + self.assertAlmostEqual(+1.280000e002, data.index[0]) + self.assertAlmostEqual(+2.560000e002, data.index[1]) + self.assertAlmostEqual(+1.408000e003, data.index[10]) # line 11 in file + self.assertAlmostEqual(+1.024000e005, data.index[-1]) + + self.assertAlmostEqual(-4.078996e001, data.iloc[0, 0]) + self.assertAlmostEqual(-5.155923e001, data.iloc[1, 0]) + self.assertAlmostEqual(-7.461130e001, data.iloc[10, 0]) # line 11 in file) + self.assertAlmostEqual(-9.785766e001, data.iloc[-1, 0]) diff --git a/src/tests/test_io/test_importers/test_ascii_header/test_ascii_header.py b/src/tests/test_io/test_importers/test_ascii_header/test_ascii_header.py index 5eee25303da4e6b29ac9d46d1891763e575acbdb..445209603c7084a403879f76889a503cf97f3212 100644 --- a/src/tests/test_io/test_importers/test_ascii_header/test_ascii_header.py +++ b/src/tests/test_io/test_importers/test_ascii_header/test_ascii_header.py @@ -6,13 +6,13 @@ from openqlab.io.importers.ascii_header import ASCII_Header from openqlab.io.importers.utils import UnknownFileType filedir = Path(__file__).parent -datadir = f"{filedir}/../data_files" +datadir = filedir / "../data_files" class TestASCII_Header(unittest.TestCase): importer = ASCII_Header - files_path = Path(datadir) - supported_files_path = Path(fr"{datadir}/ASCII_Header") + files_path = datadir + supported_files_path = datadir / "ASCII_Header" multiline_comment = "This is a multiline comment.\nIt continues at the next line.\nAnd another line\nwith newline." def read_file(self, file): diff --git a/src/tests/test_io/test_importers/test_data_container_csv/data_container_csv_empty.csv b/src/tests/test_io/test_importers/test_data_container_csv/data_container_csv_empty.csv new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/tests/test_io/test_importers/test_data_container_csv/data_container_csv_empty_with_header.csv b/src/tests/test_io/test_importers/test_data_container_csv/data_container_csv_empty_with_header.csv new file mode 100644 index 0000000000000000000000000000000000000000..62e721c1c72aeb8bfb73928c33768ffb1b165e08 --- /dev/null +++ b/src/tests/test_io/test_importers/test_data_container_csv/data_container_csv_empty_with_header.csv @@ -0,0 +1,3 @@ +-----DataContainerHeader +{"test": 1} +-----DataContainerData diff --git a/src/tests/test_io/test_importers/test_data_container_csv/test_data_container_csv.py b/src/tests/test_io/test_importers/test_data_container_csv/test_data_container_csv.py index c5529866fe067e5b64ade8d35468ae62a71de9b9..cecc6d8367374cc74ba9761d25fecc93623ec3ff 100644 --- a/src/tests/test_io/test_importers/test_data_container_csv/test_data_container_csv.py +++ b/src/tests/test_io/test_importers/test_data_container_csv/test_data_container_csv.py @@ -69,3 +69,13 @@ class TestDataContainerCSV(unittest.TestCase): self.assertAlmostEqual(1, data.iloc[0, 0]) self.assertAlmostEqual(2, data.iloc[1, 0]) + + def test_empty_file(self): + file = filedir / "data_container_csv_empty.csv" + with self.assertRaises(UnknownFileType): + self.read_file(file) + + def test_empty_file_with_header(self): + file = filedir / "data_container_csv_empty_with_header.csv" + with self.assertRaises(EmptyDataError): + self.read_file(file) diff --git a/src/tests/test_io/test_importers/test_gwinstek/test_gwinstek.py b/src/tests/test_io/test_importers/test_gwinstek/test_gwinstek.py index 447eb95aedd2b85064df919164e274192a43e599..617641d8f31564be87a489931842eb7dbb38f6b9 100644 --- a/src/tests/test_io/test_importers/test_gwinstek/test_gwinstek.py +++ b/src/tests/test_io/test_importers/test_gwinstek/test_gwinstek.py @@ -8,13 +8,13 @@ from openqlab.io.importers.gwinstek import Gwinstek from openqlab.io.importers.utils import ImportFailed, UnknownFileType filedir = Path(__file__).parent -datadir = f"{filedir}/../data_files" +datadir = filedir / "../data_files" class TestGwinstek(unittest.TestCase): importer = Gwinstek - files_path = Path(datadir) - supported_files_path = Path(fr"{datadir}/Gwinstek") + files_path = datadir + supported_files_path = datadir / "Gwinstek" def read_file(self, file): try: @@ -55,8 +55,8 @@ class TestGwinstek(unittest.TestCase): def test_missing_data(self): files = [ - fr"{filedir}/missing_data.csv", - fr"{filedir}/missing_data_1.csv", + filedir / "missing_data.csv", + filedir / "missing_data_1.csv", ] for file in files: try: @@ -66,7 +66,7 @@ class TestGwinstek(unittest.TestCase): raise AssertionError(f"{file} did not raise {EmptyDataError}") from e def test_wrong_savemode(self): - file = fr"{filedir}/wrong_savemode.csv" + file = filedir / "wrong_savemode.csv" try: with self.assertRaises(ImportFailed): self.read_file(file) @@ -74,7 +74,7 @@ class TestGwinstek(unittest.TestCase): raise AssertionError(f"{file} did not raise {ImportFailed}") from e def test_missing_savemode(self): - file = fr"{filedir}/missing_savemode.csv" + file = filedir / "missing_savemode.csv" try: with self.assertRaises(ImportFailed): self.read_file(file) @@ -132,7 +132,6 @@ class TestGwinstek(unittest.TestCase): def test_correct_rows_multitrace_detail(self): file = self.supported_files_path / "ALL0001_detail.csv" data = self.read_file(file) - print(data.iloc[:, 1]) # header self.assertEqual("s", data.header["xUnit"]) self.assertEqual("V", data.header["yUnit"]) diff --git a/src/tests/test_io/test_importers/test_gwinstek_LSF/data/missing_hashtag.LSF b/src/tests/test_io/test_importers/test_gwinstek_LSF/data/missing_hashtag.LSF new file mode 100644 index 0000000000000000000000000000000000000000..afb79b6cb023af917a972754dd7f314ec2f65189 Binary files /dev/null and b/src/tests/test_io/test_importers/test_gwinstek_LSF/data/missing_hashtag.LSF differ diff --git a/src/tests/test_io/test_importers/test_gwinstek_LSF/data/missing_x_unit.LSF b/src/tests/test_io/test_importers/test_gwinstek_LSF/data/missing_x_unit.LSF new file mode 100644 index 0000000000000000000000000000000000000000..f55019f8055a3cdd9dab4162797cfa8ab2edb7aa Binary files /dev/null and b/src/tests/test_io/test_importers/test_gwinstek_LSF/data/missing_x_unit.LSF differ diff --git a/src/tests/test_io/test_importers/test_gwinstek_LSF/test_gwinstek_LSF.py b/src/tests/test_io/test_importers/test_gwinstek_LSF/test_gwinstek_LSF.py index 36c0d6507d1e3c3aee22dc092e914092f6700658..38beff2ed4ff1035493ad6c79a44cc99bf33b0e9 100644 --- a/src/tests/test_io/test_importers/test_gwinstek_LSF/test_gwinstek_LSF.py +++ b/src/tests/test_io/test_importers/test_gwinstek_LSF/test_gwinstek_LSF.py @@ -1,20 +1,18 @@ import unittest from pathlib import Path -from pandas.errors import EmptyDataError - from openqlab.io.data_container import DataContainer from openqlab.io.importers.gwinstek_lsf import Gwinstek_LSF from openqlab.io.importers.utils import ImportFailed, UnknownFileType filedir = Path(__file__).parent -datadir = f"{filedir}/../data_files" +datadir = filedir / "../data_files" class TestGwinstek_LSF(unittest.TestCase): importer = Gwinstek_LSF - files_path = Path(datadir) - supported_files_path = Path(fr"{datadir}/Gwinstek_LSF") + files_path = datadir + supported_files_path = datadir / "Gwinstek_LSF" def read_file(self, file): try: @@ -76,3 +74,11 @@ class TestGwinstek_LSF(unittest.TestCase): self.assertAlmostEqual(-8.00e-04, data.iloc[1, 0]) self.assertAlmostEqual(0.00e00, data.iloc[100, 0]) # line 126 in file) self.assertAlmostEqual(-8.00e-04, data.iloc[-1, 0]) + + def test_missing_beginning_hashtag(self): + with self.assertRaises(ImportFailed): + self.importer(filedir / "data/missing_hashtag.LSF").read() + + def test_missing_x_unit(self): + with self.assertRaises(ImportFailed): + self.importer(filedir / "data/missing_x_unit.LSF").read() diff --git a/src/tests/test_io/test_importers/test_hp4395a/test_hp4395a.py b/src/tests/test_io/test_importers/test_hp4395a/test_hp4395a.py index 38a897844b215330a487d1c0552c54ef02d7753c..87393be1bb091409878fae8c07793d0b1cfabf92 100644 --- a/src/tests/test_io/test_importers/test_hp4395a/test_hp4395a.py +++ b/src/tests/test_io/test_importers/test_hp4395a/test_hp4395a.py @@ -13,8 +13,8 @@ filedir = Path(__file__).parent class TestHP4395A(unittest.TestCase): importer = HP4395A - files_path = Path(f"{filedir}/../data_files") - supported_files_path = Path(fr"{files_path}/HP4395A") + files_path = filedir / "../data_files" + supported_files_path = files_path / "HP4395A" def read_file(self, file): try: @@ -51,7 +51,7 @@ class TestHP4395A(unittest.TestCase): raise AssertionError(f"{file} did not raise {UnknownFileType}") from e def test_missing_data(self): - files = [fr"{filedir}/missing_data.txt"] + files = [filedir / "missing_data.txt"] for file in files: try: with self.assertRaises(EmptyDataError): diff --git a/src/tests/test_io/test_importers/test_keysight_binary/test_keysight_binary.py b/src/tests/test_io/test_importers/test_keysight_binary/test_keysight_binary.py index 06833973ed704a7ceed2a863709744503ef5723e..77683cf234b53c977e17ca9a48f2245b35f26972 100644 --- a/src/tests/test_io/test_importers/test_keysight_binary/test_keysight_binary.py +++ b/src/tests/test_io/test_importers/test_keysight_binary/test_keysight_binary.py @@ -11,7 +11,7 @@ filedir = Path(__file__).parent class TestKeysightBinary(unittest.TestCase): importer = KeysightBinary - files_path = Path(fr"{filedir}/../data_files") + files_path = filedir / "../data_files" supported_files_path = Path(fr"{files_path}/KeysightBinary") def read_file(self, file): @@ -51,9 +51,6 @@ class TestKeysightBinary(unittest.TestCase): def test_correct_rows_multitrace(self): file = self.supported_files_path / "keysight_binary.bin" data = self.read_file(file) - print(data.head()) - print(data.tail()) - print(data.iloc[0, 0]) # columns and index self.assertEqual( diff --git a/src/tests/test_io/test_importers/test_keysight_csv/test_keysight_csv.py b/src/tests/test_io/test_importers/test_keysight_csv/test_keysight_csv.py index a0d1305fdf88477a45bab5975ce53c40d6b4e79b..2f93077770d4568889d67e15a7a8708787462195 100644 --- a/src/tests/test_io/test_importers/test_keysight_csv/test_keysight_csv.py +++ b/src/tests/test_io/test_importers/test_keysight_csv/test_keysight_csv.py @@ -13,8 +13,8 @@ filedir = Path(__file__).parent class TestKeysightCSV(unittest.TestCase): importer = KeysightCSV - files_path = Path(fr"{filedir}/../data_files") - supported_files_path = Path(fr"{files_path}/KeysightCSV") + files_path = filedir / "../data_files" + supported_files_path = files_path / "KeysightCSV" def read_file(self, file): try: @@ -51,7 +51,7 @@ class TestKeysightCSV(unittest.TestCase): raise AssertionError(f"{file} did not raise {UnknownFileType}") from e def test_missing_data(self): - file = fr"{filedir}/missing_data.csv" + file = filedir / "missing_data.csv" try: with self.assertRaises(EmptyDataError): self.read_file(file) diff --git a/src/tests/test_io/test_importers/test_keysight_fra/test_keysight_fra.py b/src/tests/test_io/test_importers/test_keysight_fra/test_keysight_fra.py index 6fed903bc0b2115dd481e05637b787d31b7e7163..4e138847503589b4a091de0fe193d8fd67319a4b 100644 --- a/src/tests/test_io/test_importers/test_keysight_fra/test_keysight_fra.py +++ b/src/tests/test_io/test_importers/test_keysight_fra/test_keysight_fra.py @@ -11,7 +11,7 @@ filedir = Path(__file__).parent class TestKeysightFRA(unittest.TestCase): importer = KeysightFRA - files_path = Path(fr"{filedir}/../data_files") + files_path = filedir / "../data_files" supported_files_path = Path(fr"{files_path}/KeysightFRA") def read_file(self, file): @@ -49,7 +49,7 @@ class TestKeysightFRA(unittest.TestCase): raise AssertionError(f"{file} did not raise {UnknownFileType}") from e def test_missing_data(self): - file = Path(fr"{filedir}/missing_data.csv") + file = filedir / "missing_data.csv" try: with self.assertRaises(ImportFailed): self.read_file(file) diff --git a/src/tests/test_io/test_importers/test_rhode_schwarz/test_rhode_schwarz.py b/src/tests/test_io/test_importers/test_rhode_schwarz/test_rhode_schwarz.py index 15275ea1f047728b3501d15ee3e573c66ed3aea7..261cd508ce65d8231464c9e19ce5fc6b24449f79 100644 --- a/src/tests/test_io/test_importers/test_rhode_schwarz/test_rhode_schwarz.py +++ b/src/tests/test_io/test_importers/test_rhode_schwarz/test_rhode_schwarz.py @@ -11,8 +11,8 @@ filedir = Path(__file__).parent class TestRhodeSchwarz(unittest.TestCase): importer = RhodeSchwarz - files_path = Path(fr"{filedir}/../data_files") - supported_files_path = Path(fr"{files_path}/RhodeSchwarz") + files_path = filedir / "../data_files" + supported_files_path = files_path / "RhodeSchwarz" def read_file(self, file): try: @@ -41,8 +41,6 @@ class TestRhodeSchwarz(unittest.TestCase): self.read_file(file) def test_unsupported_files(self): - print(self.supported_files) - print(self.unsupported_files) for file in self.unsupported_files: try: with self.assertRaises(UnknownFileType): @@ -51,7 +49,7 @@ class TestRhodeSchwarz(unittest.TestCase): raise AssertionError(f"{file} did not raise {UnknownFileType}") from e def test_missing_data(self): - file = Path(fr"{filedir}/missing_data.csv") + file = filedir / "missing_data.csv" try: with self.assertRaises(ImportFailed): self.read_file(file) @@ -59,7 +57,7 @@ class TestRhodeSchwarz(unittest.TestCase): raise AssertionError(f"{file} did not raise {ImportFailed}") from e def test_missing_xUnit(self): - file = Path(fr"{filedir}/missing_xUnit") + file = filedir / "missing_xUnit" data = self.read_file(file) self.assertEqual("x", data.index.name) diff --git a/src/tests/test_io/test_importers/test_tektronix/test_tektronix.py b/src/tests/test_io/test_importers/test_tektronix/test_tektronix.py index 13574cfcf23fd41ac89303a03374429edb62d42b..b1607eb80f920e47ec46bf42fe8de349b4e066f6 100644 --- a/src/tests/test_io/test_importers/test_tektronix/test_tektronix.py +++ b/src/tests/test_io/test_importers/test_tektronix/test_tektronix.py @@ -11,8 +11,8 @@ filedir = Path(__file__).parent class TestTektronix(unittest.TestCase): importer = Tektronix - files_path = Path(fr"{filedir}/../data_files") - supported_files_path = Path(fr"{files_path}/Tektronix") + files_path = filedir / "../data_files" + supported_files_path = files_path / "Tektronix" def read_file(self, file): try: @@ -49,18 +49,18 @@ class TestTektronix(unittest.TestCase): raise AssertionError(f"{file} did not raise {UnknownFileType}") from e def test_missing_data(self): - file = fr"{filedir}/missing_data.csv" + file = filedir / "missing_data.csv" with self.assertRaises(ImportFailed): data = self.importer(file).read() def test_wrong_number_points(self): - file = fr"{filedir}/wrong_number_points.csv" + file = filedir / "wrong_number_points.csv" error_message = f"'Tektronix' importer: Number of points does not fit number of values in file '{file}'." with self.assertRaisesRegex(ImportFailed, error_message): self.importer(file).read() def test_different_frequency_axis(self): - file = fr"{filedir}/different_frequency_axis.csv" + file = filedir / "different_frequency_axis.csv" error_message = f"'Tektronix' importer: Traces in file '{file}' do not have equal frequency axis." with self.assertRaisesRegex(ImportFailed, error_message): self.importer(file).read() diff --git a/src/tests/test_io/test_importers/test_tektronix_dpx/test_tektronix_dpx.py b/src/tests/test_io/test_importers/test_tektronix_dpx/test_tektronix_dpx.py index fe3ae4728271f2d01c7ee1a25f5465ea5030249f..046368635c82467a46c942da371788c2176cfcf3 100644 --- a/src/tests/test_io/test_importers/test_tektronix_dpx/test_tektronix_dpx.py +++ b/src/tests/test_io/test_importers/test_tektronix_dpx/test_tektronix_dpx.py @@ -11,7 +11,7 @@ filedir = Path(__file__).parent class TestTektronix(unittest.TestCase): importer = TektronixDPX - files_path = Path(fr"{filedir}/../data_files") + files_path = filedir / "../data_files" supported_files_path = Path(fr"{files_path}/TektronixDPX") def read_file(self, file): diff --git a/src/tests/test_io/test_importers/test_tektronix_spectrogram/missing_required_key.mat b/src/tests/test_io/test_importers/test_tektronix_spectrogram/missing_required_key.mat new file mode 100644 index 0000000000000000000000000000000000000000..f763c4a7406252300a85fa7ed1ec51ce5fdd71d2 Binary files /dev/null and b/src/tests/test_io/test_importers/test_tektronix_spectrogram/missing_required_key.mat differ diff --git a/src/tests/test_io/test_importers/test_tektronix_spectrogram/test_tektronix_spectrogram.py b/src/tests/test_io/test_importers/test_tektronix_spectrogram/test_tektronix_spectrogram.py index 4f9298208ce8a981a07b605ad2663558bd814657..0ca134919a34c5175f41eec2931f53216a35675f 100644 --- a/src/tests/test_io/test_importers/test_tektronix_spectrogram/test_tektronix_spectrogram.py +++ b/src/tests/test_io/test_importers/test_tektronix_spectrogram/test_tektronix_spectrogram.py @@ -11,8 +11,8 @@ filedir = Path(__file__).parent class TestTekSpectrogram(unittest.TestCase): importer = TektronixSpectrogram - files_path = Path(fr"{filedir}/../data_files") - supported_files_path = Path(fr"{files_path}/TektronixSpectrogram") + files_path = filedir / "../data_files" + supported_files_path = files_path / "TektronixSpectrogram" def read_file(self, file): try: @@ -48,6 +48,12 @@ class TestTekSpectrogram(unittest.TestCase): except AssertionError as e: raise AssertionError(f"{file} did not raise {UnknownFileType}") from e + @unittest.skip("dont have a .mat file with missing keys") + def test_missing_requeired_key(self): + file = filedir / "missing_required_key.mat" + with self.assertRaises(UnknownFileType): + self.read_file(file) + def test_correct_rows_multitrace(self): file = self.supported_files_path / "test2.mat" data = self.read_file(file) @@ -89,3 +95,7 @@ class TestTekSpectrogram(unittest.TestCase): self.assertAlmostEqual(-83.220, data.iloc[16, 1], places=4) self.assertAlmostEqual(-87.400, data.iloc[16, -2], places=4) self.assertAlmostEqual(-87.520, data.iloc[16, -1], places=4) + + @unittest.skip("dont know how this function is used") + def test_get_xml_text_default(self): + self.importer._get_xml_text()