Skip to content

Commit

Permalink
flake8 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
waqasbhatti committed Sep 22, 2018
1 parent ae3166d commit e37e4bc
Show file tree
Hide file tree
Showing 41 changed files with 724 additions and 735 deletions.
434 changes: 214 additions & 220 deletions astrobase/astrokep.py

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions astrobase/checkplot.py
Expand Up @@ -136,7 +136,7 @@ def LOGEXCEPTION(message):
import cPickle as pickle
import cStringIO
from cStringIO import StringIO as strio
except:
except Exception as e:
import pickle
from io import BytesIO as strio

Expand Down Expand Up @@ -531,7 +531,7 @@ def _make_phased_magseries_plot(axes,
else:
plotvarepoch = varepoch[periodind]

except:
except Exception as e:
LOGEXCEPTION(
"varepoch provided in list form either doesn't match "
"the length of nbestperiods from the period-finder "
Expand Down Expand Up @@ -733,7 +733,7 @@ def checkplot_png(lspinfo,
phasesort=True,
phasebin=0.002,
minbinelems=7,
plotxlim=[-0.8,0.8],
plotxlim=(-0.8,0.8),
xliminsetmode=False,
plotdpi=100,
bestperiodhighlight=None,
Expand Down Expand Up @@ -1054,7 +1054,7 @@ def twolsp_checkplot_png(lspinfo1,
phasesort=True,
phasebin=0.002,
minbinelems=7,
plotxlim=[-0.8,0.8],
plotxlim=(-0.8,0.8),
xliminsetmode=False,
plotdpi=100,
bestperiodhighlight=None,
Expand Down Expand Up @@ -2060,7 +2060,7 @@ def _pkl_phased_magseries_plot(checkplotdict,
phasesort=True,
phasebin=0.002,
minbinelems=7,
plotxlim=[-0.8,0.8],
plotxlim=(-0.8,0.8),
plotdpi=100,
bestperiodhighlight=None,
xgridlines=None,
Expand Down Expand Up @@ -2162,7 +2162,7 @@ def _pkl_phased_magseries_plot(checkplotdict,
try:
thisvarepochlist = varepoch[lspmethodind]
plotvarepoch = thisvarepochlist[periodind]
except:
except Exception as e:
LOGEXCEPTION(
"varepoch provided in list form either doesn't match "
"the length of nbestperiods from the period-finder "
Expand Down Expand Up @@ -2941,7 +2941,7 @@ def checkplot_dict(lspinfolist,
xmatchinfo=None,
xmatchradiusarcsec=3.0,
lcfitfunc=None,
lcfitparams={},
lcfitparams=None,
externalplots=None,
findercmap='gray_r',
finderconvolve=None,
Expand All @@ -2954,7 +2954,7 @@ def checkplot_dict(lspinfolist,
phasesort=True,
phasebin=0.002,
minbinelems=7,
plotxlim=[-0.8,0.8],
plotxlim=(-0.8,0.8),
xliminsetmode=False,
plotdpi=100,
bestperiodhighlight=None,
Expand Down Expand Up @@ -3284,6 +3284,8 @@ def lcfitfunc(times, mags, errs, period, **lcfitparams)
# if there's a function to use for fitting, do the fit
if lcfitfunc:
try:
if lcfitparams is None:
lcfitparams = {}
overplotfit = lcfitfunc(stimes,
smags,
serrs,
Expand Down Expand Up @@ -3443,7 +3445,7 @@ def checkplot_pickle(lspinfolist,
gaia_mirror='cds',
complete_query_later=True,
lcfitfunc=None,
lcfitparams={},
lcfitparams=None,
varinfo=None,
getvarfeatures=True,
lclistpkl=None,
Expand All @@ -3465,7 +3467,7 @@ def checkplot_pickle(lspinfolist,
phasesort=True,
phasebin=0.002,
minbinelems=7,
plotxlim=[-0.8,0.8],
plotxlim=(-0.8,0.8),
xliminsetmode=False,
plotdpi=100,
returndict=False,
Expand Down
8 changes: 4 additions & 4 deletions astrobase/cpserver/checkplotlist.py
Expand Up @@ -79,7 +79,7 @@
checkplot PNGs) or the checkplotserver.py (for checkplot pickles) webapps.
'''

PROGEPILOG= '''\
PROGEPILOG = '''\
SEARCHING FOR CHECKPLOT PNGS OR PICKLES
---------------------------------------
If you have checkplots that don't have 'checkplot' somewhere in their file name,
Expand Down Expand Up @@ -167,7 +167,7 @@

try:
import cPickle as pickle
except:
except Exception as e:
import pickle

# suppress warnings
Expand Down Expand Up @@ -214,7 +214,7 @@ def checkplot_infokey_worker(task):

try:
resultkeys.append(dict_get(cpd, k))
except:
except Exception as e:
resultkeys.append(np.nan)

return resultkeys
Expand Down Expand Up @@ -675,7 +675,7 @@ def main():
'checkplot list file in this '
'directory:\n %s\nDo you want to '
'overwrite it completely? (default: no) [y/n] ' %
outjson
outjson
)

# if it's OK to overwrite, then do so
Expand Down
4 changes: 2 additions & 2 deletions astrobase/cpserver/checkplotserver.py
Expand Up @@ -43,7 +43,7 @@ def recv_sigint(signum, stack):
import asyncio
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
except:
except Exception as e:
pass

import tornado.ioloop
Expand Down Expand Up @@ -200,7 +200,7 @@ def main():
# check if this file is readable/writeable by user only
fileperm = oct(os.stat(options.sharedsecret)[stat.ST_MODE])

if fileperm == '0100600' or fileperm == '0o100600':
if fileperm == '0100400' or fileperm == '0o100400':

with open(options.sharedsecret,'r') as infd:

Expand Down
75 changes: 42 additions & 33 deletions astrobase/cpserver/checkplotserver_handlers.py
Expand Up @@ -16,15 +16,15 @@
import os.path
try:
import cPickle as pickle
except:
except Exception as e:
import pickle
import base64
import logging
import time as utime

try:
from cStringIO import StringIO as strio
except:
except Exception as e:
from io import BytesIO as strio

import numpy as np
Expand Down Expand Up @@ -90,7 +90,7 @@ def default(self, obj):
checkplot.set_logger_parent(__name__)

from ..checkplot import checkplot_pickle_update, checkplot_pickle_to_png, \
_read_checkplot_picklefile, _base64_to_file, _write_checkplot_picklefile
_read_checkplot_picklefile, _write_checkplot_picklefile

# import these for updating plots due to user input
from ..checkplot import _pkl_finder_objectinfo, _pkl_periodogram, \
Expand Down Expand Up @@ -1467,7 +1467,7 @@ def get(self, cpfile):
LOGGER.error('lctool %s, does not exist' % lctool)
resultdict['status'] = 'error'
resultdict['message'] = (
'lctool %s does not exist' % lctool
'lctool %s does not exist' % lctool
)
resultdict['result'] = {'objectid':cpobjectid}

Expand All @@ -1480,7 +1480,7 @@ def get(self, cpfile):
LOGGER.error('lctool argument not provided')
resultdict['status'] = 'error'
resultdict['message'] = (
'lctool argument not provided'
'lctool argument not provided'
)
resultdict['result'] = {'objectid':cpobjectid}

Expand Down Expand Up @@ -1508,7 +1508,7 @@ def get(self, cpfile):
if os.path.exists(tempfpath):

tempcpdict = yield self.executor.submit(
_read_checkplot_picklefile, tempfpath
_read_checkplot_picklefile, tempfpath
)

# if it doesn't exist, read the times, mags, errs from the
Expand Down Expand Up @@ -1584,7 +1584,7 @@ def get(self, cpfile):
elif xargtype is float and xarg == 'varepoch':
try:
wbarg = xargtype(wbarg)
except:
except Exception as e:
wbarg = None
# usual casting for other types
else:
Expand Down Expand Up @@ -1777,8 +1777,10 @@ def get(self, cpfile):
filt_hi = float(thisfilt[1])

filtermasks.append(
((wtimes - cptimes.min()) < filt_hi) &
((wtimes - cptimes.min()) > filt_lo)
((wtimes -
cptimes.min()) < filt_hi) &
((wtimes -
cptimes.min()) > filt_lo)
)

elif (len(thisfilt) == 3 and
Expand All @@ -1789,14 +1791,16 @@ def get(self, cpfile):
filt_hi = float(thisfilt[2])

filtermasks.append(np.logical_not(
(((wtimes - cptimes.min()) < filt_hi) &
((wtimes - cptimes.min()) > filt_lo))
(((wtimes -
cptimes.min()) < filt_hi) &
((wtimes -
cptimes.min()) > filt_lo))
))

else:
continue

except:
except Exception as e:
continue

# finally, apply the filters if applicable
Expand Down Expand Up @@ -1860,8 +1864,7 @@ def get(self, cpfile):
else:
continue


except:
except Exception as e:
continue

# finally, apply the filters if applicable
Expand Down Expand Up @@ -1910,13 +1913,13 @@ def get(self, cpfile):


phasedlcargs0 = (None,
lspmethod,
-1,
lctoolargs[0],
lctoolargs[1],
lctoolargs[2],
nbestperiods[0],
'min')
lspmethod,
-1,
lctoolargs[0],
lctoolargs[1],
lctoolargs[2],
nbestperiods[0],
'min')

if len(nbestperiods) > 1:
phasedlcargs1 = (None,
Expand Down Expand Up @@ -1987,7 +1990,9 @@ def get(self, cpfile):
'bestperiod':funcresults['bestperiod'],
'nbestperiods':funcresults['nbestperiods'],
'nbestlspvals':funcresults['nbestlspvals'],
'periodogram':pgramres[lspmethod]['periodogram'],
'periodogram':(
pgramres[lspmethod]['periodogram']
),
0:phasedlc0,
}

Expand Down Expand Up @@ -2191,8 +2196,10 @@ def get(self, cpfile):
filt_hi = float(thisfilt[1])

filtermasks.append(
((wtimes - cptimes.min()) < filt_hi) &
((wtimes - cptimes.min()) > filt_lo)
((wtimes -
cptimes.min()) < filt_hi) &
((wtimes -
cptimes.min()) > filt_lo)
)

elif (len(thisfilt) == 3 and
Expand All @@ -2203,14 +2210,16 @@ def get(self, cpfile):
filt_hi = float(thisfilt[2])

filtermasks.append(np.logical_not(
(((wtimes - cptimes.min()) < filt_hi) &
((wtimes - cptimes.min()) > filt_lo))
(((wtimes -
cptimes.min()) < filt_hi) &
((wtimes -
cptimes.min()) > filt_lo))
))

else:
continue

except:
except Exception as e:
continue

# finally, apply the filters if applicable
Expand Down Expand Up @@ -2272,7 +2281,7 @@ def get(self, cpfile):
else:
continue

except:
except Exception as e:
continue

# finally, apply the filters if applicable
Expand Down Expand Up @@ -2301,10 +2310,10 @@ def get(self, cpfile):
)
try:
spfit = lcfit.spline_fit_magseries(
stimes, # times
smags, # mags
serrs, # errs
lctoolargs[6], # period
stimes, # times
smags, # mags
serrs, # errs
lctoolargs[6], # period
magsarefluxes=lctoolkwargs['magsarefluxes'],
sigclip=None,
verbose=True
Expand Down Expand Up @@ -3094,7 +3103,7 @@ def get(self):
base64.b64decode(url_unescape(checkplotfname))
)

except:
except Exception as e:
msg = 'could not decode the incoming payload'
LOGGER.error(msg)
resultdict = {'status':'error',
Expand Down

0 comments on commit e37e4bc

Please sign in to comment.