numpy.testing.dec.skipif

Here are the examples of the python api numpy.testing.dec.skipif taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

Example 51

Project: sima
Source File: test_spikes.py
View license
    @dec.skipif(not _has_picos)
    def test_estimate_parameters(self):
        gamma_est, sigma_est = sima.spikes.estimate_parameters(
            [self.fluors_long], mode="correct")
        assert_(abs(gamma_est - self.gamma) < 0.01)
        assert_(abs(sigma_est - self.sigma) < 0.01)

Example 52

View license
    @dec.skipif(platform.machine() == "armv5tel", "See gh-413.")
    def test_invalid(self):
        with np.errstate(all='raise', under='ignore'):
            a = -np.arange(3)
            # This should work
            with np.errstate(invalid='ignore'):
                np.sqrt(a)
            # While this should fail!
            try:
                np.sqrt(a)
            except FloatingPointError:
                pass
            else:
                self.fail("Did not raise an invalid error")

Example 53

View license
    @dec.skipif(platform.machine() == "armv5tel", "See gh-413.")
    def test_invalid(self):
        with np.errstate(all='raise', under='ignore'):
            a = -np.arange(3)
            # This should work
            with np.errstate(invalid='ignore'):
                np.sqrt(a)
            # While this should fail!
            try:
                np.sqrt(a)
            except FloatingPointError:
                pass
            else:
                self.fail("Did not raise an invalid error")

Example 54

View license
@dec.skipif(sys.flags.optimize == 2)
def test_lookfor():
    out = StringIO()
    utils.lookfor('eigenvalue', module='numpy', output=out,
                  import_modules=False)
    out = out.getvalue()
    assert_('numpy.linalg.eig' in out)

Example 55

View license
@dec.skipif(sys.flags.optimize == 2)
def test_lookfor():
    out = StringIO()
    utils.lookfor('eigenvalue', module='numpy', output=out,
                  import_modules=False)
    out = out.getvalue()
    assert_('numpy.linalg.eig' in out)

Example 56

View license
    @dec.skipif(not(sys.platform[:5] == 'linux'),
                "Skipping fortran compiler mismatch on non Linux platform")
    def test_lapack(self):
        f = FindDependenciesLdd()
        deps = f.grep_dependencies(lapack_lite.__file__,
                                   asbytes_nested(['libg2c', 'libgfortran']))
        self.assertFalse(len(deps) > 1,
                         """Both g77 and gfortran runtimes linked in lapack_lite ! This is likely to
cause random crashes and wrong results. See numpy INSTALL.txt for more
information.""")

Example 57

View license
    @dec.skipif(not(sys.platform[:5] == 'linux'),
                "Skipping fortran compiler mismatch on non Linux platform")
    def test_lapack(self):
        f = FindDependenciesLdd()
        deps = f.grep_dependencies(lapack_lite.__file__,
                                   asbytes_nested(['libg2c', 'libgfortran']))
        self.assertFalse(len(deps) > 1,
                         """Both g77 and gfortran runtimes linked in lapack_lite ! This is likely to
cause random crashes and wrong results. See numpy INSTALL.txt for more
information.""")

Example 58

View license
    @dec.skipif(not _HAS_CTYPE,
                "ctypes not available on this python installation")
    @dec.knownfailureif(sys.platform ==
                        'cygwin', "This test is known to fail on cygwin")
    def test_basic(self):
        try:
            # Should succeed
            load_library('multiarray', np.core.multiarray.__file__)
        except ImportError as e:
            msg = ("ctypes is not available on this python: skipping the test"
                   " (import error was: %s)" % str(e))
            print(msg)

Example 59

View license
    @dec.skipif(not _HAS_CTYPE,
                "ctypes not available on this python installation")
    @dec.knownfailureif(sys.platform ==
                        'cygwin', "This test is known to fail on cygwin")
    def test_basic2(self):
        # Regression for #801: load_library with a full library name
        # (including extension) does not work.
        try:
            try:
                so = get_shared_lib_extension(is_python_ext=True)
                # Should succeed
                load_library('multiarray%s' % so, np.core.multiarray.__file__)
            except ImportError:
                print("No distutils available, skipping test.")
        except ImportError as e:
            msg = ("ctypes is not available on this python: skipping the test"
                   " (import error was: %s)" % str(e))
            print(msg)

Example 60

