From f817f41e520a1f837b00e6aa5a670a6f875dc63b Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Tue, 8 Oct 2024 15:07:13 +0200 Subject: [PATCH 1/2] Add basic read tests --- tests/test_read.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/test_read.py diff --git a/tests/test_read.py b/tests/test_read.py new file mode 100644 index 0000000..dac0cae --- /dev/null +++ b/tests/test_read.py @@ -0,0 +1,35 @@ +from functools import reduce +from operator import mul + +import numpy as np +import pytest +from numpy.testing import assert_array_equal +from xarray.backends.api import open_datatree + + +@pytest.mark.parametrize( + "simmed_ms", + [ + { + "name": "backend.ms", + "data_description": [(8, ["XX", "XY", "YX", "YY"]), (4, ["RR", "LL"])], + } + ], + indirect=True, +) +def test_basic_read(simmed_ms): + """Test for ramp function values produced by simulator""" + xdt = open_datatree(simmed_ms) + + for node in xdt.subtree: + if "data_description_id" in node.attrs: + vis = node.VISIBILITY.values + nelements = reduce(mul, vis.shape, 1) + expected = np.arange(nelements, dtype=np.float64) + expected = (expected + expected * 1j).reshape(vis.shape) + assert_array_equal(vis, expected) + + uvw = node.UVW.values + nelements = reduce(mul, uvw.shape, 1) + expected = np.arange(nelements, dtype=np.float64).reshape(uvw.shape) + assert_array_equal(uvw, expected) From 00d4dfad497590cec062811433f44ddb89c414cb Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Tue, 8 Oct 2024 15:11:13 +0200 Subject: [PATCH 2/2] [skip ci] Update changelog --- doc/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index e65d981..d08e1f4 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -5,6 +5,7 @@ Changelog X.Y.Z (DD-MM-YYYY) ------------------ +* Add basic read tests (:pr:`32`) * Fix Dataset and DataTree equivalence checks in test cases (:pr:`31`) 0.2.1 (04-10-2024)