diff --git a/py/desispec/database/metadata.py b/py/desispec/database/metadata.py index 50f045c2c..8c868eb8d 100644 --- a/py/desispec/database/metadata.py +++ b/py/desispec/database/metadata.py @@ -16,9 +16,8 @@ from pytz import utc from sqlalchemy import (create_engine, text, Table, ForeignKey, Column, Integer, String, Float, DateTime) -from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.associationproxy import association_proxy -from sqlalchemy.orm import sessionmaker, relationship, reconstructor +from sqlalchemy.orm import sessionmaker, relationship, reconstructor, declarative_base from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound from matplotlib.patches import Circle, Polygon, Wedge from matplotlib.collections import PatchCollection diff --git a/py/desispec/image_model.py b/py/desispec/image_model.py index 127336af7..ab07055a4 100644 --- a/py/desispec/image_model.py +++ b/py/desispec/image_model.py @@ -23,7 +23,7 @@ from desispec.qproc.qsky import qproc_sky_subtraction from desispec.qproc.qfiberflat import qproc_apply_fiberflat -@numba.jit +@numba.jit(nopython=True) def numba_proj(image,x,sigma,flux) : ''' Add a spectrum to a model of the pixel values in a CCD image assuming a Gaussian cross-dispersion profile. diff --git a/py/desispec/io/__init__.py b/py/desispec/io/__init__.py index 0a6be2ac9..625663808 100644 --- a/py/desispec/io/__init__.py +++ b/py/desispec/io/__init__.py @@ -12,7 +12,7 @@ import warnings warnings.filterwarnings('ignore', message="'.*nanomaggie.* did not parse as fits unit.*") warnings.filterwarnings('ignore', message="'.*nanomaggy.* did not parse as fits unit.*") -warnings.filterwarnings('ignore', message=".*'10\*\*6 arcsec.* did not parse as fits unit.*") +warnings.filterwarnings('ignore', message=r".*'10\*\*6 arcsec.* did not parse as fits unit.*") # from .download import download, filepath2url from .fiberflat import read_fiberflat, write_fiberflat diff --git a/py/desispec/preproc.py b/py/desispec/preproc.py index ca9b6ac20..9affe11b3 100644 --- a/py/desispec/preproc.py +++ b/py/desispec/preproc.py @@ -375,7 +375,7 @@ def _background(image,header,patch_width=200,stitch_width=10,stitch=False) : log.info("done") return bkg -@numba.jit +@numba.jit(nopython=True) def numba_mean(image_flux,image_ivar,x,hw=3) : """ Returns mean of pixels vs. row about x+-hw diff --git a/py/desispec/qproc/qextract.py b/py/desispec/qproc/qextract.py index c88b209f6..edd71acd3 100644 --- a/py/desispec/qproc/qextract.py +++ b/py/desispec/qproc/qextract.py @@ -15,7 +15,7 @@ from desispec.qproc.qframe import QFrame -@numba.jit +@numba.jit(nopython=True) def numba_extract(image_flux,image_var,x,hw=3) : n0=image_flux.shape[0] flux=np.zeros(n0) diff --git a/py/desispec/test/test_binscripts.py b/py/desispec/test/test_binscripts.py index 0a02af12a..e8048ee8c 100644 --- a/py/desispec/test/test_binscripts.py +++ b/py/desispec/test/test_binscripts.py @@ -352,15 +352,3 @@ def test_compute_sky(self): result, success = runcmd(desispec.scripts.sky.main, args=args, inputs=inputs, outputs=outputs, clobber=True) self.assertTrue(success) - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_bitmask.py b/py/desispec/test/test_bitmask.py index 6d6433070..d666449a3 100644 --- a/py/desispec/test/test_bitmask.py +++ b/py/desispec/test/test_bitmask.py @@ -22,6 +22,4 @@ def test_names(self): self.assertEqual(m.mask(name), m.mask(m.bitnum(name)), 'Failed matching mask to name for '+name) self.assertEqual(m.bitname(m.bitnum(name)), name, 'Failed bit name->num->name roundtrip for '+name) c = m.comment(name) - -if __name__ == '__main__': - unittest.main() \ No newline at end of file + diff --git a/py/desispec/test/test_bootcalib.py b/py/desispec/test/test_bootcalib.py index 81d653a2e..344f4a9a6 100644 --- a/py/desispec/test/test_bootcalib.py +++ b/py/desispec/test/test_bootcalib.py @@ -221,9 +221,3 @@ def test_main(self): y = psf.y(ispec=indices, wavelength=waves) -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) diff --git a/py/desispec/test/test_calibfinder.py b/py/desispec/test/test_calibfinder.py index d65588284..a2626678e 100644 --- a/py/desispec/test/test_calibfinder.py +++ b/py/desispec/test/test_calibfinder.py @@ -44,7 +44,3 @@ def test_init(self): print(cfinder.value("DETECTOR")) if cfinder.haskey("BIAS") : print(cfinder.findfile("BIAS")) - - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_ccdcalib.py b/py/desispec/test/test_ccdcalib.py index 02591a560..2ff3b17f7 100644 --- a/py/desispec/test/test_ccdcalib.py +++ b/py/desispec/test/test_ccdcalib.py @@ -110,15 +110,3 @@ def test_select_zero_expids(self): del os.environ['DESI_LOGLEVEL'] else: os.environ['DESI_LOGLEVEL'] = original_log_level - - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m desispec.test.test_ccdcalib - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_coadd.py b/py/desispec/test/test_coadd.py index e1a76f1c5..bb059d2db 100644 --- a/py/desispec/test/test_coadd.py +++ b/py/desispec/test/test_coadd.py @@ -891,15 +891,3 @@ def test_coadd_cameras(self): spec.R = None spec.mask = None coadd = coadd_cameras(spec) - - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m desispec.test.test_coadd - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_cosmics.py b/py/desispec/test/test_cosmics.py index b7b4e0523..1a1781137 100644 --- a/py/desispec/test/test_cosmics.py +++ b/py/desispec/test/test_cosmics.py @@ -86,7 +86,3 @@ def test_reject_cosmics(self): reject_cosmic_rays(image) cosmic = (image.pix > 0) self.assertTrue(np.all(image.mask[cosmic] & ccdmask.COSMIC)) - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_database.py b/py/desispec/test/test_database.py index 33d480c22..4f5f0574a 100644 --- a/py/desispec/test/test_database.py +++ b/py/desispec/test/test_database.py @@ -123,9 +123,3 @@ def test_frameid(self): self.assertEqual(frameid(9876543, 'z9'), 987654329) -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) diff --git a/py/desispec/test/test_emlinefit.py b/py/desispec/test/test_emlinefit.py index 3b5e2ad40..222367776 100644 --- a/py/desispec/test/test_emlinefit.py +++ b/py/desispec/test/test_emlinefit.py @@ -52,13 +52,3 @@ def test_get_emlines(self): #- but OIII should have NaN for second since it is off wavelength grid self.assertFalse(np.isnan(results['OIII']['FLUX'][0])) self.assertTrue(np.isnan(results['OIII']['FLUX'][1])) - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m desispec.test.test_emlinefit - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_extract.py b/py/desispec/test/test_extract.py index c54f2a3bd..444b24760 100644 --- a/py/desispec/test/test_extract.py +++ b/py/desispec/test/test_extract.py @@ -171,6 +171,3 @@ def test_bundles2(self): def test_bundles3(self): self._test_bundles("desi_extract_spectra -i {} -p {} -w 7500,7530,0.75 --nwavestep 10 -f {} --bundlesize 5 -o {} -m {} -s {} -n {}", 20, 5) - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_fiberbitmask.py b/py/desispec/test/test_fiberbitmask.py index 47d8b8415..a3b7a91d4 100644 --- a/py/desispec/test/test_fiberbitmask.py +++ b/py/desispec/test/test_fiberbitmask.py @@ -38,7 +38,3 @@ def test_framebitmask(self): ivar2 = get_fiberbitmasked_frame_arrays(self.frame, bitmask=1) self.assertTrue( np.all(ivar1 == ivar2) ) - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_fibercrosstalk.py b/py/desispec/test/test_fibercrosstalk.py index f0688b109..bea303b10 100644 --- a/py/desispec/test/test_fibercrosstalk.py +++ b/py/desispec/test/test_fibercrosstalk.py @@ -74,6 +74,3 @@ def test_fiber_crosstalk(self): xyset = read_xytraceset(self.psffile) correct_fiber_crosstalk(spectra,xyset=xyset) - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_fiberflat.py b/py/desispec/test/test_fiberflat.py index 66bd20311..b63cb7c1d 100644 --- a/py/desispec/test/test_fiberflat.py +++ b/py/desispec/test/test_fiberflat.py @@ -404,8 +404,3 @@ def test_slice(self): x = self.ff[1:2] x = self.ff[[1,2,3]] x = self.ff[self.ff.fibers<3] - - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_fibermap.py b/py/desispec/test/test_fibermap.py index e9bf0ab59..ffe4af862 100644 --- a/py/desispec/test/test_fibermap.py +++ b/py/desispec/test/test_fibermap.py @@ -131,14 +131,3 @@ def test_update_survey_keywords(self): update_survey_keywords(hdr) self.assertEqual(hdr['SURVEY'], 'sv2') self.assertEqual(hdr['FAPRGRM'], 'dark') - - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_flux_calibration.py b/py/desispec/test/test_flux_calibration.py index 3624afbc9..259a3f34c 100644 --- a/py/desispec/test/test_flux_calibration.py +++ b/py/desispec/test/test_flux_calibration.py @@ -232,9 +232,3 @@ def test_isStdStar(self): def test_main(self): pass - - - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_frame.py b/py/desispec/test/test_frame.py index 1401c782d..59c60cc16 100644 --- a/py/desispec/test/test_frame.py +++ b/py/desispec/test/test_frame.py @@ -112,7 +112,3 @@ def test_vet(self): # Mess with shape frame.nspec = 5 self.assertEqual(frame.vet(), 1) - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_gpu.py b/py/desispec/test/test_gpu.py index f2abe14d0..781c3a578 100644 --- a/py/desispec/test/test_gpu.py +++ b/py/desispec/test/test_gpu.py @@ -50,10 +50,3 @@ def gather(self, value, root): desispec.gpu.redistribute_gpu_ranks(comm=FakeComm(0,16)) desispec.gpu.redistribute_gpu_ranks(comm=FakeComm(1,16)) - - - - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_image.py b/py/desispec/test/test_image.py index 3627b3ba1..093bd5852 100644 --- a/py/desispec/test/test_image.py +++ b/py/desispec/test/test_image.py @@ -122,7 +122,3 @@ def test_slicing(self): img1[1:2, 'blat'] with self.assertRaises(ValueError): img1[None, 1:2] - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_io.py b/py/desispec/test/test_io.py index ef46b68a4..e43427080 100644 --- a/py/desispec/test/test_io.py +++ b/py/desispec/test/test_io.py @@ -4,12 +4,6 @@ """ import sys -if __name__ == '__main__': - print('Run this instead:') - # print('python setup.py test -m desispec.test.test_io') - print('pytest py/desispec/test/test_io.py') - sys.exit(1) - import unittest from unittest.mock import patch, MagicMock import os @@ -83,16 +77,19 @@ def tearDownClass(cls): for testfile in [cls.testfile, cls.testyfile, cls.testbrfile, cls.testlog]: if os.path.exists(testfile): os.remove(testfile) - for e in cls.origEnv: if cls.origEnv[e] is None: del os.environ[e] else: os.environ[e] = cls.origEnv[e] - if os.path.exists(cls.testDir): + if os.path.isdir(cls.testDir): rmtree(cls.testDir) + # reset the readonly cache + from ..io import meta + meta._desi_root_readonly = None + def test_write_bintable(self): """Test writing binary tables to FITS. """ @@ -975,7 +972,8 @@ def test_desi_root_readonly(self): meta._desi_root_readonly = None #- Case 1: $DESI_ROOT_READONLY is set and exists -> use it - os.environ['DESI_ROOT_READONLY'] = tempfile.mkdtemp() + tmpdir = tempfile.mkdtemp() + os.environ['DESI_ROOT_READONLY'] = tmpdir blat = meta.get_desi_root_readonly() self.assertEqual(blat, os.environ['DESI_ROOT_READONLY']) @@ -1636,9 +1634,3 @@ def test_camword_spectros(self): self.assertEqual(spectros_to_camword([5,6,0]), 'a056') -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) diff --git a/py/desispec/test/test_linalg.py b/py/desispec/test/test_linalg.py index ec94044f3..8d3dee78f 100644 --- a/py/desispec/test/test_linalg.py +++ b/py/desispec/test/test_linalg.py @@ -85,6 +85,3 @@ def test_cholesky_invert(self): def runTest(self): pass - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_parallel.py b/py/desispec/test/test_parallel.py index 9028604eb..377876444 100644 --- a/py/desispec/test/test_parallel.py +++ b/py/desispec/test/test_parallel.py @@ -161,14 +161,3 @@ def check_weight_distribution(weights, groups, num_nodes, groups_per_node): groups = weighted_partition(weights, num_groups-3, groups_per_node=groups_per_node) check_weight_distribution(weights, groups, num_nodes, groups_per_node) - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_params.py b/py/desispec/test/test_params.py index f01313bee..c5703950a 100644 --- a/py/desispec/test/test_params.py +++ b/py/desispec/test/test_params.py @@ -52,9 +52,3 @@ def test_read(self): self.assertIsNot(p3, p4) self.assertIsNot(p2, p4) -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) diff --git a/py/desispec/test/test_photo.py b/py/desispec/test/test_photo.py index c6e1c3383..53143c2be 100644 --- a/py/desispec/test/test_photo.py +++ b/py/desispec/test/test_photo.py @@ -11,11 +11,11 @@ class TestPhoto(unittest.TestCase): - def setUp(self): + @classmethod + def setUpClass(self): from astropy.table import Table - # for testing gather_targetphot and gather_tractorphot - + # sv3-dark (secondary), sv1-bright (primary), main-dark (secondary), main-dark (primary, south), main-dark (primary, north), sv3-bright (TOO) input_cat = Table() input_cat['TARGETID'] = [929413348720641, 39627061832191195, 2253225356951552, 39627565329026280, 39633086782113662, 43977491483722156] @@ -54,6 +54,10 @@ def setUp(self): tractorphot['LS_ID'] = np.array([10995128657712508, 10995128743167117, 10995128743105186]).astype(np.int64) self.tractorphot_dr10 = tractorphot + @classmethod + def tearDownClass(self): + pass + @unittest.skipUnless('NERSC_HOST' in os.environ, "not at NERSC") def test_gather_targetdirs(self): """Test that we get the correct targeting directories given a tile.""" @@ -102,6 +106,3 @@ def test_gather_tractorphot_dr10(self): tractorphot = gather_tractorphot(self.input_cat_dr10, legacysurveydir=legacysurveydir) for col in self.tractorphot_dr10.colnames: self.assertTrue(np.all(tractorphot[col] == self.tractorphot_dr10[col])) - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_pipeline_plan.py b/py/desispec/test/test_pipeline_plan.py index 3441e7dfd..f6dc34874 100644 --- a/py/desispec/test/test_pipeline_plan.py +++ b/py/desispec/test/test_pipeline_plan.py @@ -68,15 +68,3 @@ def test_create_load_prod(self): # fullgrph = load_prod() # self.assertTrue(grph == fullgrph) pass - - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_pipeline_run.py b/py/desispec/test/test_pipeline_run.py index 9c1d4fb46..c4835d1f9 100644 --- a/py/desispec/test/test_pipeline_run.py +++ b/py/desispec/test/test_pipeline_run.py @@ -82,8 +82,3 @@ def test_run(self): pass -def test_suite(): - """Allows testing of only this module with the command:: - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) diff --git a/py/desispec/test/test_pixgroup.py b/py/desispec/test/test_pixgroup.py index 90f43d6d3..2304a45e6 100644 --- a/py/desispec/test/test_pixgroup.py +++ b/py/desispec/test/test_pixgroup.py @@ -5,13 +5,6 @@ from astropy.io import fits from astropy.table import Table from copy import deepcopy - -if __name__ == '__main__': - print('Run this instead:') - thisfile = __file__.removeprefix(os.getcwd()+'/') - print(f'pytest {thisfile}') - sys.exit(1) - from ..test.util import get_frame_data from ..io import findfile, write_frame, read_spectra, write_spectra, empty_fibermap, specprod_root, iterfiles from ..io.util import add_columns @@ -377,9 +370,3 @@ def test_exp2healpix_map(self): self.assertEqual(n6, 0) -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m desispec.test.test_pixgroup - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) diff --git a/py/desispec/test/test_preproc.py b/py/desispec/test/test_preproc.py index 3a447e38d..dc7f67073 100644 --- a/py/desispec/test/test_preproc.py +++ b/py/desispec/test/test_preproc.py @@ -479,14 +479,3 @@ def test_default_pixflat(self): def test_default_mask(self): image = preproc(self.rawimage, self.header, primary_header = self.primary_header, mask=True) - - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_qa.py b/py/desispec/test/test_qa.py index 9b6912c4c..6e1f32986 100644 --- a/py/desispec/test/test_qa.py +++ b/py/desispec/test/test_qa.py @@ -316,18 +316,3 @@ def test_qa_frame_plot(self): def runTest(self): pass - - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - - - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() - #qa_frame_plot_test() diff --git a/py/desispec/test/test_ql.py b/py/desispec/test/test_ql.py index c58a4f6e6..6a93b9f80 100644 --- a/py/desispec/test/test_ql.py +++ b/py/desispec/test/test_ql.py @@ -216,8 +216,3 @@ def test_QA(self): # if runcmd(cmd) != 0: # raise RuntimeError('quicklook pipeline failed') - - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_ql_pa.py b/py/desispec/test/test_ql_pa.py index 3f4b2a5c9..48df76063 100644 --- a/py/desispec/test/test_ql_pa.py +++ b/py/desispec/test/test_ql_pa.py @@ -148,7 +148,3 @@ def setUp(self): # pargs["dumpfile"]=self.pixfile # img=pa(inp,**pargs) # self.assertTrue(np.all(img.mask == mask)) - - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_ql_qa.py b/py/desispec/test/test_ql_qa.py index 6a07403e2..e57c5a9ea 100644 --- a/py/desispec/test/test_ql_qa.py +++ b/py/desispec/test/test_ql_qa.py @@ -535,15 +535,3 @@ def testCalculateSNR(self): resl=qa(inp,**qargs) self.assertTrue("yaml" in qargs["qafile"]) self.assertTrue(len(resl["METRICS"]["MEDIAN_SNR"])==self.nspec) #- positive definite - - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - -if __name__ == '__main__': - unittest.main() - diff --git a/py/desispec/test/test_qlextract.py b/py/desispec/test/test_qlextract.py index d0a659f6d..cf00f81ea 100644 --- a/py/desispec/test/test_qlextract.py +++ b/py/desispec/test/test_qlextract.py @@ -76,6 +76,3 @@ def test_boxcar(self): self.assertEqual(resolution.shape[0], nspec) # resolution.shape[1] is number of diagonals; picked by algorithm self.assertEqual(resolution.shape[2], nwave) - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_resample.py b/py/desispec/test/test_resample.py index 6dbd50349..1c71d6400 100644 --- a/py/desispec/test/test_resample.py +++ b/py/desispec/test/test_resample.py @@ -100,8 +100,3 @@ def test_edges(self): yy = resample_flux(xx, x, y) diff = np.abs(yy - np.interp(xx, x, y)) self.assertLess(np.max(np.abs(diff)), 1e-2) - - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_resolution.py b/py/desispec/test/test_resolution.py index dd01cff12..50da72ed1 100644 --- a/py/desispec/test/test_resolution.py +++ b/py/desispec/test/test_resolution.py @@ -144,7 +144,3 @@ def test_sort_and_symmeterize(self): data2, offsets2 = desispec.resolution._sort_and_symmeterize(data, offsets) self.assertTrue(data is data2) self.assertTrue(offsets is offsets2) - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_scores.py b/py/desispec/test/test_scores.py index 01b4ad63a..6dc13c269 100644 --- a/py/desispec/test/test_scores.py +++ b/py/desispec/test/test_scores.py @@ -38,13 +38,3 @@ def test_main(self): def runTest(self): pass - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_scripts.py b/py/desispec/test/test_scripts.py index 3b8c3ad93..36a44a3b5 100644 --- a/py/desispec/test/test_scripts.py +++ b/py/desispec/test/test_scripts.py @@ -140,14 +140,3 @@ def clear_environment(self): environ[k] = self.environ_cache[k] self.environ_cache.clear() return - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - - -if __name__ == '__main__': - unittest.main() \ No newline at end of file diff --git a/py/desispec/test/test_sky.py b/py/desispec/test/test_sky.py index 3beb6c289..08953641b 100644 --- a/py/desispec/test/test_sky.py +++ b/py/desispec/test/test_sky.py @@ -160,13 +160,3 @@ def test_main(self): def runTest(self): pass - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_specstatus.py b/py/desispec/test/test_specstatus.py index 619285943..4ade65b75 100644 --- a/py/desispec/test/test_specstatus.py +++ b/py/desispec/test/test_specstatus.py @@ -142,14 +142,3 @@ def test_update_lastnight(self): newstatus = update_specstatus(specstatus, tiles, update_only=False) self.assertTrue(np.all(newstatus['LASTNIGHT'] != specstatus['LASTNIGHT'])) self.assertTrue(np.all(newstatus['LASTNIGHT'] == tiles['LASTNIGHT'])) - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - -#- run all unit tests in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_spectra.py b/py/desispec/test/test_spectra.py index 42f1cee7e..3053586fa 100644 --- a/py/desispec/test/test_spectra.py +++ b/py/desispec/test/test_spectra.py @@ -466,15 +466,3 @@ def test_slice(self): sp2 = sp1[[True,False,True,False,True]] for band in self.bands: self.assertEqual(sp2.flux[band].shape[0], 3) - - -def test_suite(): - """Allows testing of only this module with the command:: - - python setup.py test -m - """ - return unittest.defaultTestLoader.loadTestsFromName(__name__) - -#- This runs all test* functions in any TestCase class in this file -if __name__ == '__main__': - unittest.main() diff --git a/py/desispec/test/test_util.py b/py/desispec/test/test_util.py index 83798bd2e..34ae16ef9 100644 --- a/py/desispec/test/test_util.py +++ b/py/desispec/test/test_util.py @@ -405,8 +405,3 @@ def test_parse_keyval(self): key, value = util.parse_keyval("biz=False ") self.assertEqual(type(value), bool) self.assertEqual(value, False) - - -if __name__ == '__main__': - unittest.main() - diff --git a/py/desispec/test/test_zcatalog.py b/py/desispec/test/test_zcatalog.py index 599a79461..025749ac8 100644 --- a/py/desispec/test/test_zcatalog.py +++ b/py/desispec/test/test_zcatalog.py @@ -49,8 +49,3 @@ def test_find_primary_spectra(self): zcat['TSNR2_LRG'] = np.zeros(len(zcat)) n, best = find_primary_spectra(zcat, sort_column='BLAT') self.assertTrue( np.all(zcat['TEST'] == best) ) - - -if __name__ == '__main__': - unittest.main() - diff --git a/py/desispec/test/test_zproc.py b/py/desispec/test/test_zproc.py index c89c5620c..49e92c971 100644 --- a/py/desispec/test/test_zproc.py +++ b/py/desispec/test/test_zproc.py @@ -49,8 +49,3 @@ def test_distribute_ranks_to_blocks(self): #- are the ranks assigend within each block actually unique and contiguous? for block_num in block_ranks: self.assertEqual(set(block_ranks[block_num]), set(range(block_sizes[block_num]))) - - -if __name__ == '__main__': - unittest.main() -