Skip to content

Commit

Permalink
Add basic read tests (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjperkins authored Oct 8, 2024
1 parent 2e7114d commit ea685ce
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
35 changes: 35 additions & 0 deletions tests/test_read.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit ea685ce

Please sign in to comment.