Skip to content

Commit

Permalink
Raise exceptions in known problem areas
Browse files Browse the repository at this point in the history
There are some places in here where variables are used that have
not been defined. We don't seem to be using this code but it's
easier to raise an exception rather than try to delete
particular if-branches.
  • Loading branch information
timj committed Jul 16, 2019
1 parent 5bd7861 commit 986a842
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions python/lsst/meas/extensions/psfex/psfex.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,17 @@ def read_samples(prefs, set, filename, frmin, frmax, ext, next, catindex, contex

n = prefs.getPhotfluxNum() - 1
if n:
assert False, "Code to handle e.g. FLUX_APER(3) isn't yet converted"
if key.naxis == 1 and n < key.naxisn[0]:
raise RuntimeError("Code to handle e.g. FLUX_APER(3) isn't yet converted")
if key.naxis == 1 and n < key.naxisn[0]: # noqa: F821
flux += n
else:
print("Not enough apertures for %s in catalogue %s: using first aperture" %
(prefs.getPhotfluxRkey(), filename), file=sys.stderr)

n = prefs.getPhotfluxerrNum() - 1
if n:
if key.naxis == 1 and n < key.naxisn[0]:
raise RuntimeError("Code for getPhotfluxerrNum is broken")
if key.naxis == 1 and n < key.naxisn[0]: # noqa: F821
fluxerr += n
else:
print("Not enough apertures for %s in catalogue %s: using first aperture" %
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/meas/extensions/psfex/psfexPsfDeterminer.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ def determinePsf(self, exposure, psfCandidateList, metadata=None, flagKey=None):
contextvalp = []
for i, key in enumerate(context.getName()):
if context.getPcflag(i):
contextvalp.append(pcval[pc])
raise RuntimeError("Principal Components can not be accessed")
contextvalp.append(pcval[pc]) # noqa: F821
pc += 1
elif key[0] == ':':
try:
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/meas/extensions/psfex/psfexStarSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ def selectSources(self, sourceCat, matches=None, exposure=None):

# -- ... and check the integrity of the sample
if maxbadflag:
nbad = np.array([(v <= -psfexLib.BIG).sum() for v in vignet])
raise RuntimeError("vignet variable not defined. Code is broken.")
nbad = np.array([(v <= -psfexLib.BIG).sum() for v in vignet]) # noqa: F821
dbad = nbad > maxbad
# set.setBadPix(int(sum(dbad)))
bad = np.logical_or(bad, dbad)
Expand Down

0 comments on commit 986a842

Please sign in to comment.