diff --git a/tests/maf/test_3x2fom.py b/tests/maf/test_3x2fom.py index 877db349c..ed71a0d26 100644 --- a/tests/maf/test_3x2fom.py +++ b/tests/maf/test_3x2fom.py @@ -21,8 +21,8 @@ def setUp(self): "Skipping 3x3 metric test because no dust maps.", ) def test_3x2(self): - # Only testing that the metric successfully runs, not checking that the - # output values are valid. + # Only testing that the metric successfully runs, not checking that + # the output values are valid. bundle_list = [] nside = 64 colmap = maf.batches.col_map_dict("fbs") diff --git a/tests/maf/test_archive.py b/tests/maf/test_archive.py index 6fc22541a..fda055502 100644 --- a/tests/maf/test_archive.py +++ b/tests/maf/test_archive.py @@ -1,5 +1,4 @@ # imports -import os import sys import unittest from os import path @@ -128,12 +127,12 @@ def test_get_family_descriptions(self): def test_describe_families(self): if "IPython" in sys.modules: - with patch("IPython.display.display_markdown") as display_markdown, patch( - "IPython.display.HTML" - ) as display_html, patch("IPython.display") as ip_display: + with patch("IPython.display.display_markdown") as _, patch("IPython.display.HTML") as _, patch( + "IPython.display" + ) as _: self.perform_describe_families_test() else: - with patch("builtins.print") as print_mock: + with patch("builtins.print") as _: self.perform_describe_families_test() def perform_describe_families_test(self): diff --git a/tests/maf/test_basemetrics.py b/tests/maf/test_basemetrics.py index 889bfc140..4194b7e75 100644 --- a/tests/maf/test_basemetrics.py +++ b/tests/maf/test_basemetrics.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import rubin_sim.maf.metrics as metrics @@ -13,7 +10,9 @@ def test_reduce_dict(self): self.assertEqual(list(testmetric.reduce_funcs.keys()), []) def test_metric_name(self): - """Test that metric name is set appropriately automatically and explicitly""" + """Test that metric name is set appropriately automatically + and when explicitly passed. + """ # Test automatic setting of metric name testmetric = metrics.BaseMetric("testcol") self.assertEqual(testmetric.name, "Base testcol") @@ -33,7 +32,8 @@ def test_col_registry(self): colset = set() colset.add(cols) testmetric = metrics.BaseMetric(cols) - # Class registry should have dictionary with values = set of columns for metric class + # Class registry should have dictionary with values = + # set of columns for metric class for item in colset: self.assertIn(item, testmetric.col_registry.col_set) cols = ["onecolumn", "twocolumn"] diff --git a/tests/maf/test_batches.py b/tests/maf/test_batches.py index e84583291..908ca4061 100644 --- a/tests/maf/test_batches.py +++ b/tests/maf/test_batches.py @@ -27,18 +27,31 @@ def setUp(self): ) def testload_them_all(self): ack = batches.altazHealpix() + assert ack is not None ack = batches.altazLambert() + assert ack is not None ack = batches.standard_summary() + assert ack is not None ack = batches.standard_metrics("night") + assert ack is not None ack = batches.filtersPerNight() + assert ack is not None ack = batches.filtersWholeSurvey() + assert ack is not None ack = batches.glanceBatch() + assert ack is not None ack = batches.hourglassPlots() + assert ack is not None ack = batches.slewBasics() + assert ack is not None ack = batches.timeGaps() + assert ack is not None ack = batches.metadataBasics("airmass") + assert ack is not None ack = batches.metadataBasicsAngle("rotskyPos") + assert ack is not None ack = batches.metadataMaps("fiveSigmaDepth") + assert ack is not None @unittest.skipUnless( os.path.isdir(os.path.join(get_data_dir(), "maf")), @@ -47,9 +60,13 @@ def testload_them_all(self): def test_moving_objects_batches(self): slicer = MoObjSlicer() ack = batches.quick_discovery_batch(slicer) + assert ack is not None ack = batches.discovery_batch(slicer) + assert ack is not None ack = batches.characterization_inner_batch(slicer) + assert ack is not None ack = batches.characterization_outer_batch(slicer) + assert ack is not None def test_moving_fractions(self): bdict = {} @@ -58,24 +75,27 @@ def test_moving_fractions(self): bdict["days"] = bundle bdict["days"].slicer = MoObjSlicer() bdict["days"].slicer.slice_points["H"] = np.arange(50) - # Should probably fill in some data as well to make sure - # more parts of the code get exercised, but this is a start. - ack = batches.run_completeness_summary(bdict, 0.0, [10, 20], None, None) - ack = batches.run_fraction_summary(bdict, 0.0, None, None) - ack = batches.plot_fractions(bdict, out_dir=self.out_dir) - # A mystery why this batch takes a bundle while the rest take dicts. - ack = batches.plot_single(bundle, out_dir=self.out_dir) - ack = batches.plot_activity(bdict) + # This is a start, but the methods below aren't really doing anything + # without appropriately named/values bundles in the bdict. + batches.run_completeness_summary(bdict, 0.0, [10, 20], None, None) + batches.run_fraction_summary(bdict, 0.0, None, None) + batches.plot_fractions(bdict, out_dir=self.out_dir) + # This batch takes a single bundle because it plots that single + # bundle with multiple summary interpretations of the metric + batches.plot_single(bundle, out_dir=self.out_dir) + batches.plot_activity(bdict) @unittest.skipUnless( os.path.isdir(os.path.join(get_data_dir(), "maf")), "Skipping scienceRadarBatch test because operating without full MAF test data", ) def test_science_radar(self): - # Loading the science radar batch requires reading a significant set of input files + # Loading the science radar batch requires reading a significant + # set of input files # This test is skipped if running with the lighter set of test data. # batch requires reading a lot of input files for lightcurves ack = batches.science_radar_batch() + assert ack is not None @unittest.skipUnless( os.path.isdir(os.path.join(get_data_dir(), "maf")), diff --git a/tests/maf/test_cadencemetrics.py b/tests/maf/test_cadencemetrics.py index a9334f795..0e9e6266b 100644 --- a/tests/maf/test_cadencemetrics.py +++ b/tests/maf/test_cadencemetrics.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import numpy as np @@ -101,7 +98,8 @@ def test_general_uniformity_metric(self): np.testing.assert_almost_equal(result3, 0.0) # Test setup with max_value > 1 metric = metrics.GeneralUniformityMetric(col="observationStartMJD", min_value=0, max_value=10) - # Make a perfectly uniform dist covering limited range (0-1 out of 0-10 range) + # Make a perfectly uniform dist covering limited range + # (0-1 out of 0-10 range) data["observationStartMJD"] = np.arange(0.0, 1 + step / 2, step) result5 = metric.run(data, slice_point) self.assertEqual(result5, 0.9) @@ -163,7 +161,8 @@ def test_t_gaps_percent_metric(self): data["observationStartMJD"] = [1, 2, 3, 4] metric = metrics.TgapsPercentMetric(min_time=0.5, max_time=1.5, all_gaps=True) result3 = metric.run(data) - # This should be 50% -- 3 gaps of 1 day, 2 gaps of 2 days, 1 gap of 3 days + # This should be 50% -- 3 gaps of 1 day, 2 gaps of 2 days, and + # 1 gap of 3 days self.assertEqual(result3, 50) def test_night_gap_metric(self): @@ -248,7 +247,8 @@ def test_rapid_revisit_uniformity_metric(self): for i in range(10000): dtimes = rng.rand(100) data['observationStartMJD'] = dtimes.cumsum() - metric = metrics.RapidRevisitUniformityMetric(d_tmin=0.1, d_tmax=0.8, min_nvisits=50) + metric = metrics.RapidRevisitUniformityMetric(d_tmin=0.1, + d_tmax=0.8, min_nvisits=50) result = metric.run(data) resmin = np.min([resmin, result]) resmax = np.max([resmax, result]) @@ -314,7 +314,8 @@ def test_transient_metric(self): metric = metrics.TransientMetric(survey_duration=ndata / 365.25 * 2) self.assertEqual(metric.run(data_slice), 0.5) - # Set half of the m5 of the observations very bright, so kill another half. + # Set half of the m5 of the observations very bright, + # so kill another half. data_slice["fiveSigmaDepth"][0:50] = 20 self.assertEqual(metric.run(data_slice), 0.25) diff --git a/tests/maf/test_calibrationmetrics.py b/tests/maf/test_calibrationmetrics.py index 1b5b8dcf4..ebe682958 100644 --- a/tests/maf/test_calibrationmetrics.py +++ b/tests/maf/test_calibrationmetrics.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import numpy as np @@ -50,8 +47,9 @@ def test_parallax_metric(self): worse4 = metrics.ParallaxMetric(normalize=flag, rmag=22.0, seeing_col="finSeeing").run( data[0:300], slice_point ) - # Make sure the RMS increases as seeing increases, the star gets fainter, - # the background gets brighter, or the baseline decreases. + # Make sure the RMS increases as seeing increases, + # the star gets fainter, the background gets brighter, + # or the baseline decreases. if flag: pass else: @@ -102,10 +100,12 @@ def test_proper_motion_metric(self): worse4 = metrics.ProperMotionMetric(normalize=flag, rmag=22.0, seeing_col="finSeeing").run( data[0:300], slice_point ) - # Make sure the RMS increases as seeing increases, the star gets fainter, - # the background gets brighter, or the baseline decreases. + # Make sure the RMS increases as seeing increases, + # the star gets fainter, the background gets brighter, + # or the baseline decreases. if flag: - # When normalized, mag of star and m5 don't matter (just scheduling). + # When normalized, mag of star and m5 don't matter + # (just scheduling). self.assertAlmostEqual(worse2, worse1) self.assertAlmostEqual(worse4, worse3) # But using fewer points should make proper motion worse. @@ -204,7 +204,8 @@ def test_parallax_dcr_degen_metric(self): val = metric.run(data) np.testing.assert_almost_equal(val, 0.0, decimal=2) - # Generate a random distribution that should have little or no correlation + # Generate a random distribution that should have + # little or no correlation rng = np.random.RandomState(42) data["ra_pi_amp"] = rng.rand(100) * 2 - 1.0 diff --git a/tests/maf/test_healpixslicer.py b/tests/maf/test_healpixslicer.py index 1d4d4d305..811b756ef 100644 --- a/tests/maf/test_healpixslicer.py +++ b/tests/maf/test_healpixslicer.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import os import unittest @@ -37,7 +34,8 @@ def make_data_values( datavalues = datavalues[randind] datavalues = np.array(list(zip(datavalues)), dtype=[("testdata", "float")]) data.append(datavalues) - # Generate RA/Dec values equally spaces on sphere between ramin/max, decmin/max. + # Generate RA/Dec values equally spaces on sphere between + # ramin/max, decmin/max. ra = np.arange(0, size, dtype="float") ra *= (float(ramax) - float(ramin)) / (ra.max() - ra.min()) randorder = rng.rand(size) @@ -65,7 +63,8 @@ def make_data_values( def calc_dist_vincenty(ra1, dec1, ra2, dec2): """Calculates distance on a sphere using the Vincenty formula. - Give this function RA/Dec values in radians. Returns angular distance(s), in radians. + Give this function RA/Dec values in radians. + Returns angular distance(s), in radians. Note that since this is all numpy, you could input arrays of RA/Decs.""" d1 = (np.cos(dec2) * np.sin(ra2 - ra1)) ** 2 + ( np.cos(dec1) * np.sin(dec2) - np.sin(dec1) * np.cos(dec2) * np.cos(ra2 - ra1) @@ -87,7 +86,8 @@ def test_slicertype(self): self.assertEqual(testslicer.slicer_name, "HealpixSlicer") def test_nsides_nbins(self): - """Test that number of sides passed to slicer produces expected number of bins.""" + """Test that number of sides passed to slicer produces expected + number of bins.""" nsides = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512] npixx = [12, 48, 192, 768, 3072, 12288, 49152, 196608, 786432, 3145728] for nside, npix in zip(nsides, npixx): @@ -129,8 +129,10 @@ def tearDown(self): self.testslicer = None def test_slicer_equivalence(self): - """Test that slicers are marked equal when appropriate, and unequal when appropriate.""" - # Note that they are judged equal based on nsides (not on data in ra/dec spatial tree). + """Test that slicers are marked equal when appropriate, + and unequal when appropriate.""" + # Note that they are judged equal based on nsides + # (not on data in ra/dec spatial tree). testslicer2 = HealpixSlicer( nside=self.nside, verbose=False, @@ -180,7 +182,8 @@ def tearDown(self): self.testslicer = None def test_iteration(self): - """Test iteration goes through expected range and ra/dec are in expected range (radians).""" + """Test iteration goes through expected range and ra/dec + are in expected range (radians).""" npix = hp.nside2npix(self.nside) for i, s in enumerate(self.testslicer): self.assertEqual(i, s["slice_point"]["sid"]) @@ -201,7 +204,8 @@ def test_get_item(self): class TestHealpixSlicerSlicing(unittest.TestCase): - # Note that this is really testing baseSpatialSlicer, as slicing is done there for healpix grid + # Note that this is really testing baseSpatialSlicer, + # as slicing is done there for healpix grid def setUp(self): self.camera_footprint_file = os.path.join(get_data_dir(), "tests", "fov_map.npz") @@ -233,7 +237,8 @@ def tearDown(self): self.testslicer = None def test_slicing(self): - """Test slicing returns (all) data points which are within 'radius' of bin point.""" + """Test slicing returns (all) data points which are within + 'radius' of bin point.""" # Test that slicing fails before setup_slicer self.assertRaises(NotImplementedError, self.testslicer._slice_sim_data, 0) # Set up and test actual slicing. @@ -252,7 +257,8 @@ def test_slicing(self): class TestHealpixChipGap(unittest.TestCase): - # Note that this is really testing baseSpatialSlicer, as slicing is done there for healpix grid + # Note that this is really testing baseSpatialSlicer, + # as slicing is done there for healpix grid def setUp(self): self.camera_footprint_file = os.path.join(get_data_dir(), "tests", "fov_map.npz") @@ -285,7 +291,8 @@ def tearDown(self): self.testslicer = None def test_slicing(self): - """Test slicing returns (most) data points which are within 'radius' of bin point.""" + """Test slicing returns (most) data points which are + within 'radius' of bin point.""" # Test that slicing fails before setup_slicer self.assertRaises(NotImplementedError, self.testslicer._slice_sim_data, 0) # Set up and test actual slicing. @@ -293,10 +300,12 @@ def test_slicing(self): for s in self.testslicer: ra = s["slice_point"]["ra"] dec = s["slice_point"]["dec"] - # Find the points of 'dv' which are within self.radius of this slice_point + # Find the points of 'dv' which are within self.radius of + # this slice_point distances = calc_dist_vincenty(ra, dec, self.dv["ra"], self.dv["dec"]) didxs = np.where(distances <= np.radians(self.radius)) - # find the indexes of dv which the slicer says are in the camera footprint + # find the indexes of dv which the slicer says are in the + # camera footprint sidxs = s["idxs"] self.assertLessEqual(len(sidxs), len(didxs[0])) if len(sidxs) > 0: diff --git a/tests/maf/test_healpixsubsetslicer.py b/tests/maf/test_healpixsubsetslicer.py index 14cc302ca..1d4f0206d 100644 --- a/tests/maf/test_healpixsubsetslicer.py +++ b/tests/maf/test_healpixsubsetslicer.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import os import unittest @@ -36,7 +33,8 @@ def make_data_values( datavalues = datavalues[randind] datavalues = np.array(list(zip(datavalues)), dtype=[("testdata", "float")]) data.append(datavalues) - # Generate RA/Dec values equally spaces on sphere between ramin/max, decmin/max. + # Generate RA/Dec values equally spaces on sphere between ramin/max, + # decmin/max. ra = np.arange(0, size, dtype="float") ra *= (float(ramax) - float(ramin)) / (ra.max() - ra.min()) randorder = rng.rand(size) @@ -64,8 +62,10 @@ def make_data_values( def calc_dist_vincenty(ra1, dec1, ra2, dec2): """Calculates distance on a sphere using the Vincenty formula. - Give this function RA/Dec values in radians. Returns angular distance(s), in radians. - Note that since this is all numpy, you could input arrays of RA/Decs.""" + Give this function RA/Dec values in radians. + Returns angular distance(s), in radians. + Note that since this is all numpy, you could input arrays of RA/Decs. + """ d1 = (np.cos(dec2) * np.sin(ra2 - ra1)) ** 2 + ( np.cos(dec1) * np.sin(dec2) - np.sin(dec1) * np.cos(dec2) * np.cos(ra2 - ra1) ) ** 2 @@ -125,8 +125,11 @@ def tearDown(self): self.testslicer = None def test_slicer_equivalence(self): - """Test that slicers are marked equal when appropriate, and unequal when appropriate.""" - # Note that they are judged equal based on nsides (not on data in ra/dec spatial tree). + """Test that slicers are marked equal when appropriate, + and unequal when appropriate. + """ + # Note that they are judged equal based on nsides + # (not on data in ra/dec spatial tree). testslicer2 = HealpixSubsetSlicer( nside=self.nside, hpid=np.arange(0, 10), @@ -180,8 +183,9 @@ def tearDown(self): self.testslicer = None def test_iteration(self): - """Test iteration goes through expected range and ra/dec are in expected range (radians).""" - npix = hp.nside2npix(self.nside) + """Test iteration goes through expected range and ra/dec + are in expected range (radians). + """ for i, s in enumerate(self.testslicer): # We do not expect testslicer.slice_point['sid'] to == i .. # The slicer will only iterate over the subset @@ -201,7 +205,8 @@ def test_get_item(self): class TestHealpixSlicerSlicing(unittest.TestCase): - # Note that this is really testing baseSpatialSlicer, as slicing is done there for healpix grid + # Note that this is really testing baseSpatialSlicer, + # as slicing is done there for healpix grid def setUp(self): self.camera_footprint_file = os.path.join(get_data_dir(), "tests", "fov_map.npz") @@ -234,7 +239,8 @@ def tearDown(self): self.testslicer = None def test_slicing(self): - """Test slicing returns (all) data points which are within 'radius' of bin point.""" + """Test slicing returns (all) data points which are within + 'radius' of bin point.""" # Test that slicing fails before setup_slicer self.assertRaises(NotImplementedError, self.testslicer._slice_sim_data, 0) # Set up and test actual slicing. @@ -264,7 +270,8 @@ def test_subset_slice(self): ) testslicer.setup_slicer(self.dv) self.testslicer.setup_slicer(self.dv) - # For points which return values when used with the full set of points (self.testslicer) + # For points which return values when used with the full set + # of points (self.testslicer) # there will be no data when used with the subset of points for s in self.testslicer: if s["slice_point"]["sid"] > 2: diff --git a/tests/maf/test_hgplotters.py b/tests/maf/test_hgplotters.py index da2ca46ef..975d6a93f 100644 --- a/tests/maf/test_hgplotters.py +++ b/tests/maf/test_hgplotters.py @@ -34,9 +34,9 @@ def test_month_plot(self): out_dir=self.out_dir, results_db=self.results_db, ) - run_result = bundle_group.run_all() + _ = bundle_group.run_all() plot_func = plots.YearHourglassPlot(2023) - result = metric_bundle.plot(plotFunc=plot_func) + _ = metric_bundle.plot(plotFunc=plot_func) class TestTimeUseHourglassPlots(unittest.TestCase): @@ -62,9 +62,9 @@ def test_year_plot(self): out_dir=self.out_dir, results_db=self.results_db, ) - run_result = bundle_group.run_all() + _ = bundle_group.run_all() plot_func = plots.YearHourglassUsePlot(2023) - result = metric_bundle.plot(plotFunc=plot_func) + _ = metric_bundle.plot(plotFunc=plot_func) def create_sample_visit_db(dir_name): diff --git a/tests/maf/test_hourglassmetric.py b/tests/maf/test_hourglassmetric.py index eaa551464..110ac884c 100644 --- a/tests/maf/test_hourglassmetric.py +++ b/tests/maf/test_hourglassmetric.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import numpy as np diff --git a/tests/maf/test_io.py b/tests/maf/test_io.py index 3e2682b73..2340ec8a2 100644 --- a/tests/maf/test_io.py +++ b/tests/maf/test_io.py @@ -1,12 +1,9 @@ -import matplotlib -import numpy as np -import numpy.ma as ma - -matplotlib.use("Agg") import unittest from tempfile import TemporaryFile import healpy as hp +import numpy as np +import numpy.ma as ma import rubin_sim.maf.slicers as slicers diff --git a/tests/maf/test_json.py b/tests/maf/test_json.py index 2ed7ad315..600c8c315 100644 --- a/tests/maf/test_json.py +++ b/tests/maf/test_json.py @@ -1,16 +1,15 @@ import json import unittest -import matplotlib import numpy as np import numpy.ma as ma -matplotlib.use("Agg") import rubin_sim.maf.slicers as slicers def make_data_values(size=100, min=0.0, max=1.0, random=-1): - """Generate a simple array of numbers, evenly arranged between min/max, but (optional) random order.""" + """Generate a simple array of numbers, evenly arranged between min/max, + but (optional) random order.""" datavalues = np.arange(0, size, dtype="float") datavalues *= (float(max) - float(min)) / (datavalues.max() - datavalues.min()) datavalues += min @@ -70,7 +69,8 @@ def make_field_data(): def make_opsim_data_values(field_data, size=10000, min=0.0, max=1.0, random=88): - """Generate a simple array of numbers, evenly arranged between min/max, but (optional) random order.""" + """Generate a simple array of numbers, evenly arranged between min/max, + but (optional) random order.""" datavalues = np.arange(0, size, dtype="float") datavalues *= (float(max) - float(min)) / (datavalues.max() - datavalues.min()) datavalues += min diff --git a/tests/maf/test_maps.py b/tests/maf/test_maps.py index cc2299a77..5cab043c2 100644 --- a/tests/maf/test_maps.py +++ b/tests/maf/test_maps.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import os import unittest import warnings @@ -13,7 +10,9 @@ def make_data_values(size=100, min=0.0, max=1.0, random=-1): - """Generate a simple array of numbers, evenly arranged between min/max, but (optional) random order.""" + """Generate a simple array of numbers, evenly arranged between min/max, + (optional) random order. + """ datavalues = np.arange(0, size, dtype="float") datavalues *= (float(max) - float(min)) / (datavalues.max() - datavalues.min()) datavalues += min @@ -113,11 +112,12 @@ def test_dust_map3_d(self): assert "ebv3d_dist_at_10.0" in list(result3.keys()) # Check that we can call the distance at magnitude method - dists = dustmap.distance_at_dmag(5, result3["ebv3d_dists"], result3["ebv3d_ebvs"], "r") - # And call it without running the map (and thus reading more info) first - dists = maps.DustMap3D().distance_at_dmag(5, result3["ebv3d_dists"], result3["ebv3d_ebvs"], "r") + _ = dustmap.distance_at_dmag(5, result3["ebv3d_dists"], result3["ebv3d_ebvs"], "r") + # And call it without running the map + # (and thus reading more info) first + _ = maps.DustMap3D().distance_at_dmag(5, result3["ebv3d_dists"], result3["ebv3d_ebvs"], "r") # And call it as a static method at one point on the sky - dists = maps.DustMap3D().distance_at_dmag( + _ = maps.DustMap3D().distance_at_dmag( 5, result3["ebv3d_dists"][0, :], result3["ebv3d_ebvs"][0, :], "r" ) diff --git a/tests/maf/test_metricbundle.py b/tests/maf/test_metricbundle.py index b45892ae0..f9ddfe9db 100644 --- a/tests/maf/test_metricbundle.py +++ b/tests/maf/test_metricbundle.py @@ -1,13 +1,8 @@ -import unittest - -import matplotlib - -matplotlib.use("Agg") - import glob import os import shutil import tempfile +import unittest import rubin_sim.maf.db as db import rubin_sim.maf.maps as maps diff --git a/tests/maf/test_mometrics.py b/tests/maf/test_mometrics.py index e37704ea3..0d0e86285 100644 --- a/tests/maf/test_mometrics.py +++ b/tests/maf/test_mometrics.py @@ -11,10 +11,14 @@ def setUp(self): # Set up some sso_obs data to test the metrics on. # Note that sso_obs is a numpy recarray. # The expected set of columns in sso_obs is: - # cols = ['observationStartMJD', 'night', 'fieldRA', 'fieldDec', 'rotSkyPos', 'filter', - # 'visitExposureTime', 'seeingFwhmGeom', 'fiveSigmaDepth', 'solarElong', - # 'delta', 'ra', 'dec', 'magV', 'time', 'dradt', 'ddecdt', 'phase', 'solarelon', - # 'velocity', 'magFilter', 'dmagColor', 'dmagTrail', 'dmagDetect'] + # cols = ['observationStartMJD', 'night', 'fieldRA', 'fieldDec', + # 'rotSkyPos', 'filter', + # 'visitExposureTime', 'seeingFwhmGeom', 'fiveSigmaDepth', + # 'solarElong', + # 'delta', 'ra', 'dec', 'magV', 'time', 'dradt', 'ddecdt', + # 'phase', 'solarelon', + # 'velocity', 'magFilter', 'dmagColor', 'dmagTrail', + # 'dmagDetect'] # And stackers will often add # addCols = ['appMag', 'magLimit', 'snr', 'vis'] diff --git a/tests/maf/test_movieslicer.py b/tests/maf/test_movieslicer.py index fe66f10c3..ab16c080b 100644 --- a/tests/maf/test_movieslicer.py +++ b/tests/maf/test_movieslicer.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import warnings @@ -84,7 +81,8 @@ def test_setup_slicer_binsize(self): self.assertIn("bin_size", str(w[-1].message)) def test_setup_slicer_nbins_zeros(self): - """Test what happens if give slicer test data that is all single-value.""" + """Test what happens if give slicer test data that is all + single-value.""" dv = np.zeros(100, float) dv = np.array(list(zip(dv)), dtype=[("times", "float")]) nbins = 10 @@ -137,7 +135,8 @@ def test_indexing(self): def test_equivalence(self): """Test equals method.""" - # Note that two Movie slicers will be considered equal if they are both the same kind of + # Note that two Movie slicers will be considered equal + # if they are both the same kind of # slicer AND have the same bins. # Set up self.. dvmin = 0 @@ -149,7 +148,8 @@ def test_equivalence(self): slice_col_name="times", bins=bins, cumulative=False, force_no_ffmpeg=True ) self.testslicer.setup_slicer(dv) - # Set up another slicer to match (same bins, although not the same data). + # Set up another slicer to match + # (same bins, although not the same data). dv2 = make_times(nvalues + 100, dvmin, dvmax, random=56221) testslicer2 = MovieSlicer(slice_col_name="times", bins=bins, cumulative=False, force_no_ffmpeg=True) testslicer2.setup_slicer(dv2) @@ -175,7 +175,8 @@ def test_slicing(self): dvmin = 0 dvmax = 1 nbins = 100 - # Test that testbinner raises appropriate error before it's set up (first time) + # Test that testbinner raises appropriate error before it's set up + # (first time) self.assertRaises(NotImplementedError, self.testslicer._slice_sim_data, 0) for nvalues in (100, 1000): dv = make_times(nvalues, dvmin, dvmax, random=82) diff --git a/tests/maf/test_ndslicer.py b/tests/maf/test_ndslicer.py index d75f5165e..79a9eae14 100644 --- a/tests/maf/test_ndslicer.py +++ b/tests/maf/test_ndslicer.py @@ -9,8 +9,9 @@ def make_data_values(size=100, min=0.0, max=1.0, nd=3, random=-1): - """Generate a simple array of numbers, evenly arranged between min/max, in nd dimensions, but (optional) - random order.""" + """Generate a simple array of numbers, evenly arranged between min/max, + in nd dimensions, but (optional) random order. + """ data = [] for d in range(nd): datavalues = np.arange(0, size, dtype="float") @@ -61,7 +62,8 @@ def test_setup_slicer_nbins(self): for nbins in (5, 25, 74): dv = make_data_values(nvalues, self.dvmin, self.dvmax, self.nd, random=-1) # Right number of bins? - # expect one more 'bin' to accomodate last right edge, but nbins accounts for this + # expect one more 'bin' to accomodate last right edge, + # but nbins accounts for this testslicer = NDSlicer(self.dvlist, bins_list=nbins) testslicer.setup_slicer(dv) self.assertEqual(testslicer.nslice, nbins**self.nd) @@ -70,7 +72,8 @@ def test_setup_slicer_nbins(self): bindiff = np.diff(testslicer.bins[i]) expectedbindiff = (self.dvmax - self.dvmin) / float(nbins) np.testing.assert_allclose(bindiff, expectedbindiff) - # Can we use a list of nbins too and get the right number of bins? + # Can we use a list of nbins too and get the + # right number of bins? nbins_list = [] expectednbins = 1 for d in range(self.nd): @@ -93,7 +96,9 @@ def test_setup_slicer_nbins_zeros(self): self.assertEqual(testslicer.nslice, expectednbins) def test_setup_slicer_equivalent(self): - """Test setting up slicer using defined bins and nbins is equal where expected.""" + """Test setting up slicer using defined bins and nbins is + equal where expected. + """ for nbins in (20, 105): testslicer = NDSlicer(self.dvlist, bins_list=nbins) bins = make_data_values(nbins + 1, self.dvmin, self.dvmax, self.nd, random=-1) @@ -124,9 +129,11 @@ def tearDown(self): def test_equivalence(self): """Test equals method.""" - # Note that two ND slicers will be considered equal if they are both the same kind of - # slicer AND have the same bins in all dimensions. - # Set up another slicer to match (same bins, although not the same data). + # Note that two ND slicers will be considered equal if + # they are both the same kind of slicer AND have the same bins in + # all dimensions. + # Set up another slicer to match + # (same bins, although not the same data). dv2 = make_data_values(100, self.dvmin, self.dvmax, self.nd, random=10029) dvlist = dv2.dtype.names testslicer2 = NDSlicer(slice_col_list=dvlist, bins_list=self.testslicer.bins) diff --git a/tests/maf/test_neodistanceplotter.py b/tests/maf/test_neodistanceplotter.py index 5cb08a3c0..b184ab44d 100644 --- a/tests/maf/test_neodistanceplotter.py +++ b/tests/maf/test_neodistanceplotter.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import numpy as np diff --git a/tests/maf/test_onedslicer.py b/tests/maf/test_onedslicer.py index 588c29197..160e03fb3 100644 --- a/tests/maf/test_onedslicer.py +++ b/tests/maf/test_onedslicer.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import warnings @@ -10,7 +7,8 @@ def make_data_values(size=100, min_val=0.0, max_val=1.0, random=-1): - """Generate a simple array of numbers, evenly arranged between min/max, but (optional) random order.""" + """Generate a simple array of numbers, evenly arranged between min/max, + but (optional) random order.""" datavalues = np.arange(0, size, dtype="float") datavalues *= (float(max_val) - float(min_val)) / (datavalues.max() - datavalues.min()) datavalues += min_val @@ -50,7 +48,8 @@ def test_setup_slicer_bins(self): self.assertEqual(self.testslicer.nslice, len(bins) - 1) def test_setup_slicer_nbins_zeros(self): - """Test what happens if give slicer test data that is all single-value.""" + """Test what happens if give slicer test data that is all + single-value.""" dv = np.zeros(100, float) dv = np.array(list(zip(dv)), dtype=[("testdata", "float")]) bin_size = 0.1 @@ -120,7 +119,8 @@ def test_iteration(self): self.assertEqual(s["slice_point"]["bin_left"], self.bins[i]) self.assertEqual(s["slice_point"]["bin_right"], self.bins[i + 1]) # Iteration stops while i<= nslice .. - # nslice = len(bins)-1 (and bins[i+2] is out of range but bins[i+1] is last RH edge of bins + # nslice = len(bins)-1 (and bins[i+2] is out of range + # but bins[i+1] is last RH edge of bins self.assertEqual(i, self.testslicer.nslice - 1) def test_get_item(self): @@ -140,8 +140,8 @@ def tearDown(self): def test_equivalence(self): """Test equals method.""" - # Note that two OneD slicers will be considered equal if they are both the same kind of - # slicer AND have the same bins. + # Note that two OneD slicers will be considered equal if + # they are both the same kind of slicer AND have the same bins. # Set up self.. dvmin = 0 dvmax = 1 @@ -151,13 +151,15 @@ def test_equivalence(self): # Set up reference self.testslicer = OneDSlicer(slice_col_name="testdata", bins=bins) self.testslicer.setup_slicer(dv) - # Set up another slicer to match (same bins, although not the same data). + # Set up another slicer to match + # (same bins, although not the same data). dv2 = make_data_values(nvalues + 100, dvmin, dvmax, random=334) testslicer2 = OneDSlicer(slice_col_name="testdata", bins=bins) testslicer2.setup_slicer(dv2) self.assertTrue(self.testslicer == testslicer2) self.assertFalse(self.testslicer != testslicer2) - # Set up another slicer that should not match (different bins, based on data) + # Set up another slicer that should not match + # (different bins, based on data) dv2 = make_data_values(nvalues, dvmin + 1, dvmax + 1, random=445) testslicer2 = OneDSlicer(slice_col_name="testdata", bins=None) testslicer2.setup_slicer(dv2) @@ -206,9 +208,11 @@ def test_slicing(self): dvmax = 1 stepsize = 0.01 bins = np.arange(dvmin, dvmax + stepsize / 2, stepsize) - # Test that testbinner raises appropriate error before it's set up (first time) + # Test that testbinner raises appropriate error before it's set up + # (first time) self.assertRaises(NotImplementedError, self.testslicer._slice_sim_data, 0) - # test that we're not dumping extra visits into the 'last bin' (that it's closed both sides) + # test that we're not dumping extra visits into the 'last bin' + # (that it's closed both sides) nvalues = 1000 dv = make_data_values(nvalues, 0, 2, random=560) bins = np.arange(0, 1.05, 0.1) diff --git a/tests/maf/test_opsimutils.py b/tests/maf/test_opsimutils.py index 60fbb3e98..fe2b50981 100644 --- a/tests/maf/test_opsimutils.py +++ b/tests/maf/test_opsimutils.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import os import sqlite3 import unittest @@ -13,7 +10,9 @@ class TestOpsimUtils(unittest.TestCase): def test_scale_benchmarks(self): - """Test scaling the design and stretch benchmarks for the length of the run.""" + """Test scaling the design and stretch benchmarks for the + length of the run. + """ # First test that method returns expected dictionaries. for i in ("design", "stretch"): benchmark = opsimUtils.scale_benchmarks(10.0, i) diff --git a/tests/maf/test_resultsdb.py b/tests/maf/test_resultsdb.py index 656b0d80f..0184101f5 100644 --- a/tests/maf/test_resultsdb.py +++ b/tests/maf/test_resultsdb.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import os import shutil import tempfile @@ -62,7 +59,8 @@ def test_add_data(self): self.info_label, self.metric_data_file, ) - # Try to re-add metric (should get back same metric id as previous, with no add). + # Try to re-add metric + # (should get back same metric id as previous, with no add). metric_id2 = results_db.update_metric( self.metric_name, self.slicer_name, @@ -81,13 +79,15 @@ def test_add_data(self): results_db.update_summary_stat(metric_id, self.summary_stat_name2, self.summary_stat_value2) # Add something like tableFrac summary statistic. results_db.update_summary_stat(metric_id, self.summary_stat_name3, self.summary_stat_value3) - # Test get warning when try to add a non-conforming summary stat (not 'name' & 'value' cols). + # Test get warning when try to add a non-conforming summary stat + # (not 'name' & 'value' cols). teststat = np.empty(10, dtype=[("col", "|S12"), ("value", float)]) with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") results_db.update_summary_stat(metric_id, "testfail", teststat) self.assertIn("not save", str(w[-1].message)) - # Test get warning when try to add a string (non-conforming) summary stat. + # Test we get warning when try to add a string (non-conforming) + # summary stat. teststat = "teststring" with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") diff --git a/tests/maf/test_simplemetrics.py b/tests/maf/test_simplemetrics.py index b779f19c4..a548f46f8 100644 --- a/tests/maf/test_simplemetrics.py +++ b/tests/maf/test_simplemetrics.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import numpy as np @@ -196,7 +193,7 @@ def test_surfb_metric(self): data["skyBrightness"] = 25.0 data["numExposures"] = 2.0 data["filter"] = "r" - result = testmetric.run(data, None) + _ = testmetric.run(data, None) if __name__ == "__main__": diff --git a/tests/maf/test_snmetrics.py b/tests/maf/test_snmetrics.py index ad398416b..7278afe5b 100644 --- a/tests/maf/test_snmetrics.py +++ b/tests/maf/test_snmetrics.py @@ -5,7 +5,7 @@ import numpy as np from rubin_sim.data import get_data_dir -from rubin_sim.maf.metrics import SNCadenceMetric, SNNSNMetric, SNSLMetric, SNSNRMetric +from rubin_sim.maf.metrics import SNCadenceMetric, SNSLMetric, SNSNRMetric from rubin_sim.maf.utils.sn_utils import Lims, ReferenceData m5_ref = dict(zip("ugrizy", [23.60, 24.83, 24.38, 23.92, 23.35, 22.44])) @@ -325,8 +325,9 @@ def test_snsl_metric(self): # and the result should be # Changing the reference value because we have new coadd and mag limits # Change again to switch to per-season calc rather than average - # Change again to reflect updated calculation (due to counting year = 365.25 days, not 360) - n_sl_ref = 1.4569195613987307e-06 # 1.478166e-6 # 1.42168e-6 # 0.00012650940 + # Change again to reflect updated calculation + # (due to counting year = 365.25 days, not 360) + n_sl_ref = 1.4569195613987307e-06 assert np.abs(n_sl - n_sl_ref) < 1.0e-8 diff --git a/tests/maf/test_snmetrics_nsn.py b/tests/maf/test_snmetrics_nsn.py index 5d36bbd4d..49941e199 100644 --- a/tests/maf/test_snmetrics_nsn.py +++ b/tests/maf/test_snmetrics_nsn.py @@ -56,15 +56,17 @@ def test_nsn(self): expected["sparse_pointing"] = metric.badval # Very dense pointing expected["dense_pointing"] = np.rec.fromrecords([(5.158324, 0.276509)], names=["nSN", "zlim"]) - # These are of the same point on the sky, with/without DD fields - they should be the same - # as the metric rejects DD visits internally---XXX except now the metric does - # not reject visits based on notes, so not sure why these still pass fine. + # These are of the same point on the sky, with/without DD fields - + # they should be the same as the metric rejects DD visits internally + # ---XXX except now the metric does + # not reject visits based on notes, so not sure why these still pass expected["one_season_noDD"] = np.rec.fromrecords([(0.870031, 0.289703)], names=["nSN", "zlim"]) expected["one_season_wDD"] = np.rec.fromrecords([(0.870031, 0.289703)], names=["nSN", "zlim"]) # Here we muddle with the visit exposure time (without changing m5) expected["one_season_singleExp_20"] = np.rec.fromrecords([(0.879159, 0.29006)], names=["nSN", "zlim"]) - # Here we muddle with the number of visits per exposure, without changing m5 or visitExpTime + # Here we muddle with the number of visits per exposure, + # without changing m5 or visitExpTime expected["one_season_singleExp_30"] = np.rec.fromrecords( [(0.870031, 0.289703)], names=["nSN", "zlim"] ) diff --git a/tests/maf/test_stackers.py b/tests/maf/test_stackers.py index bbae4d3d0..cd806d1f4 100644 --- a/tests/maf/test_stackers.py +++ b/tests/maf/test_stackers.py @@ -2,7 +2,6 @@ import unittest import warnings -import matplotlib import numpy as np import rubin_sim.maf.stackers as stackers @@ -16,8 +15,6 @@ calc_lmst_last, ) -matplotlib.use("Agg") - class TestStackerClasses(unittest.TestCase): def setUp(self): @@ -153,7 +150,8 @@ def test_setup_dither_stackers(self): degrees = True stackerlist = stackers.setup_dither_stackers(ra_col, dec_col, degrees) self.assertEqual(len(stackerlist), 0) - # Test that we get one (and the right one) when using particular columns. + # Test that we get one (and the right one) + # when using particular columns. ra_col = "hexDitherFieldPerNightRa" dec_col = "hexDitherFieldPerNightDec" stackerlist = stackers.setup_dither_stackers(ra_col, dec_col, degrees) @@ -309,13 +307,16 @@ def test_random_rot_dither_per_filter_change_stacker(self): random_dithers = data["randomDitherPerFilterChangeRotTelPos"] # Check that first three visits have the same rot_tel_pos, etc. rot_offsets = rot_tel_pos - random_dithers - self.assertEqual(rot_offsets[0], 0) # no dither w/o a filter change + # no dither w/o a filter change + self.assertEqual(rot_offsets[0], 0) offset_changes = np.where(rot_offsets[1:] != rot_offsets[:-1])[0] filt_changes = np.where(filt[1:] != filt[:-1])[0] - np.testing.assert_array_equal(offset_changes, filt_changes) # dither after every filter + # dither after every filter + np.testing.assert_array_equal(offset_changes, filt_changes) - # now test to ensure that user-defined max_rot_angle value works and that - # visits in between filter changes for which no offset can be found are left undithered + # now test to ensure that user-defined max_rot_angle value works + # and that visits in between filter changes for which no offset + # can be found are left undithered # (g band visits span rotator range, so can't be dithered) gvisits = np.where(filt == "g") maxrot = 30 @@ -438,13 +439,13 @@ def test_ecliptic_stacker(self): data["ra"] += ra data["dec"] += dec s = stackers.EclipticStacker(ra_col="ra", dec_col="dec", degrees=True) - new_data = s.run(data) + _ = s.run(data) data = np.zeros(ra.size, dtype=list(zip(["ra", "dec"], [float] * 2))) data["ra"] += ra data["dec"] += dec s = stackers.EclipticStacker(ra_col="ra", dec_col="dec", degrees=True, subtract_sun_lon=False) - new_data = s.run(data) + _ = s.run(data) if __name__ == "__main__": diff --git a/tests/maf/test_stringcount.py b/tests/maf/test_stringcount.py index 03445dc2c..d39108716 100644 --- a/tests/maf/test_stringcount.py +++ b/tests/maf/test_stringcount.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import numpy as np diff --git a/tests/maf/test_summary_plots.py b/tests/maf/test_summary_plots.py index 8caf81fb5..aff088bf3 100644 --- a/tests/maf/test_summary_plots.py +++ b/tests/maf/test_summary_plots.py @@ -42,9 +42,11 @@ def setUp(self): self.metric_values.columns.name = "metric" self.metric_values.index.name = "run" - self.metric_set = pd.DataFrame({"mag": False, "invert": False, "metric": self.metrics}).set_index( - "metric", drop=False - ) + styles = ["-" for i in range(self.num_metrics)] + + self.metric_set = pd.DataFrame( + {"mag": False, "invert": False, "metric": self.metrics, "style": styles} + ).set_index("metric", drop=False) self.metric_set.loc[self.mag_metrics, "mag"] = True self.metric_set.loc[self.inverted_metrics, "invert"] = True self.metric_set.loc["metric3", "style"] = "b--" @@ -146,10 +148,13 @@ def test_plot_run_metric_mesh(self): def _run_infos_norm_df(df, norm_run, invert_cols=None, mag_cols=None): """ Normalize values in a DataFrame, based on the values in a given run. - Can normalize some columns (metric values) differently (invert_cols, reverse_cols, mag_cols) - if those columns are specified; this lets the final normalized dataframe 'look' the same way - in a plot (i.e. "up" is better (reverse_cols), they center on 1 (mag_cols), and the magnitude scales - as expected (invert_cols)). + Can normalize some columns (metric values) differently + (invert_cols, reverse_cols, mag_cols) + if those columns are specified; this lets the final normalized dataframe + 'look' the same way + in a plot (i.e. "up" is better (reverse_cols), they center on 1 (mag_cols), + and the magnitude scales as expected (invert_cols)). + Parameters ---------- df : pd.DataFrame @@ -159,7 +164,8 @@ def _run_infos_norm_df(df, norm_run, invert_cols=None, mag_cols=None): invert_cols: list Columns (metric values) to convert to 1 / value mag_cols: list - Columns (metrics values) to treat as magnitudes (1 + (difference from norm_run)) + Columns (metrics values) to treat as magnitudes + (1 + (difference from norm_run)) Returns ------- diff --git a/tests/maf/test_summarymetrics.py b/tests/maf/test_summarymetrics.py index 83b6b5e55..3ae2750cb 100644 --- a/tests/maf/test_summarymetrics.py +++ b/tests/maf/test_summarymetrics.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import healpy as hp diff --git a/tests/maf/test_technicalmetrics.py b/tests/maf/test_technicalmetrics.py index c2a23728b..66fded0fd 100644 --- a/tests/maf/test_technicalmetrics.py +++ b/tests/maf/test_technicalmetrics.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import numpy as np diff --git a/tests/maf/test_unislicer.py b/tests/maf/test_unislicer.py index 9857a2328..4d5ed3f58 100644 --- a/tests/maf/test_unislicer.py +++ b/tests/maf/test_unislicer.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import numpy as np @@ -9,7 +6,9 @@ def make_data_values(size=100, min=0.0, max=1.0, random=-1): - """Generate a simple array of numbers, evenly arranged between min/max, but (optional) random order.""" + """Generate a simple array of numbers, + evenly arranged between min/max, but (optional) random order. + """ datavalues = np.arange(0, size, dtype="float") datavalues *= (float(max) - float(min)) / (datavalues.max() - datavalues.min()) datavalues += min @@ -39,7 +38,9 @@ def test_slicer_nbins(self): self.assertEqual(self.testslicer.nslice, 1) def test_setup_slicer_indices(self): - """Test slicer returns correct indices (all) after setup. Note this also tests slicing.""" + """Test slicer returns correct indices (all) after setup. + Note this also tests slicing. + """ dvmin = 0 dvmax = 1 nvalues = 1000 @@ -59,7 +60,9 @@ def tearDown(self): self.testslicer = None def test_iteration(self): - """Test iteration -- which is a one-step identity op for a unislicer.""" + """Test iteration -- which is a one-step identity op for a + unislicer. + """ dvmin = 0 dvmax = 1 nvalues = 1000 @@ -94,8 +97,9 @@ def tearDown(self): def test_equivalence(self): """Test equals method.""" - # Note that two uni slicers will be considered equal if they are both the same kind of - # slicer (unislicer). They will not necessarily slice data equally though (the indices are + # Note that two uni slicers will be considered equal if they are + # both the same kind of slicer (unislicer). + # They will not necessarily slice data equally though (the indices are # not necessarily the same!). # These should be the same, even though data is not the same. testslicer2 = UniSlicer() diff --git a/tests/maf/test_vectormetrics.py b/tests/maf/test_vectormetrics.py index 25515e185..ce29d7121 100644 --- a/tests/maf/test_vectormetrics.py +++ b/tests/maf/test_vectormetrics.py @@ -1,8 +1,4 @@ import os - -import matplotlib - -matplotlib.use("Agg") import unittest import numpy as np diff --git a/tests/maf/test_visitgroupsmetric.py b/tests/maf/test_visitgroupsmetric.py index aed807e68..25be94e44 100644 --- a/tests/maf/test_visitgroupsmetric.py +++ b/tests/maf/test_visitgroupsmetric.py @@ -1,6 +1,3 @@ -import matplotlib - -matplotlib.use("Agg") import unittest import numpy as np @@ -39,7 +36,8 @@ def test_visit_groups(self): tmin = 15.0 / 60.0 / 24.0 tmax = 90.0 / 60.0 / 24.0 tstart = 49406.00 - # The test data needs to have times for all observations: set up the times in two stages .. the night + # The test data needs to have times for all observations: + # set up the times in two stages .. the night night = np.array( [ 0, diff --git a/tests/scheduler/test_scalarbf.py b/tests/scheduler/test_scalarbf.py index 9585e34a7..a3eb925e0 100644 --- a/tests/scheduler/test_scalarbf.py +++ b/tests/scheduler/test_scalarbf.py @@ -1,10 +1,11 @@ import unittest + import healpy as hp import numpy as np + +from rubin_sim.scheduler.basis_functions import HealpixLimitedBasisFunctionMixin, SimpleArrayBasisFunction from rubin_sim.scheduler.features import Conditions from rubin_sim.scheduler.utils import set_default_nside -from rubin_sim.scheduler.basis_functions import HealpixLimitedBasisFunctionMixin -from rubin_sim.scheduler.basis_functions import SimpleArrayBasisFunction class SimpleArrayAtHpixBasisFunction(HealpixLimitedBasisFunctionMixin, SimpleArrayBasisFunction): diff --git a/tests/scheduler/test_surveys.py b/tests/scheduler/test_surveys.py index 8eceeabbd..38b42767d 100644 --- a/tests/scheduler/test_surveys.py +++ b/tests/scheduler/test_surveys.py @@ -1,16 +1,16 @@ import os import unittest -import pandas as pd -import numpy as np import healpy as hp +import numpy as np +import pandas as pd import rubin_sim.scheduler.basis_functions as basis_functions import rubin_sim.scheduler.surveys as surveys from rubin_sim.data import get_data_dir -from rubin_sim.scheduler.utils import set_default_nside -from rubin_sim.scheduler.model_observatory import ModelObservatory from rubin_sim.scheduler.basis_functions import SimpleArrayBasisFunction +from rubin_sim.scheduler.model_observatory import ModelObservatory +from rubin_sim.scheduler.utils import set_default_nside class TestSurveys(unittest.TestCase):