View license
    @dec.skipif(_ctypes_missing or _ctypes_multivariate_fail,
                msg="Compiled test functions not loaded")
    def setUp(self):
        self.lib = ctypes.CDLL(clib_test.__file__)
        restype = ctypes.c_double
        argtypes = (ctypes.c_int, ctypes.c_double)
        for name in ['_multivariate_typical', '_multivariate_indefinite',
                     '_multivariate_sin']:
            func = getattr(self.lib, name)
            func.restype = restype
            func.argtypes = argtypes

Example 61

View license
    @dec.skipif(_ctypes_missing or _ctypes_multivariate_fail,
                msg="Compiled test functions not loaded")
    def test_typical(self):
        # 1) Typical function with two extra arguments:
        assert_quad(quad(self.lib._multivariate_typical, 0, pi, (2, 1.8)),
                    0.30614353532540296487)

Example 62

View license
    @dec.skipif(_ctypes_missing or _ctypes_multivariate_fail,
                msg="Compiled test functions not loaded")
    def test_indefinite(self):
        # 2) Infinite integration limits --- Euler's constant
        assert_quad(quad(self.lib._multivariate_indefinite, 0, Inf),
                    0.577215664901532860606512)

Example 63

View license
    @dec.skipif(_ctypes_missing or _ctypes_multivariate_fail,
                msg="Compiled test functions not loaded")
    def test_threadsafety(self):
        # Ensure multivariate ctypes are threadsafe
        def threadsafety(y):
            return y + quad(self.lib._multivariate_sin, 0, 1)[0]
        assert_quad(quad(threadsafety, 0, 1), 0.9596976941318602)

Example 64

View license
    @dec.skipif(_ctypes_missing or _ctypes_multivariate_fail,
                msg="Compiled test functions not loaded")
    def setUp(self):
        self.lib = ctypes.CDLL(clib_test.__file__)
        restype = ctypes.c_double
        argtypes = (ctypes.c_int, ctypes.c_double)
        for name in ['_multivariate_typical', '_multivariate_indefinite',
                     '_multivariate_sin']:
            func = getattr(self.lib, name)
            func.restype = restype
            func.argtypes = argtypes

Example 65

View license
    @dec.skipif(_ctypes_missing or _ctypes_multivariate_fail,
                msg="Compiled test functions not loaded")
    def test_typical(self):
        # 1) Typical function with two extra arguments:
        assert_quad(quad(self.lib._multivariate_typical, 0, pi, (2, 1.8)),
                    0.30614353532540296487)

Example 66

View license
    @dec.skipif(_ctypes_missing or _ctypes_multivariate_fail,
                msg="Compiled test functions not loaded")
    def test_indefinite(self):
        # 2) Infinite integration limits --- Euler's constant
        assert_quad(quad(self.lib._multivariate_indefinite, 0, Inf),
                    0.577215664901532860606512)

Example 67

View license
    @dec.skipif(_ctypes_missing or _ctypes_multivariate_fail,
                msg="Compiled test functions not loaded")
    def test_threadsafety(self):
        # Ensure multivariate ctypes are threadsafe
        def threadsafety(y):
            return y + quad(self.lib._multivariate_sin, 0, 1)[0]
        assert_quad(quad(threadsafety, 0, 1), 0.9596976941318602)

Example 68

View license
    @dec.skipif(_ctypes_missing or _ctypes_multivariate_fail,
                msg="Compiled test functions not loaded")
    def test_improvement(self):
        def myfunc(x):           # Euler's constant integrand
            return -exp(-x)*log(x)
        import time
        start = time.time()
        for i in xrange(20):
            quad(self.lib._multivariate_indefinite, 0, 100)
        fast = time.time() - start
        start = time.time()
        for i in xrange(20):
            quad(myfunc, 0, 100)
        slow = time.time() - start
        # 2+ times faster speeds generated by nontrivial ctypes
        # function (single variable)
        assert_(fast < 0.5*slow, (fast, slow))

Example 69

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.7.0',
                "No np.datetime64 in Numpy < 1.7.0")
    def test_year_attribute(self):
        expected = np.array([
            '1999',
            '2004',
            '1817',
            '2100',
            '2013',
            '1631'
        ], dtype='datetime64[Y]')

        assert_array_equal(self.data["attr_year"], expected)

Example 70

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.7.0',
                "No np.datetime64 in Numpy < 1.7.0")
    def test_date_attribute(self):
        expected = np.array([
            '1999-01-31',
            '2004-12-01',
            '1817-04-28',
            '2100-09-10',
            '2013-11-30',
            '1631-10-15'
        ], dtype='datetime64[D]')

        assert_array_equal(self.data["attr_date"], expected)

