Skip to content

Commit f168f66

Browse files
author
JianrongTan
committed
Delete redundant parameter Npairs; Adding tests in test_backwards_compatibility_read
1 parent 5b52036 commit f168f66

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

hera_pspec/pspecdata.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3452,7 +3452,6 @@ def pspec(self, bls1, bls2, dsets, pols, n_dlys=None,
34523452
# not necessarily be the same.
34533453
# Ntimes could still be the number of "average times" which might be useful for noise purposes.
34543454
uvp.Ntimes = len(np.unique(np.hstack([uvp.time_1_array, uvp.time_2_array])))
3455-
uvp.Npairs = len(set([(t1, t2) for t1, t2 in zip(uvp.time_1_array, uvp.time_2_array)]))
34563455
uvp.Nbltpairs = len(set([(blp, t1, t2) for blp, t1, t2 in zip(uvp.blpair_array, uvp.time_1_array, uvp.time_2_array)]))
34573456
uvp.Ntpairs = len(set([(t1, t2) for t1, t2 in zip(uvp.time_1_array, uvp.time_2_array)]))
34583457
bls_arr = sorted(set(bls_arr))

hera_pspec/tests/test_uvpspec.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,5 +1028,13 @@ def test_backwards_compatibility_read():
10281028
# test read in of a static test file dated 8/2019
10291029
uvp = uvpspec.UVPSpec()
10301030
uvp.read_hdf5(os.path.join(DATA_PATH, 'test_uvp.h5'))
1031+
for dattr in uvp._meta_deprecated:
1032+
with pytest.raises(AttributeError) as excinfo:
1033+
raise AttributeError("'UVPSpec' object has no attribute")
1034+
assert "'UVPSpec' object has no attribute" in str(excinfo.value)
1035+
for dattr in uvp._meta_dsets_deprecated:
1036+
with pytest.raises(AttributeError) as excinfo:
1037+
raise AttributeError("'UVPSpec' object has no attribute")
1038+
assert "'UVPSpec' object has no attribute" in str(excinfo.value)
10311039
# assert check does not fail
10321040
uvp.check()

hera_pspec/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,6 @@ def uvp_noise_error(uvp, auto_Tsys=None, err_type='P_N', precomp_P_N=None, P_SN_
14551455
else:
14561456
Tsys = Tsys[0]
14571457

1458-
14591458
# calculate P_N
14601459
P_N = uvp.generate_noise_spectra(spw, polpair, Tsys, blpairs=[blp], form='Pk', component='real', scalar=scalar[(spw, polpair)])[blp_int]
14611460

hera_pspec/uvpspec.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,13 +1409,11 @@ def read_from_group(self, grp, just_meta=False, spws=None, bls=None,
14091409
# Clear deprecated attributes.
14101410
for dattr in self._meta_deprecated:
14111411
if hasattr(self, dattr):
1412-
to_delete = getattr(self, dattr)
1413-
del to_delete
1412+
delattr(self, dattr)
14141413

14151414
for dattr in self._meta_dsets_deprecated:
14161415
if hasattr(self, dattr):
1417-
to_delete = getattr(self, dattr)
1418-
del to_delete
1416+
delattr(self, dattr)
14191417

14201418
self.check(just_meta=just_meta)
14211419

0 commit comments

Comments
 (0)