From 609db566b9c56b323669769c0167129ccaf4f3a8 Mon Sep 17 00:00:00 2001 From: Humna Awan Date: Fri, 21 Feb 2025 16:30:51 -0800 Subject: [PATCH 1/3] bug fix: scheduler_note vs note. --- rubin_sim/maf/maf_night_report.py | 4 ++-- rubin_sim/maf/metric_bundles/metric_bundle.py | 2 +- rubin_sim/maf/metric_bundles/mo_metric_bundle.py | 2 +- rubin_sim/maf/metrics/sn_n_sn_metric.py | 2 +- rubin_sim/maf/metrics/use_metrics.py | 2 +- rubin_sim/maf/slicers/time_interval_slicers.py | 2 +- tests/maf/test_3x2fom.py | 2 +- tests/maf/test_hgplotters.py | 2 +- tests/maf/test_opsimutils.py | 4 ++-- tests/maf/test_timeintervalslicers.py | 6 ++++-- 10 files changed, 15 insertions(+), 13 deletions(-) diff --git a/rubin_sim/maf/maf_night_report.py b/rubin_sim/maf/maf_night_report.py index c651dcbbf..31f4f04f0 100755 --- a/rubin_sim/maf/maf_night_report.py +++ b/rubin_sim/maf/maf_night_report.py @@ -127,11 +127,11 @@ def make_bundle_list( # stats from the note column if notes: display_dict = {"group": "Basic Stats", "subgroup": "Percent stats"} - metric = metrics.StringCountMetric(col="note", percent=True, metric_name="Percents") + metric = metrics.StringCountMetric(col="scheduler_note", percent=True, metric_name="Percents") bundle = metricBundles.MetricBundle(metric, unislicer, sql, display_dict=display_dict) bundleList.append(bundle) display_dict["subgroup"] = "Count Stats" - metric = metrics.StringCountMetric(col="note", metric_name="Counts") + metric = metrics.StringCountMetric(col="scheduler_note", metric_name="Counts") bundle = metricBundles.MetricBundle(metric, unislicer, sql, display_dict=display_dict) bundleList.append(bundle) diff --git a/rubin_sim/maf/metric_bundles/metric_bundle.py b/rubin_sim/maf/metric_bundles/metric_bundle.py index f87abe5b0..318c749d0 100644 --- a/rubin_sim/maf/metric_bundles/metric_bundle.py +++ b/rubin_sim/maf/metric_bundles/metric_bundle.py @@ -62,7 +62,7 @@ class MetricBundle: Setting this provides an easy way to specify different configurations of a metric, a slicer, or just to rewrite your constraint into friendlier terms. - (i.e. a constraint like 'note not like "%DD%"' can become + (i.e. a constraint like 'scheduler_note not like "%DD%"' can become "non-DD" in the file name and plot labels by specifying info_label). plot_dict : `dict` of plotting parameters, opt diff --git a/rubin_sim/maf/metric_bundles/mo_metric_bundle.py b/rubin_sim/maf/metric_bundles/mo_metric_bundle.py index 55a180298..5a51260fe 100644 --- a/rubin_sim/maf/metric_bundles/mo_metric_bundle.py +++ b/rubin_sim/maf/metric_bundles/mo_metric_bundle.py @@ -138,7 +138,7 @@ class MoMetricBundle(MetricBundle): Setting this provides an easy way to specify different configurations of a metric, a slicer, or just to rewrite your constraint into friendlier terms. - (i.e. a constraint like 'note not like "%DD%"' can become + (i.e. a constraint like 'scheduler_note not like "%DD%"' can become "non-DD" in the file name and plot labels by specifying info_label). plot_dict : `dict` of plotting parameters, opt diff --git a/rubin_sim/maf/metrics/sn_n_sn_metric.py b/rubin_sim/maf/metrics/sn_n_sn_metric.py index 97bd064bb..ee928db8a 100644 --- a/rubin_sim/maf/metrics/sn_n_sn_metric.py +++ b/rubin_sim/maf/metrics/sn_n_sn_metric.py @@ -39,7 +39,7 @@ class SNNSNMetric(BaseMetric): seeing_col : `str`, opt seeing column name (default: seeingFwhmEff) note_col : `str`, opt - note column name (default: note) + note column name (default: scheduler_note) season : `list`, opt list of seasons to process (float)(default: -1 = all seasons) coadd : `bool`, opt diff --git a/rubin_sim/maf/metrics/use_metrics.py b/rubin_sim/maf/metrics/use_metrics.py index 2de5cfbb6..8ffe2feff 100644 --- a/rubin_sim/maf/metrics/use_metrics.py +++ b/rubin_sim/maf/metrics/use_metrics.py @@ -48,7 +48,7 @@ def run(self, data_slice, slice_point=None): # pylint: disable=invalid-name if band in note_elems[1]: use_name = "wide with u, g, or r" - assert use_name is not None, f"Unrecognized note: {note}" + assert use_name is not None, f"Unrecognized scheduler_note: {note}" return use_name diff --git a/rubin_sim/maf/slicers/time_interval_slicers.py b/rubin_sim/maf/slicers/time_interval_slicers.py index 9a5b0fe52..b9fce34e2 100644 --- a/rubin_sim/maf/slicers/time_interval_slicers.py +++ b/rubin_sim/maf/slicers/time_interval_slicers.py @@ -179,7 +179,7 @@ def setup_slicer(self, sim_data, maps=None): visits.sort_values("mjd", inplace=True) visits["end_mjd"] = visits.mjd + visits.duration / (60 * 60 * 24.0) - same_note = visits.note == visits.note.shift(-1) + same_note = visits.scheduler_note == visits.scheduler_note.shift(-1) adjacent_times = visits.end_mjd + self.gap_tolerance / 24.0 > visits.mjd.shift(-1) visits["sid"] = np.logical_not(np.logical_and(same_note, adjacent_times)).cumsum().shift() visits["sid"].fillna(0, inplace=True) diff --git a/tests/maf/test_3x2fom.py b/tests/maf/test_3x2fom.py index 802fcad05..9cfe74b83 100644 --- a/tests/maf/test_3x2fom.py +++ b/tests/maf/test_3x2fom.py @@ -41,7 +41,7 @@ def test_3x2(self): depth_cut=ptsrc_lim_mag_i_band, ) s = maf.slicers.HealpixSlicer(nside=nside, use_cache=False) - sql = 'note not like "DD%" and night < 365' + sql = 'scheduler_note not like "DD%" and night < 365' threeby_two_summary_simple = maf.metrics.StaticProbesFoMEmulatorMetricSimple( nside=nside, metric_name="3x2ptFoM_simple" ) diff --git a/tests/maf/test_hgplotters.py b/tests/maf/test_hgplotters.py index 975d6a93f..6dceee79b 100644 --- a/tests/maf/test_hgplotters.py +++ b/tests/maf/test_hgplotters.py @@ -119,7 +119,7 @@ def create_sample_visit_db(dir_name): 88282: "g", 82396: "r", }, - "note": { + "scheduler_note": { 75831: "blob, zy, b", 88243: "blob, ug, b", 84877: "blob, iz, b", diff --git a/tests/maf/test_opsimutils.py b/tests/maf/test_opsimutils.py index b385b1f2b..ed9a97ba6 100644 --- a/tests/maf/test_opsimutils.py +++ b/tests/maf/test_opsimutils.py @@ -54,9 +54,9 @@ def test_calc_coadded_depth(self): def test_get_sim_data(self): """Test that we can get simulation data""" database_file = os.path.join(get_data_dir(), "tests", TEST_DB) - dbcols = ["fieldRA", "fieldDec", "note"] + dbcols = ["fieldRA", "fieldDec", "scheduler_note"] sql = "night < 10" - full_sql = "SELECT fieldRA, fieldDec, note FROM observations where night < 10;" + full_sql = "SELECT fieldRA, fieldDec, scheduler_note FROM observations where night < 10;" # Check that we get data the usual way data = opsimUtils.get_sim_data(database_file, sql, dbcols) assert np.size(data) > 0 diff --git a/tests/maf/test_timeintervalslicers.py b/tests/maf/test_timeintervalslicers.py index 5da8c9412..d91ab3a49 100644 --- a/tests/maf/test_timeintervalslicers.py +++ b/tests/maf/test_timeintervalslicers.py @@ -23,7 +23,7 @@ 60000.203, ], "visitTime": [86, 86, 86, 86, 86, 86], - "note": [ + "scheduler_note": [ "greedy", "blob, yy, a", "blob, yy, a", @@ -71,7 +71,9 @@ def test_setup_slicer(self): visits = pd.DataFrame(SIMDATA) for sid in slice_points["sid"]: these_visits = visits.iloc[sim_idxs[sid]] - self.assertTrue(np.all(these_visits["note"] == these_visits["note"].values[0])) + self.assertTrue( + np.all(these_visits["scheduler_note"] == these_visits["scheduler_note"].values[0]) + ) class TestVisitIntervalSlicer(unittest.TestCase): From 8b14537090f67ecfd8f78fd17181c6fcb39f0d52 Mon Sep 17 00:00:00 2001 From: Humna Awan Date: Fri, 21 Feb 2025 19:44:25 -0800 Subject: [PATCH 2/3] updated sql quotes to work with sqlite3. --- rubin_sim/maf/batches/common.py | 2 +- rubin_sim/maf/batches/glance_batch.py | 6 ++--- rubin_sim/maf/batches/radar_limited.py | 14 +++++----- rubin_sim/maf/batches/science_radar_batch.py | 26 +++++++++---------- rubin_sim/maf/batches/time_batch.py | 14 +++++----- rubin_sim/maf/batches/time_sci_batch.py | 6 ++--- rubin_sim/maf/maf_night_report.py | 6 ++--- rubin_sim/maf/metric_bundles/metric_bundle.py | 4 +-- rubin_sim/skybrightness/allsky_db.py | 2 +- tests/maf/test_3x2fom.py | 2 +- tests/maf/test_batchcommon.py | 4 +-- tests/maf/test_metricbundle.py | 2 +- 12 files changed, 44 insertions(+), 44 deletions(-) diff --git a/rubin_sim/maf/batches/common.py b/rubin_sim/maf/batches/common.py index e438c8c97..f75420189 100644 --- a/rubin_sim/maf/batches/common.py +++ b/rubin_sim/maf/batches/common.py @@ -73,7 +73,7 @@ def filter_list(all=True, extra_sql=None, extra_info_label=None): sqls[f] = "" info_labels[f] = md + "all bands" else: - sqls[f] = 'filter = "%s"' % f + sqls[f] = "filter = '%s'" % f info_labels[f] = md + "%s band" % f if extra_sql is not None and len(extra_sql) > 0: for s in sqls: diff --git a/rubin_sim/maf/batches/glance_batch.py b/rubin_sim/maf/batches/glance_batch.py index 0f5ad31eb..e7c743a6d 100644 --- a/rubin_sim/maf/batches/glance_batch.py +++ b/rubin_sim/maf/batches/glance_batch.py @@ -76,7 +76,7 @@ def glanceBatch( else: raise ValueError("Camera must be LSST or Comcam") - sql_per_filt = ['%s %s="%s"' % (sqlC, colmap["filter"], filtername) for filtername in filternames] + sql_per_filt = ["%s %s='%s'" % (sqlC, colmap["filter"], filtername) for filtername in filternames] sql_per_and_all_filters = [sql_constraint] + sql_per_filt standardStats = standard_summary() @@ -349,7 +349,7 @@ def glanceBatch( displayDict["caption"] = "Fraction of observations that are in pairs" displayDict["subgroup"] = "Solar System" - sql = '%s (filter="g" or filter="r" or filter="i")' % sqlC + sql = "%s (filter='g' or filter='r' or filter='i')" % sqlC pairSlicer = slicers.HealpixSlicer( nside=pairnside, lat_col=colmap["dec"], @@ -402,7 +402,7 @@ def glanceBatch( displayDict["subgroup"] = "" for ddf in ddf_surveys: label = ddf.replace("DD:", "") - sql = 'scheduler_note like "%s%%"' % ("DD:" + label) + sql = f"scheduler_note like 'DD:{label}%'" slicer = slicers.UniSlicer() metric = metrics.CumulativeMetric() metricb = metric_bundles.MetricBundle( diff --git a/rubin_sim/maf/batches/radar_limited.py b/rubin_sim/maf/batches/radar_limited.py index 26c1efd71..f1ebe5fdc 100644 --- a/rubin_sim/maf/batches/radar_limited.py +++ b/rubin_sim/maf/batches/radar_limited.py @@ -479,7 +479,7 @@ def radar_limited( for filtername in "ugrizy": displayDict["caption"] = "Surface brightness limit in %s, no extinction applied." % filtername displayDict["order"] = filterorders[f] - sql = 'filter="%s"' % filtername + sql = "filter='%s'" % filtername metric = metrics.SurfaceBrightLimitMetric() bundle = mb.MetricBundle( metric, @@ -529,7 +529,7 @@ def radar_limited( for yr_cut in yrs: ptsrc_lim_mag_i_band = mag_cuts[yr_cut] sqlconstraint = "night <= %s" % (yr_cut * 365.25 + 0.5) - sqlconstraint += ' and scheduler_note not like "DD%"' + sqlconstraint += " and scheduler_note not like 'DD%'" info_label = f"{bandpass} band non-DD year {yr_cut}" ThreebyTwoSummary_simple = metrics.StaticProbesFoMEmulatorMetricSimple( nside=nside, year=yr_cut, metric_name="3x2ptFoM_simple" @@ -581,7 +581,7 @@ def radar_limited( subgroupCount += 1 displayDict["subgroup"] = f"{subgroupCount}: WL" displayDict["order"] = 0 - sqlconstraint = 'scheduler_note not like "DD%" and (filter="g" or filter="r" or filter="i")' + sqlconstraint = "scheduler_note not like 'DD%' and (filter='g' or filter='r' or filter='i')" info_label = "gri band non-DD" minExpTime = 15 m = metrics.WeakLensingNvisits( @@ -612,8 +612,8 @@ def radar_limited( # Do the weak lensing per year for year in [10]: sqlconstraint = ( - 'scheduler_note not like "DD%"' - + ' and (filter="g" or filter="r" or filter="i") and night < %i' % (year * 365.25) + "scheduler_note not like 'DD%'" + + " and (filter='g' or filter='r' or filter='i') and night < %i" % (year * 365.25) ) m = metrics.WeakLensingNvisits( lsst_filter=bandpass, @@ -648,8 +648,8 @@ def radar_limited( bundleList.append(bundle) sqlconstraint = ( - 'scheduler_note not like "DD%"' - + ' and (filter="r" or filter="i" or filter="z") and night < %i' % (year * 365.25) + "scheduler_note not like 'DD%'" + + " and (filter='r' or filter='i' or filter='z') and night < %i" % (year * 365.25) ) m = metrics.WeakLensingNvisits( lsst_filter=bandpass, diff --git a/rubin_sim/maf/batches/science_radar_batch.py b/rubin_sim/maf/batches/science_radar_batch.py index 805bfbd17..306b4c60a 100644 --- a/rubin_sim/maf/batches/science_radar_batch.py +++ b/rubin_sim/maf/batches/science_radar_batch.py @@ -509,7 +509,7 @@ def science_radar_batch( for filtername in "ugrizy": displayDict["caption"] = "Surface brightness limit in %s, no extinction applied." % filtername displayDict["order"] = filterorders[f] - sql = 'filter="%s"' % filtername + sql = "filter='%s'" % filtername metric = metrics.SurfaceBrightLimitMetric() bundle = mb.MetricBundle( metric, @@ -568,7 +568,7 @@ def science_radar_batch( for yr_cut in yrs: ptsrc_lim_mag_i_band = mag_cuts[yr_cut] sqlconstraint = "night <= %s" % (yr_cut * 365.25 + 0.5) - sqlconstraint += ' and scheduler_note not like "DD%"' + sqlconstraint += " and scheduler_note not like 'DD%'" info_label = f"{bandpass} band non-DD year {yr_cut}" ThreebyTwoSummary = maf.StaticProbesFoMEmulatorMetric(nside=nside, metric_name="3x2ptFoM") @@ -612,7 +612,7 @@ def science_radar_batch( plotDict = {"n_ticks": 5} # Have to include all filters in query to check for filter coverage. # Galaxy numbers calculated using 'bandpass' images only though. - sqlconstraint = 'scheduler_note not like "DD%"' + sqlconstraint = "scheduler_note not like 'DD%'" info_label = f"{bandpass} band galaxies non-DD" metric = maf.DepthLimitedNumGalMetric( nside=nside, @@ -652,7 +652,7 @@ def science_radar_batch( subgroupCount += 1 displayDict["subgroup"] = f"{subgroupCount}: WL" displayDict["order"] = 0 - sqlconstraint = 'scheduler_note not like "DD%" and (filter="g" or filter="r" or filter="i")' + sqlconstraint = "scheduler_note not like 'DD%' and (filter='g' or filter='r' or filter='i')" info_label = "gri band non-DD" minExpTime = 15 m = metrics.WeakLensingNvisits( @@ -684,8 +684,8 @@ def science_radar_batch( for year in np.arange(1, 10): displayDict["order"] = year sqlconstraint = ( - 'scheduler_note not like "DD%"' - + ' and (filter="g" or filter="r" or filter="i") and night < %i' % (year * 365.25) + "scheduler_note not like 'DD%'" + + " and (filter='g' or filter='r' or filter='i') and night < %i" % (year * 365.25) ) m = metrics.WeakLensingNvisits( lsst_filter=bandpass, @@ -720,8 +720,8 @@ def science_radar_batch( bundleList.append(bundle) sqlconstraint = ( - 'scheduler_note not like "DD%"' - + ' and (filter="r" or filter="i" or filter="z") and night < %i' % (year * 365.25) + "scheduler_note not like 'DD%'" + + " and (filter='r' or filter='i' or filter='z') and night < %i" % (year * 365.25) ) m = metrics.WeakLensingNvisits( lsst_filter=bandpass, @@ -779,8 +779,8 @@ def science_radar_batch( # Kuiper per year in gri and riz for year in np.arange(1, 10): sqlconstraint = ( - 'scheduler_note not like "DD%"' - + ' and (filter="g" or filter="r" or filter="i") and night < %i' % (year * 365.25) + "scheduler_note not like 'DD%'" + + " and (filter='g' or filter='r' or filter='i') and night < %i" % (year * 365.25) ) metric1 = metrics.KuiperMetric("rotSkyPos", metric_name="Kuiper_rotSkyPos_gri_year%i" % year) metric2 = metrics.KuiperMetric("rotTelPos", metric_name="Kuiper_rotTelPos_gri_year%i" % year) @@ -1827,7 +1827,7 @@ def science_radar_batch( i_starMap = maf.maps.StellarDensityMap(filtername="i") lv_slicer = maf.maf_contrib.generate_known_lv_dwarf_slicer() lv_metric = maf.maf_contrib.LVDwarfsMetric() - sqlconstraint = '(filter = "i" OR filter = "g")' + sqlconstraint = "(filter = 'i' OR filter = 'g')" info_label = "gi" cutoff = -6.4 summary_metrics = [ @@ -1874,7 +1874,7 @@ def science_radar_batch( "star-galaxy separation), over the southern celestial pole," "to a distance of 0.1 Mpc." ) - sqlconstraint = '(filter = "i" OR filter = "g") and fieldDec < -60' + sqlconstraint = "(filter = 'i' OR filter = 'g') and fieldDec < -60" info_label = "gi SCP" lv_metric3 = maf.maf_contrib.LVDwarfsMetric(distlim=0.1 * u.Mpc) # for a distance limit, healpix map summary_area = maf.metrics.AreaThresholdMetric(lower_threshold=0.0, metric_name="Area M_v>0.0") @@ -1942,7 +1942,7 @@ def science_radar_batch( displayDict = {"group": "Scaling Numbers", "subgroup": ""} displayDict["subgroup"] = "N gals" - sql = 'filter="i"' + sql = "filter='i'" metric = metrics.NgalScaleMetric() # galaxy counting uses dustmap slicer = slicers.HealpixSlicer(nside=nside, use_cache=False) diff --git a/rubin_sim/maf/batches/time_batch.py b/rubin_sim/maf/batches/time_batch.py index ee11db90d..2b60a0d22 100644 --- a/rubin_sim/maf/batches/time_batch.py +++ b/rubin_sim/maf/batches/time_batch.py @@ -74,9 +74,9 @@ def intraNight( "order": 0, } if extraSql is not None and len(extraSql) > 0: - sql = '(%s) and (filter="g" or filter="r" or filter="i")' % extraSql + sql = "(%s) and (filter='g' or filter='r' or filter='i')" % extraSql else: - sql = 'filter="g" or filter="r" or filter="i"' + sql = "filter='g' or filter='r' or filter='i'" md = "gri" if info_label is not None: md += " " + info_label @@ -215,11 +215,11 @@ def intraNight( bundleList.append(bundle) # subsets of adjacent filters filtersubsets = { - "ug": '(filter = "u" or filter = "g")', - "gr": '(filter = "g" or filter = "r")', - "ri": '(filter = "r" or filter = "i")', - "iz": '(filter = "i" or filter = "z")', - "zy": '(filter = "z" or filter = "y")', + "ug": "(filter = 'u' or filter = 'g')", + "gr": "(filter = 'g' or filter = 'r')", + "ri": "(filter = 'r' or filter = 'i')", + "iz": "(filter = 'i' or filter = 'z')", + "zy": "(filter = 'z' or filter = 'y')", } sqls = [extraSql] if extraSql is not None and len(extraSql) > 0: diff --git a/rubin_sim/maf/batches/time_sci_batch.py b/rubin_sim/maf/batches/time_sci_batch.py index 337b11a74..2ee5df66b 100644 --- a/rubin_sim/maf/batches/time_sci_batch.py +++ b/rubin_sim/maf/batches/time_sci_batch.py @@ -60,9 +60,9 @@ def phaseGap( # largest phase gap for periods periods = [0.1, 1.0, 10.0, 100.0] sqls = [ - 'filter = "u"', - 'filter="r"', - 'filter="g" or filter="r" or filter="i" or filter="z"', + "filter='u'", + "filter='r'", + "filter='g' or filter='r' or filter='i' or filter='z'", "", ] filter_names = ["u", "r", "griz", "all"] diff --git a/rubin_sim/maf/maf_night_report.py b/rubin_sim/maf/maf_night_report.py index 31f4f04f0..29dd031f1 100755 --- a/rubin_sim/maf/maf_night_report.py +++ b/rubin_sim/maf/maf_night_report.py @@ -36,7 +36,7 @@ def make_bundle_list( azCol = "azimuth" # Construct sql queries for each filter and all filters filters = ["u", "g", "r", "i", "z", "y"] - sqls = ['night=%i and filter="%s"' % (night, f) for f in filters] + sqls = ["night=%i and filter='%s'" % (night, f) for f in filters] sqls.append("night=%i" % night) bundleList = [] @@ -107,12 +107,12 @@ def make_bundle_list( # Make plots of the solar system pairs that were taken in the night metric = metrics.PairMetric(mjd_col=mjdCol) - sql = 'night=%i and (filter ="r" or filter="g" or filter="i")' % night + sql = "night=%i and (filter ='r' or filter='g' or filter='i')" % night bundle = metricBundles.MetricBundle(metric, reg_slicer, sql) bundleList.append(bundle) metric = metrics.PairMetric(mjd_col=mjdCol, metric_name="z Pairs") - sql = 'night=%i and filter="z"' % night + sql = "night=%i and filter='z'" % night bundle = metricBundles.MetricBundle(metric, reg_slicer, sql) bundleList.append(bundle) diff --git a/rubin_sim/maf/metric_bundles/metric_bundle.py b/rubin_sim/maf/metric_bundles/metric_bundle.py index 318c749d0..319bfcddc 100644 --- a/rubin_sim/maf/metric_bundles/metric_bundle.py +++ b/rubin_sim/maf/metric_bundles/metric_bundle.py @@ -90,7 +90,7 @@ class MetricBundle: Together these define a unique combination of an opsim benchmark, or "metric bundle". An example would be: - a CountMetric, a HealpixSlicer, and a constraint of 'filter="r"'. + a CountMetric, a HealpixSlicer, and a constraint of "filter='r'". After the metric is evaluated at each slice_point created by the slicer, the resulting metric values are saved in the MetricBundle. @@ -243,7 +243,7 @@ def _build_metadata(self, info_label, metadata=None): """If no info_label is provided, process the constraint (by removing extra spaces, quotes, the word 'filter' and equal signs) to make a info_label version. - e.g. 'filter = "r"' becomes 'r' + e.g. "filter = 'r'" becomes 'r' """ # Pass the deprecated version into info_label if info_label is not set if metadata is not None and info_label is None: diff --git a/rubin_sim/skybrightness/allsky_db.py b/rubin_sim/skybrightness/allsky_db.py index 0fcc39871..e66e269a6 100644 --- a/rubin_sim/skybrightness/allsky_db.py +++ b/rubin_sim/skybrightness/allsky_db.py @@ -40,7 +40,7 @@ def all_sky_db(date_id, sql_q=None, dtypes=None, db_address=None, filt="R"): if sql_q is None: sql_q = ( "select stars.ra, stars.dec, obs.alt, obs.starMag, obs.sky, obs.filter from obs, " - 'stars where obs.starID = stars.ID and obs.filter = "%s" and obs.dateID = %i;' % (filt, date_id) + "stars where obs.starID = stars.ID and obs.filter = '%s' and obs.dateID = %i;" % (filt, date_id) ) if dtypes is None: names = ["ra", "dec", "alt", "starMag", "sky", "filter"] diff --git a/tests/maf/test_3x2fom.py b/tests/maf/test_3x2fom.py index 9cfe74b83..dc6386e53 100644 --- a/tests/maf/test_3x2fom.py +++ b/tests/maf/test_3x2fom.py @@ -41,7 +41,7 @@ def test_3x2(self): depth_cut=ptsrc_lim_mag_i_band, ) s = maf.slicers.HealpixSlicer(nside=nside, use_cache=False) - sql = 'scheduler_note not like "DD%" and night < 365' + sql = "scheduler_note not like 'DD%' and night < 365" threeby_two_summary_simple = maf.metrics.StaticProbesFoMEmulatorMetricSimple( nside=nside, metric_name="3x2ptFoM_simple" ) diff --git a/tests/maf/test_batchcommon.py b/tests/maf/test_batchcommon.py index 5d63c3d01..45f564d65 100644 --- a/tests/maf/test_batchcommon.py +++ b/tests/maf/test_batchcommon.py @@ -16,7 +16,7 @@ def test_filter_list(self): filterlist, colors, orders, sqls, info_label = batches.common.filter_list(all=False, extra_sql=None) self.assertEqual(len(filterlist), 6) self.assertEqual(len(colors), 6) - self.assertEqual(sqls["u"], 'filter = "u"') + self.assertEqual(sqls["u"], "filter = 'u'") filterlist, colors, orders, sqls, info_label = batches.common.filter_list(all=True, extra_sql=None) self.assertIn("all", filterlist) self.assertEqual(sqls["all"], "") @@ -24,7 +24,7 @@ def test_filter_list(self): all=True, extra_sql="night=3" ) self.assertEqual(sqls["all"], "night=3") - self.assertEqual(sqls["u"], '(night=3) and (filter = "u")') + self.assertEqual(sqls["u"], "(night=3) and (filter = 'u')") self.assertEqual(info_label["u"], "night=3 u band") filterlist, colors, orders, sqls, info_label = batches.common.filter_list( all=True, extra_sql="night=3", extra_info_label="night 3" diff --git a/tests/maf/test_metricbundle.py b/tests/maf/test_metricbundle.py index 29318dc7d..bea8ef846 100644 --- a/tests/maf/test_metricbundle.py +++ b/tests/maf/test_metricbundle.py @@ -32,7 +32,7 @@ def test_out(self): nside = 8 slicer = slicers.HealpixSlicer(nside=nside) metric = metrics.MeanMetric(col="airmass") - sql = 'filter="r"' + sql = "filter='r'" stacker1 = stackers.HourAngleStacker() stacker2 = stackers.GalacticStacker() map = maps.GalCoordsMap() From e3dcf10a2613d0919a94e583a9cf9be512cfccee Mon Sep 17 00:00:00 2001 From: Humna Awan Date: Mon, 24 Feb 2025 15:29:09 -0800 Subject: [PATCH 3/3] black updates. --- rubin_sim/maf/__init__.py | 3 +-- rubin_sim/maf/batches/hourglass_batch.py | 3 +-- rubin_sim/maf/batches/metadata_batch.py | 3 +-- rubin_sim/maf/batches/openshutter_batch.py | 3 +-- rubin_sim/maf/batches/skycoverage.py | 3 +-- rubin_sim/maf/batches/slew_batch.py | 3 +-- rubin_sim/maf/batches/time_batch.py | 3 +-- rubin_sim/maf/batches/time_sci_batch.py | 3 +-- rubin_sim/maf/plots/hg_plotters.py | 3 +-- rubin_sim/maf/run_comparison/archive.py | 3 +-- rubin_sim/maf/run_comparison/summary_plots.py | 3 +-- tests/maf/test_timeintervalslicers.py | 2 +- 12 files changed, 12 insertions(+), 23 deletions(-) diff --git a/rubin_sim/maf/__init__.py b/rubin_sim/maf/__init__.py index 1eacbadf0..016cd7998 100644 --- a/rubin_sim/maf/__init__.py +++ b/rubin_sim/maf/__init__.py @@ -19,8 +19,7 @@ # the GNU General Public License along with this program. If not, # see . # -"""Python interface to the metrics analysis framework. -""" +"""Python interface to the metrics analysis framework.""" from .batches import * from .db import * from .maf_contrib import * diff --git a/rubin_sim/maf/batches/hourglass_batch.py b/rubin_sim/maf/batches/hourglass_batch.py index 7747b3034..de6517d56 100644 --- a/rubin_sim/maf/batches/hourglass_batch.py +++ b/rubin_sim/maf/batches/hourglass_batch.py @@ -1,5 +1,4 @@ -"""Run the hourglass metric. -""" +"""Run the hourglass metric.""" __all__ = ("hourglassPlots",) diff --git a/rubin_sim/maf/batches/metadata_batch.py b/rubin_sim/maf/batches/metadata_batch.py index 2b1065d29..73838681f 100644 --- a/rubin_sim/maf/batches/metadata_batch.py +++ b/rubin_sim/maf/batches/metadata_batch.py @@ -1,5 +1,4 @@ -"""Some basic physical quantity metrics. -""" +"""Some basic physical quantity metrics.""" __all__ = ( "metadataBasics", diff --git a/rubin_sim/maf/batches/openshutter_batch.py b/rubin_sim/maf/batches/openshutter_batch.py index 175d23d1c..a6620bd67 100644 --- a/rubin_sim/maf/batches/openshutter_batch.py +++ b/rubin_sim/maf/batches/openshutter_batch.py @@ -1,5 +1,4 @@ -"""Evaluate the open shutter fraction. -""" +"""Evaluate the open shutter fraction.""" __all__ = ("openshutterFractions",) diff --git a/rubin_sim/maf/batches/skycoverage.py b/rubin_sim/maf/batches/skycoverage.py index 9f355349c..b4ef00ac4 100644 --- a/rubin_sim/maf/batches/skycoverage.py +++ b/rubin_sim/maf/batches/skycoverage.py @@ -1,5 +1,4 @@ -"""Evaluate some bulk properties of the sky coverage -""" +"""Evaluate some bulk properties of the sky coverage""" __all__ = ("meanRADec", "eastWestBias") diff --git a/rubin_sim/maf/batches/slew_batch.py b/rubin_sim/maf/batches/slew_batch.py index 5e6c80344..e32a9b31b 100644 --- a/rubin_sim/maf/batches/slew_batch.py +++ b/rubin_sim/maf/batches/slew_batch.py @@ -1,5 +1,4 @@ -"""Sets of slew metrics. -""" +"""Sets of slew metrics.""" __all__ = ("slewBasics",) diff --git a/rubin_sim/maf/batches/time_batch.py b/rubin_sim/maf/batches/time_batch.py index 2b60a0d22..ffe53fe0a 100644 --- a/rubin_sim/maf/batches/time_batch.py +++ b/rubin_sim/maf/batches/time_batch.py @@ -1,5 +1,4 @@ -"""Sets of metrics to look at time between visits/pairs, etc. -""" +"""Sets of metrics to look at time between visits/pairs, etc.""" __all__ = ("intraNight", "interNight", "timeGaps", "seasons") diff --git a/rubin_sim/maf/batches/time_sci_batch.py b/rubin_sim/maf/batches/time_sci_batch.py index 2ee5df66b..0461093b5 100644 --- a/rubin_sim/maf/batches/time_sci_batch.py +++ b/rubin_sim/maf/batches/time_sci_batch.py @@ -1,5 +1,4 @@ -"""Sets of metrics to look at impact of cadence on science -""" +"""Sets of metrics to look at impact of cadence on science""" __all__ = ("phaseGap",) diff --git a/rubin_sim/maf/plots/hg_plotters.py b/rubin_sim/maf/plots/hg_plotters.py index 3df11d15e..2eaa2b6df 100644 --- a/rubin_sim/maf/plots/hg_plotters.py +++ b/rubin_sim/maf/plots/hg_plotters.py @@ -1,5 +1,4 @@ -"""Second generation hourglass plotting classes. -""" +"""Second generation hourglass plotting classes.""" # pylint: disable=too-many-arguments # pylint: disable=super-init-not-called diff --git a/rubin_sim/maf/run_comparison/archive.py b/rubin_sim/maf/run_comparison/archive.py index 5874270b1..30f3fa0d7 100644 --- a/rubin_sim/maf/run_comparison/archive.py +++ b/rubin_sim/maf/run_comparison/archive.py @@ -1,5 +1,4 @@ -"""Tools for use of project-generated opsim simulations and analysis. -""" +"""Tools for use of project-generated opsim simulations and analysis.""" __all__ = ( "get_metric_subsets", diff --git a/rubin_sim/maf/run_comparison/summary_plots.py b/rubin_sim/maf/run_comparison/summary_plots.py index 54cc60e56..3f263438e 100644 --- a/rubin_sim/maf/run_comparison/summary_plots.py +++ b/rubin_sim/maf/run_comparison/summary_plots.py @@ -1,5 +1,4 @@ -"""Summary metric plotting functions. -""" +"""Summary metric plotting functions.""" __all__ = ( "normalize_metric_summaries", diff --git a/tests/maf/test_timeintervalslicers.py b/tests/maf/test_timeintervalslicers.py index d91ab3a49..49f33d208 100644 --- a/tests/maf/test_timeintervalslicers.py +++ b/tests/maf/test_timeintervalslicers.py @@ -73,7 +73,7 @@ def test_setup_slicer(self): these_visits = visits.iloc[sim_idxs[sid]] self.assertTrue( np.all(these_visits["scheduler_note"] == these_visits["scheduler_note"].values[0]) - ) + ) class TestVisitIntervalSlicer(unittest.TestCase):