Example 71

View license
    @dec.skipif(not(sys.platform[:5] == 'linux'),
                "Skipping fortran compiler mismatch on non Linux platform")
    def test_lapack(self):
        f = FindDependenciesLdd()
        deps = f.grep_dependencies(flapack.__file__,
                                   ['libg2c', 'libgfortran'])
        self.assertFalse(len(deps) > 1,
"""Both g77 and gfortran runtimes linked in scipy.linalg.flapack ! This is
likely to cause random crashes and wrong results. See numpy INSTALL.txt for
more information.""")

Example 72

View license
    @dec.skipif(not(sys.platform[:5] == 'linux'),
                "Skipping fortran compiler mismatch on non Linux platform")
    def test_lapack(self):
        f = FindDependenciesLdd()
        deps = f.grep_dependencies(flapack.__file__,
                                   ['libg2c', 'libgfortran'])
        self.assertFalse(len(deps) > 1,
"""Both g77 and gfortran runtimes linked in scipy.linalg.flapack ! This is
likely to cause random crashes and wrong results. See numpy INSTALL.txt for
more information.""")

Example 73

View license
@dec.skipif(pil_missing, msg="The Python Image Library could not be found.")
def test_imread():
    lp = os.path.join(os.path.dirname(__file__), 'dots.png')
    with warnings.catch_warnings(record=True):  # Py3k ResourceWarning
        img = ndi.imread(lp, mode="RGB")
    assert_array_equal(img.shape, (300, 420, 3))

    with warnings.catch_warnings(record=True):  # PIL ResourceWarning
        img = ndi.imread(lp, flatten=True)
    assert_array_equal(img.shape, (300, 420))

    with open(lp, 'rb') as fobj:
        img = ndi.imread(fobj, mode="RGB")
        assert_array_equal(img.shape, (300, 420, 3))

Example 74

View license
@dec.skipif(pil_missing, msg="The Python Image Library could not be found.")
def test_imread():
    lp = os.path.join(os.path.dirname(__file__), 'dots.png')
    with warnings.catch_warnings(record=True):  # Py3k ResourceWarning
        img = ndi.imread(lp, mode="RGB")
    assert_array_equal(img.shape, (300, 420, 3))

    with warnings.catch_warnings(record=True):  # PIL ResourceWarning
        img = ndi.imread(lp, flatten=True)
    assert_array_equal(img.shape, (300, 420))

    with open(lp, 'rb') as fobj:
        img = ndi.imread(fobj, mode="RGB")
        assert_array_equal(img.shape, (300, 420, 3))

Example 75

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_real_twosided_32(self):
        x = np.zeros(16, 'f')
        x[0] = 1
        f, p = periodogram(x, return_onesided=False)
        assert_allclose(f, fftpack.fftfreq(16, 1.0))
        q = np.ones(16, 'f')/16.0
        q[0] = 0
        assert_allclose(p, q)
        assert_(p.dtype == q.dtype)

Example 76

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_complex_32(self):
        x = np.zeros(16, 'F')
        x[0] = 1.0 + 2.0j
        f, p = periodogram(x)
        assert_allclose(f, fftpack.fftfreq(16, 1.0))
        q = 5.0*np.ones(16, 'f')/16.0
        q[0] = 0
        assert_allclose(p, q)
        assert_(p.dtype == q.dtype)

Example 77

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_real_twosided_32(self):
        x = np.zeros(16, 'f')
        x[0] = 1
        x[8] = 1
        f, p = welch(x, nperseg=8, return_onesided=False)
        assert_allclose(f, fftpack.fftfreq(8, 1.0))
        q = np.array([0.08333333, 0.07638889, 0.11111111,
                      0.11111111, 0.11111111, 0.11111111, 0.11111111,
                      0.07638889], 'f')
        assert_allclose(p, q, atol=1e-7, rtol=1e-7)
        assert_(p.dtype == q.dtype)

Example 78

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_real_twosided_32(self):
        x = np.zeros(16, 'f')
        x[0] = 1
        x[8] = 1
        f, p = csd(x, x, nperseg=8, return_onesided=False)
        assert_allclose(f, fftpack.fftfreq(8, 1.0))
        q = np.array([0.08333333, 0.07638889, 0.11111111,
                      0.11111111, 0.11111111, 0.11111111, 0.11111111,
                      0.07638889], 'f')
        assert_allclose(p, q, atol=1e-7, rtol=1e-7)
        assert_(p.dtype == q.dtype)

