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/constants/codata.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 _codata
__all__ = [ # noqa: F822
'physical_constants', 'value', 'unit', 'precision', 'find',
'ConstantWarning', 'txt20... | 1,015 | 29.787879 | 79 | py |
scipy | scipy-main/scipy/constants/__init__.py | r"""
==================================
Constants (:mod:`scipy.constants`)
==================================
.. currentmodule:: scipy.constants
Physical and mathematical constants and units.
Mathematical constants
======================
================ ===========================================================... | 12,423 | 34.701149 | 94 | py |
scipy | scipy-main/scipy/constants/_codata.py | """
Fundamental Physical Constants
------------------------------
These constants are taken from CODATA Recommended Values of the Fundamental
Physical Constants 2018.
Object
------
physical_constants : dict
A dictionary containing physical constants. Keys are the names of physical
constants, values are tuples... | 155,622 | 87.978273 | 124 | py |
scipy | scipy-main/scipy/constants/_constants.py | """
Collection of physical constants and conversion factors.
Most constants are in SI units, so you can do
print '10 mile per minute is', 10*mile/minute, 'm/s or', 10*mile/(minute*knot), 'knots'
The list is not meant to be comprehensive, but just convenient for everyday use.
"""
from __future__ import annotations
i... | 10,369 | 27.646409 | 93 | py |
scipy | scipy-main/scipy/constants/tests/test_constants.py | from numpy.testing import assert_equal, assert_allclose
import scipy.constants as sc
def test_convert_temperature():
assert_equal(sc.convert_temperature(32, 'f', 'Celsius'), 0)
assert_equal(sc.convert_temperature([0, 0], 'celsius', 'Kelvin'),
[273.15, 273.15])
assert_equal(sc.convert_temp... | 1,632 | 44.361111 | 79 | py |
scipy | scipy-main/scipy/constants/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/constants/tests/test_codata.py | from scipy.constants import find, value, ConstantWarning, c, speed_of_light
from numpy.testing import (assert_equal, assert_, assert_almost_equal,
suppress_warnings)
import scipy.constants._codata as _cd
def test_find():
keys = find('weak mixing', disp=False)
assert_equal(keys, ['we... | 1,959 | 32.793103 | 78 | py |
scipy | scipy-main/scipy/interpolate/_interpnd_info.py | """
Here we perform some symbolic computations required for the N-D
interpolation routines in `interpnd.pyx`.
"""
from sympy import symbols, binomial, Matrix
def _estimate_gradients_2d_global():
#
# Compute
#
#
f1, f2, df1, df2, x = symbols(['f1', 'f2', 'df1', 'df2', 'x'])
c = [f1, (df1 + 3... | 869 | 21.894737 | 67 | py |
scipy | scipy-main/scipy/interpolate/fitpack2.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.interpolate` namespace for importing the functions
# included below.
import warnings
from . import _fitpack2
__all__ = [ # noqa: F822
'BivariateSpline',
'InterpolatedUnivariateSpline',
'LSQBivariateSpline',
... | 1,195 | 24.446809 | 81 | py |
scipy | scipy-main/scipy/interpolate/_fitpack_py.py | __all__ = ['splrep', 'splprep', 'splev', 'splint', 'sproot', 'spalde',
'bisplrep', 'bisplev', 'insert', 'splder', 'splantider']
import numpy as np
# These are in the API for fitpack even if not used in fitpack.py itself.
from ._fitpack_impl import bisplrep, bisplev, dblint # noqa: F401
from . import _fit... | 27,528 | 33.97967 | 83 | py |
scipy | scipy-main/scipy/interpolate/setup.py | import os
from os.path import join
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
from scipy._build_utils import (get_f2py_int64_options,
ilp64_pre_build_hook,
uses_blas64, numpy_no... | 2,692 | 33.974026 | 89 | py |
scipy | scipy-main/scipy/interpolate/rbf.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.interpolate` namespace for importing the functions
# included below.
import warnings
from . import _rbf
__all__ = [ # noqa: F822
'Rbf',
'cdist',
'linalg',
'pdist',
'squareform',
'xlogy',
]
def __d... | 818 | 23.088235 | 81 | py |
scipy | scipy-main/scipy/interpolate/_rbfinterp.py | """Module for RBF interpolation."""
import warnings
from itertools import combinations_with_replacement
import numpy as np
from numpy.linalg import LinAlgError
from scipy.spatial import KDTree
from scipy.special import comb
from scipy.linalg.lapack import dgesv # type: ignore[attr-defined]
from ._rbfinterp_pythran i... | 19,587 | 34.679417 | 79 | py |
scipy | scipy-main/scipy/interpolate/_pade.py | from numpy import zeros, asarray, eye, poly1d, hstack, r_
from scipy import linalg
__all__ = ["pade"]
def pade(an, m, n=None):
"""
Return Pade approximation to a polynomial as the ratio of two polynomials.
Parameters
----------
an : (N,) array_like
Taylor series coefficients.
m : int
... | 1,827 | 25.882353 | 78 | py |
scipy | scipy-main/scipy/interpolate/_ndgriddata.py | """
Convenience interface to N-D interpolation
.. versionadded:: 0.9
"""
import numpy as np
from .interpnd import LinearNDInterpolator, NDInterpolatorBase, \
CloughTocher2DInterpolator, _ndim_coords_from_arrays
from scipy.spatial import cKDTree
__all__ = ['griddata', 'NearestNDInterpolator', 'LinearNDInterpolat... | 9,943 | 33.769231 | 112 | py |
scipy | scipy-main/scipy/interpolate/_fitpack2.py | """
fitpack --- curve and surface fitting with splines
fitpack is based on a collection of Fortran routines DIERCKX
by P. Dierckx (see http://www.netlib.org/dierckx/) transformed
to double routines by Pearu Peterson.
"""
# Created by Pearu Peterson, June,August 2003
__all__ = [
'UnivariateSpline',
'Interpolate... | 89,209 | 36.736887 | 92 | py |
scipy | scipy-main/scipy/interpolate/polyint.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.interpolate` namespace for importing the functions
# included below.
import warnings
from . import _polyint
__all__ = [ # noqa: F822
'BarycentricInterpolator',
'KroghInterpolator',
'approximate_taylor_polynomia... | 941 | 25.914286 | 81 | py |
scipy | scipy-main/scipy/interpolate/fitpack.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.interpolate` namespace for importing the functions
# included below.
import warnings
from . import _fitpack_py
__all__ = [ # noqa: F822
'BSpline',
'bisplev',
'bisplrep',
'dblint',
'insert',
'spalde'... | 948 | 22.146341 | 81 | py |
scipy | scipy-main/scipy/interpolate/_bsplines.py | import operator
from math import prod
import numpy as np
from scipy._lib._util import normalize_axis_index
from scipy.linalg import (get_lapack_funcs, LinAlgError,
cholesky_banded, cho_solve_banded,
solve, solve_banded)
from scipy.optimize import minimize_scalar
from... | 69,387 | 33.030407 | 90 | py |
scipy | scipy-main/scipy/interpolate/_rgi.py | __all__ = ['RegularGridInterpolator', 'interpn']
import itertools
import numpy as np
from .interpnd import _ndim_coords_from_arrays
from ._cubic import PchipInterpolator
from ._rgi_cython import evaluate_linear_2d, find_indices
from ._bsplines import make_interp_spline
from ._fitpack2 import RectBivariateSpline
de... | 26,908 | 39.043155 | 112 | py |
scipy | scipy-main/scipy/interpolate/_rbf.py | """rbf - Radial basis functions for interpolation/smoothing scattered N-D data.
Written by John Travers <jtravs@gmail.com>, February 2007
Based closely on Matlab code by Alex Chirokov
Additional, large, improvements by Robert Hetland
Some additional alterations by Travis Oliphant
Interpolation with multi-dimensional t... | 11,672 | 39.113402 | 82 | py |
scipy | scipy-main/scipy/interpolate/_fitpack_impl.py | """
fitpack (dierckx in netlib) --- A Python-C wrapper to FITPACK (by P. Dierckx).
FITPACK is a collection of FORTRAN programs for curve and surface
fitting with splines and tensor product splines.
See
https://web.archive.org/web/20010524124604/http://www.cs.kuleuven.ac.be:80/cwis/research/nalag/resea... | 28,486 | 34.475716 | 124 | py |
scipy | scipy-main/scipy/interpolate/_interpolate.py | __all__ = ['interp1d', 'interp2d', 'lagrange', 'PPoly', 'BPoly', 'NdPPoly']
from math import prod
import warnings
import numpy as np
from numpy import (array, transpose, searchsorted, atleast_1d, atleast_2d,
ravel, poly1d, asarray, intp)
import scipy.special as spec
from scipy.special import comb
... | 88,129 | 34.665722 | 89 | py |
scipy | scipy-main/scipy/interpolate/_rbfinterp_pythran.py | import numpy as np
def linear(r):
return -r
def thin_plate_spline(r):
if r == 0:
return 0.0
else:
return r**2*np.log(r)
def cubic(r):
return r**3
def quintic(r):
return -r**5
def multiquadric(r):
return -np.sqrt(r**2 + 1)
def inverse_multiquadric(r):
return 1/np.s... | 5,831 | 25.875576 | 77 | py |
scipy | scipy-main/scipy/interpolate/_polyint.py | import warnings
import numpy as np
from scipy.special import factorial
from scipy._lib._util import _asarray_validated, float_factorial
__all__ = ["KroghInterpolator", "krogh_interpolate", "BarycentricInterpolator",
"barycentric_interpolate", "approximate_taylor_polynomial"]
def _isscalar(x):
"""Che... | 26,463 | 34.285333 | 87 | py |
scipy | scipy-main/scipy/interpolate/_ndbspline.py | import operator
import numpy as np
from math import prod
from . import _bspl # type: ignore
__all__ = ["NdBSpline"]
def _get_dtype(dtype):
"""Return np.complex128 for complex dtypes, np.float64 otherwise."""
if np.issubdtype(dtype, np.complexfloating):
return np.complex_
else:
return n... | 7,320 | 34.36715 | 110 | py |
scipy | scipy-main/scipy/interpolate/__init__.py | """
========================================
Interpolation (:mod:`scipy.interpolate`)
========================================
.. currentmodule:: scipy.interpolate
Sub-package for objects used in interpolation.
As listed below, this sub-package contains spline functions and classes,
1-D and multidimensional (univari... | 3,530 | 16.480198 | 72 | py |
scipy | scipy-main/scipy/interpolate/_cubic.py | """Interpolation algorithms using piecewise cubic polynomials."""
import numpy as np
from . import PPoly
from ._polyint import _isscalar
from scipy.linalg import solve_banded, solve
__all__ = ["CubicHermiteSpline", "PchipInterpolator", "pchip_interpolate",
"Akima1DInterpolator", "CubicSpline"]
def prep... | 33,920 | 38.169746 | 121 | py |
scipy | scipy-main/scipy/interpolate/interpolate.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.interpolate` namespace for importing the functions
# included below.
import warnings
from . import _interpolate
__all__ = [ # noqa: F822
'BPoly',
'BSpline',
'NdPPoly',
'PPoly',
'RectBivariateSpline',
... | 1,180 | 21.283019 | 81 | py |
scipy | scipy-main/scipy/interpolate/ndgriddata.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.interpolate` namespace for importing the functions
# included below.
import warnings
from . import _ndgriddata
__all__ = [ # noqa: F822
'CloughTocher2DInterpolator',
'LinearNDInterpolator',
'NDInterpolatorBase'... | 912 | 25.852941 | 81 | py |
scipy | scipy-main/scipy/interpolate/tests/test_interpolate.py | from numpy.testing import (assert_, assert_equal, assert_almost_equal,
assert_array_almost_equal, assert_array_equal,
assert_allclose, suppress_warnings)
from pytest import raises as assert_raises
import pytest
from numpy import mgrid, pi, sin, ogrid, poly1d, linsp... | 95,850 | 36.588627 | 85 | py |
scipy | scipy-main/scipy/interpolate/tests/test_pade.py | from numpy.testing import (assert_array_equal, assert_array_almost_equal)
from scipy.interpolate import pade
def test_pade_trivial():
nump, denomp = pade([1.0], 0)
assert_array_equal(nump.c, [1.0])
assert_array_equal(denomp.c, [1.0])
nump, denomp = pade([1.0], 0, 0)
assert_array_equal(nump.c, [1.0... | 3,786 | 36.127451 | 110 | py |
scipy | scipy-main/scipy/interpolate/tests/test_interpnd.py | import os
import numpy as np
from numpy.testing import (assert_equal, assert_allclose, assert_almost_equal,
suppress_warnings)
from pytest import raises as assert_raises
import pytest
import scipy.interpolate.interpnd as interpnd
import scipy.spatial._qhull as qhull
import pickle
def dat... | 13,627 | 34.21447 | 92 | py |
scipy | scipy-main/scipy/interpolate/tests/test_rgi.py | import itertools
import pytest
import numpy as np
from numpy.testing import (assert_allclose, assert_equal, assert_warns,
assert_array_almost_equal, assert_array_equal)
from pytest import raises as assert_raises
from scipy.interpolate import (RegularGridInterpolator, interpn,
... | 41,718 | 39.661793 | 79 | py |
scipy | scipy-main/scipy/interpolate/tests/test_rbfinterp.py | import pickle
import pytest
import numpy as np
from numpy.linalg import LinAlgError
from numpy.testing import assert_allclose, assert_array_equal
from scipy.stats.qmc import Halton
from scipy.spatial import cKDTree
from scipy.interpolate._rbfinterp import (
_AVAILABLE, _SCALE_INVARIANT, _NAME_TO_MIN_DEGREE, _monomi... | 18,127 | 34.685039 | 79 | py |
scipy | scipy-main/scipy/interpolate/tests/test_rbf.py | # Created by John Travers, Robert Hetland, 2007
""" Test functions for rbf module """
import numpy as np
from numpy.testing import (assert_, assert_array_almost_equal,
assert_almost_equal)
from numpy import linspace, sin, cos, random, exp, allclose
from scipy.interpolate._rbf import Rbf
FUN... | 6,559 | 28.41704 | 78 | py |
scipy | scipy-main/scipy/interpolate/tests/test_polyint.py | import warnings
import io
import numpy as np
from numpy.testing import (
assert_almost_equal, assert_array_equal, assert_array_almost_equal,
assert_allclose, assert_equal, assert_)
from pytest import raises as assert_raises
import pytest
from scipy.interpolate import (
KroghInterpolator, krogh_interpolate... | 30,292 | 36.444994 | 85 | py |
scipy | scipy-main/scipy/interpolate/tests/test_fitpack.py | import itertools
import os
import numpy as np
from numpy.testing import (assert_equal, assert_allclose, assert_,
assert_almost_equal, assert_array_almost_equal)
from pytest import raises as assert_raises
import pytest
from scipy._lib._testutils import check_free_memory
from scipy.interpolat... | 15,175 | 30.290722 | 80 | py |
scipy | scipy-main/scipy/interpolate/tests/test_gil.py | import itertools
import threading
import time
import numpy as np
from numpy.testing import assert_equal
import pytest
import scipy.interpolate
class TestGIL:
"""Check if the GIL is properly released by scipy.interpolate functions."""
def setup_method(self):
self.messages = []
def log(self, mess... | 1,874 | 27.409091 | 79 | py |
scipy | scipy-main/scipy/interpolate/tests/test_bsplines.py | import operator
import itertools
import numpy as np
from numpy.testing import assert_equal, assert_allclose, assert_
from pytest import raises as assert_raises
import pytest
from scipy.interpolate import (
BSpline, BPoly, PPoly, make_interp_spline, make_lsq_spline, _bspl,
splev, splrep, splprep, splde... | 76,664 | 34.791317 | 82 | py |
scipy | scipy-main/scipy/interpolate/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/interpolate/tests/test_ndgriddata.py | import numpy as np
from numpy.testing import assert_equal, assert_array_equal, assert_allclose
import pytest
from pytest import raises as assert_raises
from scipy.interpolate import (griddata, NearestNDInterpolator,
LinearNDInterpolator,
CloughTocher2DInter... | 9,445 | 37.242915 | 94 | py |
scipy | scipy-main/scipy/interpolate/tests/test_fitpack2.py | # Created by Pearu Peterson, June 2003
import itertools
import numpy as np
from numpy.testing import (assert_equal, assert_almost_equal, assert_array_equal,
assert_array_almost_equal, assert_allclose, suppress_warnings)
from pytest import raises as assert_raises
from numpy import array, diff, linspace, meshgri... | 58,667 | 42.329394 | 98 | py |
scipy | scipy-main/scipy/spatial/_plotutils.py | import numpy as np
from scipy._lib.decorator import decorator as _decorator
__all__ = ['delaunay_plot_2d', 'convex_hull_plot_2d', 'voronoi_plot_2d']
@_decorator
def _held_figure(func, obj, ax=None, **kw):
import matplotlib.pyplot as plt
if ax is None:
fig = plt.figure()
ax = fig.gca()
... | 7,176 | 25.581481 | 79 | py |
scipy | scipy-main/scipy/spatial/_kdtree.py | # Copyright Anne M. Archibald 2008
# Released under the scipy license
import numpy as np
from ._ckdtree import cKDTree, cKDTreeNode
__all__ = ['minkowski_distance_p', 'minkowski_distance',
'distance_matrix',
'Rectangle', 'KDTree']
def minkowski_distance_p(x, y, p=2):
"""Compute the pth powe... | 33,444 | 35.313789 | 86 | py |
scipy | scipy-main/scipy/spatial/_spherical_voronoi.py | """
Spherical Voronoi Code
.. versionadded:: 0.18.0
"""
#
# Copyright (C) Tyler Reddy, Ross Hemsley, Edd Edmondson,
# Nikolai Nowaczyk, Joe Pitt-Francis, 2015.
#
# Distributed under the same BSD license as SciPy.
#
import numpy as np
import scipy
from . import _voronoi
from scipy.spatial import cKDTr... | 13,564 | 38.548105 | 82 | py |
scipy | scipy-main/scipy/spatial/setup.py | from os.path import join, dirname
import glob
def pre_build_hook(build_ext, ext):
from scipy._build_utils.compiler_helper import (set_cxx_flags_hook,
try_add_flag)
cc = build_ext._cxx_compiler
args = ext.extra_compile_args
set_cxx_flags_hook(build_e... | 4,502 | 35.314516 | 79 | py |
scipy | scipy-main/scipy/spatial/kdtree.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.spatial` namespace for importing the functions
# included below.
import warnings
from . import _kdtree
__all__ = [ # noqa: F822
'KDTree',
'Rectangle',
'cKDTree',
'cKDTreeNode',
'distance_matrix',
'm... | 870 | 23.885714 | 77 | py |
scipy | scipy-main/scipy/spatial/qhull.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.spatial` namespace for importing the functions
# included below.
import warnings
from . import _qhull
__all__ = [ # noqa: F822
'ConvexHull',
'Delaunay',
'HalfspaceIntersection',
'QhullError',
'Voronoi',... | 889 | 22.421053 | 77 | py |
scipy | scipy-main/scipy/spatial/_procrustes.py | """
This module provides functions to perform full Procrustes analysis.
This code was originally written by Justin Kucynski and ported over from
scikit-bio by Yoshiki Vazquez-Baeza.
"""
import numpy as np
from scipy.linalg import orthogonal_procrustes
__all__ = ['procrustes']
def procrustes(data1, data2):
r""... | 4,427 | 32.293233 | 79 | py |
scipy | scipy-main/scipy/spatial/ckdtree.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.spatial` namespace for importing the functions
# included below.
import warnings
from . import _ckdtree
__all__ = [ # noqa: F822
'cKDTree',
'cKDTreeNode',
'coo_entries',
'operator',
'ordered_pairs',
... | 862 | 22.972222 | 77 | py |
scipy | scipy-main/scipy/spatial/_geometric_slerp.py | from __future__ import annotations
__all__ = ['geometric_slerp']
import warnings
from typing import TYPE_CHECKING
import numpy as np
from scipy.spatial.distance import euclidean
if TYPE_CHECKING:
import numpy.typing as npt
def _geometric_slerp(start, end, t):
# create an orthogonal basis using QR decompos... | 7,945 | 32.108333 | 77 | py |
scipy | scipy-main/scipy/spatial/__init__.py | """
=============================================================
Spatial algorithms and data structures (:mod:`scipy.spatial`)
=============================================================
.. currentmodule:: scipy.spatial
.. toctree::
:hidden:
spatial.distance
Spatial transformations
=======================
... | 3,683 | 27.338462 | 93 | py |
scipy | scipy-main/scipy/spatial/distance.py | """
Distance computations (:mod:`scipy.spatial.distance`)
=====================================================
.. sectionauthor:: Damian Eads
Function reference
------------------
Distance matrix computation from a collection of raw observation vectors
stored in a rectangular array.
.. autosummary::
:toctree: g... | 92,867 | 29.750993 | 100 | py |
scipy | scipy-main/scipy/spatial/tests/test_distance.py | #
# Author: Damian Eads
# Date: April 17, 2008
#
# Copyright (C) 2008 Damian Eads
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this... | 83,271 | 36.125279 | 112 | py |
scipy | scipy-main/scipy/spatial/tests/test_qhull.py | import os
import copy
import numpy as np
from numpy.testing import (assert_equal, assert_almost_equal,
assert_, assert_allclose, assert_array_equal)
import pytest
from pytest import raises as assert_raises
import scipy.spatial._qhull as qhull
from scipy.spatial import cKDTree as KDTree
from... | 43,730 | 36.440925 | 98 | py |
scipy | scipy-main/scipy/spatial/tests/test__plotutils.py | import pytest
from numpy.testing import assert_, assert_array_equal, suppress_warnings
try:
import matplotlib
matplotlib.rcParams['backend'] = 'Agg'
import matplotlib.pyplot as plt
has_matplotlib = True
except Exception:
has_matplotlib = False
from scipy.spatial import \
delaunay_plot_2d, voro... | 1,943 | 34.345455 | 79 | py |
scipy | scipy-main/scipy/spatial/tests/test__procrustes.py | import numpy as np
from numpy.testing import assert_allclose, assert_equal, assert_almost_equal
from pytest import raises as assert_raises
from scipy.spatial import procrustes
class TestProcrustes:
def setup_method(self):
"""creates inputs"""
# an L
self.data1 = np.array([[1, 3], [1, 2], ... | 4,974 | 41.521368 | 79 | py |
scipy | scipy-main/scipy/spatial/tests/test_kdtree.py | # Copyright Anne M. Archibald 2008
# Released under the scipy license
import os
from numpy.testing import (assert_equal, assert_array_equal, assert_,
assert_almost_equal, assert_array_almost_equal,
assert_allclose)
from pytest import raises as assert_raises
import ... | 49,113 | 31.269382 | 104 | py |
scipy | scipy-main/scipy/spatial/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/spatial/tests/test_slerp.py | import numpy as np
from numpy.testing import assert_allclose
import pytest
from scipy.spatial import geometric_slerp
def _generate_spherical_points(ndim=3, n_pts=2):
# generate uniform points on sphere
# see: https://stackoverflow.com/a/23785326
# tentatively extended to arbitrary dims
# for 0-sphere... | 16,396 | 38.321343 | 79 | py |
scipy | scipy-main/scipy/spatial/tests/test_spherical_voronoi.py | import numpy as np
import itertools
from numpy.testing import (assert_equal,
assert_almost_equal,
assert_array_equal,
assert_array_almost_equal)
import pytest
from pytest import raises as assert_raises
from scipy.spatial import SphericalVo... | 14,361 | 39.342697 | 80 | py |
scipy | scipy-main/scipy/spatial/tests/test_hausdorff.py | import numpy as np
from numpy.testing import (assert_allclose,
assert_array_equal,
assert_equal)
import pytest
from scipy.spatial.distance import directed_hausdorff
from scipy.spatial import distance
from scipy._lib._util import check_random_state
class TestHausdo... | 7,114 | 40.127168 | 78 | py |
scipy | scipy-main/scipy/spatial/transform/setup.py | def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('transform', parent_package, top_path)
config.add_data_dir('tests')
config.add_data_files('_rotation.pyi')
config.add_extension('_rotation',
sou... | 361 | 26.846154 | 65 | py |
scipy | scipy-main/scipy/spatial/transform/_rotation_groups.py | import numpy as np
from scipy.constants import golden as phi
def icosahedral(cls):
g1 = tetrahedral(cls).as_quat()
a = 0.5
b = 0.5 / phi
c = phi / 2
g2 = np.array([[+a, +b, +c, 0],
[+a, +b, -c, 0],
[+a, +c, 0, +b],
[+a, +c, 0, -b],
... | 4,422 | 30.368794 | 78 | py |
scipy | scipy-main/scipy/spatial/transform/rotation.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.spatial` namespace for importing the functions
# included below.
import warnings
from . import _rotation
__all__ = [ # noqa: F822
'Rotation',
'Slerp',
'check_random_state',
'create_group',
're',
]
def... | 872 | 24.676471 | 82 | py |
scipy | scipy-main/scipy/spatial/transform/__init__.py | """
Spatial Transformations (:mod:`scipy.spatial.transform`)
========================================================
.. currentmodule:: scipy.spatial.transform
This package implements various spatial transformations. For now,
only rotations are supported.
Rotations in 3 dimensions
-------------------------
.. autos... | 700 | 22.366667 | 65 | py |
scipy | scipy-main/scipy/spatial/transform/_rotation_spline.py | import numpy as np
from scipy.linalg import solve_banded
from ._rotation import Rotation
def _create_skew_matrix(x):
"""Create skew-symmetric matrices corresponding to vectors.
Parameters
----------
x : ndarray, shape (n, 3)
Set of vectors.
Returns
-------
ndarray, shape (n, 3, 3... | 14,083 | 29.550976 | 87 | py |
scipy | scipy-main/scipy/spatial/transform/tests/test_rotation_spline.py | from itertools import product
import numpy as np
from numpy.testing import assert_allclose
from pytest import raises
from scipy.spatial.transform import Rotation, RotationSpline
from scipy.spatial.transform._rotation_spline import (
_angular_rate_to_rotvec_dot_matrix,
_rotvec_dot_to_angular_rate_matrix,
_ma... | 5,105 | 30.325153 | 74 | py |
scipy | scipy-main/scipy/spatial/transform/tests/test_rotation.py | import pytest
import numpy as np
from numpy.testing import assert_equal, assert_array_almost_equal
from numpy.testing import assert_allclose
from scipy.spatial.transform import Rotation, Slerp
from scipy.stats import special_ortho_group
from itertools import permutations
import pickle
import copy
def test_generic_qu... | 47,183 | 30.26839 | 107 | py |
scipy | scipy-main/scipy/spatial/transform/tests/test_rotation_groups.py | import pytest
import numpy as np
from numpy.testing import assert_array_almost_equal
from scipy.spatial.transform import Rotation
from scipy.optimize import linear_sum_assignment
from scipy.spatial.distance import cdist
from scipy.constants import golden as phi
from scipy.spatial import cKDTree
TOL = 1E-12
NS = rang... | 5,560 | 31.711765 | 78 | py |
scipy | scipy-main/scipy/spatial/transform/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/_lib/decorator.py | # ######################### LICENSE ############################ #
# Copyright (c) 2005-2015, Michele Simionato
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# Redistributions of so... | 15,045 | 36.615 | 79 | py |
scipy | scipy-main/scipy/_lib/_bunch.py | import sys as _sys
from keyword import iskeyword as _iskeyword
def _validate_names(typename, field_names, extra_field_names):
"""
Ensure that all the given names are valid Python identifiers that
do not start with '_'. Also check that there are no duplicates
among field_names + extra_field_names.
... | 8,116 | 34.915929 | 79 | py |
scipy | scipy-main/scipy/_lib/_threadsafety.py | import threading
import scipy._lib.decorator
__all__ = ['ReentrancyError', 'ReentrancyLock', 'non_reentrant']
class ReentrancyError(RuntimeError):
pass
class ReentrancyLock:
"""
Threading lock that raises an exception for reentrant calls.
Calls from different threads are serialized, and nested c... | 1,455 | 23.677966 | 74 | py |
scipy | scipy-main/scipy/_lib/_testutils.py | """
Generic test utilities.
"""
import os
import re
import sys
import numpy as np
import inspect
import sysconfig
__all__ = ['PytestTester', 'check_free_memory', '_TestPythranFunc', 'IS_MUSL']
IS_MUSL = False
try:
# Note that packaging is not a dependency, hence we need this try-except:
from packaging.tag... | 8,273 | 31.069767 | 88 | py |
scipy | scipy-main/scipy/_lib/uarray.py | """`uarray` provides functions for generating multimethods that dispatch to
multiple different backends
This should be imported, rather than `_uarray` so that an installed version could
be used instead, if available. This means that users can call
`uarray.set_backend` directly instead of going through SciPy.
"""
# ... | 773 | 23.1875 | 81 | py |
scipy | scipy-main/scipy/_lib/_pep440.py | """Utility to compare pep440 compatible version strings.
The LooseVersion and StrictVersion classes that distutils provides don't
work; they don't recognize anything like alpha/beta/rc/dev versions.
"""
# Copyright (c) Donald Stufft and individual contributors.
# All rights reserved.
# Redistribution and use in sour... | 14,005 | 27.70082 | 79 | py |
scipy | scipy-main/scipy/_lib/_unuran_utils.py | """Helper functions to get location of UNU.RAN source files."""
import pathlib
from typing import Union
def _unuran_dir(ret_path: bool = False) -> Union[pathlib.Path, str]:
"""Directory where root unuran/ directory lives."""
p = pathlib.Path(__file__).parent / "unuran"
return p if ret_path else str(p)
| 318 | 28 | 68 | py |
scipy | scipy-main/scipy/_lib/setup.py | import os
def check_boost_submodule():
from scipy._lib._boost_utils import _boost_dir
if not os.path.exists(_boost_dir(ret_path=True).parent / 'README.md'):
raise RuntimeError("Missing the `boost` submodule! Run `git submodule "
"update --init` to fix this.")
def check_hi... | 3,817 | 35.711538 | 82 | py |
scipy | scipy-main/scipy/_lib/_util.py | import re
from contextlib import contextmanager
import functools
import operator
import warnings
import numbers
from collections import namedtuple
import inspect
import math
from typing import (
Optional,
Union,
TYPE_CHECKING,
TypeVar,
)
import numpy as np
if np.lib.NumpyVersion(np.__version__) >= '1.... | 25,661 | 33.216 | 86 | py |
scipy | scipy-main/scipy/_lib/_highs_utils.py | """Helper functions to get location of source files."""
import pathlib
def _highs_dir() -> pathlib.Path:
"""Directory where root highs/ directory lives."""
p = pathlib.Path(__file__).parent / 'highs'
return p
| 224 | 21.5 | 55 | py |
scipy | scipy-main/scipy/_lib/deprecation.py | import functools
import warnings
from importlib import import_module
__all__ = ["_deprecated"]
# Object to use as default value for arguments to be deprecated. This should
# be used over 'None' as the user could parse 'None' as a positional argument
_NoValue = object()
def _sub_module_deprecation(*, sub_package, m... | 5,086 | 31.819355 | 102 | py |
scipy | scipy-main/scipy/_lib/_boost_utils.py | '''Helper functions to get location of header files.'''
import pathlib
from typing import Union
def _boost_dir(ret_path: bool = False) -> Union[pathlib.Path, str]:
'''Directory where root Boost/ directory lives.'''
p = pathlib.Path(__file__).parent / 'boost_math/include'
return p if ret_path else str(p)
| 320 | 28.181818 | 67 | py |
scipy | scipy-main/scipy/_lib/doccer.py | ''' Utilities to allow inserting docstring fragments for common
parameters into function and method docstrings'''
import sys
__all__ = [
'docformat', 'inherit_docstring_from', 'indentcount_lines',
'filldoc', 'unindent_dict', 'unindent_string', 'extend_notes_in_docstring',
'replace_notes_in_docstring', 'do... | 8,362 | 29.300725 | 79 | py |
scipy | scipy-main/scipy/_lib/_disjoint_set.py | """
Disjoint set data structure
"""
class DisjointSet:
""" Disjoint set data structure for incremental connectivity queries.
.. versionadded:: 1.6.0
Attributes
----------
n_subsets : int
The number of subsets.
Methods
-------
add
merge
connected
subset
subset... | 6,160 | 23.160784 | 79 | py |
scipy | scipy-main/scipy/_lib/_gcutils.py | """
Module for testing automatic garbage collection of objects
.. autosummary::
:toctree: generated/
set_gc_state - enable or disable garbage collection
gc_state - context manager for given state of garbage collector
assert_deallocated - context manager to check for circular references on object
"""
impo... | 2,669 | 24.188679 | 82 | py |
scipy | scipy-main/scipy/_lib/_finite_differences.py | from numpy import arange, newaxis, hstack, prod, array
def _central_diff_weights(Np, ndiv=1):
"""
Return weights for an Np-point central derivative.
Assumes equally-spaced function points.
If weights are in the vector w, then
derivative is w[0] * f(x-ho*dx) + ... + w[-1] * f(x+h0*dx)
Parame... | 4,172 | 27.582192 | 78 | py |
scipy | scipy-main/scipy/_lib/__init__.py | """
Module containing private utility functions
===========================================
The ``scipy._lib`` namespace is empty (for now). Tests for all
utilities in submodules of ``_lib`` can be run with::
from scipy import _lib
_lib.test()
"""
from scipy._lib._testutils import PytestTester
test = PytestT... | 353 | 22.6 | 62 | py |
scipy | scipy-main/scipy/_lib/_docscrape.py | """Extract reference documentation from the NumPy source tree.
"""
# copied from numpydoc/docscrape.py
import inspect
import textwrap
import re
import pydoc
from warnings import warn
from collections import namedtuple
from collections.abc import Callable, Mapping
import copy
import sys
def strip_blank_lines(l): # n... | 21,547 | 30.641703 | 78 | py |
scipy | scipy-main/scipy/_lib/_ccallback.py | from . import _ccallback_c
import ctypes
PyCFuncPtr = ctypes.CFUNCTYPE(ctypes.c_void_p).__bases__[0]
ffi = None
class CData:
pass
def _import_cffi():
global ffi, CData
if ffi is not None:
return
try:
import cffi
ffi = cffi.FFI()
CData = ffi.CData
except ImportE... | 6,963 | 27.080645 | 110 | py |
scipy | scipy-main/scipy/_lib/_tmpdirs.py | ''' Contexts for *with* statement providing temporary directories
'''
import os
from contextlib import contextmanager
from shutil import rmtree
from tempfile import mkdtemp
@contextmanager
def tempdir():
"""Create and return a temporary directory. This has the same
behavior as mkdtemp but can be used as a con... | 2,374 | 26.298851 | 79 | py |
scipy | scipy-main/scipy/_lib/_array_api.py | """Utility functions to use Python Array API compatible libraries.
For the context about the Array API see:
https://data-apis.org/array-api/latest/purpose_and_scope.html
The SciPy use case of the Array API is described on the following page:
https://data-apis.org/array-api/latest/use_cases.html#use-case-scipy
"""
fro... | 4,640 | 32.388489 | 86 | py |
scipy | scipy-main/scipy/_lib/_uarray/setup.py | def pre_build_hook(build_ext, ext):
from scipy._build_utils.compiler_helper import (
set_cxx_flags_hook, try_add_flag)
cc = build_ext._cxx_compiler
args = ext.extra_compile_args
set_cxx_flags_hook(build_ext, ext)
if cc.compiler_type == 'msvc':
args.append('/EHsc')
else:
... | 1,014 | 31.741935 | 82 | py |
scipy | scipy-main/scipy/_lib/_uarray/__init__.py | """
.. note:
If you are looking for overrides for NumPy-specific methods, see the
documentation for :obj:`unumpy`. This page explains how to write
back-ends and multimethods.
``uarray`` is built around a back-end protocol, and overridable multimethods.
It is necessary to define multimethods for back-ends t... | 4,493 | 37.410256 | 91 | py |
scipy | scipy-main/scipy/_lib/_uarray/_backend.py | import typing
import types
import inspect
import functools
from . import _uarray
import copyreg
import pickle
import contextlib
from ._uarray import ( # type: ignore
BackendNotImplementedError,
_Function,
_SkipBackendContext,
_SetBackendContext,
_BackendState,
)
__all__ = [
"set_backend",
... | 20,476 | 28.128023 | 101 | py |
scipy | scipy-main/scipy/_lib/tests/test_tmpdirs.py | """ Test tmpdirs module """
from os import getcwd
from os.path import realpath, abspath, dirname, isfile, join as pjoin, exists
from scipy._lib._tmpdirs import tempdir, in_tempdir, in_dir
from numpy.testing import assert_, assert_equal
MY_PATH = abspath(__file__)
MY_DIR = dirname(MY_PATH)
def test_tempdir():
w... | 1,240 | 27.860465 | 77 | py |
scipy | scipy-main/scipy/_lib/tests/test__testutils.py | import sys
from scipy._lib._testutils import _parse_size, _get_mem_available
import pytest
def test__parse_size():
expected = {
'12': 12e6,
'12 b': 12,
'12k': 12e3,
' 12 M ': 12e6,
' 12 G ': 12e9,
' 12Tb ': 12e12,
'12 Mib ': 12 * 1024.0**2,
'1... | 800 | 23.272727 | 65 | py |
scipy | scipy-main/scipy/_lib/tests/test_warnings.py | """
Tests which scan for certain occurrences in the code, they may not find
all of these occurrences but should catch almost all. This file was adapted
from NumPy.
"""
import os
from pathlib import Path
import ast
import tokenize
import scipy
import pytest
class ParseCall(ast.NodeVisitor):
def __init__(self):... | 4,275 | 31.393939 | 80 | py |
scipy | scipy-main/scipy/_lib/tests/test__util.py | from multiprocessing import Pool
from multiprocessing.pool import Pool as PWL
import os
import re
import math
from fractions import Fraction
import numpy as np
from numpy.testing import assert_equal, assert_
import pytest
from pytest import raises as assert_raises, deprecated_call
import scipy
from scipy._lib._util i... | 13,835 | 33.41791 | 78 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.