Skip to content

Commit

Permalink
fixed minor typos in pspecdata and fixed tests in test_pspecdata
Browse files Browse the repository at this point in the history
  • Loading branch information
nkern committed Apr 4, 2018
1 parent b19212a commit 3b837b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
10 changes: 5 additions & 5 deletions hera_pspec/pspecdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,12 @@ def pspec(self, bls, input_data_weight='identity', norm='I', taper='none', littl
# we take all N choose 2 combinations with replacement within each baseline group.
# this includes a baseline being crossed with itself, which will lead to a bias
# unless the data in each dset is from a different night / LST, or the
# enforce_cross_bl option is set (by default).
# enforce_bl_cross option is set (by default).
red_bls = copy.copy(bls)
bls = map(lambda bl_group: list(itertools.combinations_with_replacement(bl_group, 2)), bls)
fed_bl_group = True
else:
raise ValueError("could not parse format of bls. must be fed as a list of tuples, " \
raise TypeError("could not parse format of bls. must be fed as a list of tuples, " \
"or a list of lists of tuples.")

# iterate through all bls and ensure bl pair exists in all dsets, else remove
Expand All @@ -901,7 +901,7 @@ def pspec(self, bls, input_data_weight='identity', norm='I', taper='none', littl
for i, blg in enumerate(bls):
new_blg = []
for blp in blg:
if enforce_cross_bl:
if enforce_bl_cross:
if blp[0] == blp[1]:
continue
new_blg.append(blp)
Expand Down Expand Up @@ -962,10 +962,10 @@ def pspec(self, bls, input_data_weight='identity', norm='I', taper='none', littl
pv *= scalar

# Save power spectra and dataset/baseline pairs
pvs.append(pv)
pspecs.append(pv)
pairs.append((key1, key2))

return np.array(pvs), pairs
return np.array(pspecs), pairs

def rephase_to_dset(self, dset_index=0, inplace=True):
"""
Expand Down
13 changes: 9 additions & 4 deletions hera_pspec/tests/test_pspecdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def test_scalar(self):
#self.assertAlmostEqual(scalar, 3732415176.85 / 10.**9)

# FIXME: Remove this when pyuvdata support for the above is ready
self.assertRaises(NotImplementedError, self.ds.scalar)
#self.assertRaises(NotImplementedError, self.ds.scalar)

def test_validate_datasets(self):
# test freq exception
Expand Down Expand Up @@ -499,7 +499,7 @@ def test_pspec(self):
# check basic execution with baseline list
bls = [(24, 25), (37, 38), (38, 39), (52, 53)]
pspec, pairs = ds.pspec(bls, input_data_weight='identity', norm='I', taper='none',
little_h=True, reverse_bl_pairing=False, enforce_cross_bl=False,
little_h=True, add_reverse_bl_pairs=False, enforce_bl_cross=False,
verbose=False)
nt.assert_equal(len(pairs), len(bls))
nt.assert_equal(pairs[0], ((0, 24, 25, 'XX'), (1, 24, 25, 'XX')))
Expand All @@ -511,17 +511,22 @@ def test_pspec(self):
antpos = dict(zip(ants, antpos))
red_bls = redcal.get_pos_reds(antpos, low_hi=True)
pspec, pairs = ds.pspec(red_bls, input_data_weight='identity', norm='I', taper='none',
little_h=True, reverse_bl_pairing=False, enforce_cross_bl=False,
little_h=True, add_reverse_bl_pairs=False, enforce_bl_cross=False,
verbose=False)
nt.assert_true(((0, 24, 37, 'XX'), (1, 24, 37, 'XX')) in pairs)
nt.assert_equal(len(pairs), 42)
pspec, pairs = ds.pspec(red_bls, input_data_weight='identity', norm='I', taper='none',
little_h=True, reverse_bl_pairing=True, enforce_cross_bl=True,
little_h=True, add_reverse_bl_pairs=True, enforce_bl_cross=True,
verbose=False)
nt.assert_true(((0, 24, 25, 'XX'), (1, 52, 53, 'XX')) in pairs)
nt.assert_true(((0, 52, 53, 'XX'), (1, 24, 25, 'XX')) in pairs)
nt.assert_equal(len(pairs), 42)

# check exception
nt.assert_raises(TypeError, ds.pspec, [0])

# get exception for bl_group
nt.assert_raises(NotImplementedError, ds.pspec, red_bls, average_bl_group=True)


"""
Expand Down

0 comments on commit 3b837b2

Please sign in to comment.