Example 79

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_complex_32(self):
        x = np.zeros(16, 'F')
        x[0] = 1.0 + 2.0j
        x[8] = 1.0 + 2.0j
        f, p = csd(x, x, nperseg=8)
        assert_allclose(f, fftpack.fftfreq(8, 1.0))
        q = np.array([0.41666666, 0.38194442, 0.55555552, 0.55555552,
                      0.55555558, 0.55555552, 0.55555552, 0.38194442], 'f')
        assert_allclose(p, q, atol=1e-7, rtol=1e-7)
        assert_(p.dtype == q.dtype,
                'dtype mismatch, %s, %s' % (p.dtype, q.dtype))

Example 80

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_real_twosided_32(self):
        x = np.zeros(16, 'f')
        x[0] = 1
        f, p = periodogram(x, return_onesided=False)
        assert_allclose(f, fftpack.fftfreq(16, 1.0))
        q = np.ones(16, 'f')/16.0
        q[0] = 0
        assert_allclose(p, q)
        assert_(p.dtype == q.dtype)

Example 81

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_complex_32(self):
        x = np.zeros(16, 'F')
        x[0] = 1.0 + 2.0j
        f, p = periodogram(x)
        assert_allclose(f, fftpack.fftfreq(16, 1.0))
        q = 5.0*np.ones(16, 'f')/16.0
        q[0] = 0
        assert_allclose(p, q)
        assert_(p.dtype == q.dtype)

Example 82

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_real_twosided_32(self):
        x = np.zeros(16, 'f')
        x[0] = 1
        x[8] = 1
        f, p = welch(x, nperseg=8, return_onesided=False)
        assert_allclose(f, fftpack.fftfreq(8, 1.0))
        q = np.array([0.08333333, 0.07638889, 0.11111111,
                      0.11111111, 0.11111111, 0.11111111, 0.11111111,
                      0.07638889], 'f')
        assert_allclose(p, q, atol=1e-7, rtol=1e-7)
        assert_(p.dtype == q.dtype)

Example 83

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_complex_32(self):
        x = np.zeros(16, 'F')
        x[0] = 1.0 + 2.0j
        x[8] = 1.0 + 2.0j
        f, p = welch(x, nperseg=8)
        assert_allclose(f, fftpack.fftfreq(8, 1.0))
        q = np.array([0.41666666, 0.38194442, 0.55555552, 0.55555552,
                      0.55555558, 0.55555552, 0.55555552, 0.38194442], 'f')
        assert_allclose(p, q, atol=1e-7, rtol=1e-7)
        assert_(p.dtype == q.dtype,
                'dtype mismatch, %s, %s' % (p.dtype, q.dtype))

Example 84

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_real_twosided_32(self):
        x = np.zeros(16, 'f')
        x[0] = 1
        x[8] = 1
        f, p = csd(x, x, nperseg=8, return_onesided=False)
        assert_allclose(f, fftpack.fftfreq(8, 1.0))
        q = np.array([0.08333333, 0.07638889, 0.11111111,
                      0.11111111, 0.11111111, 0.11111111, 0.11111111,
                      0.07638889], 'f')
        assert_allclose(p, q, atol=1e-7, rtol=1e-7)
        assert_(p.dtype == q.dtype)

Example 85

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_complex_32(self):
        x = np.zeros(16, 'F')
        x[0] = 1.0 + 2.0j
        x[8] = 1.0 + 2.0j
        f, p = csd(x, x, nperseg=8)
        assert_allclose(f, fftpack.fftfreq(8, 1.0))
        q = np.array([0.41666666, 0.38194442, 0.55555552, 0.55555552,
                      0.55555558, 0.55555552, 0.55555552, 0.38194442], 'f')
        assert_allclose(p, q, atol=1e-7, rtol=1e-7)
        assert_(p.dtype == q.dtype,
                'dtype mismatch, %s, %s' % (p.dtype, q.dtype))

Example 86

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_sparse_matrix_norms(self):
        for sparse_type in self._sparse_types:
            for M in self._test_matrices:
                S = sparse_type(M)
                assert_allclose(spnorm(S), npnorm(M))
                assert_allclose(spnorm(S, 'fro'), npnorm(M, 'fro'))
                assert_allclose(spnorm(S, np.inf), npnorm(M, np.inf))
                assert_allclose(spnorm(S, -np.inf), npnorm(M, -np.inf))
                assert_allclose(spnorm(S, 1), npnorm(M, 1))
                assert_allclose(spnorm(S, -1), npnorm(M, -1))

