def test_select_targets(self): """Test select targets works with either data or filenames """ # ADM parallelization across pixels only works for sweep files. for filelist in [self.sweepfiles]: # ADM No QSO cuts and limit to pixels for speed. # ADM This doesn't affect coverage. targets = cuts.select_targets(filelist, numproc=1, test=True, cmxdir=self.cmxdir, noqso=True, nside=self.nside, pixlist=self.pix) t1 = cuts.select_targets(filelist[0:1], numproc=1, test=True, cmxdir=self.cmxdir, noqso=True, nside=self.nside, pixlist=self.pix) t2 = cuts.select_targets(filelist[0], numproc=1, test=True, cmxdir=self.cmxdir, noqso=True, nside=self.nside, pixlist=self.pix) for col in t1.dtype.names: try: notNaN = ~np.isnan(t1[col]) except TypeError: # - can't check string columns for NaN notNaN = np.ones(len(t1), dtype=bool) self.assertTrue(np.all(t1[col][notNaN] == t2[col][notNaN]))
def test_missing_files(self): """Test the code will die gracefully if input files are missing """ with self.assertRaises(ValueError): targets = cuts.select_targets([ 'blat.foo1234', ], numproc=1)
def test_parallel_select(self): """Test multiprocessing parallelization works """ for nproc in [1, 2]: for filelist in [self.tractorfiles, self.sweepfiles]: targets = cuts.select_targets(filelist, numproc=nproc, cmxdir=self.cmxdir) self.assertTrue('CMX_TARGET' in targets.dtype.names) self.assertEqual(len(targets), np.count_nonzero(targets['CMX_TARGET']))
def test_select_targets(self): """Test select targets works with either data or filenames """ for filelist in [self.tractorfiles, self.sweepfiles]: targets = cuts.select_targets(filelist, numproc=1, cmxdir=self.cmxdir) t1 = cuts.select_targets(filelist[0:1], numproc=1, cmxdir=self.cmxdir) t2 = cuts.select_targets(filelist[0], numproc=1, cmxdir=self.cmxdir) for col in t1.dtype.names: try: notNaN = ~np.isnan(t1[col]) except TypeError: # - can't check string columns for NaN notNaN = np.ones(len(t1), dtype=bool) self.assertTrue(np.all(t1[col][notNaN] == t2[col][notNaN]))
def test_parallel_select(self): """Test multiprocessing parallelization works """ for nproc in [1, 2]: # ADM parallelization across pixels only works for sweep files. for filelist in [self.sweepfiles]: # ADM No QSO cuts for speed. Doesn't affect coverage. targets = cuts.select_targets(filelist, numproc=nproc, cmxdir=self.cmxdir, noqso=True, nside=self.nside, pixlist=self.pix) self.assertTrue('CMX_TARGET' in targets.dtype.names) self.assertEqual(len(targets), np.count_nonzero(targets['CMX_TARGET']))