Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-23173: Update W504 to W503 and fix flake8 warnings #77

Merged
merged 1 commit into from
Apr 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/lsst/ap/association/association.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ def check_dia_source_radec(self, dia_sources):
DataFrame of DiaSources trimmed of all entries with NaN values for
RA/DEC.
"""
nan_mask = (dia_sources.loc[:, "ra"].isnull() |
dia_sources.loc[:, "decl"].isnull())
nan_mask = (dia_sources.loc[:, "ra"].isnull()
| dia_sources.loc[:, "decl"].isnull())
if np.any(nan_mask):
nan_idxs = np.argwhere(nan_mask.to_numpy()).flatten()
for nan_idx in nan_idxs:
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/ap/association/diaCalculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ def run(self, diaObjectCat, diaSourceCat, updatedDiaObjectIds, filterName):
["diaObjectId", "filterName", "diaSourceId"],
inplace=True,
drop=False)
elif (diaSourceCat.index.names !=
["diaObjectId", "filterName", "diaSourceId"]):
elif (diaSourceCat.index.names
!= ["diaObjectId", "filterName", "diaSourceId"]):
self.log.warn(
"Input diaSourceCat is indexed on column(s) incompatible with "
"this task. Should be indexed on 'multi-index, "
Expand Down
12 changes: 6 additions & 6 deletions python/lsst/ap/association/diaCalculationPlugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ def _weightedMean(df):
tmpDf = df[~np.logical_or(np.isnan(df["psFlux"]),
np.isnan(df["psFluxErr"]))]
tot_weight = np.nansum(1 / tmpDf["psFluxErr"] ** 2)
fluxMean = np.nansum(tmpDf["psFlux"] /
tmpDf["psFluxErr"] ** 2)
fluxMean = np.nansum(tmpDf["psFlux"]
/ tmpDf["psFluxErr"] ** 2)
fluxMean /= tot_weight
fluxMeanErr = np.sqrt(1 / tot_weight)
nFluxData = len(tmpDf)
Expand Down Expand Up @@ -486,8 +486,8 @@ def calculate(self,
meanName = "{}PSFluxMean".format(filterName)

def _chi2(df):
delta = (df["psFlux"] -
diaObjects.at[df.diaObjectId.iat[0], meanName])
delta = (df["psFlux"]
- diaObjects.at[df.diaObjectId.iat[0], meanName])
return np.nansum((delta / df["psFluxErr"]) ** 2)

diaObjects.loc[:, "{}PSFluxChi2".format(filterName)] = \
Expand Down Expand Up @@ -1029,8 +1029,8 @@ def _meanFlux(df):
tmpDf = df[~np.logical_or(np.isnan(df["totFlux"]),
np.isnan(df["totFluxErr"]))]
tot_weight = np.nansum(1 / tmpDf["totFluxErr"] ** 2)
fluxMean = np.nansum(tmpDf["totFlux"] /
tmpDf["totFluxErr"] ** 2)
fluxMean = np.nansum(tmpDf["totFlux"]
/ tmpDf["totFluxErr"] ** 2)
fluxMean /= tot_weight
fluxMeanErr = np.sqrt(1 / tot_weight)

Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
max-line-length = 110
ignore = E133, E226, E228, N802, N803, N806, N812, N815, N816, W504
ignore = E133, E226, E228, N802, N803, N806, N812, N815, N816, W503
exclude =
bin,
doc,
Expand All @@ -11,4 +11,4 @@ exclude =

[tool:pytest]
addopts = --flake8
flake8-ignore = E133 E226 E228 N802 N803 N806 N812 N815 N816 W504
flake8-ignore = E133 E226 E228 N802 N803 N806 N812 N815 N816 W503
12 changes: 6 additions & 6 deletions tests/test_association_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,16 @@ def _set_source_values(self, dia_source, flux, fluxErr, filterName,
dia_source["midPointTai"] = midPointTai
dia_source["psFlux"] = flux / self.flux0
dia_source["psFluxErr"] = np.sqrt(
(fluxErr / self.flux0) ** 2 +
(flux * self.flux0_err / self.flux0 ** 2) ** 2)
(fluxErr / self.flux0) ** 2
+ (flux * self.flux0_err / self.flux0 ** 2) ** 2)
dia_source["apFlux"] = flux / self.flux0
dia_source["apFluxErr"] = np.sqrt(
(fluxErr / self.flux0) ** 2 +
(flux * self.flux0_err / self.flux0 ** 2) ** 2)
(fluxErr / self.flux0) ** 2
+ (flux * self.flux0_err / self.flux0 ** 2) ** 2)
dia_source["totFlux"] = flux / self.flux0
dia_source["totFluxErr"] = np.sqrt(
(fluxErr / self.flux0) ** 2 +
(flux * self.flux0_err / self.flux0 ** 2) ** 2)
(fluxErr / self.flux0) ** 2
+ (flux * self.flux0_err / self.flux0 ** 2) ** 2)
dia_source["filterName"] = filterName
dia_source["filterId"] = filterId
dia_source["x"] = 0.
Expand Down
6 changes: 3 additions & 3 deletions tests/test_dia_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ def calculate(self,
filterName,
**kwargs):
diaObjects.at[diaObjectId, "%sChiFlux" % filterName] = np.sum(
((filterDiaSources["psFlux"] -
diaObjects.at[diaObjectId, "%sMeanFlux" % filterName]) /
filterDiaSources["psFluxErr"]) ** 2)
((filterDiaSources["psFlux"]
- diaObjects.at[diaObjectId, "%sMeanFlux" % filterName])
/ filterDiaSources["psFluxErr"]) ** 2)


@register("testCollidingDiaPlugin")
Expand Down
12 changes: 6 additions & 6 deletions tests/test_dia_calculation_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,9 @@ def testCalculate(self):
run_multi_plugin(diaObjects, diaSources, "u", plug)
self.assertAlmostEqual(
diaObjects.loc[objId, "uPSFluxChi2"],
np.nansum(((diaSources["psFlux"] -
np.nanmean(diaSources["psFlux"])) /
diaSources["psFluxErr"]) ** 2))
np.nansum(((diaSources["psFlux"]
- np.nanmean(diaSources["psFlux"]))
/ diaSources["psFluxErr"]) ** 2))

# Test expected chi^2 value with a nan value set.
fluxes[4] = np.nan
Expand All @@ -507,9 +507,9 @@ def testCalculate(self):
run_multi_plugin(diaObjects, diaSources, "r", plug)
self.assertAlmostEqual(
diaObjects.loc[objId, "rPSFluxChi2"],
np.nansum(((diaSources["psFlux"] -
np.nanmean(diaSources["psFlux"])) /
diaSources["psFluxErr"]) ** 2))
np.nansum(((diaSources["psFlux"]
- np.nanmean(diaSources["psFlux"]))
/ diaSources["psFluxErr"]) ** 2))


class TestMadDiaPsFlux(unittest.TestCase):
Expand Down