Example 87

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_sparse_matrix_norms_with_axis(self):
        for sparse_type in self._sparse_types:
            for M in self._test_matrices:
                S = sparse_type(M)
                for axis in None, (0, 1), (1, 0):
                    assert_allclose(spnorm(S, axis=axis), npnorm(M, axis=axis))
                    for ord in 'fro', np.inf, -np.inf, 1, -1:
                        assert_allclose(spnorm(S, ord, axis=axis),
                                        npnorm(M, ord, axis=axis))
                # Some numpy matrix norms are allergic to negative axes.
                for axis in (-2, -1), (-1, -2), (1, -2):
                    assert_allclose(spnorm(S, axis=axis), npnorm(M, axis=axis))
                    assert_allclose(spnorm(S, 'f', axis=axis),
                                    npnorm(M, 'f', axis=axis))
                    assert_allclose(spnorm(S, 'fro', axis=axis),
                                    npnorm(M, 'fro', axis=axis))

Example 88

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_sparse_vector_norms(self):
        for sparse_type in self._sparse_types:
            for M in self._test_matrices:
                S = sparse_type(M)
                for axis in (0, 1, -1, -2, (0, ), (1, ), (-1, ), (-2, )):
                    assert_allclose(spnorm(S, axis=axis), npnorm(M, axis=axis))
                    for ord in None, 2, np.inf, -np.inf, 1, 0.5, 0.42:
                        assert_allclose(spnorm(S, ord, axis=axis),
                                        npnorm(M, ord, axis=axis))

Example 89

View license
@dec.skipif(True, "64-bit indices in sparse matrices not available")
def test_csr_matmat_int64_overflow():
    n = 3037000500
    assert n**2 > np.iinfo(np.int64).max

    # the test would take crazy amounts of memory
    check_free_memory(n * (8*2 + 1) * 3 / 1e6)

    # int64 overflow
    data = np.ones((n,), dtype=np.int8)
    indptr = np.arange(n+1, dtype=np.int64)
    indices = np.zeros(n, dtype=np.int64)
    a = csr_matrix((data, indices, indptr))
    b = a.T

    assert_raises(RuntimeError, a.dot, b)

Example 90

View license
@npt.dec.skipif(NUMPY_BELOW_1_7)
def check_loc_scale(distfn, arg, m, v, msg):
    loc, scale = 10.0, 10.0
    mt, vt = distfn.stats(loc=loc, scale=scale, *arg)
    npt.assert_allclose(m*scale + loc, mt)
    npt.assert_allclose(v*scale*scale, vt)

Example 91

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_sparse_matrix_norms(self):
        for sparse_type in self._sparse_types:
            for M in self._test_matrices:
                S = sparse_type(M)
                assert_allclose(spnorm(S), npnorm(M))
                assert_allclose(spnorm(S, 'fro'), npnorm(M, 'fro'))
                assert_allclose(spnorm(S, np.inf), npnorm(M, np.inf))
                assert_allclose(spnorm(S, -np.inf), npnorm(M, -np.inf))
                assert_allclose(spnorm(S, 1), npnorm(M, 1))
                assert_allclose(spnorm(S, -1), npnorm(M, -1))

Example 92

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_sparse_matrix_norms_with_axis(self):
        for sparse_type in self._sparse_types:
            for M in self._test_matrices:
                S = sparse_type(M)
                for axis in None, (0, 1), (1, 0):
                    assert_allclose(spnorm(S, axis=axis), npnorm(M, axis=axis))
                    for ord in 'fro', np.inf, -np.inf, 1, -1:
                        assert_allclose(spnorm(S, ord, axis=axis),
                                        npnorm(M, ord, axis=axis))
                # Some numpy matrix norms are allergic to negative axes.
                for axis in (-2, -1), (-1, -2), (1, -2):
                    assert_allclose(spnorm(S, axis=axis), npnorm(M, axis=axis))
                    assert_allclose(spnorm(S, 'f', axis=axis),
                                    npnorm(M, 'f', axis=axis))
                    assert_allclose(spnorm(S, 'fro', axis=axis),
                                    npnorm(M, 'fro', axis=axis))

Example 93

