Skip to content

Commit

Permalink
more pep8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Alan Weaver committed Dec 1, 2015
1 parent 4e605c8 commit fb2fd90
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 70 deletions.
3 changes: 2 additions & 1 deletion pydl/pydlutils/bspline/cholesky_band.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-
from __future__ import print_function
#


def cholesky_band(l,mininf=0.0,verbose=False):
"""Compute Cholesky decomposition of banded matrix.
Expand Down
2 changes: 2 additions & 0 deletions pydl/pydlutils/bspline/cholesky_solve.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-


def cholesky_solve(a,bb):
"""Solve the equation Ax=b where A is a Cholesky-banded matrix.
Expand Down
8 changes: 5 additions & 3 deletions pydl/pydlutils/bspline/tests/test_iterfit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-


def test_iterfit():
import numpy as np
from .. import iterfit
Expand Down Expand Up @@ -27,11 +29,11 @@ def test_iterfit():
assert y0.size == 100
y = smooth(y0,10)
assert y.size == 100
x = np.arange(y0.size,dtype='d')
sset,outmask = iterfit(x,y,nord=3,maxiter=0,bkspace=10)
x = np.arange(y0.size, dtype='d')
sset,outmask = iterfit(x, y, nord=3, maxiter=0, bkspace=10)
assert sset.npoly == 1
assert sset.funcname == 'legendre'
# print(sset)
# yfit,mask = sset.value(x)
# print(yfit)
# pylab.plot(x,y,'k-',x,yfit,'r-')
# pylab.plot(x, y, 'k-', x, yfit, 'r-')
3 changes: 2 additions & 1 deletion pydl/pydlutils/spheregroup/spheregroup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-
from __future__ import print_function
#


