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/integrate/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/integrate/tests/test_integrate.py | # Authors: Nils Wagner, Ed Schofield, Pauli Virtanen, John Travers
"""
Tests for numerical integration.
"""
import numpy as np
from numpy import (arange, zeros, array, dot, sqrt, cos, sin, eye, pi, exp,
allclose)
from numpy.testing import (
assert_, assert_array_almost_equal,
assert_allclose... | 24,403 | 28.226347 | 79 | py |
scipy | scipy-main/scipy/integrate/tests/test_banded_ode_solvers.py | import itertools
import numpy as np
from numpy.testing import assert_allclose
from scipy.integrate import ode
def _band_count(a):
"""Returns ml and mu, the lower and upper band sizes of a."""
nrows, ncols = a.shape
ml = 0
for k in range(-nrows+1, 0):
if np.diag(a, k).any():
ml = -k... | 6,687 | 29.538813 | 77 | py |
scipy | scipy-main/scipy/integrate/_ivp/radau.py | import numpy as np
from scipy.linalg import lu_factor, lu_solve
from scipy.sparse import csc_matrix, issparse, eye
from scipy.sparse.linalg import splu
from scipy.optimize._numdiff import group_columns
from .common import (validate_max_step, validate_tol, select_initial_step,
norm, num_jac, EPS, wa... | 19,743 | 33.337391 | 80 | py |
scipy | scipy-main/scipy/integrate/_ivp/base.py | import numpy as np
def check_arguments(fun, y0, support_complex):
"""Helper function for checking arguments common to all solvers."""
y0 = np.asarray(y0)
if np.issubdtype(y0.dtype, np.complexfloating):
if not support_complex:
raise ValueError("`y0` is complex, but the chosen solver doe... | 10,295 | 34.381443 | 84 | py |
scipy | scipy-main/scipy/integrate/_ivp/lsoda.py | import numpy as np
from scipy.integrate import ode
from .common import validate_tol, validate_first_step, warn_extraneous
from .base import OdeSolver, DenseOutput
class LSODA(OdeSolver):
"""Adams/BDF method with automatic stiffness detection and switching.
This is a wrapper to the Fortran solver from ODEPACK... | 9,927 | 43.124444 | 84 | py |
scipy | scipy-main/scipy/integrate/_ivp/ivp.py | import inspect
import numpy as np
from .bdf import BDF
from .radau import Radau
from .rk import RK23, RK45, DOP853
from .lsoda import LSODA
from scipy.optimize import OptimizeResult
from .common import EPS, OdeSolution
from .base import OdeSolver
METHODS = {'RK23': RK23,
'RK45': RK45,
'DOP853': ... | 28,893 | 40.634006 | 92 | py |
scipy | scipy-main/scipy/integrate/_ivp/bdf.py | import numpy as np
from scipy.linalg import lu_factor, lu_solve
from scipy.sparse import issparse, csc_matrix, eye
from scipy.sparse.linalg import splu
from scipy.optimize._numdiff import group_columns
from .common import (validate_max_step, validate_tol, select_initial_step,
norm, EPS, num_jac, va... | 17,522 | 35.50625 | 83 | py |
scipy | scipy-main/scipy/integrate/_ivp/setup.py | def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('_ivp', parent_package, top_path)
config.add_data_dir('tests')
return config
if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(... | 343 | 27.666667 | 60 | py |
scipy | scipy-main/scipy/integrate/_ivp/rk.py | import numpy as np
from .base import OdeSolver, DenseOutput
from .common import (validate_max_step, validate_tol, select_initial_step,
norm, warn_extraneous, validate_first_step)
from . import dop853_coefficients
# Multiply steps computed from asymptotic behaviour of errors by this.
SAFETY = 0.9
... | 22,766 | 36.945 | 107 | py |
scipy | scipy-main/scipy/integrate/_ivp/common.py | from itertools import groupby
from warnings import warn
import numpy as np
from scipy.sparse import find, coo_matrix
EPS = np.finfo(float).eps
def validate_first_step(first_step, t0, t_bound):
"""Assert that first_step is valid and return it."""
if first_step <= 0:
raise ValueError("`first_step` mus... | 15,220 | 33.671982 | 79 | py |
scipy | scipy-main/scipy/integrate/_ivp/dop853_coefficients.py | import numpy as np
N_STAGES = 12
N_STAGES_EXTENDED = 16
INTERPOLATOR_POWER = 7
C = np.array([0.0,
0.526001519587677318785587544488e-01,
0.789002279381515978178381316732e-01,
0.118350341907227396726757197510,
0.281649658092772603273242802490,
0.3333... | 7,237 | 36.309278 | 57 | py |
scipy | scipy-main/scipy/integrate/_ivp/__init__.py | """Suite of ODE solvers implemented in Python."""
from .ivp import solve_ivp
from .rk import RK23, RK45, DOP853
from .radau import Radau
from .bdf import BDF
from .lsoda import LSODA
from .common import OdeSolution
from .base import DenseOutput, OdeSolver
| 256 | 27.555556 | 49 | py |
scipy | scipy-main/scipy/integrate/_ivp/tests/test_ivp.py | from itertools import product
from numpy.testing import (assert_, assert_allclose, assert_array_less,
assert_equal, assert_no_warnings, suppress_warnings)
import pytest
from pytest import raises as assert_raises
import numpy as np
from scipy.optimize._numdiff import group_columns
from scipy.i... | 35,940 | 31.852834 | 102 | py |
scipy | scipy-main/scipy/integrate/_ivp/tests/test_rk.py | import pytest
from numpy.testing import assert_allclose, assert_
import numpy as np
from scipy.integrate import RK23, RK45, DOP853
from scipy.integrate._ivp import dop853_coefficients
@pytest.mark.parametrize("solver", [RK23, RK45, DOP853])
def test_coefficient_properties(solver):
assert_allclose(np.sum(solver.B)... | 1,326 | 33.921053 | 72 | py |
scipy | scipy-main/scipy/integrate/_ivp/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/sparse/dia.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _dia
__all__ = [ # noqa: F822
'check_shape',
'dia_matrix',
'dia_matvec',
'get_index_dtype',
'get_sum_dtype',... | 936 | 22.425 | 76 | py |
scipy | scipy-main/scipy/sparse/_index.py | """Indexing mixin for sparse matrix classes.
"""
import numpy as np
from warnings import warn
from ._sputils import isintlike
INT_TYPES = (int, np.integer)
def _broadcast_arrays(a, b):
"""
Same as np.broadcast_arrays(a, b) but old writeability rules.
NumPy >= 1.17.0 transitions broadcast_arrays to retur... | 12,931 | 32.58961 | 79 | py |
scipy | scipy-main/scipy/sparse/base.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _base
__all__ = [ # noqa: F822
'MAXPRINT',
'SparseEfficiencyWarning',
'SparseFormatWarning',
'SparseWarning',
... | 1,016 | 22.651163 | 76 | py |
scipy | scipy-main/scipy/sparse/sparsetools.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _sparsetools
__all__ = [ # noqa: F822
'bsr_diagonal',
'bsr_eldiv_bsr',
'bsr_elmul_bsr',
'bsr_ge_bsr',
'bsr_g... | 2,390 | 21.345794 | 76 | py |
scipy | scipy-main/scipy/sparse/_dok.py | """Dictionary Of Keys based matrix"""
__docformat__ = "restructuredtext en"
__all__ = ['dok_array', 'dok_matrix', 'isspmatrix_dok']
import itertools
import numpy as np
from ._matrix import spmatrix, _array_doc_to_matrix
from ._base import _spbase, sparray, issparse
from ._index import IndexMixin
from ._sputils impo... | 16,352 | 33.572939 | 87 | py |
scipy | scipy-main/scipy/sparse/_sputils.py | """ Utility functions for sparse matrix module
"""
import sys
import operator
import numpy as np
from math import prod
import scipy.sparse as sp
__all__ = ['upcast', 'getdtype', 'getdata', 'isscalarlike', 'isintlike',
'isshape', 'issequence', 'isdense', 'ismatrix', 'get_sum_dtype']
supported_dtypes = [np... | 13,023 | 30.61165 | 80 | py |
scipy | scipy-main/scipy/sparse/_data.py | """Base class for sparse matrice with a .data attribute
subclasses must provide a _with_data() method that
creates a new matrix with the same sparsity pattern
as self but with a different data array
"""
import numpy as np
from ._base import _spbase, _ufuncs_with_fixed_point_at_zero
from ._sputils import... | 16,409 | 32.627049 | 84 | py |
scipy | scipy-main/scipy/sparse/csr.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _csr
__all__ = [ # noqa: F822
'csr_count_blocks',
'csr_matrix',
'csr_tobsr',
'csr_tocsc',
'get_csr_submatrix... | 887 | 23 | 76 | py |
scipy | scipy-main/scipy/sparse/spfuncs.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _spfuncs
__all__ = [ # noqa: F822
'isspmatrix_csr', 'csr_matrix', 'isspmatrix_csc', 'csr_count_blocks',
'estimate_blocks... | 842 | 27.1 | 76 | py |
scipy | scipy-main/scipy/sparse/_extract.py | """Functions to extract parts of sparse matrices
"""
__docformat__ = "restructuredtext en"
__all__ = ['find', 'tril', 'triu']
from ._coo import coo_matrix
def find(A):
"""Return the indices and values of the nonzero elements of a matrix
Parameters
----------
A : dense or sparse matrix
Mat... | 4,648 | 26.347059 | 90 | py |
scipy | scipy-main/scipy/sparse/compressed.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _compressed
__all__ = [ # noqa: F822
'IndexMixin',
'SparseEfficiencyWarning',
'check_shape',
'csr_column_index1'... | 1,286 | 22.4 | 76 | py |
scipy | scipy-main/scipy/sparse/setup.py | import os
import sys
import subprocess
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
from scipy._build_utils.compiler_helper import set_cxx_flags_hook
from scipy._build_utils import numpy_nodepr_api
config = Configuration('sparse',parent_packag... | 2,319 | 35.25 | 105 | py |
scipy | scipy-main/scipy/sparse/bsr.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _bsr
__all__ = [ # noqa: F822
'bsr_matmat',
'bsr_matrix',
'bsr_matvec',
'bsr_matvecs',
'bsr_sort_indices',
... | 1,058 | 21.531915 | 76 | py |
scipy | scipy-main/scipy/sparse/_matrix.py | from ._sputils import isintlike, isscalarlike
class spmatrix:
"""This class provides a base class for all sparse matrix classes.
It cannot be instantiated. Most of the work is provided by subclasses.
"""
_is_array = False
@property
def _bsr_container(self):
from ._bsr import bsr_mat... | 4,036 | 25.913333 | 76 | py |
scipy | scipy-main/scipy/sparse/dok.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _dok
__all__ = [ # noqa: F822
'IndexMixin',
'check_shape',
'dok_matrix',
'get_index_dtype',
'getdtype',
... | 980 | 21.813953 | 76 | py |
scipy | scipy-main/scipy/sparse/csc.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _csc
__all__ = [ # noqa: F822
'csc_matrix',
'csc_tocsr',
'expandptr',
'get_index_dtype',
'isspmatrix_csc',
... | 838 | 22.971429 | 76 | py |
scipy | scipy-main/scipy/sparse/extract.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _extract
__all__ = [ # noqa: F822
'coo_matrix',
'find',
'tril',
'triu',
]
def __dir__():
return __all__
... | 781 | 23.4375 | 76 | py |
scipy | scipy-main/scipy/sparse/_bsr.py | """Compressed Block Sparse Row format"""
__docformat__ = "restructuredtext en"
__all__ = ['bsr_array', 'bsr_matrix', 'isspmatrix_bsr']
from warnings import warn
import numpy as np
from ._matrix import spmatrix, _array_doc_to_matrix
from ._data import _data_matrix, _minmax_mixin
from ._compressed import _cs_matrix
... | 26,014 | 34.155405 | 114 | py |
scipy | scipy-main/scipy/sparse/data.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _data
__all__ = [ # noqa: F822
'isscalarlike',
'matrix',
'name',
'npfunc',
'spmatrix',
'validateaxis',
]... | 811 | 22.882353 | 76 | py |
scipy | scipy-main/scipy/sparse/_dia.py | """Sparse DIAgonal format"""
__docformat__ = "restructuredtext en"
__all__ = ['dia_array', 'dia_matrix', 'isspmatrix_dia']
import numpy as np
from ._matrix import spmatrix, _array_doc_to_matrix
from ._base import issparse, _formats, _spbase, sparray
from ._data import _data_matrix
from ._sputils import (isshape, up... | 16,458 | 33.147303 | 105 | py |
scipy | scipy-main/scipy/sparse/_lil.py | """List of Lists sparse matrix class
"""
__docformat__ = "restructuredtext en"
__all__ = ['lil_array', 'lil_matrix', 'isspmatrix_lil']
from bisect import bisect_left
import numpy as np
from ._matrix import spmatrix, _array_doc_to_matrix
from ._base import _spbase, sparray, issparse
from ._index import IndexMixin, ... | 18,618 | 32.248214 | 87 | py |
scipy | scipy-main/scipy/sparse/construct.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _construct
__all__ = [ # noqa: F822
'block_diag',
'bmat',
'bsr_matrix',
'check_random_state',
'coo_matrix',
... | 1,158 | 20.462963 | 76 | py |
scipy | scipy-main/scipy/sparse/_generate_sparsetools.py | """
python generate_sparsetools.py
Generate manual wrappers for C++ sparsetools code.
Type codes used:
'i': integer scalar
'I': integer array
'T': data array
'B': boolean array
'V': std::vector<integer>*
'W': std::vector<data>*
'*': indicates that the next argument is an output arg... | 13,723 | 28.834783 | 98 | py |
scipy | scipy-main/scipy/sparse/_spfuncs.py | """ Functions that operate on sparse matrices
"""
__all__ = ['count_blocks','estimate_blocksize']
from ._base import issparse
from ._csr import csr_array
from ._sparsetools import csr_count_blocks
def estimate_blocksize(A,efficiency=0.7):
"""Attempt to determine the blocksize of a sparse matrix
Returns a b... | 1,987 | 24.818182 | 74 | py |
scipy | scipy-main/scipy/sparse/_compressed.py | """Base class for sparse matrix formats using compressed storage."""
__all__ = []
from warnings import warn
import operator
import numpy as np
from scipy._lib._util import _prune_array
from ._base import _spbase, issparse, SparseEfficiencyWarning
from ._data import _data_matrix, _minmax_mixin
from . import _sparseto... | 51,332 | 37.859198 | 106 | py |
scipy | scipy-main/scipy/sparse/_base.py | """Base class for sparse matrices"""
from warnings import warn
import numpy as np
from ._sputils import (asmatrix, check_reshape_kwargs, check_shape,
get_sum_dtype, isdense, isscalarlike,
matrix, validateaxis,)
from ._matrix import spmatrix
__all__ = ['isspmatrix', 'iss... | 50,003 | 31.962426 | 87 | py |
scipy | scipy-main/scipy/sparse/_matrix_io.py | import numpy as np
import scipy.sparse
__all__ = ['save_npz', 'load_npz']
# Make loading safe vs. malicious input
PICKLE_KWARGS = dict(allow_pickle=False)
def save_npz(file, matrix, compressed=True):
""" Save a sparse matrix to a file using ``.npz`` format.
Parameters
----------
file : str or file... | 5,347 | 34.184211 | 106 | py |
scipy | scipy-main/scipy/sparse/_csr.py | """Compressed Sparse Row matrix format"""
__docformat__ = "restructuredtext en"
__all__ = ['csr_array', 'csr_matrix', 'isspmatrix_csr']
import numpy as np
from ._matrix import spmatrix, _array_doc_to_matrix
from ._base import _spbase, sparray
from ._sparsetools import (csr_tocsc, csr_tobsr, csr_count_blocks,
... | 12,064 | 31.259358 | 82 | py |
scipy | scipy-main/scipy/sparse/sputils.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _sputils
__all__ = [ # noqa: F822
'asmatrix',
'check_reshape_kwargs',
'check_shape',
'downcast_intp_index',
... | 1,187 | 21.415094 | 76 | py |
scipy | scipy-main/scipy/sparse/__init__.py | """
=====================================
Sparse matrices (:mod:`scipy.sparse`)
=====================================
.. currentmodule:: scipy.sparse
.. toctree::
:hidden:
sparse.csgraph
sparse.linalg
SciPy 2-D sparse array package for numeric data.
.. note::
This package is switching to an array inte... | 8,781 | 27.329032 | 92 | py |
scipy | scipy-main/scipy/sparse/coo.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _coo
__all__ = [ # noqa: F822
'SparseEfficiencyWarning',
'check_reshape_kwargs',
'check_shape',
'coo_matrix',
... | 1,091 | 21.75 | 76 | py |
scipy | scipy-main/scipy/sparse/_coo.py | """ A sparse matrix in COOrdinate or 'triplet' format"""
__docformat__ = "restructuredtext en"
__all__ = ['coo_array', 'coo_matrix', 'isspmatrix_coo']
from warnings import warn
import numpy as np
from ._matrix import spmatrix, _array_doc_to_matrix
from ._sparsetools import coo_tocsr, coo_todense, coo_matvec
from .... | 23,095 | 35.200627 | 106 | py |
scipy | scipy-main/scipy/sparse/lil.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse` namespace for importing the functions
# included below.
import warnings
from . import _lil
__all__ = [ # noqa: F822
'INT_TYPES',
'IndexMixin',
'bisect_left',
'check_reshape_kwargs',
'check_shape... | 981 | 22.380952 | 76 | py |
scipy | scipy-main/scipy/sparse/_construct.py | """Functions to construct sparse matrices and arrays
"""
__docformat__ = "restructuredtext en"
__all__ = ['spdiags', 'eye', 'identity', 'kron', 'kronsum',
'hstack', 'vstack', 'bmat', 'rand', 'random', 'diags', 'block_diag',
'diags_array']
import numbers
from functools import partial
import nump... | 32,912 | 30.954369 | 85 | py |
scipy | scipy-main/scipy/sparse/_csc.py | """Compressed Sparse Column matrix format"""
__docformat__ = "restructuredtext en"
__all__ = ['csc_array', 'csc_matrix', 'isspmatrix_csc']
import numpy as np
from ._matrix import spmatrix, _array_doc_to_matrix
from ._base import _spbase, sparray
from ._sparsetools import csc_tocsr, expandptr
from ._sputils import u... | 8,297 | 29.065217 | 82 | py |
scipy | scipy-main/scipy/sparse/csgraph/setup.py | def configuration(parent_package='', top_path=None):
import numpy
from numpy.distutils.misc_util import Configuration
config = Configuration('csgraph', parent_package, top_path)
config.add_data_dir('tests')
config.add_extension('_shortest_path',
sources=['_shortest_path.c'],
inc... | 1,098 | 27.921053 | 63 | py |
scipy | scipy-main/scipy/sparse/csgraph/_validation.py | import numpy as np
from scipy.sparse import csr_matrix, issparse
from ._tools import csgraph_to_dense, csgraph_from_dense,\
csgraph_masked_from_dense, csgraph_from_masked
DTYPE = np.float64
def validate_graph(csgraph, directed, dtype=DTYPE,
csr_output=True, dense_output=True,
... | 2,329 | 39.877193 | 77 | py |
scipy | scipy-main/scipy/sparse/csgraph/_laplacian.py | """
Laplacian of a compressed-sparse graph
"""
import numpy as np
from scipy.sparse import issparse
from scipy.sparse.linalg import LinearOperator
###############################################################################
# Graph laplacian
def laplacian(
csgraph,
normed=False,
return_diag=False,
... | 17,827 | 31.064748 | 79 | py |
scipy | scipy-main/scipy/sparse/csgraph/__init__.py | r"""
Compressed sparse graph routines (:mod:`scipy.sparse.csgraph`)
==============================================================
.. currentmodule:: scipy.sparse.csgraph
Fast graph algorithms based on sparse matrix representations.
Contents
--------
.. autosummary::
:toctree: generated/
connected_components... | 7,739 | 36.033493 | 99 | py |
scipy | scipy-main/scipy/sparse/csgraph/tests/test_spanning_tree.py | """Test the minimum spanning tree function"""
import numpy as np
from numpy.testing import assert_
import numpy.testing as npt
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import minimum_spanning_tree
def test_minimum_spanning_tree():
# Create a graph with two connected components.
graph = [... | 2,115 | 31.060606 | 74 | py |
scipy | scipy-main/scipy/sparse/csgraph/tests/test_flow.py | import numpy as np
from numpy.testing import assert_array_equal
import pytest
from scipy.sparse import csr_matrix, csc_matrix
from scipy.sparse.csgraph import maximum_flow
from scipy.sparse.csgraph._flow import (
_add_reverse_edges, _make_edge_pointers, _make_tails
)
methods = ['edmonds_karp', 'dinic']
def test_... | 7,420 | 35.737624 | 75 | py |
scipy | scipy-main/scipy/sparse/csgraph/tests/test_conversions.py | import numpy as np
from numpy.testing import assert_array_almost_equal
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import csgraph_from_dense, csgraph_to_dense
def test_csgraph_from_dense():
np.random.seed(1234)
G = np.random.random((10, 10))
some_nulls = (G < 0.4)
all_nulls = (G < 0.... | 1,855 | 28.935484 | 73 | py |
scipy | scipy-main/scipy/sparse/csgraph/tests/test_graph_laplacian.py | import pytest
import numpy as np
from numpy.testing import assert_allclose
from pytest import raises as assert_raises
from scipy import sparse
from scipy.sparse import csgraph
def check_int_type(mat):
return np.issubdtype(mat.dtype, np.signedinteger) or np.issubdtype(
mat.dtype, np.uint
)
def test_... | 10,623 | 28.593315 | 76 | py |
scipy | scipy-main/scipy/sparse/csgraph/tests/test_matching.py | from itertools import product
import numpy as np
from numpy.testing import assert_array_equal, assert_equal
import pytest
from scipy.sparse import csr_matrix, coo_matrix, diags
from scipy.sparse.csgraph import (
maximum_bipartite_matching, min_weight_full_bipartite_matching
)
def test_maximum_bipartite_matching... | 8,532 | 34.554167 | 79 | py |
scipy | scipy-main/scipy/sparse/csgraph/tests/test_connected_components.py | import numpy as np
from numpy.testing import assert_equal, assert_array_almost_equal
from scipy.sparse import csgraph
def test_weak_connections():
Xde = np.array([[0, 1, 0],
[0, 0, 0],
[0, 0, 0]])
Xsp = csgraph.csgraph_from_dense(Xde, null_value=0)
for X in Xsp, X... | 3,199 | 31 | 79 | py |
scipy | scipy-main/scipy/sparse/csgraph/tests/test_reordering.py | import numpy as np
from numpy.testing import assert_equal
from scipy.sparse.csgraph import reverse_cuthill_mckee, structural_rank
from scipy.sparse import csc_matrix, csr_matrix, coo_matrix
def test_graph_reverse_cuthill_mckee():
A = np.array([[1, 0, 0, 0, 1, 0, 0, 0],
[0, 1, 1, 0, 0, 1, 0, 1],
... | 2,613 | 35.816901 | 71 | py |
scipy | scipy-main/scipy/sparse/csgraph/tests/test_traversal.py | import numpy as np
from numpy.testing import assert_array_almost_equal
from scipy.sparse.csgraph import (breadth_first_tree, depth_first_tree,
csgraph_to_dense, csgraph_from_dense)
def test_graph_breadth_first():
csgraph = np.array([[0, 1, 2, 0, 0],
[1, 0, 0, 0, 3],
... | 2,325 | 32.710145 | 71 | py |
scipy | scipy-main/scipy/sparse/csgraph/tests/test_shortest_path.py | from io import StringIO
import warnings
import numpy as np
from numpy.testing import assert_array_almost_equal, assert_array_equal, assert_allclose
from pytest import raises as assert_raises
from scipy.sparse.csgraph import (shortest_path, dijkstra, johnson,
bellman_ford, construct_dis... | 14,441 | 35.469697 | 88 | py |
scipy | scipy-main/scipy/sparse/csgraph/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/sparse/tests/test_deprecations.py | import scipy as sp
import pytest
def test_array_api_deprecations():
X = sp.sparse.csr_array([
[1,2,3],
[4,0,6]
])
msg = "1.13.0"
with pytest.deprecated_call(match=msg):
X.get_shape()
with pytest.deprecated_call(match=msg):
X.set_shape((2,3))
with pytest.depre... | 709 | 19.285714 | 43 | py |
scipy | scipy-main/scipy/sparse/tests/test_spfuncs.py | from numpy import array, kron, diag
from numpy.testing import assert_, assert_equal
from scipy.sparse import _spfuncs as spfuncs
from scipy.sparse import csr_matrix, csc_matrix, bsr_matrix
from scipy.sparse._sparsetools import (csr_scale_rows, csr_scale_columns,
bsr_scale_rows, b... | 3,258 | 32.255102 | 86 | py |
scipy | scipy-main/scipy/sparse/tests/test_sputils.py | """unit tests for sparse utility functions"""
import numpy as np
from numpy.testing import assert_equal
from pytest import raises as assert_raises
from scipy.sparse import _sputils as sputils
from scipy.sparse._sputils import matrix
class TestSparseUtils:
def test_upcast(self):
assert_equal(sputils.upca... | 7,297 | 36.045685 | 79 | py |
scipy | scipy-main/scipy/sparse/tests/test_extract.py | """test sparse matrix construction functions"""
from numpy.testing import assert_equal
from scipy.sparse import csr_matrix
import numpy as np
from scipy.sparse import _extract
class TestExtract:
def setup_method(self):
self.cases = [
csr_matrix([[1,2]]),
csr_matrix([[1,0]]),
... | 1,313 | 29.55814 | 76 | py |
scipy | scipy-main/scipy/sparse/tests/test_csr.py | import numpy as np
from numpy.testing import assert_array_almost_equal, assert_
from scipy.sparse import csr_matrix, hstack
import pytest
def _check_csr_rowslice(i, sl, X, Xcsr):
np_slice = X[i, sl]
csr_slice = Xcsr[i, sl]
assert_array_almost_equal(np_slice, csr_slice.toarray()[0])
assert_(type(csr_sl... | 5,651 | 32.247059 | 86 | py |
scipy | scipy-main/scipy/sparse/tests/test_construct.py | """test sparse matrix construction functions"""
import numpy as np
from numpy import array
from numpy.testing import (assert_equal, assert_,
assert_array_equal, assert_array_almost_equal_nulp)
import pytest
from pytest import raises as assert_raises
from scipy._lib._testutils import check_free_memory
from scip... | 26,565 | 41.710611 | 107 | py |
scipy | scipy-main/scipy/sparse/tests/test_matrix_io.py | import os
import numpy as np
import tempfile
from pytest import raises as assert_raises
from numpy.testing import assert_equal, assert_
from scipy.sparse import (csc_matrix, csr_matrix, bsr_matrix, dia_matrix,
coo_matrix, save_npz, load_npz, dok_matrix)
DATA_DIR = os.path.join(os.path.dirn... | 2,542 | 28.229885 | 85 | py |
scipy | scipy-main/scipy/sparse/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/sparse/tests/test_sparsetools.py | import sys
import os
import gc
import threading
import numpy as np
from numpy.testing import assert_equal, assert_, assert_allclose
from scipy.sparse import (_sparsetools, coo_matrix, csr_matrix, csc_matrix,
bsr_matrix, dia_matrix)
from scipy.sparse._sputils import supported_dtypes
from scipy... | 10,553 | 30.224852 | 95 | py |
scipy | scipy-main/scipy/sparse/tests/test_base.py | #
# Authors: Travis Oliphant, Ed Schofield, Robert Cimrman, Nathan Bell, and others
""" Test functions for sparse matrices. Each class in the "Matrix class
based tests" section become subclasses of the classes in the "Generic
tests" section. This is done by the functions in the "Tailored base
class for generic tests" ... | 186,416 | 35.75414 | 122 | py |
scipy | scipy-main/scipy/sparse/tests/test_array_api.py | import pytest
import numpy as np
import numpy.testing as npt
import scipy.sparse
import scipy.sparse.linalg as spla
sparray_types = ('bsr', 'coo', 'csc', 'csr', 'dia', 'dok', 'lil')
sparray_classes = [
getattr(scipy.sparse, f'{T}_array') for T in sparray_types
]
A = np.array([
[0, 1, 2, 0],
[2, 0, 0, 3],... | 13,436 | 23.520073 | 78 | py |
scipy | scipy-main/scipy/sparse/tests/test_csc.py | import numpy as np
from numpy.testing import assert_array_almost_equal, assert_
from scipy.sparse import csr_matrix, csc_matrix, lil_matrix
import pytest
def test_csc_getrow():
N = 10
np.random.seed(0)
X = np.random.random((N, N))
X[X > 0.7] = 0
Xcsc = csc_matrix(X)
for i in range(N):
... | 2,902 | 28.323232 | 79 | py |
scipy | scipy-main/scipy/sparse/linalg/_expm_multiply.py | """Compute the action of the matrix exponential."""
from warnings import warn
import numpy as np
import scipy.linalg
import scipy.sparse.linalg
from scipy.linalg._decomp_qr import qr
from scipy.sparse._sputils import is_pydata_spmatrix
from scipy.sparse.linalg import aslinearoperator
from scipy.sparse.linalg._interfa... | 26,296 | 31.425401 | 80 | py |
scipy | scipy-main/scipy/sparse/linalg/_svdp.py | """
Python wrapper for PROPACK
--------------------------
PROPACK is a collection of Fortran routines for iterative computation
of partial SVDs of large matrices or linear operators.
Based on BSD licensed pypropack project:
http://github.com/jakevdp/pypropack
Author: Jake Vanderplas <vanderplas@astro.washington.e... | 11,685 | 35.291925 | 79 | py |
scipy | scipy-main/scipy/sparse/linalg/setup.py | def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('linalg', parent_package, top_path)
config.add_subpackage('_isolve')
config.add_subpackage('_dsolve')
config.add_subpackage('_eigen')
config.add_data_dir('tests')
... | 511 | 23.380952 | 62 | py |
scipy | scipy-main/scipy/sparse/linalg/eigen.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse.linalg` namespace for importing the functions
# included below.
import warnings
from . import _eigen
__all__ = [ # noqa: F822
'ArpackError', 'ArpackNoConvergence',
'eigs', 'eigsh', 'lobpcg', 'svds', 'arpack'... | 1,151 | 29.315789 | 79 | py |
scipy | scipy-main/scipy/sparse/linalg/isolve.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse.linalg` namespace for importing the functions
# included below.
import warnings
from . import _isolve
__all__ = [ # noqa: F822
'bicg', 'bicgstab', 'cg', 'cgs', 'gcrotmk', 'gmres',
'lgmres', 'lsmr', 'lsqr',
... | 904 | 28.193548 | 83 | py |
scipy | scipy-main/scipy/sparse/linalg/matfuncs.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse.linalg` namespace for importing the functions
# included below.
import warnings
from . import _matfuncs
__all__ = [ # noqa: F822
'expm', 'inv', 'solve', 'solve_triangular',
'isspmatrix', 'spsolve', 'is_pydat... | 948 | 29.612903 | 83 | py |
scipy | scipy-main/scipy/sparse/linalg/_norm.py | """Sparse matrix norms.
"""
import numpy as np
from scipy.sparse import issparse
from scipy.sparse.linalg import svds
import scipy.sparse as sp
from numpy import sqrt, abs
__all__ = ['norm']
def _sparse_frobenius_norm(x):
data = sp._sputils._todata(x)
return np.linalg.norm(data)
def norm(x, ord=None, axi... | 6,069 | 30.28866 | 79 | py |
scipy | scipy-main/scipy/sparse/linalg/_onenormest.py | """Sparse block 1-norm estimator.
"""
import numpy as np
from scipy.sparse.linalg import aslinearoperator
__all__ = ['onenormest']
def onenormest(A, t=2, itmax=5, compute_v=False, compute_w=False):
"""
Compute a lower bound of the 1-norm of a sparse matrix.
Parameters
----------
A : ndarray or... | 15,486 | 32.09188 | 80 | py |
scipy | scipy-main/scipy/sparse/linalg/dsolve.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse.linalg` namespace for importing the functions
# included below.
import warnings
from . import _dsolve
__all__ = [ # noqa: F822
'MatrixRankWarning', 'SuperLU', 'factorized',
'spilu', 'splu', 'spsolve',
's... | 1,203 | 29.871795 | 79 | py |
scipy | scipy-main/scipy/sparse/linalg/__init__.py | """
Sparse linear algebra (:mod:`scipy.sparse.linalg`)
==================================================
.. currentmodule:: scipy.sparse.linalg
Abstract linear operators
-------------------------
.. autosummary::
:toctree: generated/
LinearOperator -- abstract representation of a linear operator
aslinearo... | 3,717 | 26.138686 | 84 | py |
scipy | scipy-main/scipy/sparse/linalg/interface.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.sparse.linalg` namespace for importing the functions
# included below.
import warnings
from . import _interface
__all__ = [ # noqa: F822
'LinearOperator', 'aslinearoperator',
'isspmatrix', 'isshape', 'isintlike', '... | 935 | 29.193548 | 83 | py |
scipy | scipy-main/scipy/sparse/linalg/_matfuncs.py | """
Sparse matrix functions
"""
#
# Authors: Travis Oliphant, March 2002
# Anthony Scopatz, August 2012 (Sparse Updates)
# Jake Vanderplas, August 2012 (Sparse Updates)
#
__all__ = ['expm', 'inv']
import numpy as np
from scipy.linalg._basic import solve, solve_triangular
from scipy.sparse._base im... | 27,210 | 30.494213 | 93 | py |
scipy | scipy-main/scipy/sparse/linalg/_interface.py | """Abstract linear algebra library.
This module defines a class hierarchy that implements a kind of "lazy"
matrix representation, called the ``LinearOperator``. It can be used to do
linear algebra with extremely large sparse or structured matrices, without
representing those explicitly in memory. Such matrices can be ... | 27,845 | 30.112849 | 82 | py |
scipy | scipy-main/scipy/sparse/linalg/_dsolve/setup.py | from os.path import join, dirname
import sys
import glob
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import get_info
from scipy._build_utils import numpy_nodepr_api
config = Configuration('_dsolve',parent_pac... | 1,614 | 28.907407 | 61 | py |
scipy | scipy-main/scipy/sparse/linalg/_dsolve/linsolve.py | from warnings import warn
import numpy as np
from numpy import asarray
from scipy.sparse import (issparse,
SparseEfficiencyWarning, csc_matrix, csr_matrix)
from scipy.sparse._sputils import is_pydata_spmatrix
from scipy.linalg import LinAlgError
import copy
from . import _superlu
noScikit =... | 26,180 | 34.236878 | 80 | py |
scipy | scipy-main/scipy/sparse/linalg/_dsolve/_add_newdocs.py | from numpy.lib import add_newdoc
add_newdoc('scipy.sparse.linalg._dsolve._superlu', 'SuperLU',
"""
LU factorization of a sparse matrix.
Factorization is represented as::
Pr @ A @ Pc = L @ U
To construct these `SuperLU` objects, call the `splu` and `spilu`
functions.
Attributes
-... | 3,795 | 23.810458 | 75 | py |
scipy | scipy-main/scipy/sparse/linalg/_dsolve/__init__.py | """
Linear Solvers
==============
The default solver is SuperLU (included in the scipy distribution),
which can solve real or complex linear systems in both single and
double precisions. It is automatically replaced by UMFPACK, if
available. Note that UMFPACK works in double precision only, so
switch it off by::
... | 1,991 | 26.666667 | 70 | py |
scipy | scipy-main/scipy/sparse/linalg/_dsolve/tests/test_linsolve.py | import sys
import threading
import numpy as np
from numpy import array, finfo, arange, eye, all, unique, ones, dot
import numpy.random as random
from numpy.testing import (
assert_array_almost_equal, assert_almost_equal,
assert_equal, assert_array_equal, assert_, assert_allclose,
assert_warns, ... | 27,633 | 33.456359 | 90 | py |
scipy | scipy-main/scipy/sparse/linalg/_dsolve/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/sparse/linalg/tests/test_norm.py | """Test functions for the sparse.linalg.norm module
"""
import pytest
import numpy as np
from numpy.linalg import norm as npnorm
from numpy.testing import assert_allclose, assert_equal
from pytest import raises as assert_raises
import scipy.sparse
from scipy.sparse.linalg import norm as spnorm
# https://github.com/... | 6,163 | 42.408451 | 79 | py |
scipy | scipy-main/scipy/sparse/linalg/tests/test_matfuncs.py | #
# Created by: Pearu Peterson, March 2002
#
""" Test functions for scipy.linalg._matfuncs module
"""
import math
import numpy as np
from numpy import array, eye, exp, random
from numpy.linalg import matrix_power
from numpy.testing import (
assert_allclose, assert_, assert_array_almost_equal, assert_equal,
... | 21,280 | 35.565292 | 91 | py |
scipy | scipy-main/scipy/sparse/linalg/tests/test_interface.py | """Test functions for the sparse.linalg._interface module
"""
from functools import partial
from itertools import product
import operator
from pytest import raises as assert_raises, warns
from numpy.testing import assert_, assert_equal
import numpy as np
import scipy.sparse as sparse
import scipy.sparse.linalg._inte... | 17,943 | 36.228216 | 84 | py |
scipy | scipy-main/scipy/sparse/linalg/tests/test_pydata_sparse.py | import pytest
import numpy as np
import scipy.sparse as sp
import scipy.sparse.linalg as splin
from numpy.testing import assert_allclose, assert_equal
try:
import sparse
except Exception:
sparse = None
pytestmark = pytest.mark.skipif(sparse is None,
reason="pydata/sparse not ... | 6,124 | 24.309917 | 76 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.