View license
    @dec.skipif(NumpyVersion(np.__version__) < '1.8.0')
    def test_sparse_vector_norms(self):
        for sparse_type in self._sparse_types:
            for M in self._test_matrices:
                S = sparse_type(M)
                for axis in (0, 1, -1, -2, (0, ), (1, ), (-1, ), (-2, )):
                    assert_allclose(spnorm(S, axis=axis), npnorm(M, axis=axis))
                    for ord in None, 2, np.inf, -np.inf, 1, 0.5, 0.42:
                        assert_allclose(spnorm(S, ord, axis=axis),
                                        npnorm(M, ord, axis=axis))

Example 94

View license
@dec.skipif(True, "64-bit indices in sparse matrices not available")
def test_csr_matmat_int64_overflow():
    n = 3037000500
    assert n**2 > np.iinfo(np.int64).max

    # the test would take crazy amounts of memory
    check_free_memory(n * (8*2 + 1) * 3 / 1e6)

    # int64 overflow
    data = np.ones((n,), dtype=np.int8)
    indptr = np.arange(n+1, dtype=np.int64)
    indices = np.zeros(n, dtype=np.int64)
    a = csr_matrix((data, indices, indptr))
    b = a.T

    assert_raises(RuntimeError, a.dot, b)

Example 95

View license
    @dec.skipif(not has_matplotlib, "Matplotlib not available")
    def test_delaunay(self):
        # Smoke test
        fig = plt.figure()
        obj = Delaunay(self.points)
        s_before = obj.simplices.copy()
        r = delaunay_plot_2d(obj, ax=fig.gca())
        assert_array_equal(obj.simplices, s_before)  # shouldn't modify
        assert_(r is fig)
        delaunay_plot_2d(obj, ax=fig.gca())

Example 96

View license
@npt.dec.skipif(NUMPY_BELOW_1_7)
def check_loc_scale(distfn, arg, m, v, msg):
    loc, scale = 10.0, 10.0
    mt, vt = distfn.stats(loc=loc, scale=scale, *arg)
    npt.assert_allclose(m*scale + loc, mt)
    npt.assert_allclose(v*scale*scale, vt)

Example 97

Project: dipy
Source File: test_ivim.py
View license
@dec.skipif(SCIPY_VERSION < LooseVersion('0.17'),
            "Gives wrong value for f")
def test_noisy_fit():
    """
    Test fitting for noisy signals. This tests whether the threshold condition
    applies correctly and returns the linear fitting parameters.

    For older scipy versions, the returned value of `f` from a linear fit is around 135
    and D and D_star values are equal. Hence doing a test based on Scipy version.
    """
    model_one_stage = IvimModel(gtab)
    fit_one_stage = model_one_stage.fit(noisy_single)
    assert_array_less(fit_one_stage.model_params, [10000., 0.3, .01, 0.001])

Example 98

Project: dipy
Source File: test_ivim.py
View license
@dec.skipif(SCIPY_VERSION < LooseVersion('0.17'),
            "Gives wrong value for f")
def test_noisy_fit():
    """
    Test fitting for noisy signals. This tests whether the threshold condition
    applies correctly and returns the linear fitting parameters.

    For older scipy versions, the returned value of `f` from a linear fit is around 135
    and D and D_star values are equal. Hence doing a test based on Scipy version.
    """
    model_one_stage = IvimModel(gtab)
    fit_one_stage = model_one_stage.fit(noisy_single)
    assert_array_less(fit_one_stage.model_params, [10000., 0.3, .01, 0.001])

Example 99

Project: dipy
Source File: test_fvtk.py
View license
@npt.dec.skipif(not fvtk.have_matplotlib)
def test_colormaps_matplotlib():
    v = np.random.random(1000)
    for name in 'jet', 'Blues', 'Accent', 'bone':
        # Matplotlib version of get_cmap
        rgba1 = fvtk.get_cmap(name)(v)
        # Dipy version of get_cmap
        rgba2 = data.get_cmap(name)(v)
        # dipy's colormaps are close to matplotlibs colormaps, but not perfect
        npt.assert_array_almost_equal(rgba1, rgba2, 1)

Example 100

Project: dipy
Source File: test_fvtk.py
View license
@npt.dec.skipif(not fvtk.have_matplotlib)
def test_colormaps_matplotlib():
    v = np.random.random(1000)
    for name in 'jet', 'Blues', 'Accent', 'bone':
        # Matplotlib version of get_cmap
        rgba1 = fvtk.get_cmap(name)(v)
        # Dipy version of get_cmap
        rgba2 = data.get_cmap(name)(v)
        # dipy's colormaps are close to matplotlibs colormaps, but not perfect
        npt.assert_array_almost_equal(rgba1, rgba2, 1)