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/ndimage/tests/test_measurements.py | import os.path
import numpy as np
from numpy.testing import (assert_, assert_array_almost_equal, assert_equal,
assert_almost_equal, assert_array_equal,
suppress_warnings)
from pytest import raises as assert_raises
import scipy.ndimage as ndimage
from . import ty... | 47,782 | 33.302225 | 79 | py |
scipy | scipy-main/scipy/ndimage/tests/test_filters.py | ''' Some tests for filters '''
import functools
import itertools
import math
import numpy
from numpy.testing import (assert_equal, assert_allclose,
assert_array_almost_equal,
assert_array_equal, assert_almost_equal,
suppress_warnings, ass... | 93,324 | 41.614155 | 79 | py |
scipy | scipy-main/scipy/ndimage/tests/test_splines.py | """Tests for spline filtering."""
import numpy as np
import pytest
from numpy.testing import assert_almost_equal
from scipy import ndimage
def get_spline_knot_values(order):
"""Knot values to the right of a B-spline's center."""
knot_values = {0: [1],
1: [1],
2: [6, 1],... | 2,199 | 32.333333 | 76 | py |
scipy | scipy-main/scipy/ndimage/tests/test_interpolation.py | import sys
import numpy
from numpy.testing import (assert_, assert_equal, assert_array_equal,
assert_array_almost_equal, assert_allclose,
suppress_warnings)
import pytest
from pytest import raises as assert_raises
import scipy.ndimage as ndimage
from . import type... | 54,771 | 40.243976 | 79 | py |
scipy | scipy-main/scipy/ndimage/tests/test_morphology.py | import numpy
import numpy as np
from numpy.testing import (assert_, assert_equal, assert_array_equal,
assert_array_almost_equal)
import pytest
from pytest import raises as assert_raises
from scipy import ndimage
from . import types
class TestNdimageMorphology:
@pytest.mark.parametriz... | 106,686 | 43.527129 | 79 | py |
scipy | scipy-main/scipy/ndimage/tests/test_fourier.py | import numpy
from numpy import fft
from numpy.testing import (assert_almost_equal, assert_array_almost_equal,
assert_equal)
import pytest
from scipy import ndimage
class TestNdimageFourier:
@pytest.mark.parametrize('shape', [(32, 16), (31, 15), (1, 10)])
@pytest.mark.parametrize(... | 6,664 | 42.848684 | 76 | py |
scipy | scipy-main/scipy/ndimage/tests/test_datatypes.py | """ Testing data types for ndimage calls
"""
import sys
import numpy as np
from numpy.testing import assert_array_almost_equal, assert_
import pytest
from scipy import ndimage
def test_map_coordinates_dts():
# check that ndimage accepts different data types for interpolation
data = np.array([[4, 1, 3, 2],
... | 2,742 | 39.940299 | 82 | py |
scipy | scipy-main/scipy/ndimage/tests/__init__.py | from __future__ import annotations
from typing import List, Type
import numpy
# list of numarray data types
integer_types: list[type] = [
numpy.int8, numpy.uint8, numpy.int16, numpy.uint16,
numpy.int32, numpy.uint32, numpy.int64, numpy.uint64]
float_types: list[type] = [numpy.float32, numpy.float64]
complex... | 426 | 27.466667 | 63 | py |
scipy | scipy-main/scipy/ndimage/tests/test_c_api.py | import numpy as np
from numpy.testing import assert_allclose
from scipy import ndimage
from scipy.ndimage import _ctest
from scipy.ndimage import _cytest
from scipy._lib._ccallback import LowLevelCallable
FILTER1D_FUNCTIONS = [
lambda filter_size: _ctest.filter1d(filter_size),
lambda filter_size: _cytest.filt... | 3,452 | 35.347368 | 106 | py |
scipy | scipy-main/scipy/ndimage/utils/generate_label_testvectors.py | import numpy as np
from scipy.ndimage import label
def generate_test_vecs(infile, strelfile, resultfile):
"test label with different structuring element neighborhoods"
def bitimage(l):
return np.array([[c for c in s] for s in l]) == '1'
data = [np.ones((7, 7)),
bitimage(["1110111",
... | 1,669 | 36.111111 | 79 | py |
scipy | scipy-main/scipy/datasets/setup.py | def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('datasets', parent_package, top_path)
config.add_data_dir('tests')
return config
if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configurati... | 346 | 30.545455 | 64 | py |
scipy | scipy-main/scipy/datasets/_utils.py | import os
import shutil
from ._registry import method_files_map
try:
import platformdirs
except ImportError:
platformdirs = None # type: ignore[assignment]
def _clear_cache(datasets, cache_dir=None, method_map=None):
if method_map is None:
# Use SciPy Datasets method map
method_map = met... | 2,967 | 35.195122 | 78 | py |
scipy | scipy-main/scipy/datasets/_registry.py | ##########################################################################
# This file serves as the dataset registry for SciPy Datasets SubModule.
##########################################################################
# To generate the SHA256 hash, use the command
# openssl sha256 <filename>
registry = {
"as... | 1,072 | 38.740741 | 91 | py |
scipy | scipy-main/scipy/datasets/_download_all.py | """
Platform independent script to download all the
`scipy.datasets` module data files.
This doesn't require a full scipy build.
Run: python _download_all.py <download_dir>
"""
import argparse
try:
import pooch
except ImportError:
pooch = None
if __package__ is None or __package__ == '':
# Running as py... | 1,701 | 28.344828 | 78 | py |
scipy | scipy-main/scipy/datasets/_fetchers.py | from numpy import array, frombuffer, load
from ._registry import registry, registry_urls
try:
import pooch
except ImportError:
pooch = None
data_fetcher = None
else:
data_fetcher = pooch.create(
# Use the default cache folder for the operating system
# Pooch uses appdirs (https://github... | 6,759 | 29.588235 | 91 | py |
scipy | scipy-main/scipy/datasets/__init__.py | """
================================
Datasets (:mod:`scipy.datasets`)
================================
.. currentmodule:: scipy.datasets
Dataset Methods
===============
.. autosummary::
:toctree: generated/
ascent
face
electrocardiogram
Utility Methods
===============
.. autosummary::
:toctree: gen... | 2,816 | 29.956044 | 83 | py |
scipy | scipy-main/scipy/datasets/tests/test_data.py | from scipy.datasets._registry import registry
from scipy.datasets._fetchers import data_fetcher
from scipy.datasets._utils import _clear_cache
from scipy.datasets import ascent, face, electrocardiogram, download_all
from numpy.testing import assert_equal, assert_almost_equal
import os
import pytest
try:
import poo... | 4,064 | 31.782258 | 76 | py |
scipy | scipy-main/scipy/datasets/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/linalg/_decomp_cossin.py | from collections.abc import Iterable
import numpy as np
from scipy._lib._util import _asarray_validated
from scipy.linalg import block_diag, LinAlgError
from .lapack import _compute_lwork, get_lapack_funcs
__all__ = ['cossin']
def cossin(X, p=None, q=None, separate=False,
swap_sign=False, compute_u=True,... | 8,882 | 38.65625 | 79 | py |
scipy | scipy-main/scipy/linalg/_testutils.py | import numpy as np
class _FakeMatrix:
def __init__(self, data):
self._data = data
self.__array_interface__ = data.__array_interface__
class _FakeMatrix2:
def __init__(self, data):
self._data = data
def __array__(self):
return self._data
def _get_array(shape, dtype):
... | 1,730 | 26.046875 | 70 | py |
scipy | scipy-main/scipy/linalg/_generate_pyx.py | """
Code generator script to make the Cython BLAS and LAPACK wrappers
from the files "cython_blas_signatures.txt" and
"cython_lapack_signatures.txt" which contain the signatures for
all the BLAS/LAPACK routines that should be included in the wrappers.
"""
from collections import defaultdict
from operator import itemge... | 26,513 | 32.689962 | 101 | py |
scipy | scipy-main/scipy/linalg/interpolative.py | #******************************************************************************
# Copyright (C) 2013 Kenneth L. Ho
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain t... | 32,188 | 30.775913 | 92 | py |
scipy | scipy-main/scipy/linalg/_decomp_qz.py | import warnings
import numpy as np
from numpy import asarray_chkfinite
from ._misc import LinAlgError, _datacopied, LinAlgWarning
from .lapack import get_lapack_funcs
__all__ = ['qz', 'ordqz']
_double_precision = ['i', 'l', 'd']
def _select_function(sort):
if callable(sort):
# assume the user knows wh... | 16,336 | 35.304444 | 79 | py |
scipy | scipy-main/scipy/linalg/_misc.py | import numpy as np
from numpy.linalg import LinAlgError
from .blas import get_blas_funcs
from .lapack import get_lapack_funcs
__all__ = ['LinAlgError', 'LinAlgWarning', 'norm']
class LinAlgWarning(RuntimeWarning):
"""
The warning emitted when a linear algebra related operation is close
to fail conditions... | 6,283 | 31.729167 | 83 | py |
scipy | scipy-main/scipy/linalg/decomp_lu.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.linalg` namespace for importing the functions
# included below.
import warnings
from . import _decomp_lu
__all__ = [ # noqa: F822
'lu', 'lu_solve', 'lu_factor',
'asarray_chkfinite', 'LinAlgWarning', 'get_lapack_func... | 856 | 26.645161 | 76 | py |
scipy | scipy-main/scipy/linalg/_interpolative_backend.py | #******************************************************************************
# Copyright (C) 2013 Kenneth L. Ho
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain t... | 45,192 | 25.868609 | 79 | py |
scipy | scipy-main/scipy/linalg/decomp.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.linalg` namespace for importing the functions
# included below.
import warnings
from . import _decomp
__all__ = [ # noqa: F822
'eig', 'eigvals', 'eigh', 'eigvalsh',
'eig_banded', 'eigvals_banded',
'eigh_tridiago... | 1,057 | 31.060606 | 76 | py |
scipy | scipy-main/scipy/linalg/setup.py | from os.path import join
import os
def configuration(parent_package='', top_path=None):
from distutils.sysconfig import get_python_inc
from numpy.distutils.system_info import get_info, numpy_info
from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs
from scipy._build_utils import... | 6,804 | 38.109195 | 79 | py |
scipy | scipy-main/scipy/linalg/_flinalg_py.py | #
# Author: Pearu Peterson, March 2002
#
__all__ = ['get_flinalg_funcs']
# The following ensures that possibly missing flavor (C or Fortran) is
# replaced with the available one. If none is available, exception
# is raised at the first attempt to use the resources.
try:
from . import _flinalg
except ImportError:
... | 1,489 | 27.113208 | 83 | py |
scipy | scipy-main/scipy/linalg/_matfuncs_inv_ssq.py | """
Matrix functions that use Pade approximation with inverse scaling and squaring.
"""
import warnings
import numpy as np
from scipy.linalg._matfuncs_sqrtm import SqrtmError, _sqrtm_triu
from scipy.linalg._decomp_schur import schur, rsf2csf
from scipy.linalg._matfuncs import funm
from scipy.linalg import svdvals, s... | 28,030 | 30.602029 | 79 | py |
scipy | scipy-main/scipy/linalg/_decomp_qr.py | """QR decomposition functions."""
import numpy
# Local imports
from .lapack import get_lapack_funcs
from ._misc import _datacopied
__all__ = ['qr', 'qr_multiply', 'rq']
def safecall(f, name, *args, **kwargs):
"""Call a LAPACK routine, determining lwork automatically and handling
error return values"""
l... | 13,727 | 30.925581 | 79 | py |
scipy | scipy-main/scipy/linalg/misc.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.linalg` namespace for importing the functions
# included below.
import warnings
from . import _misc
__all__ = [ # noqa: F822
'LinAlgError', 'LinAlgWarning', 'norm', 'get_blas_funcs',
'get_lapack_funcs'
]
def __dir... | 799 | 26.586207 | 76 | py |
scipy | scipy-main/scipy/linalg/_basic.py | #
# Author: Pearu Peterson, March 2002
#
# w/ additions by Travis Oliphant, March 2002
# and Jake Vanderplas, August 2012
from warnings import warn
from itertools import product
import numpy as np
from numpy import atleast_1d, atleast_2d
from .lapack import get_lapack_funcs, _compute_lwork
from ._misc imp... | 69,470 | 34.939472 | 79 | py |
scipy | scipy-main/scipy/linalg/decomp_qr.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.linalg` namespace for importing the functions
# included below.
import warnings
from . import _decomp_qr
__all__ = [ # noqa: F822
'qr', 'qr_multiply', 'rq', 'get_lapack_funcs', 'safecall'
]
def __dir__():
return _... | 796 | 27.464286 | 76 | py |
scipy | scipy-main/scipy/linalg/_special_matrices.py | import math
import warnings
import numpy as np
from numpy.lib.stride_tricks import as_strided
__all__ = ['tri', 'tril', 'triu', 'toeplitz', 'circulant', 'hankel',
'hadamard', 'leslie', 'kron', 'block_diag', 'companion',
'helmert', 'hilbert', 'invhilbert', 'pascal', 'invpascal', 'dft',
... | 40,711 | 28.100786 | 81 | py |
scipy | scipy-main/scipy/linalg/_procrustes.py | """
Solve the orthogonal Procrustes problem.
"""
import numpy as np
from ._decomp_svd import svd
__all__ = ['orthogonal_procrustes']
def orthogonal_procrustes(A, B, check_finite=True):
"""
Compute the matrix solution of the orthogonal Procrustes problem.
Given matrices A and B of equal shape, find an ... | 2,786 | 29.293478 | 79 | py |
scipy | scipy-main/scipy/linalg/matfuncs.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.linalg` namespace for importing the functions
# included below.
import warnings
from . import _matfuncs
__all__ = [ # noqa: F822
'expm', 'cosm', 'sinm', 'tanm', 'coshm', 'sinhm',
'tanhm', 'logm', 'funm', 'signm', 's... | 1,098 | 32.30303 | 76 | py |
scipy | scipy-main/scipy/linalg/decomp_svd.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.linalg` namespace for importing the functions
# included below.
import warnings
from . import _decomp_svd
__all__ = [ # noqa: F822
'svd', 'svdvals', 'diagsvd', 'orth', 'subspace_angles', 'null_space',
'LinAlgError',... | 850 | 28.344828 | 76 | py |
scipy | scipy-main/scipy/linalg/_matfuncs_sqrtm.py | """
Matrix square root for general matrices and for upper triangular matrices.
This module exists to avoid cyclic imports.
"""
__all__ = ['sqrtm']
import numpy as np
from scipy._lib._util import _asarray_validated
# Local imports
from ._misc import norm
from .lapack import ztrsyl, dtrsyl
from ._decomp_schur import... | 6,661 | 30.57346 | 77 | py |
scipy | scipy-main/scipy/linalg/_decomp_ldl.py | from warnings import warn
import numpy as np
from numpy import (atleast_2d, ComplexWarning, arange, zeros_like, imag, diag,
iscomplexobj, tril, triu, argsort, empty_like)
from ._decomp import _asarray_validated
from .lapack import get_lapack_funcs, _compute_lwork
__all__ = ['ldl']
def ldl(A, lowe... | 12,516 | 34.458924 | 80 | py |
scipy | scipy-main/scipy/linalg/_sketches.py | """ Sketching-based Matrix Computations """
# Author: Jordi Montes <jomsdev@gmail.com>
# August 28, 2017
import numpy as np
from scipy._lib._util import check_random_state, rng_integers
from scipy.sparse import csc_matrix
__all__ = ['clarkson_woodruff_transform']
def cwt_matrix(n_rows, n_columns, seed=None):
... | 6,145 | 33.144444 | 86 | py |
scipy | scipy-main/scipy/linalg/_matfuncs_sqrtm_triu.py | # pythran export within_block_loop(float64[:,:], float64[:,:],
# (int, int) list, intp)
# pythran export within_block_loop(complex128[:,:], complex128[:,:],
# (int, int) list, intp)
def within_block_loop(R, T, start_stop_pairs, nblocks):
for start, ... | 966 | 39.291667 | 79 | py |
scipy | scipy-main/scipy/linalg/_decomp_schur.py | """Schur decomposition functions."""
import numpy
from numpy import asarray_chkfinite, single, asarray, array
from numpy.linalg import norm
# Local imports.
from ._misc import LinAlgError, _datacopied
from .lapack import get_lapack_funcs
from ._decomp import eigvals
__all__ = ['schur', 'rsf2csf']
_double_precision ... | 10,355 | 33.52 | 79 | py |
scipy | scipy-main/scipy/linalg/_expm_frechet.py | """Frechet derivative of the matrix exponential."""
import numpy as np
import scipy.linalg
__all__ = ['expm_frechet', 'expm_cond']
def expm_frechet(A, E, method=None, compute_expm=True, check_finite=True):
"""
Frechet derivative of the matrix exponential of A in the direction E.
Parameters
---------... | 12,326 | 28.775362 | 79 | py |
scipy | scipy-main/scipy/linalg/decomp_schur.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.linalg` namespace for importing the functions
# included below.
import warnings
from . import _decomp_schur
__all__ = [ # noqa: F822
'schur', 'rsf2csf', 'asarray_chkfinite', 'single', 'array', 'norm',
'LinAlgError',... | 882 | 29.448276 | 77 | py |
scipy | scipy-main/scipy/linalg/_cython_signature_generator.py | """
A script that uses f2py to generate the signature files used to make
the Cython BLAS and LAPACK wrappers from the fortran source code for
LAPACK and the reference BLAS.
To generate the BLAS wrapper signatures call:
python _cython_signature_generator.py blas <blas_directory> <out_file>
To generate the LAPACK wrapp... | 10,580 | 55.887097 | 297 | py |
scipy | scipy-main/scipy/linalg/lapack.py | """
Low-level LAPACK functions (:mod:`scipy.linalg.lapack`)
=======================================================
This module contains low-level functions from the LAPACK library.
.. versionadded:: 0.12.0
.. note::
The common ``overwrite_<>`` option in many routines, allows the
input arrays to be overwrit... | 15,647 | 14.046154 | 77 | py |
scipy | scipy-main/scipy/linalg/_solvers.py | """Matrix equation solver routines"""
# Author: Jeffrey Armstrong <jeff@approximatrix.com>
# February 24, 2012
# Modified: Chad Fulton <ChadFulton@gmail.com>
# June 19, 2014
# Modified: Ilhan Polat <ilhanpolat@gmail.com>
# September 13, 2016
import warnings
import numpy as np
from numpy.linalg import inv, LinAlgErro... | 28,380 | 32.46816 | 80 | py |
scipy | scipy-main/scipy/linalg/__init__.py | """
====================================
Linear algebra (:mod:`scipy.linalg`)
====================================
.. currentmodule:: scipy.linalg
.. toctree::
:hidden:
linalg.blas
linalg.cython_blas
linalg.cython_lapack
linalg.interpolative
linalg.lapack
Linear algebra functions.
.. eventually, ... | 7,733 | 31.225 | 93 | py |
scipy | scipy-main/scipy/linalg/_matfuncs.py | #
# Author: Travis Oliphant, March 2002
#
from itertools import product
import numpy as np
from numpy import (dot, diag, prod, logical_not, ravel, transpose,
conjugate, absolute, amax, sign, isfinite, triu)
from numpy.lib.scimath import sqrt as csqrt
# Local imports
from scipy.linalg import LinAlgE... | 25,030 | 27.412032 | 79 | py |
scipy | scipy-main/scipy/linalg/flinalg.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
import warnings
from . import _flinalg_py
__all__ = ['get_flinalg_funcs', 'has_column_major_storage'] # noqa: F822
def __dir__():
return __all__
def __getattr__(name):
if name not in __all__:
raise AttributeError(
... | 677 | 27.25 | 76 | py |
scipy | scipy-main/scipy/linalg/blas.py | """
Low-level BLAS functions (:mod:`scipy.linalg.blas`)
===================================================
This module contains low-level functions from the BLAS library.
.. versionadded:: 0.12.0
.. note::
The common ``overwrite_<>`` option in many routines, allows the
input arrays to be overwritten to avoid... | 11,677 | 23.078351 | 79 | py |
scipy | scipy-main/scipy/linalg/_decomp_svd.py | """SVD decomposition functions."""
import numpy
from numpy import zeros, r_, diag, dot, arccos, arcsin, where, clip
# Local imports.
from ._misc import LinAlgError, _datacopied
from .lapack import get_lapack_funcs, _compute_lwork
from ._decomp import _asarray_validated
__all__ = ['svd', 'svdvals', 'diagsvd', 'orth', ... | 14,923 | 28.611111 | 80 | py |
scipy | scipy-main/scipy/linalg/special_matrices.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.linalg` namespace for importing the functions
# included below.
import warnings
from . import _special_matrices
__all__ = [ # noqa: F822
'tri', 'tril', 'triu', 'toeplitz', 'circulant', 'hankel',
'hadamard', 'leslie'... | 1,026 | 32.129032 | 79 | py |
scipy | scipy-main/scipy/linalg/_decomp_lu.py | """LU decomposition functions."""
from warnings import warn
from numpy import asarray, asarray_chkfinite
import numpy as np
from itertools import product
# Local imports
from ._misc import _datacopied, LinAlgWarning
from .lapack import get_lapack_funcs
from ._decomp_lu_cython import lu_dispatcher
lapack_cast_dict =... | 12,573 | 32.530667 | 79 | py |
scipy | scipy-main/scipy/linalg/_decomp_cholesky.py | """Cholesky decomposition functions."""
from numpy import asarray_chkfinite, asarray, atleast_2d
# Local imports
from ._misc import LinAlgError, _datacopied
from .lapack import get_lapack_funcs
__all__ = ['cholesky', 'cho_factor', 'cho_solve', 'cholesky_banded',
'cho_solve_banded']
def _cholesky(a, lowe... | 11,903 | 32.158774 | 81 | py |
scipy | scipy-main/scipy/linalg/decomp_cholesky.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.linalg` namespace for importing the functions
# included below.
import warnings
from . import _decomp_cholesky
__all__ = [ # noqa: F822
'cholesky', 'cho_factor', 'cho_solve', 'cholesky_banded',
'cho_solve_banded', '... | 917 | 29.6 | 79 | py |
scipy | scipy-main/scipy/linalg/basic.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.linalg` namespace for importing the functions
# included below.
import warnings
from . import _basic
__all__ = [ # noqa: F822
'solve', 'solve_triangular', 'solveh_banded', 'solve_banded',
'solve_toeplitz', 'solve_ci... | 1,026 | 31.09375 | 76 | py |
scipy | scipy-main/scipy/linalg/_decomp.py | #
# Author: Pearu Peterson, March 2002
#
# additions by Travis Oliphant, March 2002
# additions by Eric Jones, June 2002
# additions by Johannes Loehnert, June 2006
# additions by Bart Vandereycken, June 2006
# additions by Andrew D Straw, May 2007
# additions by Tiziano Zito, November 2008
#
# April 2010: Functio... | 61,501 | 37.342893 | 83 | py |
scipy | scipy-main/scipy/linalg/_decomp_polar.py | import numpy as np
from scipy.linalg import svd
__all__ = ['polar']
def polar(a, side="right"):
"""
Compute the polar decomposition.
Returns the factors of the polar decomposition [1]_ `u` and `p` such
that ``a = up`` (if `side` is "right") or ``a = pu`` (if `side` is
"left"), where `p` is posi... | 3,578 | 30.955357 | 77 | py |
scipy | scipy-main/scipy/linalg/tests/test_cythonized_array_utils.py | import numpy as np
from scipy.linalg import bandwidth, issymmetric, ishermitian
import pytest
from pytest import raises
def test_bandwidth_dtypes():
n = 5
for t in np.typecodes['All']:
A = np.zeros([n, n], dtype=t)
if t in 'eUVOMm':
raises(TypeError, bandwidth, A)
elif t ==... | 3,840 | 30.483607 | 71 | py |
scipy | scipy-main/scipy/linalg/tests/test_interpolative.py | #******************************************************************************
# Copyright (C) 2013 Kenneth L. Ho
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the... | 8,956 | 36.012397 | 79 | py |
scipy | scipy-main/scipy/linalg/tests/test_matfuncs.py | #
# Created by: Pearu Peterson, March 2002
#
""" Test functions for linalg.matfuncs module
"""
import random
import functools
import numpy as np
from numpy import array, identity, dot, sqrt
from numpy.testing import (assert_array_almost_equal, assert_allclose, assert_,
assert_array_less, as... | 38,684 | 38.676923 | 109 | py |
scipy | scipy-main/scipy/linalg/tests/test_decomp.py | import itertools
import platform
import sys
import numpy as np
from numpy.testing import (assert_equal, assert_almost_equal,
assert_array_almost_equal, assert_array_equal,
assert_, assert_allclose)
import pytest
from pytest import raises as assert_raises
from sci... | 104,327 | 36.951255 | 120 | py |
scipy | scipy-main/scipy/linalg/tests/test_solvers.py | import os
import numpy as np
from numpy.testing import assert_array_almost_equal, assert_allclose
import pytest
from pytest import raises as assert_raises
from scipy.linalg import solve_sylvester
from scipy.linalg import solve_continuous_lyapunov, solve_discrete_lyapunov
from scipy.linalg import solve_continuous_are,... | 31,556 | 39.6139 | 79 | py |
scipy | scipy-main/scipy/linalg/tests/test_procrustes.py | from itertools import product, permutations
import numpy as np
from numpy.testing import assert_array_less, assert_allclose
from pytest import raises as assert_raises
from scipy.linalg import inv, eigh, norm
from scipy.linalg import orthogonal_procrustes
from scipy.sparse._sputils import matrix
def test_orthogonal_... | 6,758 | 34.203125 | 80 | py |
scipy | scipy-main/scipy/linalg/tests/test_special_matrices.py | import pytest
import numpy as np
from numpy import arange, add, array, eye, copy, sqrt
from numpy.testing import (assert_equal, assert_array_equal,
assert_array_almost_equal, assert_allclose)
from pytest import raises as assert_raises
from scipy.fft import fft
from scipy.special import comb
... | 27,049 | 37.587732 | 79 | py |
scipy | scipy-main/scipy/linalg/tests/test_decomp_cossin.py | import pytest
import numpy as np
from numpy.random import seed
from numpy.testing import assert_allclose
from scipy.linalg.lapack import _compute_lwork
from scipy.stats import ortho_group, unitary_group
from scipy.linalg import cossin, get_lapack_funcs
REAL_DTYPES = (np.float32, np.float64)
COMPLEX_DTYPES = (np.compl... | 5,772 | 36.00641 | 78 | py |
scipy | scipy-main/scipy/linalg/tests/test_decomp_lu.py | import pytest
from pytest import raises as assert_raises
import numpy as np
from scipy.linalg import lu, lu_factor, lu_solve, get_lapack_funcs, solve
from numpy.testing import assert_allclose, assert_array_equal
class TestLU:
def setup_method(self):
self.rng = np.random.default_rng(1682281250228846)
... | 11,186 | 40.742537 | 79 | py |
scipy | scipy-main/scipy/linalg/tests/test_basic.py | import itertools
import warnings
import numpy as np
from numpy import (arange, array, dot, zeros, identity, conjugate, transpose,
float32)
from numpy.random import random
from numpy.testing import (assert_equal, assert_almost_equal, assert_,
assert_array_almost_equal, ass... | 69,820 | 37.490077 | 82 | py |
scipy | scipy-main/scipy/linalg/tests/test_fblas.py | # Test interfaces to fortran blas.
#
# The tests are more of interface than they are of the underlying blas.
# Only very small matrices checked -- N=3 or so.
#
# !! Complex calculations really aren't checked that carefully.
# !! Only real valued complex numbers are used in tests.
from numpy import float32, float64, co... | 18,685 | 29.733553 | 77 | py |
scipy | scipy-main/scipy/linalg/tests/test_decomp_ldl.py | from numpy.testing import assert_array_almost_equal, assert_allclose, assert_
from numpy import (array, eye, zeros, empty_like, empty, tril_indices_from,
tril, triu_indices_from, spacing, float32, float64,
complex64, complex128)
from numpy.random import rand, randint, seed
from sci... | 4,933 | 35.014599 | 78 | py |
scipy | scipy-main/scipy/linalg/tests/test_blas.py | #
# Created by: Pearu Peterson, April 2002
#
__usage__ = """
Build linalg:
python setup.py build
Run tests if scipy is installed:
python -c 'import scipy;scipy.linalg.test()'
"""
import math
import pytest
import numpy as np
from numpy.testing import (assert_equal, assert_almost_equal, assert_,
... | 40,417 | 35.676951 | 79 | py |
scipy | scipy-main/scipy/linalg/tests/test_sketches.py | """Tests for _sketches.py."""
import numpy as np
from numpy.testing import assert_, assert_equal
from scipy.linalg import clarkson_woodruff_transform
from scipy.linalg._sketches import cwt_matrix
from scipy.sparse import issparse, rand
from scipy.sparse.linalg import norm
class TestClarksonWoodruffTransform:
"""... | 3,960 | 32.285714 | 74 | py |
scipy | scipy-main/scipy/linalg/tests/test_misc.py | from scipy.linalg import norm
def test_norm():
assert norm([]) == 0.0
| 76 | 11.833333 | 29 | py |
scipy | scipy-main/scipy/linalg/tests/test_decomp_polar.py | import numpy as np
from numpy.linalg import norm
from numpy.testing import (assert_, assert_allclose, assert_equal)
from scipy.linalg import polar, eigh
diag2 = np.array([[2, 0], [0, 3]])
a13 = np.array([[1, 2, 2]])
precomputed_cases = [
[[[0]], 'right', [[1]], [[0]]],
[[[0]], 'left', [[1]], [[0]]],
[[[9... | 2,646 | 28.087912 | 66 | py |
scipy | scipy-main/scipy/linalg/tests/test_decomp_cholesky.py | from numpy.testing import assert_array_almost_equal, assert_array_equal
from pytest import raises as assert_raises
from numpy import array, transpose, dot, conjugate, zeros_like, empty
from numpy.random import random
from scipy.linalg import cholesky, cholesky_banded, cho_solve_banded, \
cho_factor, cho_solve
fr... | 7,265 | 34.793103 | 78 | py |
scipy | scipy-main/scipy/linalg/tests/test_solve_toeplitz.py | """Test functions for linalg._solve_toeplitz module
"""
import numpy as np
from scipy.linalg._solve_toeplitz import levinson
from scipy.linalg import solve, toeplitz, solve_toeplitz
from numpy.testing import assert_equal, assert_allclose
import pytest
from pytest import raises as assert_raises
def test_solve_equival... | 4,010 | 31.877049 | 79 | py |
scipy | scipy-main/scipy/linalg/tests/test_cython_blas.py | import numpy as np
from numpy.testing import (assert_allclose,
assert_equal)
import scipy.linalg.cython_blas as blas
class TestDGEMM:
def test_transposes(self):
a = np.arange(12, dtype='d').reshape((3, 4))[:2,:2]
b = np.arange(1, 13, dtype='d').reshape((4, 3))[:2,:2... | 4,087 | 33.352941 | 77 | py |
scipy | scipy-main/scipy/linalg/tests/test_cython_lapack.py | from numpy.testing import assert_allclose
from scipy.linalg import cython_lapack as cython_lapack
from scipy.linalg import lapack
class TestLamch:
def test_slamch(self):
for c in [b'e', b's', b'b', b'p', b'n', b'r', b'm', b'u', b'l', b'o']:
assert_allclose(cython_lapack._test_slamch(c),
... | 574 | 30.944444 | 78 | py |
scipy | scipy-main/scipy/linalg/tests/test_lapack.py | #
# Created by: Pearu Peterson, September 2002
#
import sys
from functools import reduce
from numpy.testing import (assert_equal, assert_array_almost_equal, assert_,
assert_allclose, assert_almost_equal,
assert_array_equal)
import pytest
from pytest import raises ... | 129,487 | 37.039953 | 80 | py |
scipy | scipy-main/scipy/linalg/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/linalg/tests/test_matmul_toeplitz.py | """Test functions for linalg.matmul_toeplitz function
"""
import numpy as np
from scipy.linalg import toeplitz, matmul_toeplitz
from pytest import raises as assert_raises
from numpy.testing import assert_allclose
class TestMatmulToeplitz:
def setup_method(self):
self.rng = np.random.RandomState(42)
... | 3,870 | 29.722222 | 74 | py |
scipy | scipy-main/scipy/linalg/tests/test_decomp_update.py | import itertools
import numpy as np
from numpy.testing import assert_, assert_allclose, assert_equal
from pytest import raises as assert_raises
from scipy import linalg
import scipy.linalg._decomp_update as _decomp_update
from scipy.linalg._decomp_update import qr_delete, qr_update, qr_insert
def assert_unitary(a, rt... | 68,486 | 39.262787 | 79 | py |
scipy | scipy-main/scipy/fftpack/pseudo_diffs.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.fftpack` namespace for importing the functions
# included below.
import warnings
from . import _pseudo_diffs
__all__ = [ # noqa: F822
'diff',
'tilbert', 'itilbert', 'hilbert', 'ihilbert',
'cs_diff', 'cc_diff', '... | 901 | 28.096774 | 78 | py |
scipy | scipy-main/scipy/fftpack/_realtransforms.py | """
Real spectrum transforms (DCT, DST, MDCT)
"""
__all__ = ['dct', 'idct', 'dst', 'idst', 'dctn', 'idctn', 'dstn', 'idstn']
from scipy.fft import _pocketfft
from ._helper import _good_shape
_inverse_typemap = {1: 1, 2: 3, 3: 2, 4: 4}
def dctn(x, type=2, shape=None, axes=None, norm=None, overwrite_x=False):
""... | 19,214 | 31.078464 | 80 | py |
scipy | scipy-main/scipy/fftpack/setup.py | # Created by Pearu Peterson, August 2002
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('fftpack',parent_package, top_path)
config.add_data_dir('tests')
config.add_extension('convolve', sources=['convolve.c'])
return... | 449 | 25.470588 | 62 | py |
scipy | scipy-main/scipy/fftpack/_basic.py | """
Discrete Fourier Transforms - _basic.py
"""
# Created by Pearu Peterson, August,September 2002
__all__ = ['fft','ifft','fftn','ifftn','rfft','irfft',
'fft2','ifft2']
from scipy.fft import _pocketfft
from ._helper import _good_shape
def fft(x, n=None, axis=-1, overwrite_x=False):
"""
Return dis... | 13,098 | 29.5338 | 78 | py |
scipy | scipy-main/scipy/fftpack/helper.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.fftpack` namespace for importing the functions
# included below.
import warnings
from . import _helper
__all__ = [ # noqa: F822
'fftshift', 'ifftshift', 'fftfreq', 'rfftfreq', 'next_fast_len'
]
def __dir__():
retu... | 795 | 27.428571 | 77 | py |
scipy | scipy-main/scipy/fftpack/_helper.py | import operator
from numpy.fft.helper import fftshift, ifftshift, fftfreq
import scipy.fft._pocketfft.helper as _helper
import numpy as np
__all__ = ['fftshift', 'ifftshift', 'fftfreq', 'rfftfreq', 'next_fast_len']
def rfftfreq(n, d=1.0):
"""DFT sample frequencies (for usage with rfft, irfft).
The returned f... | 3,354 | 28.690265 | 78 | py |
scipy | scipy-main/scipy/fftpack/realtransforms.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.fftpack` namespace for importing the functions
# included below.
import warnings
from . import _realtransforms
__all__ = [ # noqa: F822
'dct', 'idct', 'dst', 'idst', 'dctn', 'idctn', 'dstn', 'idstn'
]
def __dir__():
... | 826 | 28.535714 | 80 | py |
scipy | scipy-main/scipy/fftpack/__init__.py | """
=========================================================
Legacy discrete Fourier transforms (:mod:`scipy.fftpack`)
=========================================================
.. legacy::
New code should use :mod:`scipy.fft`.
Fast Fourier Transforms (FFTs)
==============================
.. autosummary::
:to... | 3,155 | 29.346154 | 78 | py |
scipy | scipy-main/scipy/fftpack/basic.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.fftpack` namespace for importing the functions
# included below.
import warnings
from . import _basic
__all__ = [ # noqa: F822
'fft','ifft','fftn','ifftn','rfft','irfft',
'fft2','ifft2'
]
def __dir__():
return... | 790 | 26.275862 | 77 | py |
scipy | scipy-main/scipy/fftpack/_pseudo_diffs.py | """
Differential and pseudo-differential operators.
"""
# Created by Pearu Peterson, September 2002
__all__ = ['diff',
'tilbert','itilbert','hilbert','ihilbert',
'cs_diff','cc_diff','sc_diff','ss_diff',
'shift']
from numpy import pi, asarray, sin, cos, sinh, cosh, tanh, iscomplexobj
f... | 14,200 | 24.726449 | 80 | py |
scipy | scipy-main/scipy/fftpack/tests/test_real_transforms.py | from os.path import join, dirname
import numpy as np
from numpy.testing import assert_array_almost_equal, assert_equal
import pytest
from pytest import raises as assert_raises
from scipy.fftpack._realtransforms import (
dct, idct, dst, idst, dctn, idctn, dstn, idstn)
# Matlab reference data
MDATA = np.load(join(... | 23,953 | 28.355392 | 86 | py |
scipy | scipy-main/scipy/fftpack/tests/gen_fftw_ref.py | from subprocess import Popen, PIPE, STDOUT
import numpy as np
SZ = [2, 3, 4, 8, 12, 15, 16, 17, 32, 64, 128, 256, 512, 1024]
def gen_data(dt):
arrays = {}
if dt == np.float128:
pg = './fftw_longdouble'
elif dt == np.double:
pg = './fftw_double'
elif dt == np.float32:
pg = '.... | 1,923 | 24.653333 | 77 | py |
scipy | scipy-main/scipy/fftpack/tests/test_basic.py | # Created by Pearu Peterson, September 2002
from numpy.testing import (assert_, assert_equal, assert_array_almost_equal,
assert_array_almost_equal_nulp, assert_array_less)
import pytest
from pytest import raises as assert_raises
from scipy.fftpack import ifft, fft, fftn, ifftn, rfft, irfft, ... | 30,284 | 33.730505 | 161 | py |
scipy | scipy-main/scipy/fftpack/tests/test_import.py | """Test possibility of patching fftpack with pyfftw.
No module source outside of scipy.fftpack should contain an import of
the form `from scipy.fftpack import ...`, so that a simple replacement
of scipy.fftpack by the corresponding fftw interface completely swaps
the two FFT implementations.
Because this simply inspe... | 1,120 | 34.03125 | 71 | py |
scipy | scipy-main/scipy/fftpack/tests/gendata.py | import numpy as np
from scipy.io import loadmat
m = loadmat('test.mat', squeeze_me=True, struct_as_record=True,
mat_dtype=True)
np.savez('test.npz', **m)
| 163 | 22.428571 | 63 | py |
scipy | scipy-main/scipy/fftpack/tests/test_pseudo_diffs.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_pseudo_diffs.py [<level>]
"""
from numpy.testing import (assert_... | 13,389 | 34.144357 | 83 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.