repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
scipy
scipy-main/scipy/fftpack/tests/test_helper.py
# Created by Pearu Peterson, September 2002 __usage__ = """ Build fftpack: python setup_fftpack.py build Run tests if scipy is installed: python -c 'import scipy;scipy.fftpack.test(<level>)' Run tests if fftpack is not installed: python tests/test_helper.py [<level>] """ from numpy.testing import assert_array_a...
1,675
29.472727
64
py
scipy
scipy-main/scipy/fftpack/tests/__init__.py
0
0
0
py
scipy
scipy-main/scipy/misc/setup.py
def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('misc',parent_package,top_path) config.add_data_files('*.dat') config.add_data_dir('tests') return config if __name__ == '__main__': from numpy.distutils.core import s...
374
30.25
58
py
scipy
scipy-main/scipy/misc/doccer.py
# This file is not meant for public use and will be removed in SciPy v2.0.0. import warnings from scipy._lib import doccer __all__ = [ # noqa: F822 'docformat', 'inherit_docstring_from', 'indentcount_lines', 'filldoc', 'unindent_dict', 'unindent_string', 'extend_notes_in_docstring', 'replace_notes_in_do...
766
24.566667
79
py
scipy
scipy-main/scipy/misc/common.py
# This file is not meant for public use and will be removed in SciPy v2.0.0. # Use the `scipy.datasets` namespace for importing the dataset functions # included below. import warnings from . import _common __all__ = [ # noqa: F822 'central_diff_weights', 'derivative', 'ascent', 'face', 'electrocardiogram', ...
869
28
79
py
scipy
scipy-main/scipy/misc/__init__.py
""" ========================================== Miscellaneous routines (:mod:`scipy.misc`) ========================================== .. currentmodule:: scipy.misc .. deprecated:: 1.10.0 This module is deprecated and will be completely removed in SciPy v2.0.0. Various utilities that don't have another home. ....
1,726
24.397059
73
py
scipy
scipy-main/scipy/misc/_common.py
""" Functions which are common and require SciPy Base and Level 1 SciPy (special, linalg) """ from scipy._lib.deprecation import _deprecated from scipy._lib._finite_differences import _central_diff_weights, _derivative from numpy import array, frombuffer, load __all__ = ['central_diff_weights', 'derivative', 'ascent...
11,120
31.422741
93
py
scipy
scipy-main/scipy/misc/tests/test_common.py
from numpy.testing import assert_equal, assert_almost_equal, suppress_warnings from scipy.misc import face, ascent, electrocardiogram def test_face(): with suppress_warnings() as sup: sup.filter(category=DeprecationWarning) assert_equal(face().shape, (768, 1024, 3)) def test_ascent(): with ...
833
29.888889
78
py
scipy
scipy-main/scipy/misc/tests/test_config.py
""" Check the SciPy config is valid. """ import scipy import pytest from unittest.mock import patch pytestmark = pytest.mark.skipif( not hasattr(scipy.__config__, "_built_with_meson"), reason="Requires Meson builds", ) class TestSciPyConfigs: REQUIRED_CONFIG_KEYS = [ "Compilers", "Machine...
1,244
26.666667
75
py
scipy
scipy-main/scipy/misc/tests/test_doccer.py
''' Some tests for the documenting decorator and support functions ''' import sys import pytest from numpy.testing import assert_equal, suppress_warnings from scipy._lib import doccer # python -OO strips docstrings DOCSTRINGS_STRIPPED = sys.flags.optimize > 1 docstring = \ """Docstring %(strtest1)s %(st...
3,738
26.696296
70
py
scipy
scipy-main/scipy/misc/tests/__init__.py
0
0
0
py
scipy
scipy-main/scipy/special/_lambertw.py
from ._ufuncs import _lambertw def lambertw(z, k=0, tol=1e-8): r""" lambertw(z, k=0, tol=1e-8) Lambert W function. The Lambert W function `W(z)` is defined as the inverse function of ``w * exp(w)``. In other words, the value of ``W(z)`` is such that ``z = W(z) * exp(W(z))`` for any complex n...
3,806
25.255172
76
py
scipy
scipy-main/scipy/special/_testutils.py
import os import functools import operator from scipy._lib import _pep440 import numpy as np from numpy.testing import assert_ import pytest import scipy.special as sc __all__ = ['with_special_errors', 'assert_func_equal', 'FuncData'] #------------------------------------------------------------------------------ ...
11,971
36.647799
96
py
scipy
scipy-main/scipy/special/_generate_pyx.py
""" python _generate_pyx.py Generate Ufunc definition source files for scipy.special. Produces files '_ufuncs.c' and '_ufuncs_cxx.c' by first producing Cython. This will generate both calls to PyUFunc_FromFuncAndData and the required ufunc inner loops. The functions signatures are contained in 'functions.json', the ...
52,068
33.255921
114
py
scipy
scipy-main/scipy/special/specfun.py
# This file is not meant for public use and will be removed in SciPy v2.0.0. # Use the `scipy.special` namespace for importing the functions # included below. import warnings from . import _specfun # type: ignore __all__ = [ # noqa: F822 'airyzo', 'bernob', 'cerzo', 'clpmn', 'clpn', 'clqmn',...
1,059
19.384615
77
py
scipy
scipy-main/scipy/special/_mptestutils.py
import os import sys import time from itertools import zip_longest import numpy as np from numpy.testing import assert_ import pytest from scipy.special._testutils import assert_func_equal try: import mpmath except ImportError: pass # ------------------------------------------------------------------------...
14,517
31.478747
100
py
scipy
scipy-main/scipy/special/setup.py
import os import sys from os.path import join, dirname from distutils.sysconfig import get_python_inc import subprocess import numpy from numpy.distutils.misc_util import get_numpy_include_dirs, get_info from scipy._build_utils.compiler_helper import (set_c_flags_hook, s...
7,177
38.43956
80
py
scipy
scipy-main/scipy/special/_spfun_stats.py
# Last Change: Sat Mar 21 02:00 PM 2009 J # Copyright (c) 2001, 2002 Enthought, Inc. # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # a. Redistributions of source code must retain the abov...
3,806
34.25
79
py
scipy
scipy-main/scipy/special/spfun_stats.py
# This file is not meant for public use and will be removed in SciPy v2.0.0. # Use the `scipy.special` namespace for importing the functions # included below. import warnings from . import _spfun_stats __all__ = ['multigammaln', 'loggam'] # noqa: F822 def __dir__(): return __all__ def __getattr__(name): ...
770
28.653846
77
py
scipy
scipy-main/scipy/special/_basic.py
# # Author: Travis Oliphant, 2002 # import operator import numpy as np import math import warnings from numpy import (pi, asarray, floor, isscalar, iscomplex, real, imag, sqrt, where, mgrid, sin, place, issubdtype, extract, inexact, nan, zeros, sinc) from . import _ufuncs from ._...
95,701
29.29503
96
py
scipy
scipy-main/scipy/special/_sf_error.py
"""Warnings and Exceptions that can be raised by special functions.""" import warnings class SpecialFunctionWarning(Warning): """Warning that can be emitted by special functions.""" pass warnings.simplefilter("always", category=SpecialFunctionWarning) class SpecialFunctionError(Exception): """Exceptio...
375
22.5
70
py
scipy
scipy-main/scipy/special/_orthogonal.py
""" A collection of functions to find the weights and abscissas for Gaussian Quadrature. These calculations are done by finding the eigenvalues of a tridiagonal matrix whose entries are dependent on the coefficients in the recursion formula for the orthogonal polynomials with the corresponding weighting function over ...
74,237
27.76327
163
py
scipy
scipy-main/scipy/special/add_newdocs.py
# This file is not meant for public use and will be removed in SciPy v2.0.0. import warnings from . import _add_newdocs __all__ = ['get', 'add_newdoc', 'Dict', 'docdict'] # noqa: F822 def __dir__(): return __all__ def __getattr__(name): if name not in __all__: raise AttributeError( "s...
644
25.875
76
py
scipy
scipy-main/scipy/special/_ellip_harm.py
import numpy as np from ._ufuncs import _ellip_harm from ._ellip_harm_2 import _ellipsoid, _ellipsoid_norm def ellip_harm(h2, k2, n, p, s, signm=1, signn=1): r""" Ellipsoidal harmonic functions E^p_n(l) These are also known as Lame functions of the first kind, and are solutions to the Lame equation:...
5,272
24.229665
127
py
scipy
scipy-main/scipy/special/orthogonal.py
# This file is not meant for public use and will be removed in SciPy v2.0.0. # Use the `scipy.special` namespace for importing the functions # included below. import warnings from . import _orthogonal _polyfuns = ['legendre', 'chebyt', 'chebyu', 'chebyc', 'chebys', 'jacobi', 'laguerre', 'genlaguerre', '...
2,053
35.678571
77
py
scipy
scipy-main/scipy/special/_add_newdocs.py
# Docstrings for generated ufuncs # # The syntax is designed to look like the function add_newdoc is being # called from numpy.lib, but in this file add_newdoc puts the # docstrings in a dictionary. This dictionary is used in # _generate_pyx.py to generate the docstrings for the ufuncs in # scipy.special at the C level...
391,328
26.350363
194
py
scipy
scipy-main/scipy/special/sf_error.py
# This file is not meant for public use and will be removed in SciPy v2.0.0. # Use the `scipy.special` namespace for importing the functions # included below. import warnings from . import _sf_error __all__ = [ # noqa: F822 'SpecialFunctionWarning', 'SpecialFunctionError' ] def __dir__(): return __all_...
792
26.344828
77
py
scipy
scipy-main/scipy/special/_spherical_bessel.py
from ._ufuncs import (_spherical_jn, _spherical_yn, _spherical_in, _spherical_kn, _spherical_jn_d, _spherical_yn_d, _spherical_in_d, _spherical_kn_d) def spherical_jn(n, z, derivative=False): r"""Spherical Bessel function of the first kind or its derivative. Defined...
10,217
28.194286
80
py
scipy
scipy-main/scipy/special/__init__.py
""" ======================================== Special functions (:mod:`scipy.special`) ======================================== .. currentmodule:: scipy.special Almost all of the functions below accept NumPy arrays as input arguments as well as single numbers. This means they follow broadcasting and automatic array-lo...
30,387
36.058537
104
py
scipy
scipy-main/scipy/special/_logsumexp.py
import numpy as np from scipy._lib._util import _asarray_validated __all__ = ["logsumexp", "softmax", "log_softmax"] def logsumexp(a, axis=None, b=None, keepdims=False, return_sign=False): """Compute the log of the sum of exponentials of input elements. Parameters ---------- a : array_like I...
8,523
27.508361
79
py
scipy
scipy-main/scipy/special/basic.py
# This file is not meant for public use and will be removed in SciPy v2.0.0. # Use the `scipy.special` namespace for importing the functions # included below. import warnings from . import _basic from ._ufuncs import (mathieu_a, mathieu_b, iv, jv, gamma, psi, hankel1, hankel2, yv, kv) __all__ =...
1,896
18.357143
77
py
scipy
scipy-main/scipy/special/tests/test_logit.py
import numpy as np from numpy.testing import (assert_equal, assert_almost_equal, assert_allclose) from scipy.special import logit, expit, log_expit class TestLogit: def check_logit_out(self, dtype, expected): a = np.linspace(0, 1, 10) a = np.array(a, dtype=dtype) ...
5,540
36.952055
75
py
scipy
scipy-main/scipy/special/tests/test_precompute_gammainc.py
import pytest from scipy.special._testutils import MissingModule, check_version from scipy.special._mptestutils import ( Arg, IntArg, mp_assert_allclose, assert_mpmath_equal) from scipy.special._precompute.gammainc_asy import ( compute_g, compute_alpha, compute_d) from scipy.special._precompute.gammainc_data i...
4,459
39.917431
75
py
scipy
scipy-main/scipy/special/tests/test_wright_bessel.py
# Reference MPMATH implementation: # # import mpmath # from mpmath import nsum # # def Wright_Series_MPMATH(a, b, z, dps=50, method='r+s+e', steps=[1000]): # """Compute Wright' generalized Bessel function as Series. # # This uses mpmath for arbitrary precision. # """ # with mpmath.workdps(dps): # res...
4,155
34.827586
78
py
scipy
scipy-main/scipy/special/tests/test_data.py
import os import numpy as np from numpy.testing import suppress_warnings import pytest from scipy.special import ( lpn, lpmn, lpmv, lqn, lqmn, sph_harm, eval_legendre, eval_hermite, eval_laguerre, eval_genlaguerre, binom, cbrt, expm1, log1p, zeta, jn, jv, jvp, yn, yv, yvp, iv, ivp, kn, kv, kvp, gamma,...
28,485
45.394137
135
py
scipy
scipy-main/scipy/special/tests/test_cython_special.py
from __future__ import annotations from typing import Callable import pytest from itertools import product from numpy.testing import assert_allclose, suppress_warnings from scipy import special from scipy.special import cython_special bint_points = [True, False] int_points = [-10, -1, 1, 10] real_points = [-10.0, -1...
18,656
51.852691
90
py
scipy
scipy-main/scipy/special/tests/test_digamma.py
import numpy as np from numpy import pi, log, sqrt from numpy.testing import assert_, assert_equal from scipy.special._testutils import FuncData import scipy.special as sc # Euler-Mascheroni constant euler = 0.57721566490153286 def test_consistency(): # Make sure the implementation of digamma for real arguments...
1,394
31.44186
100
py
scipy
scipy-main/scipy/special/tests/test_cdflib.py
""" Test cdflib functions versus mpmath, if available. The following functions still need tests: - ncfdtr - ncfdtri - ncfdtridfn - ncfdtridfd - ncfdtrinc - nbdtrik - nbdtrin - nrdtrimn - nrdtrisd - pdtrik - nctdtr - nctdtrit - nctdtridf - nctdtrinc """ import itertools import numpy as np from numpy.testing import a...
13,419
30.136891
84
py
scipy
scipy-main/scipy/special/tests/test_dd.py
# Tests for a few of the "double-double" C functions defined in cephes/dd_*. import pytest from numpy.testing import assert_allclose from scipy.special._test_internal import _dd_exp, _dd_log, _dd_expm1 # Each tuple in test_data contains: # (dd_func, xhi, xlo, expected_yhi, expected_ylo) # The expected values were ...
1,974
41.021277
78
py
scipy
scipy-main/scipy/special/tests/test_orthogonal.py
import numpy as np from numpy import array, sqrt from numpy.testing import (assert_array_almost_equal, assert_equal, assert_almost_equal, assert_allclose) from pytest import raises as assert_raises from scipy import integrate import scipy.special as sc from scipy.special import gamma import ...
31,471
38.193026
89
py
scipy
scipy-main/scipy/special/tests/test_ndtr.py
import numpy as np from numpy.testing import assert_equal, assert_allclose import scipy.special as sc def test_ndtr(): assert_equal(sc.ndtr(0), 0.5) assert_allclose(sc.ndtr(1), 0.8413447460685429) class TestNdtri: def test_zero(self): assert sc.ndtri(0.5) == 0.0 def test_asymptotes(self): ...
2,680
33.371795
69
py
scipy
scipy-main/scipy/special/tests/test_nan_inputs.py
"""Test how the ufuncs in special handle nan inputs. """ from typing import Callable, Dict import numpy as np from numpy.testing import assert_array_equal, assert_, suppress_warnings import pytest import scipy.special as sc KNOWNFAILURES: Dict[str, Callable] = {} POSTPROCESSING: Dict[str, Callable] = {} def _get...
1,837
27.276923
72
py
scipy
scipy-main/scipy/special/tests/test_basic.py
# this program corresponds to special.py ### Means test is not done yet # E Means test is giving error (E) # F Means test is failing (F) # EF Means test is giving error and Failing #! Means test is segfaulting # 8 Means test runs forever ### test_besselpoly ### test_mathieu_a ### test_mathieu_even_coef ##...
158,898
39.360427
110
py
scipy
scipy-main/scipy/special/tests/test_round.py
import numpy as np import pytest from scipy.special import _test_internal @pytest.mark.skipif(not _test_internal.have_fenv(), reason="no fenv()") def test_add_round_up(): np.random.seed(1234) _test_internal.test_add_round(10**5, 'up') @pytest.mark.skipif(not _test_internal.have_fenv(), reason="no fenv()") ...
421
23.823529
71
py
scipy
scipy-main/scipy/special/tests/test_ellip_harm.py
# # Tests for the Ellipsoidal Harmonic Function, # Distributed under the same license as SciPy itself. # import numpy as np from numpy.testing import (assert_equal, assert_almost_equal, assert_allclose, assert_, suppress_warnings) from scipy.special._testutils import assert_func_equal from s...
9,640
33.555556
79
py
scipy
scipy-main/scipy/special/tests/test_wrightomega.py
import pytest import numpy as np from numpy.testing import assert_, assert_equal, assert_allclose import scipy.special as sc from scipy.special._testutils import assert_func_equal def test_wrightomega_nan(): pts = [complex(np.nan, 0), complex(0, np.nan), complex(np.nan, np.nan), ...
3,560
29.177966
79
py
scipy
scipy-main/scipy/special/tests/test_lambertw.py
# # Tests for the lambertw function, # Adapted from the MPMath tests [1] by Yosef Meller, mellerf@netvision.net.il # Distributed under the same license as SciPy itself. # # [1] mpmath source code, Subversion revision 992 # http://code.google.com/p/mpmath/source/browse/trunk/mpmath/tests/test_functions2.py?spec=svn9...
4,556
40.427273
107
py
scipy
scipy-main/scipy/special/tests/test_owens_t.py
import numpy as np from numpy.testing import assert_equal, assert_allclose import scipy.special as sc def test_symmetries(): np.random.seed(1234) a, h = np.random.rand(100), np.random.rand(100) assert_equal(sc.owens_t(h, a), sc.owens_t(-h, a)) assert_equal(sc.owens_t(h, a), -sc.owens_t(h, -a)) def ...
1,791
32.185185
72
py
scipy
scipy-main/scipy/special/tests/test_log_softmax.py
import numpy as np from numpy.testing import assert_allclose import pytest import scipy.special as sc @pytest.mark.parametrize('x, expected', [ (np.array([1000, 1]), np.array([0, -999])), # Expected value computed using mpmath (with mpmath.mp.dps = 200) and then # converted to float. (np.arange(4),...
3,415
30.054545
79
py
scipy
scipy-main/scipy/special/tests/test_orthogonal_eval.py
import numpy as np from numpy.testing import assert_, assert_allclose import pytest from scipy.special import _ufuncs import scipy.special._orthogonal as orth from scipy.special._testutils import FuncData def test_eval_chebyt(): n = np.arange(0, 10000, 7) x = 2*np.random.rand() - 1 v1 = np.cos(n*np.arcco...
9,319
33.64684
82
py
scipy
scipy-main/scipy/special/tests/test_sph_harm.py
import numpy as np from numpy.testing import assert_allclose import scipy.special as sc def test_first_harmonics(): # Test against explicit representations of the first four # spherical harmonics which use `theta` as the azimuthal angle, # `phi` as the polar angle, and include the Condon-Shortley # ph...
1,106
28.131579
69
py
scipy
scipy-main/scipy/special/tests/test_exponential_integrals.py
import pytest import numpy as np from numpy.testing import assert_allclose import scipy.special as sc class TestExp1: def test_branch_cut(self): assert np.isnan(sc.exp1(-1)) assert sc.exp1(complex(-1, 0)).imag == ( -sc.exp1(complex(-1, -0.0)).imag ) assert_allclose( ...
3,687
29.991597
66
py
scipy
scipy-main/scipy/special/tests/test_pdtr.py
import numpy as np import scipy.special as sc from numpy.testing import assert_almost_equal, assert_array_equal class TestPdtr: def test(self): val = sc.pdtr(0, 1) assert_almost_equal(val, np.exp(-1)) def test_m_zero(self): val = sc.pdtr([0, 1, 2], 0) assert_array_equal(val, [...
1,284
25.22449
65
py
scipy
scipy-main/scipy/special/tests/test_erfinv.py
import numpy as np from numpy.testing import assert_allclose, assert_equal import pytest import scipy.special as sc class TestInverseErrorFunction: def test_compliment(self): # Test erfcinv(1 - x) == erfinv(x) x = np.linspace(-1, 1, 101) assert_allclose(sc.erfcinv(1 - x), sc.erfinv(x), rt...
3,059
33
78
py
scipy
scipy-main/scipy/special/tests/test_cosine_distr.py
import numpy as np from numpy.testing import assert_allclose import pytest from scipy.special._ufuncs import _cosine_cdf, _cosine_invcdf # These values are (x, p) where p is the expected exact value of # _cosine_cdf(x). These values will be tested for exact agreement. _coscdf_exact = [ (-4.0, 0.0), (0, 0.5),...
2,689
31.02381
78
py
scipy
scipy-main/scipy/special/tests/test_gammainc.py
import pytest import numpy as np from numpy.testing import assert_allclose, assert_array_equal import scipy.special as sc from scipy.special._testutils import FuncData INVALID_POINTS = [ (1, -1), (0, 0), (-1, 1), (np.nan, 1), (1, np.nan) ] class TestGammainc: @pytest.mark.parametrize('a, ...
3,815
26.854015
73
py
scipy
scipy-main/scipy/special/tests/test_powm1.py
import pytest import numpy as np from numpy.testing import assert_allclose from scipy.special import powm1 # Expected values were computed with mpmath, e.g. # # >>> import mpmath # >>> mpmath.np.dps = 200 # >>> print(float(mpmath.powm1(2.0, 1e-7)) # 6.931472045825965e-08 # powm1_test_cases = [ (1.25, 0.75...
2,276
33.5
66
py
scipy
scipy-main/scipy/special/tests/test_sf_error.py
import sys import warnings from numpy.testing import assert_, assert_equal, IS_PYPY import pytest from pytest import raises as assert_raises import scipy.special as sc from scipy.special._ufuncs import _sf_error_test_function _sf_error_code_map = { # skip 'ok' 'singular': 1, 'underflow': 2, 'overflow...
3,521
27.634146
77
py
scipy
scipy-main/scipy/special/tests/test_sici.py
import numpy as np import scipy.special as sc from scipy.special._testutils import FuncData def test_sici_consistency(): # Make sure the implementation of sici for real arguments agrees # with the implementation of sici for complex arguments. # On the negative real axis Cephes drops the imaginary part i...
1,227
32.189189
70
py
scipy
scipy-main/scipy/special/tests/test_gamma.py
import numpy as np import scipy.special as sc class TestRgamma: def test_gh_11315(self): assert sc.rgamma(-35) == 0 def test_rgamma_zeros(self): x = np.array([0, -10, -100, -1000, -10000]) assert np.all(sc.rgamma(x) == 0)
258
18.923077
51
py
scipy
scipy-main/scipy/special/tests/test_logsumexp.py
import numpy as np from numpy.testing import (assert_almost_equal, assert_equal, assert_allclose, assert_array_almost_equal, assert_) from scipy.special import logsumexp, softmax def test_logsumexp(): # Test whether logsumexp() function correctly handles large inputs. a = np.arange...
6,180
30.697436
78
py
scipy
scipy-main/scipy/special/tests/test_boxcox.py
import numpy as np from numpy.testing import assert_equal, assert_almost_equal, assert_allclose from scipy.special import boxcox, boxcox1p, inv_boxcox, inv_boxcox1p # There are more tests of boxcox and boxcox1p in test_mpmath.py. def test_boxcox_basic(): x = np.array([0.5, 1, 2, 4]) # lambda = 0 => y = lo...
2,672
23.981308
76
py
scipy
scipy-main/scipy/special/tests/test_faddeeva.py
import pytest import numpy as np from numpy.testing import assert_allclose import scipy.special as sc from scipy.special._testutils import FuncData class TestVoigtProfile: @pytest.mark.parametrize('x, sigma, gamma', [ (np.nan, 1, 1), (0, np.nan, 1), (0, 1, np.nan), (1, np.nan, 0)...
2,568
28.872093
64
py
scipy
scipy-main/scipy/special/tests/test_precompute_utils.py
import pytest from scipy.special._testutils import MissingModule, check_version from scipy.special._mptestutils import mp_assert_allclose from scipy.special._precompute.utils import lagrange_inversion try: import sympy except ImportError: sympy = MissingModule('sympy') try: import mpmath as mp except Imp...
1,165
30.513514
68
py
scipy
scipy-main/scipy/special/tests/__init__.py
0
0
0
py
scipy
scipy-main/scipy/special/tests/test_ndtri_exp.py
import pytest import numpy as np from numpy.testing import assert_equal, assert_allclose from scipy.special import log_ndtr, ndtri_exp from scipy.special._testutils import assert_func_equal def log_ndtr_ndtri_exp(y): return log_ndtr(ndtri_exp(y)) @pytest.fixture(scope="class") def uniform_random_points(): r...
3,708
38.042105
79
py
scipy
scipy-main/scipy/special/tests/test_cdft_asymptotic.py
# gh-14777 regression tests # Test stdtr and stdtrit with infinite df and large values of df import numpy as np from numpy.testing import assert_allclose, assert_equal from scipy.special import stdtr, stdtrit, ndtr, ndtri def test_stdtr_vs_R_large_df(): df = [1e10, 1e12, 1e120, np.inf] t = 1. res = stdtr...
1,429
27.6
64
py
scipy
scipy-main/scipy/special/tests/test_trig.py
import numpy as np from numpy.testing import assert_equal, assert_allclose, suppress_warnings from scipy.special._ufuncs import _sinpi as sinpi from scipy.special._ufuncs import _cospi as cospi def test_integer_real_part(): x = np.arange(-100, 101) y = np.hstack((-np.linspace(310, -30, 10), np.linspace(-30, ...
2,097
30.313433
75
py
scipy
scipy-main/scipy/special/tests/test_kolmogorov.py
import itertools import sys import pytest import numpy as np from numpy.testing import assert_ from scipy.special._testutils import FuncData from scipy.special import kolmogorov, kolmogi, smirnov, smirnovi from scipy.special._ufuncs import (_kolmogc, _kolmogci, _kolmogp, _smirnovc, ...
18,407
43.571429
110
py
scipy
scipy-main/scipy/special/tests/test_mpmath.py
""" Test SciPy functions versus mpmath, if available. """ import numpy as np from numpy.testing import assert_, assert_allclose from numpy import pi import pytest import itertools from scipy._lib import _pep440 import scipy.special as sc from scipy.special._testutils import ( MissingModule, check_version, FuncDa...
75,189
36.075937
123
py
scipy
scipy-main/scipy/special/tests/test_spfun_stats.py
import numpy as np from numpy.testing import (assert_array_equal, assert_array_almost_equal_nulp, assert_almost_equal) from pytest import raises as assert_raises from scipy.special import gammaln, multigammaln class TestMultiGammaLn: def test1(self): # A test of the identity # Gamma_...
1,998
31.241935
74
py
scipy
scipy-main/scipy/special/tests/test_loggamma.py
import numpy as np from numpy.testing import assert_allclose, assert_ from scipy.special._testutils import FuncData from scipy.special import gamma, gammaln, loggamma def test_identities1(): # test the identity exp(loggamma(z)) = gamma(z) x = np.array([-99.5, -9.5, -0.5, 0.5, 9.5, 99.5]) y = x.copy() ...
1,992
27.070423
69
py
scipy
scipy-main/scipy/special/tests/test_spence.py
import numpy as np from numpy import sqrt, log, pi from scipy.special._testutils import FuncData from scipy.special import spence def test_consistency(): # Make sure the implementation of spence for real arguments # agrees with the implementation of spence for imaginary arguments. x = np.logspace(-30, 30...
1,099
32.333333
71
py
scipy
scipy-main/scipy/special/tests/test_precompute_expn_asy.py
from numpy.testing import assert_equal from scipy.special._testutils import check_version, MissingModule from scipy.special._precompute.expn_asy import generate_A try: import sympy from sympy import Poly except ImportError: sympy = MissingModule("sympy") @check_version(sympy, "1.0") def test_generate_A(...
583
22.36
65
py
scipy
scipy-main/scipy/special/tests/test_pcf.py
"""Tests for parabolic cylinder functions. """ import numpy as np from numpy.testing import assert_allclose, assert_equal import scipy.special as sc def test_pbwa_segfault(): # Regression test for https://github.com/scipy/scipy/issues/6208. # # Data generated by mpmath. # w = 1.022765672113168671...
664
25.6
69
py
scipy
scipy-main/scipy/special/tests/test_zeta.py
import scipy.special as sc import numpy as np from numpy.testing import assert_equal, assert_allclose def test_zeta(): assert_allclose(sc.zeta(2,2), np.pi**2/6 - 1, rtol=1e-12) def test_zetac(): # Expected values in the following were computed using Wolfram # Alpha's `Zeta[x] - 1` x = [-2.1, 0.8, 0....
1,367
26.36
66
py
scipy
scipy-main/scipy/special/tests/test_spherical_bessel.py
# # Tests of spherical Bessel functions. # import numpy as np from numpy.testing import (assert_almost_equal, assert_allclose, assert_array_almost_equal, suppress_warnings) import pytest from numpy import sin, cos, sinh, cosh, exp, inf, nan, r_, pi from scipy.special import spherical_jn, sph...
14,284
36.592105
99
py
scipy
scipy-main/scipy/special/tests/test_hypergeometric.py
import pytest import numpy as np from numpy.testing import assert_allclose, assert_equal import scipy.special as sc class TestHyperu: def test_negative_x(self): a, b, x = np.meshgrid( [-1, -0.5, 0, 0.5, 1], [-1, -0.5, 0, 0.5, 1], np.linspace(-100, -1, 10), ) ...
5,598
38.70922
79
py
scipy
scipy-main/scipy/special/tests/test_bdtr.py
import numpy as np import scipy.special as sc import pytest from numpy.testing import assert_allclose, assert_array_equal, suppress_warnings class TestBdtr: def test(self): val = sc.bdtr(0, 1, 0.5) assert_allclose(val, 0.5) def test_sum_is_one(self): val = sc.bdtr([0, 1, 2], 2, 0.5) ...
3,231
27.60177
80
py
scipy
scipy-main/scipy/special/tests/test_hyp2f1.py
"""Tests for hyp2f1 for complex values. Author: Albert Steppi, with credit to Adam Kullberg (FormerPhycisist) for the implementation of mp_hyp2f1 below, which modifies mpmath's hyp2f1 to return the same branch as scipy's on the standard branch cut. """ import sys import pytest import numpy as np from typing import Na...
78,547
35.014672
79
py
scipy
scipy-main/scipy/special/_precompute/gammainc_asy.py
""" Precompute coefficients of Temme's asymptotic expansion for gammainc. This takes about 8 hours to run on a 2.3 GHz Macbook Pro with 4GB ram. Sources: [1] NIST, "Digital Library of Mathematical Functions", https://dlmf.nist.gov/ """ import os from scipy.special._precompute.utils import lagrange_inversion try...
2,502
20.393162
74
py
scipy
scipy-main/scipy/special/_precompute/loggamma.py
"""Precompute series coefficients for log-Gamma.""" try: import mpmath except ImportError: pass def stirling_series(N): with mpmath.workdps(100): coeffs = [mpmath.bernoulli(2*n)/(2*n*(2*n - 1)) for n in range(1, N + 1)] return coeffs def taylor_series_at_1(N): coeffs =...
1,094
23.886364
67
py
scipy
scipy-main/scipy/special/_precompute/wright_bessel.py
"""Precompute coefficients of several series expansions of Wright's generalized Bessel function Phi(a, b, x). See https://dlmf.nist.gov/10.46.E1 with rho=a, beta=b, z=x. """ from argparse import ArgumentParser, RawTextHelpFormatter import numpy as np from scipy.integrate import quad from scipy.optimize import minimize...
12,866
36.51312
79
py
scipy
scipy-main/scipy/special/_precompute/hyp2f1_data.py
"""This script evaluates scipy's implementation of hyp2f1 against mpmath's. Author: Albert Steppi This script is long running and generates a large output file. With default arguments, the generated file is roughly 700MB in size and it takes around 40 minutes using an Intel(R) Core(TM) i5-8250U CPU with n_jobs set to...
14,710
29.331959
79
py
scipy
scipy-main/scipy/special/_precompute/expn_asy.py
"""Precompute the polynomials for the asymptotic expansion of the generalized exponential integral. Sources ------- [1] NIST, Digital Library of Mathematical Functions, https://dlmf.nist.gov/8.20#ii """ import os try: import sympy from sympy import Poly x = sympy.symbols('x') except ImportError: ...
1,265
22.018182
71
py
scipy
scipy-main/scipy/special/_precompute/setup.py
def configuration(parent_name='special', top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('_precompute', parent_name, top_path) return config if __name__ == '__main__': from numpy.distutils.core import setup setup(**configuration().todict())
307
27
64
py
scipy
scipy-main/scipy/special/_precompute/wrightomega.py
import numpy as np try: import mpmath except ImportError: pass def mpmath_wrightomega(x): return mpmath.lambertw(mpmath.exp(x), mpmath.mpf('-0.5')) def wrightomega_series_error(x): series = x desired = mpmath_wrightomega(x) return abs(series - desired) / desired def wrightomega_exp_error(...
955
21.761905
61
py
scipy
scipy-main/scipy/special/_precompute/zetac.py
"""Compute the Taylor series for zeta(x) - 1 around x = 0.""" try: import mpmath except ImportError: pass def zetac_series(N): coeffs = [] with mpmath.workdps(100): coeffs.append(-1.5) for n in range(1, N): coeff = mpmath.diff(mpmath.zeta, 0, n)/mpmath.factorial(n) ...
591
20.142857
70
py
scipy
scipy-main/scipy/special/_precompute/utils.py
try: import mpmath as mp except ImportError: pass try: from sympy.abc import x except ImportError: pass def lagrange_inversion(a): """Given a series f(x) = a[1]*x + a[2]*x**2 + ... + a[n-1]*x**(n - 1), use the Lagrange inversion formula to compute a series g(x) = b[1]*x + b[2]*x**2...
887
21.769231
69
py
scipy
scipy-main/scipy/special/_precompute/wright_bessel_data.py
"""Compute a grid of values for Wright's generalized Bessel function and save the values to data files for use in tests. Using mpmath directly in tests would take too long. This takes about 10 minutes to run on a 2.7 GHz i7 Macbook Pro. """ from functools import lru_cache import os from time import time import numpy ...
5,647
35.915033
78
py
scipy
scipy-main/scipy/special/_precompute/struve_convergence.py
""" Convergence regions of the expansions used in ``struve.c`` Note that for v >> z both functions tend rapidly to 0, and for v << -z, they tend to infinity. The floating-point functions over/underflow in the lower left and right corners of the figure. Figure legend ============= Red region Power series is clo...
3,462
27.154472
108
py
scipy
scipy-main/scipy/special/_precompute/gammainc_data.py
"""Compute gammainc and gammaincc for large arguments and parameters and save the values to data files for use in tests. We can't just compare to mpmath's gammainc in test_mpmath.TestSystematic because it would take too long. Note that mpmath's gammainc is computed using hypercomb, but since it doesn't allow the user ...
4,077
31.624
80
py
scipy
scipy-main/scipy/special/_precompute/__init__.py
0
0
0
py
scipy
scipy-main/scipy/special/_precompute/cosine_cdf.py
import mpmath def f(x): return (mpmath.pi + x + mpmath.sin(x)) / (2*mpmath.pi) # Note: 40 digits might be overkill; a few more digits than the default # might be sufficient. mpmath.mp.dps = 40 ts = mpmath.taylor(f, -mpmath.pi, 20) p, q = mpmath.pade(ts, 9, 10) p = [float(c) for c in p] q = [float(c) for c in q...
354
18.722222
71
py
scipy
scipy-main/scipy/special/_precompute/lambertw.py
"""Compute a Pade approximation for the principal branch of the Lambert W function around 0 and compare it to various other approximations. """ import numpy as np try: import mpmath import matplotlib.pyplot as plt except ImportError: pass def lambertw_pade(): derivs = [mpmath.diff(mpmath.lambertw, 0...
1,961
27.434783
69
py
scipy
scipy-main/scipy/special/utils/makenpz.py
""" python makenpz.py DIRECTORY Build a npz containing all data files in the directory. """ import os import numpy as np import argparse from stat import ST_MTIME def newer(source, target): """ Return true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target...
2,671
29.022472
78
py
scipy
scipy-main/scipy/special/utils/convert.py
# This script is used to parse BOOST special function test data into something # we can easily import in numpy. import re import os # Where to put the data (directory will be created) DATA_DIR = 'scipy/special/tests/data/boost' # Where to pull out boost data BOOST_SRC = "boostmath/test" CXX_COMMENT = re.compile(r'^\s...
3,443
26.333333
79
py
scipy
scipy-main/scipy/special/utils/datafunc.py
import csv import numpy as np def parse_txt_data(filename): f = open(filename) try: reader = csv.reader(f, delimiter=',') data = [list(map(float, row)) for row in reader] nc = len(data[0]) for i in data: if not nc == len(i): raise ValueError(i) ...
1,750
27.241935
82
py
scipy
scipy-main/scipy/constants/constants.py
# This file is not meant for public use and will be removed in SciPy v2.0.0. # Use the `scipy.constants` namespace for importing the functions # included below. import warnings from . import _constants __all__ = [ # noqa: F822 'Avogadro', 'Boltzmann', 'Btu', 'Btu_IT', 'Btu_th', 'G', 'Julian_year', 'N_A', 'P...
2,477
38.967742
79
py
scipy
scipy-main/scipy/constants/setup.py
def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('constants', parent_package, top_path) config.add_data_dir('tests') return config if __name__ == '__main__': from numpy.distutils.core import setup setup(**configurat...
347
30.636364
65
py