def spheregroup(ra,dec,linklength,chunksize=None):
"""Perform friends-of-friends grouping given ra/dec coordinates.
Expand Down
6 changes: 4 additions & 2 deletions pydl/pydlutils/spheregroup/tests/test_spheregroup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-


def test_spheregroup(recwarn):
import numpy as np
from astropy.tests.helper import raises
Expand Down Expand Up @@ -51,10 +53,10 @@ def test_spheregroup(recwarn):
# Exceptions
#
with raises(PydlutilsException):
group = spheregroup(np.array([137.0]),np.array([55.0]),linklength)
group = spheregroup(np.array([137.0]), np.array([55.0]), linklength)
#
# warnings
#
group = spheregroup(ra,dec,linklength,chunksize=linklength)
group = spheregroup(ra, dec, linklength, chunksize=linklength)
w = recwarn.pop(PydlutilsUserWarning)
assert "chunksize changed to" in str(w.message)
14 changes: 8 additions & 6 deletions pydl/pydlutils/spheregroup/tests/test_spherematch.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-


def test_spherematch():
import numpy as np
from .. import spherematch
i1_should_be = np.array([17, 0, 2, 16, 12, 13, 1, 5, 15, 7,
19, 8, 11, 10, 14, 18, 3, 9, 6, 4])
i2_should_be = np.array([ 2, 0, 17, 3, 16, 15, 14, 5, 6, 10,
8, 19, 18, 4, 9, 7, 11, 12, 1, 13])
i1_should_be = np.array([17, 0, 2, 16, 12, 13, 1, 5, 15, 7,
19, 8, 11, 10, 14, 18, 3, 9, 6, 4])
i2_should_be = np.array([2, 0, 17, 3, 16, 15, 14, 5, 6, 10,
8, 19, 18, 4, 9, 7, 11, 12, 1, 13])
np.random.seed(137)
searchrad = 3.0/3600.0
n = 20
ra1 = 360.0*np.random.random((n,))
dec1 = 90.0 - np.rad2deg(np.arccos(2.0*np.random.random((n,)) - 1.0))
ra2 = ra1 + np.random.normal(0,1.0/3600.0)
dec2 = dec1 + np.random.normal(0,1.0/3600.0)
ra2 = ra1 + np.random.normal(0, 1.0/3600.0)
dec2 = dec1 + np.random.normal(0, 1.0/3600.0)
foo = np.arange(n)
np.random.shuffle(foo)
i1, i2, d12 = spherematch(ra1, dec1, ra2[foo], dec2[foo], searchrad,
Expand Down
1 change: 1 addition & 0 deletions pydl/pydlutils/tests/test_mangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from astropy.tests.helper import raises
from ..mangle import is_cap_used


class TestMangle(object):
"""Test the functions in pydl.pydlutils.mangle.
"""
Expand Down
108 changes: 54 additions & 54 deletions pydl/pydlutils/tests/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def test_computechi2(self):
1.30800, 0.507725, 1.12840, 0.955025, 1.35925,
1.10126, 1.45690, 0.575700, 0.949710, 1.23368,
0.536489, 0.772543, 0.957729, 0.883976, 1.11559])
templates = np.vstack((np.ones((20,),dtype='d'),x)).transpose()
chi2 = computechi2(y,sqivar,templates)
templates = np.vstack((np.ones((20,), dtype='d'), x)).transpose()
chi2 = computechi2(y, sqivar, templates)
#
# 20 data points, 2 parameters = 18 degrees of freedom.
#
Expand All @@ -47,57 +47,57 @@ def test_djs_median(self):
data2 = 100.0*np.random.random((10, 10))
data3 = 100.0*np.random.random((10, 10, 10))
data_width_5 = np.array([
49.68311576, 74.83671757, 49.68311576, 42.12573137,
32.11576752, 27.22092569, 15.08905903, 15.08905903,
27.22092569, 20.07809411, 41.55978953, 41.55978953,
35.01184343, 35.01184343, 38.7967727 , 38.7967727 ,
38.7967727 , 38.7967727 , 38.7967727 , 28.85780425,
28.85780425, 30.23801035, 30.23801035, 27.0687078 ,
30.23801035, 64.77058052, 29.42407045, 38.51749618,
62.48793217, 38.51749618, 29.42407045, 38.51749618,
18.46919414, 18.46919414, 42.72395431, 54.11584807,
54.11584807, 75.67593452, 75.67593452, 72.4380356 ,
61.68761955, 61.68761955, 45.36796557, 45.36796557,
61.68761955, 76.57621138, 76.57621138, 76.57621138,
23.28589488, 23.28589488, 13.82755909, 12.10607597,
13.82755909, 27.51891089, 44.21266068, 44.21266068,
44.21266068, 47.18083025, 47.18083025, 47.18083025,
47.18083025, 47.18083025, 35.50809933, 35.50809933,
25.52222293, 25.52222293, 67.8568479 , 88.54983822,
67.8568479 , 93.40053148, 93.40053148, 64.12514945,
47.82074715, 47.82074715, 47.82074715, 34.82234113,
34.82234113, 52.91092248, 78.51075522, 92.16442338,
92.16442338, 92.16442338, 72.07989558, 72.07989558,
68.72579501, 72.07989558, 72.07989558, 70.43134908,
34.55273356, 62.09010468, 62.09010468, 70.43134908,
68.89705132, 68.89705132, 68.89705132, 66.30426084,
55.92748086, 55.92748086, 55.92748086, 65.11387444])
49.68311576, 74.83671757, 49.68311576, 42.12573137,
32.11576752, 27.22092569, 15.08905903, 15.08905903,
27.22092569, 20.07809411, 41.55978953, 41.55978953,
35.01184343, 35.01184343, 38.7967727, 38.7967727,
38.7967727, 38.7967727, 38.7967727, 28.85780425,
28.85780425, 30.23801035, 30.23801035, 27.0687078,
30.23801035, 64.77058052, 29.42407045, 38.51749618,
62.48793217, 38.51749618, 29.42407045, 38.51749618,
18.46919414, 18.46919414, 42.72395431, 54.11584807,
54.11584807, 75.67593452, 75.67593452, 72.4380356,
61.68761955, 61.68761955, 45.36796557, 45.36796557,
61.68761955, 76.57621138, 76.57621138, 76.57621138,
23.28589488, 23.28589488, 13.82755909, 12.10607597,
13.82755909, 27.51891089, 44.21266068, 44.21266068,
44.21266068, 47.18083025, 47.18083025, 47.18083025,
47.18083025, 47.18083025, 35.50809933, 35.50809933,
25.52222293, 25.52222293, 67.8568479, 88.54983822,
67.8568479, 93.40053148, 93.40053148, 64.12514945,
47.82074715, 47.82074715, 47.82074715, 34.82234113,
34.82234113, 52.91092248, 78.51075522, 92.16442338,
92.16442338, 92.16442338, 72.07989558, 72.07989558,
68.72579501, 72.07989558, 72.07989558, 70.43134908,
34.55273356, 62.09010468, 62.09010468, 70.43134908,
68.89705132, 68.89705132, 68.89705132, 66.30426084,
55.92748086, 55.92748086, 55.92748086, 65.11387444])
data_width_5_reflect = np.array([
49.68311576, 49.68311576, 49.68311576, 42.12573137,
32.11576752, 27.22092569, 15.08905903, 15.08905903,
27.22092569, 20.07809411, 41.55978953, 41.55978953,
35.01184343, 35.01184343, 38.7967727 , 38.7967727 ,
38.7967727 , 38.7967727 , 38.7967727 , 28.85780425,
28.85780425, 30.23801035, 30.23801035, 27.0687078 ,
30.23801035, 64.77058052, 29.42407045, 38.51749618,
62.48793217, 38.51749618, 29.42407045, 38.51749618,
18.46919414, 18.46919414, 42.72395431, 54.11584807,
54.11584807, 75.67593452, 75.67593452, 72.4380356 ,
61.68761955, 61.68761955, 45.36796557, 45.36796557,
61.68761955, 76.57621138, 76.57621138, 76.57621138,
23.28589488, 23.28589488, 13.82755909, 12.10607597,
13.82755909, 27.51891089, 44.21266068, 44.21266068,
44.21266068, 47.18083025, 47.18083025, 47.18083025,
47.18083025, 47.18083025, 35.50809933, 35.50809933,
25.52222293, 25.52222293, 67.8568479 , 88.54983822,
67.8568479 , 93.40053148, 93.40053148, 64.12514945,
47.82074715, 47.82074715, 47.82074715, 34.82234113,
34.82234113, 52.91092248, 78.51075522, 92.16442338,
92.16442338, 92.16442338, 72.07989558, 72.07989558,
68.72579501, 72.07989558, 72.07989558, 70.43134908,
34.55273356, 62.09010468, 62.09010468, 70.43134908,
68.89705132, 68.89705132, 68.89705132, 55.92748086,
65.11387444, 55.92748086, 55.92748086, 55.92748086])
49.68311576, 49.68311576, 49.68311576, 42.12573137,
32.11576752, 27.22092569, 15.08905903, 15.08905903,
27.22092569, 20.07809411, 41.55978953, 41.55978953,
35.01184343, 35.01184343, 38.7967727, 38.7967727,
38.7967727, 38.7967727, 38.7967727, 28.85780425,
28.85780425, 30.23801035, 30.23801035, 27.0687078,
30.23801035, 64.77058052, 29.42407045, 38.51749618,
62.48793217, 38.51749618, 29.42407045, 38.51749618,
18.46919414, 18.46919414, 42.72395431, 54.11584807,
54.11584807, 75.67593452, 75.67593452, 72.4380356,
61.68761955, 61.68761955, 45.36796557, 45.36796557,
61.68761955, 76.57621138, 76.57621138, 76.57621138,
23.28589488, 23.28589488, 13.82755909, 12.10607597,
13.82755909, 27.51891089, 44.21266068, 44.21266068,
44.21266068, 47.18083025, 47.18083025, 47.18083025,
47.18083025, 47.18083025, 35.50809933, 35.50809933,
25.52222293, 25.52222293, 67.8568479, 88.54983822,
67.8568479, 93.40053148, 93.40053148, 64.12514945,
47.82074715, 47.82074715, 47.82074715, 34.82234113,
34.82234113, 52.91092248, 78.51075522, 92.16442338,
92.16442338, 92.16442338, 72.07989558, 72.07989558,
68.72579501, 72.07989558, 72.07989558, 70.43134908,
34.55273356, 62.09010468, 62.09010468, 70.43134908,
68.89705132, 68.89705132, 68.89705132, 55.92748086,
65.11387444, 55.92748086, 55.92748086, 55.92748086])
#
# Degenerate cases that fall back on numpy.median().
#
Expand Down Expand Up @@ -129,6 +129,6 @@ def test_djs_median(self):
with raises(ValueError):
foo = djs_median(data3, width=5, boundary='reflect')


def test_find_contiguous(self):
assert find_contiguous(np.array([0,1,1,1,0,1,1,0,1])) == [1,2,3]
assert (find_contiguous(np.array([0, 1, 1, 1, 0, 1, 1, 0, 1])) ==
[1, 2, 3])
1 change: 1 addition & 0 deletions pydl/pydlutils/tests/test_sdss.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
sdss_flagval, set_maskbits, sdss_astrombad,
sdss_objid)


class TestSDSS(object):
"""Test the functions in pydl.pydlutils.sdss.
"""
Expand Down
6 changes: 3 additions & 3 deletions pydl/pydlutils/tests/test_trace.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-
import numpy as np
from os.path import dirname,join
from os.path import dirname, join
from astropy.io import fits
from astropy.tests.helper import raises
from ..trace import (fchebyshev, fchebyshev_split, fpoly, func_fit,
Expand Down Expand Up @@ -235,7 +235,7 @@ def test_traceset_sdss(self):
assert tset.xRange == tset.xmax - tset.xmin
assert tset.nx == int(tset.xmax - tset.xmin + 1)
assert tset.xmid == 0.5 * (tset.xmin + tset.xmax)
x,y = traceset2xy(tset)
x, y = traceset2xy(tset)
tset2 = xy2traceset(x, y, ncoeff=tset.ncoeff)
assert tset2.xmin == tset.xmin
assert tset2.xmax == tset.xmax
Expand All @@ -250,7 +250,7 @@ def test_traceset_boss(self):
assert tset.xRange == tset.xmax - tset.xmin
assert tset.nx == int(tset.xmax - tset.xmin + 1)
assert tset.xmid == 0.5 * (tset.xmin + tset.xmax)
x,y = traceset2xy(tset)
x, y = traceset2xy(tset)
tset2 = xy2traceset(x, y, ncoeff=tset.ncoeff,
xjumplo=tset.xjumplo,
xjumphi=tset.xjumphi,
Expand Down

0 comments on commit fb2fd90

Please sign in to comment.