Skip to content

Commit

Permalink
Add a few extra tests for non-overlapping power spectra
Browse files Browse the repository at this point in the history
  • Loading branch information
philbull committed May 7, 2018
1 parent 8579725 commit 18fddac
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions hera_pspec/tests/test_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def test_select_common(self):
inplace=False)
uvp3 = self.uvp.select(blpairs=np.unique(self.uvp.blpair_array)[1:],
inplace=False)
uvp4 = self.uvp.select(blpairs=np.unique(self.uvp.blpair_array)[:2],
inplace=False)
uvp5 = self.uvp.select(blpairs=np.unique(self.uvp.blpair_array)[:1],
inplace=False)
uvp6 = self.uvp.select(times=np.unique(self.uvp.time_avg_array)[:1],
inplace=False)

# Check that selecting on common times works
uvp_list = [uvp1, uvp2]
Expand All @@ -118,6 +124,31 @@ def test_select_common(self):
np.testing.assert_array_equal(uvp_new[0].time_avg_array,
uvp_new[1].time_avg_array)

# Check that selecting on common baseline-pairs works
uvp_list_2 = [uvp1, uvp2, uvp3]
uvp_new_2 = grouping.select_common(uvp_list_2, spws=True, blpairs=True,
times=True, pols=True, inplace=False)
self.assertEqual(uvp_new_2[0], uvp_new_2[1])
self.assertEqual(uvp_new_2[0], uvp_new_2[2])
np.testing.assert_array_equal(uvp_new_2[0].time_avg_array,
uvp_new_2[1].time_avg_array)

# Check that zero overlap in times raises a ValueError
self.assertRaises(ValueError, grouping.select_common, [uvp2, uvp6],
spws=True, blpairs=True, times=True,
pols=True, inplace=False)

# Check that zero overlap in times does *not* raise a ValueError if
# not selecting on times
uvp_new_3 = grouping.select_common([uvp2, uvp6], spws=True,
blpairs=True, times=False,
pols=True, inplace=False)

# Check that zero overlap in baselines raises a ValueError
self.assertRaises(ValueError, grouping.select_common, [uvp3, uvp5],
spws=True, blpairs=True, times=True,
pols=True, inplace=False)

# Check that matching times are ignored when set to False
uvp_new = grouping.select_common(uvp_list, spws=True, blpairs=True,
times=False, pols=True, inplace=False)
Expand Down

0 comments on commit 18fddac

Please sign in to comment.