Skip to content

Commit

Permalink
more coverage, remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
bhazelton committed Dec 4, 2023
1 parent f5c5c84 commit 8efda88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
14 changes: 14 additions & 0 deletions pyuvdata/uvcal/tests/test_calh5.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

import pyuvdata.tests as uvtest
from pyuvdata import UVCal
from pyuvdata.data import DATA_PATH
from pyuvdata.uvcal import FastCalH5Meta
from pyuvdata.uvcal.tests import extend_jones_axis, time_array_to_time_range
from pyuvdata.uvcal.uvcal import _future_array_shapes_warning
from pyuvdata.uvdata import FastUVH5Meta


@pytest.mark.filterwarnings("ignore:" + _future_array_shapes_warning)
Expand Down Expand Up @@ -114,6 +116,18 @@ def test_calh5_meta(gain_data, tmp_path):
calobj.write_calh5(write_file, clobber=True)
cal_meta = FastCalH5Meta(write_file)

cal_meta2 = FastCalH5Meta(write_file)
assert cal_meta == cal_meta2

write_file2 = str(tmp_path / "outtest2.calh5")
calobj.write_calh5(write_file, clobber=True)

cal_meta2 = FastCalH5Meta(write_file2)
assert cal_meta != cal_meta2

uvh5_meta = FastUVH5Meta(os.path.join(DATA_PATH, "zen.2458432.34569.uvh5"))
assert cal_meta != uvh5_meta

ant_nums = cal_meta.antenna_numbers
jpol_nums = cal_meta.jones_array
jpol_names = cal_meta.pols
Expand Down
21 changes: 0 additions & 21 deletions pyuvdata/uvdata/uvh5.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,27 +394,6 @@ def channel_width(self) -> float:
else:
return float(h["channel_width"][()])

@cached_property
def extra_keywords(self) -> dict:
"""The extra_keywords from the file."""
header = self.header
if "extra_keywords" not in header:
return {}

extra_keywords = {}
for key in header["extra_keywords"].keys():
if header["extra_keywords"][key].dtype.type in (np.string_, np.object_):
extra_keywords[key] = bytes(header["extra_keywords"][key][()]).decode(
"utf8"
)
else:
# special handling for empty datasets == python `None` type
if header["extra_keywords"][key].shape is None:
extra_keywords[key] = None
else:
extra_keywords[key] = header["extra_keywords"][key][()]
return extra_keywords

@cached_property
def unique_antpair_1_array(self) -> np.ndarray:
"""The unique antenna 1 indices in the file."""
Expand Down

0 comments on commit 8efda88

Please sign in to comment.