Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ec50fb1

Browse files
author
Yaron de Leeuw
committed
STY: error and warning formatting on 'function_base.py'
1 parent a38fee9 commit ec50fb1

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

numpy/lib/function_base.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -339,18 +339,19 @@ def histogramdd(sample, bins=10, range=None, normed=False, weights=None):
339339
for i in arange(D):
340340
if isscalar(bins[i]):
341341
if bins[i] < 1:
342-
raise ValueError("Element at index %s in `bins` should be "
343-
"a positive integer." % i)
342+
raise ValueError(
343+
"Element at index %s in `bins` should be a positive "
344+
"integer." % i)
344345
nbin[i] = bins[i] + 2 # +2 for outlier bins
345346
edges[i] = linspace(smin[i], smax[i], nbin[i]-1)
346347
else:
347348
edges[i] = asarray(bins[i], float)
348349
nbin[i] = len(edges[i]) + 1 # +1 for outlier bins
349350
dedges[i] = diff(edges[i])
350351
if np.any(np.asarray(dedges[i]) <= 0):
351-
raise ValueError("""
352-
Found bin edge of size <= 0. Did you specify `bins` with
353-
non-monotonic sequence?""")
352+
raise ValueError(
353+
"Found bin edge of size <= 0. Did you specify `bins` with"
354+
"non-monotonic sequence?")
354355

355356
nbin = asarray(nbin)
356357

@@ -700,7 +701,8 @@ def piecewise(x, condlist, funclist, *args, **kw):
700701
condlist.append(~totlist)
701702
n += 1
702703
if (n != n2):
703-
raise ValueError("function list and condition list must be the same")
704+
raise ValueError(
705+
"function list and condition list must be the same")
704706
zerod = False
705707
# This is a hack to work around problems with NumPy's
706708
# handling of 0-d arrays and boolean indexing with
@@ -771,8 +773,8 @@ def select(condlist, choicelist, default=0):
771773
n = len(condlist)
772774
n2 = len(choicelist)
773775
if n2 != n:
774-
raise ValueError("list of cases must be same length as list of "
775-
"conditions")
776+
raise ValueError(
777+
"list of cases must be same length as list of conditions")
776778
choicelist = [default] + choicelist
777779
S = 0
778780
pfac = 1
@@ -1600,11 +1602,13 @@ def __init__(self, pyfunc, otypes='', doc=None, excluded=None,
16001602
self.otypes = otypes
16011603
for char in self.otypes:
16021604
if char not in typecodes['All']:
1603-
raise ValueError("Invalid otype specified: %s" % (char,))
1605+
raise ValueError(
1606+
"Invalid otype specified: %s" % (char,))
16041607
elif iterable(otypes):
16051608
self.otypes = ''.join([_nx.dtype(x).char for x in otypes])
16061609
else:
1607-
raise ValueError("Invalid otype specification")
1610+
raise ValueError(
1611+
"Invalid otype specification")
16081612

16091613
# Excluded variable support
16101614
if excluded is None:
@@ -2938,8 +2942,9 @@ def percentile(a, q, interpolation='linear', axis=None, out=None,
29382942
elif interpolation == 'linear':
29392943
pass # keep index as fraction and interpolate
29402944
else:
2941-
raise ValueError("interpolation can only be 'linear', 'lower' "
2942-
"'higher', 'midpoint', or 'nearest'")
2945+
raise ValueError(
2946+
"interpolation can only be 'linear', 'lower' 'higher', "
2947+
"'midpoint', or 'nearest'")
29432948

29442949
if indices.dtype == intp: # take the points along axis
29452950
ap.partition(indices, axis=axis)
@@ -3182,8 +3187,9 @@ def meshgrid(*xi, **kwargs):
31823187
31833188
"""
31843189
if len(xi) < 2:
3185-
raise ValueError('meshgrid() takes 2 or more arguments'
3186-
' (%d given)' % int(len(xi) > 0))
3190+
raise ValueError(
3191+
'meshgrid() takes 2 or more arguments '
3192+
'(%d given)' % int(len(xi) > 0))
31873193

31883194
args = np.atleast_1d(*xi)
31893195
ndim = len(args)
@@ -3192,7 +3198,8 @@ def meshgrid(*xi, **kwargs):
31923198
sparse = kwargs.get('sparse', False)
31933199
indexing = kwargs.get('indexing', 'xy')
31943200
if not indexing in ['xy', 'ij']:
3195-
raise ValueError("Valid values for `indexing` are 'xy' and 'ij'.")
3201+
raise ValueError(
3202+
"Valid values for `indexing` are 'xy' and 'ij'.")
31963203

31973204
s0 = (1,) * ndim
31983205
output = [x.reshape(s0[:i] + (-1,) + s0[i + 1::])
@@ -3290,9 +3297,9 @@ def delete(arr, obj, axis=None):
32903297
ndim = arr.ndim
32913298
axis = ndim - 1
32923299
if ndim == 0:
3293-
warnings.warn("in the future the special handling of scalars "
3294-
"will be removed from delete and raise an error",
3295-
DeprecationWarning)
3300+
warnings.warn(
3301+
"in the future the special handling of scalars will be removed "
3302+
"from delete and raise an error", DeprecationWarning)
32963303
if wrap:
32973304
return wrap(arr)
32983305
else:

0 commit comments

Comments
 (0)