pep8 + updated wafo.stats packages
parent
629ed411c9
commit
d308357c5b
@ -1,26 +1,27 @@
|
||||
from __future__ import division, print_function, absolute_import
|
||||
|
||||
from info import __doc__
|
||||
import misc
|
||||
import data
|
||||
import demos
|
||||
import kdetools
|
||||
import objects
|
||||
import spectrum
|
||||
import transform
|
||||
import definitions
|
||||
import polynomial
|
||||
import stats
|
||||
import interpolate
|
||||
import dctpack
|
||||
from .info import __doc__
|
||||
from . import misc
|
||||
from . import data
|
||||
from . import demos
|
||||
from . import kdetools
|
||||
from . import objects
|
||||
from . import spectrum
|
||||
from . import transform
|
||||
from . import definitions
|
||||
from . import polynomial
|
||||
from . import stats
|
||||
from . import interpolate
|
||||
from . import dctpack
|
||||
try:
|
||||
import fig
|
||||
from . import fig
|
||||
except ImportError:
|
||||
print 'fig import only supported on Windows'
|
||||
print('fig import only supported on Windows')
|
||||
|
||||
try:
|
||||
from wafo.version import version as __version__
|
||||
except ImportError:
|
||||
__version__='nobuilt'
|
||||
__version__ = 'nobuilt'
|
||||
|
||||
from numpy.testing import Tester
|
||||
test = Tester().test
|
@ -1,136 +0,0 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
def meshgrid(*xi, **kwargs):
|
||||
"""
|
||||
Return coordinate matrices from one or more coordinate vectors.
|
||||
|
||||
Make N-D coordinate arrays for vectorized evaluations of
|
||||
N-D scalar/vector fields over N-D grids, given
|
||||
one-dimensional coordinate arrays x1, x2,..., xn.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
x1, x2,..., xn : array_like
|
||||
1-D arrays representing the coordinates of a grid.
|
||||
indexing : 'xy' or 'ij' (optional)
|
||||
cartesian ('xy', default) or matrix ('ij') indexing of output
|
||||
sparse : True or False (default) (optional)
|
||||
If True a sparse grid is returned in order to conserve memory.
|
||||
copy : True (default) or False (optional)
|
||||
If False a view into the original arrays are returned in order to
|
||||
conserve memory. Please note that sparse=False, copy=False will likely
|
||||
return non-contiguous arrays. Furthermore, more than one element of a
|
||||
broadcasted array may refer to a single memory location. If you
|
||||
need to write to the arrays, make copies first.
|
||||
|
||||
Returns
|
||||
-------
|
||||
X1, X2,..., XN : ndarray
|
||||
For vectors `x1`, `x2`,..., 'xn' with lengths ``Ni=len(xi)`` ,
|
||||
return ``(N1, N2, N3,...Nn)`` shaped arrays if indexing='ij'
|
||||
or ``(N2, N1, N3,...Nn)`` shaped arrays if indexing='xy'
|
||||
with the elements of `xi` repeated to fill the matrix along
|
||||
the first dimension for `x1`, the second for `x2` and so on.
|
||||
|
||||
Notes
|
||||
-----
|
||||
This function supports both indexing conventions through the indexing
|
||||
keyword argument. Giving the string 'ij' returns a meshgrid with matrix
|
||||
indexing, while 'xy' returns a meshgrid with Cartesian indexing. The
|
||||
difference is illustrated by the following code snippet:
|
||||
|
||||
xv, yv = meshgrid(x, y, sparse=False, indexing='ij')
|
||||
for i in range(nx):
|
||||
for j in range(ny):
|
||||
# treat xv[i,j], yv[i,j]
|
||||
|
||||
xv, yv = meshgrid(x, y, sparse=False, indexing='xy')
|
||||
for i in range(nx):
|
||||
for j in range(ny):
|
||||
# treat xv[j,i], yv[j,i]
|
||||
|
||||
See Also
|
||||
--------
|
||||
index_tricks.mgrid : Construct a multi-dimensional "meshgrid"
|
||||
using indexing notation.
|
||||
index_tricks.ogrid : Construct an open multi-dimensional "meshgrid"
|
||||
using indexing notation.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> nx, ny = (3, 2)
|
||||
>>> x = np.linspace(0, 1, nx)
|
||||
>>> y = np.linspace(0, 1, ny)
|
||||
>>> xv, yv = meshgrid(x, y)
|
||||
>>> xv
|
||||
array([[ 0. , 0.5, 1. ],
|
||||
[ 0. , 0.5, 1. ]])
|
||||
>>> yv
|
||||
array([[ 0., 0., 0.],
|
||||
[ 1., 1., 1.]])
|
||||
>>> xv, yv = meshgrid(x, y, sparse=True) # make sparse output arrays
|
||||
>>> xv
|
||||
array([[ 0. , 0.5, 1. ]])
|
||||
>>> yv
|
||||
array([[ 0.],
|
||||
[ 1.]])
|
||||
|
||||
`meshgrid` is very useful to evaluate functions on a grid.
|
||||
|
||||
>>> x = np.arange(-5, 5, 0.1)
|
||||
>>> y = np.arange(-5, 5, 0.1)
|
||||
>>> xx, yy = meshgrid(x, y, sparse=True)
|
||||
>>> z = np.sin(xx**2+yy**2)/(xx**2+yy**2)
|
||||
|
||||
>>> import matplotlib.pyplot as plt
|
||||
>>> h = plt.contourf(x,y,z)
|
||||
"""
|
||||
copy_ = kwargs.get('copy', True)
|
||||
args = np.atleast_1d(*xi)
|
||||
ndim = len(args)
|
||||
|
||||
if not isinstance(args, list) or ndim < 2:
|
||||
raise TypeError(
|
||||
'meshgrid() takes 2 or more arguments (%d given)' % int(ndim > 0))
|
||||
|
||||
sparse = kwargs.get('sparse', False)
|
||||
indexing = kwargs.get('indexing', 'xy')
|
||||
|
||||
s0 = (1,) * ndim
|
||||
output = [x.reshape(s0[:i] + (-1,) + s0[i + 1::])
|
||||
for i, x in enumerate(args)]
|
||||
|
||||
shape = [x.size for x in output]
|
||||
|
||||
if indexing == 'xy':
|
||||
# switch first and second axis
|
||||
output[0].shape = (1, -1) + (1,) * (ndim - 2)
|
||||
output[1].shape = (-1, 1) + (1,) * (ndim - 2)
|
||||
shape[0], shape[1] = shape[1], shape[0]
|
||||
|
||||
if sparse:
|
||||
if copy_:
|
||||
return [x.copy() for x in output]
|
||||
else:
|
||||
return output
|
||||
else:
|
||||
# Return the full N-D matrix (not only the 1-D vector)
|
||||
if copy_:
|
||||
mult_fact = np.ones(shape, dtype=int)
|
||||
return [x * mult_fact for x in output]
|
||||
else:
|
||||
return np.broadcast_arrays(*output)
|
||||
|
||||
|
||||
def ndgrid(*args, **kwargs):
|
||||
"""
|
||||
Same as calling meshgrid with indexing='ij' (see meshgrid for
|
||||
documentation).
|
||||
"""
|
||||
kwargs['indexing'] = 'ij'
|
||||
return meshgrid(*args, **kwargs)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,76 +1,133 @@
|
||||
import unittest
|
||||
import numpy as np
|
||||
from wafo.spectrum.models import (Bretschneider, Jonswap, OchiHubble, Tmaspec,
|
||||
Torsethaugen, McCormick, Wallop)
|
||||
|
||||
|
||||
def test_bretschneider():
|
||||
S = Bretschneider(Hm0=6.5, Tp=10)
|
||||
vals = S((0, 1, 2, 3))
|
||||
true_vals = np.array([0., 1.69350993, 0.06352698, 0.00844783])
|
||||
assert((np.abs(vals - true_vals) < 1e-7).all())
|
||||
|
||||
|
||||
def test_if_jonswap_with_gamma_one_equals_bretschneider():
|
||||
S = Jonswap(Hm0=7, Tp=11, gamma=1)
|
||||
vals = S((0, 1, 2, 3))
|
||||
true_vals = np.array([0., 1.42694133, 0.05051648, 0.00669692])
|
||||
assert((np.abs(vals - true_vals) < 1e-7).all())
|
||||
|
||||
w = np.linspace(0, 5)
|
||||
S2 = Bretschneider(Hm0=7, Tp=11)
|
||||
# JONSWAP with gamma=1 should be equal to Bretscneider:
|
||||
assert(np.all(np.abs(S(w) - S2(w)) < 1.e-7))
|
||||
|
||||
|
||||
def test_tmaspec():
|
||||
S = Tmaspec(Hm0=7, Tp=11, gamma=1, h=10)
|
||||
vals = S((0, 1, 2, 3))
|
||||
true_vals = np.array([0., 0.70106233, 0.05022433, 0.00669692])
|
||||
assert((np.abs(vals - true_vals) < 1e-7).all())
|
||||
|
||||
|
||||
def test_torsethaugen():
|
||||
|
||||
S = Torsethaugen(Hm0=7, Tp=11, gamma=1, h=10)
|
||||
vals = S((0, 1, 2, 3))
|
||||
true_vals = np.array([0., 1.19989709, 0.05819794, 0.0093541])
|
||||
assert((np.abs(vals - true_vals) < 1e-7).all())
|
||||
|
||||
vals = S.wind(range(4))
|
||||
true_vals = np.array([0., 1.13560528, 0.05529849, 0.00888989])
|
||||
assert((np.abs(vals - true_vals) < 1e-7).all())
|
||||
vals = S.swell(range(4))
|
||||
true_vals = np.array([0., 0.0642918, 0.00289946, 0.00046421])
|
||||
assert((np.abs(vals - true_vals) < 1e-7).all())
|
||||
|
||||
|
||||
def test_ochihubble():
|
||||
|
||||
S = OchiHubble(par=2)
|
||||
vals = S(range(4))
|
||||
true_vals = np.array([0., 0.90155636, 0.04185445, 0.00583207])
|
||||
assert((np.abs(vals - true_vals) < 1e-7).all())
|
||||
|
||||
|
||||
def test_mccormick():
|
||||
|
||||
S = McCormick(Hm0=6.5, Tp=10)
|
||||
vals = S(range(4))
|
||||
true_vals = np.array([0., 1.87865908, 0.15050447, 0.02994663])
|
||||
assert((np.abs(vals - true_vals) < 1e-7).all())
|
||||
|
||||
|
||||
def test_wallop():
|
||||
|
||||
S = Wallop(Hm0=6.5, Tp=10)
|
||||
vals = S(range(4))
|
||||
true_vals = np.array([0.00000000e+00, 9.36921871e-01, 2.76991078e-03,
|
||||
7.72996150e-05])
|
||||
assert((np.abs(vals - true_vals) < 1e-7).all())
|
||||
from wafo.spectrum.models import (Bretschneider, Jonswap, OchiHubble, Tmaspec,
|
||||
Torsethaugen, McCormick, Wallop, Spreading)
|
||||
|
||||
|
||||
class TestCase(unittest.TestCase):
|
||||
def assertListAlmostEqual(self, list1, list2, places=None, msg=None):
|
||||
self.assertEqual(len(list1), len(list2))
|
||||
for a, b in zip(list1, list2):
|
||||
self.assertAlmostEqual(a, b, places, msg)
|
||||
|
||||
|
||||
class TestSpectra(TestCase):
|
||||
def test_bretschneider(self):
|
||||
S = Bretschneider(Hm0=6.5, Tp=10)
|
||||
vals = S((0, 1, 2, 3)).tolist()
|
||||
true_vals = [0., 1.69350993, 0.06352698, 0.00844783]
|
||||
self.assertListAlmostEqual(vals, true_vals)
|
||||
|
||||
def test_if_jonswap_with_gamma_one_equals_bretschneider(self):
|
||||
S = Jonswap(Hm0=7, Tp=11, gamma=1)
|
||||
vals = S((0, 1, 2, 3))
|
||||
true_vals = np.array([0., 1.42694133, 0.05051648, 0.00669692])
|
||||
self.assertListAlmostEqual(vals, true_vals)
|
||||
w = np.linspace(0, 5)
|
||||
S2 = Bretschneider(Hm0=7, Tp=11)
|
||||
# JONSWAP with gamma=1 should be equal to Bretscneider:
|
||||
self.assertListAlmostEqual(S(w), S2(w))
|
||||
|
||||
def test_tmaspec(self):
|
||||
S = Tmaspec(Hm0=7, Tp=11, gamma=1, h=10)
|
||||
vals = S((0, 1, 2, 3))
|
||||
true_vals = np.array([0., 0.70106233, 0.05022433, 0.00669692])
|
||||
self.assertListAlmostEqual(vals, true_vals)
|
||||
|
||||
def test_torsethaugen(self):
|
||||
S = Torsethaugen(Hm0=7, Tp=11, gamma=1, h=10)
|
||||
vals = S((0, 1, 2, 3))
|
||||
true_vals = np.array([0., 1.19989709, 0.05819794, 0.0093541])
|
||||
self.assertListAlmostEqual(vals, true_vals)
|
||||
|
||||
vals = S.wind(range(4))
|
||||
true_vals = np.array([0., 1.13560528, 0.05529849, 0.00888989])
|
||||
self.assertListAlmostEqual(vals, true_vals)
|
||||
|
||||
vals = S.swell(range(4))
|
||||
true_vals = np.array([0., 0.0642918, 0.00289946, 0.00046421])
|
||||
self.assertListAlmostEqual(vals, true_vals)
|
||||
|
||||
def test_ochihubble(self):
|
||||
|
||||
S = OchiHubble(par=2)
|
||||
vals = S(range(4))
|
||||
true_vals = np.array([0., 0.90155636, 0.04185445, 0.00583207])
|
||||
self.assertListAlmostEqual(vals, true_vals)
|
||||
|
||||
def test_mccormick(self):
|
||||
|
||||
S = McCormick(Hm0=6.5, Tp=10)
|
||||
vals = S(range(4))
|
||||
true_vals = np.array([0., 1.87865908, 0.15050447, 0.02994663])
|
||||
self.assertListAlmostEqual(vals, true_vals)
|
||||
|
||||
def test_wallop(self):
|
||||
S = Wallop(Hm0=6.5, Tp=10)
|
||||
vals = S(range(4))
|
||||
true_vals = np.array([0.00000000e+00, 9.36921871e-01, 2.76991078e-03,
|
||||
7.72996150e-05])
|
||||
self.assertListAlmostEqual(vals, true_vals)
|
||||
|
||||
|
||||
class TestSpreading(TestCase):
|
||||
def test_cos2s(self):
|
||||
theta = np.linspace(0, 2 * np.pi)
|
||||
d = Spreading(type='cos2s')
|
||||
dvals = [[1.10168934e+00],
|
||||
[1.03576796e+00],
|
||||
[8.60302298e-01],
|
||||
[6.30309013e-01],
|
||||
[4.06280137e-01],
|
||||
[2.29514882e-01],
|
||||
[1.13052757e-01],
|
||||
[4.82339343e-02],
|
||||
[1.76754409e-02],
|
||||
[5.50490020e-03],
|
||||
[1.43800617e-03],
|
||||
[3.09907242e-04],
|
||||
[5.39672445e-05],
|
||||
[7.39553743e-06],
|
||||
[7.70796579e-07],
|
||||
[5.84247670e-08],
|
||||
[3.03264905e-09],
|
||||
[9.91950201e-11],
|
||||
[1.81442131e-12],
|
||||
[1.55028269e-14],
|
||||
[4.63223469e-17],
|
||||
[2.90526245e-20],
|
||||
[1.35842977e-24],
|
||||
[3.26077455e-31],
|
||||
[1.65021852e-45],
|
||||
[1.65021852e-45],
|
||||
[3.26077455e-31],
|
||||
[1.35842977e-24],
|
||||
[2.90526245e-20],
|
||||
[4.63223469e-17],
|
||||
[1.55028269e-14],
|
||||
[1.81442131e-12],
|
||||
[9.91950201e-11],
|
||||
[3.03264905e-09],
|
||||
[5.84247670e-08],
|
||||
[7.70796579e-07],
|
||||
[7.39553743e-06],
|
||||
[5.39672445e-05],
|
||||
[3.09907242e-04],
|
||||
[1.43800617e-03],
|
||||
[5.50490020e-03],
|
||||
[1.76754409e-02],
|
||||
[4.82339343e-02],
|
||||
[1.13052757e-01],
|
||||
[2.29514882e-01],
|
||||
[4.06280137e-01],
|
||||
[6.30309013e-01],
|
||||
[8.60302298e-01],
|
||||
[1.03576796e+00],
|
||||
[1.10168934e+00]]
|
||||
|
||||
self.assertListAlmostEqual(d(theta)[0], dvals)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# main()
|
||||
import nose
|
||||
nose.run()
|
||||
#test_tmaspec()
|
||||
unittest.main()
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,116 @@
|
||||
"""
|
||||
Sane parameters for stats.distributions.
|
||||
"""
|
||||
|
||||
distcont = [
|
||||
['alpha', (3.5704770516650459,)],
|
||||
['anglit', ()],
|
||||
['arcsine', ()],
|
||||
['beta', (2.3098496451481823, 0.62687954300963677)],
|
||||
['betaprime', (5, 6)],
|
||||
['bradford', (0.29891359763170633,)],
|
||||
['burr', (10.5, 4.3)],
|
||||
['cauchy', ()],
|
||||
['chi', (78,)],
|
||||
['chi2', (55,)],
|
||||
['cosine', ()],
|
||||
['dgamma', (1.1023326088288166,)],
|
||||
['dweibull', (2.0685080649914673,)],
|
||||
['erlang', (10,)],
|
||||
['expon', ()],
|
||||
['exponpow', (2.697119160358469,)],
|
||||
['exponweib', (2.8923945291034436, 1.9505288745913174)],
|
||||
['f', (29, 18)],
|
||||
['fatiguelife', (29,)], # correction numargs = 1
|
||||
['fisk', (3.0857548622253179,)],
|
||||
['foldcauchy', (4.7164673455831894,)],
|
||||
['foldnorm', (1.9521253373555869,)],
|
||||
['frechet_l', (3.6279911255583239,)],
|
||||
['frechet_r', (1.8928171603534227,)],
|
||||
['gamma', (1.9932305483800778,)],
|
||||
['gausshyper', (13.763771604130699, 3.1189636648681431,
|
||||
2.5145980350183019, 5.1811649903971615)], # veryslow
|
||||
['genexpon', (9.1325976465418908, 16.231956600590632, 3.2819552690843983)],
|
||||
['genextreme', (-0.1,)],
|
||||
['gengamma', (4.4162385429431925, 3.1193091679242761)],
|
||||
['genhalflogistic', (0.77274727809929322,)],
|
||||
['genlogistic', (0.41192440799679475,)],
|
||||
['genpareto', (0.1,)], # use case with finite moments
|
||||
['gilbrat', ()],
|
||||
['gompertz', (0.94743713075105251,)],
|
||||
['gumbel_l', ()],
|
||||
['gumbel_r', ()],
|
||||
['halfcauchy', ()],
|
||||
['halflogistic', ()],
|
||||
['halfnorm', ()],
|
||||
['hypsecant', ()],
|
||||
['invgamma', (4.0668996136993067,)],
|
||||
['invgauss', (0.14546264555347513,)],
|
||||
['invweibull', (10.58,)],
|
||||
['johnsonsb', (4.3172675099141058, 3.1837781130785063)],
|
||||
['johnsonsu', (2.554395574161155, 2.2482281679651965)],
|
||||
['ksone', (1000,)], # replace 22 by 100 to avoid failing range, ticket 956
|
||||
['kstwobign', ()],
|
||||
['laplace', ()],
|
||||
['levy', ()],
|
||||
['levy_l', ()],
|
||||
['levy_stable', (0.35667405469844993,
|
||||
-0.67450531578494011)], # NotImplementedError
|
||||
# rvs not tested
|
||||
['loggamma', (0.41411931826052117,)],
|
||||
['logistic', ()],
|
||||
['loglaplace', (3.2505926592051435,)],
|
||||
['lognorm', (0.95368226960575331,)],
|
||||
['lomax', (1.8771398388773268,)],
|
||||
['maxwell', ()],
|
||||
['mielke', (10.4, 3.6)],
|
||||
['nakagami', (4.9673794866666237,)],
|
||||
['ncf', (27, 27, 0.41578441799226107)],
|
||||
['nct', (14, 0.24045031331198066)],
|
||||
['ncx2', (21, 1.0560465975116415)],
|
||||
['norm', ()],
|
||||
['pareto', (2.621716532144454,)],
|
||||
['pearson3', (0.1,)],
|
||||
['powerlaw', (1.6591133289905851,)],
|
||||
['powerlognorm', (2.1413923530064087, 0.44639540782048337)],
|
||||
['powernorm', (4.4453652254590779,)],
|
||||
['rayleigh', ()],
|
||||
['rdist', (0.9,)], # feels also slow
|
||||
['recipinvgauss', (0.63004267809369119,)],
|
||||
['reciprocal', (0.0062309367010521255, 1.0062309367010522)],
|
||||
['rice', (0.7749725210111873,)],
|
||||
['semicircular', ()],
|
||||
['t', (2.7433514990818093,)],
|
||||
['triang', (0.15785029824528218,)],
|
||||
['truncexpon', (4.6907725456810478,)],
|
||||
['truncnorm', (-1.0978730080013919, 2.7306754109031979)],
|
||||
['truncnorm', (0.1, 2.)],
|
||||
['tukeylambda', (3.1321477856738267,)],
|
||||
['uniform', ()],
|
||||
['vonmises', (3.9939042581071398,)],
|
||||
['vonmises_line', (3.9939042581071398,)],
|
||||
['wald', ()],
|
||||
['weibull_max', (2.8687961709100187,)],
|
||||
['weibull_min', (1.7866166930421596,)],
|
||||
['wrapcauchy', (0.031071279018614728,)]]
|
||||
|
||||
|
||||
distdiscrete = [
|
||||
['bernoulli',(0.3,)],
|
||||
['binom', (5, 0.4)],
|
||||
['boltzmann',(1.4, 19)],
|
||||
['dlaplace', (0.8,)], # 0.5
|
||||
['geom', (0.5,)],
|
||||
['hypergeom',(30, 12, 6)],
|
||||
['hypergeom',(21,3,12)], # numpy.random (3,18,12) numpy ticket:921
|
||||
['hypergeom',(21,18,11)], # numpy.random (18,3,11) numpy ticket:921
|
||||
['logser', (0.6,)], # reenabled, numpy ticket:921
|
||||
['nbinom', (5, 0.5)],
|
||||
['nbinom', (0.4, 0.4)], # from tickets: 583
|
||||
['planck', (0.51,)], # 4.1
|
||||
['poisson', (0.6,)],
|
||||
['randint', (7, 31)],
|
||||
['skellam', (15, 8)],
|
||||
['zipf', (6.5,)]
|
||||
]
|
||||
|
@ -0,0 +1,54 @@
|
||||
"""Functions copypasted from newer versions of numpy.
|
||||
|
||||
"""
|
||||
from __future__ import division, print_function, absolute_import
|
||||
|
||||
import warnings
|
||||
|
||||
import numpy as np
|
||||
|
||||
from scipy.lib._version import NumpyVersion
|
||||
|
||||
if NumpyVersion(np.__version__) > '1.7.0.dev':
|
||||
_assert_warns = np.testing.assert_warns
|
||||
else:
|
||||
def _assert_warns(warning_class, func, *args, **kw):
|
||||
r"""
|
||||
Fail unless the given callable throws the specified warning.
|
||||
|
||||
This definition is copypasted from numpy 1.9.0.dev.
|
||||
The version in earlier numpy returns None.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
warning_class : class
|
||||
The class defining the warning that `func` is expected to throw.
|
||||
func : callable
|
||||
The callable to test.
|
||||
*args : Arguments
|
||||
Arguments passed to `func`.
|
||||
**kwargs : Kwargs
|
||||
Keyword arguments passed to `func`.
|
||||
|
||||
Returns
|
||||
-------
|
||||
The value returned by `func`.
|
||||
|
||||
"""
|
||||
with warnings.catch_warnings(record=True) as l:
|
||||
warnings.simplefilter('always')
|
||||
result = func(*args, **kw)
|
||||
if not len(l) > 0:
|
||||
raise AssertionError("No warning raised when calling %s"
|
||||
% func.__name__)
|
||||
if not l[0].category is warning_class:
|
||||
raise AssertionError("First warning for %s is not a "
|
||||
"%s( is %s)" % (func.__name__, warning_class, l[0]))
|
||||
return result
|
||||
|
||||
|
||||
if NumpyVersion(np.__version__) >= '1.6.0':
|
||||
count_nonzero = np.count_nonzero
|
||||
else:
|
||||
def count_nonzero(a):
|
||||
return (a != 0).sum()
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue