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/_lib/tests/test_import_cycles.py | import sys
import subprocess
from .test_public_api import PUBLIC_MODULES
# Regression tests for gh-6793.
# Check that all modules are importable in a new Python process.
# This is not necessarily true if there are import cycles present.
def test_public_modules_importable():
pids = [subprocess.Popen([sys.executab... | 500 | 32.4 | 72 | py |
scipy | scipy-main/scipy/_lib/tests/test_ccallback.py | from numpy.testing import assert_equal, assert_
from pytest import raises as assert_raises
import time
import pytest
import ctypes
import threading
from scipy._lib import _ccallback_c as _test_ccallback_cython
from scipy._lib import _test_ccallback
from scipy._lib._ccallback import LowLevelCallable
try:
import cf... | 6,033 | 29.17 | 96 | py |
scipy | scipy-main/scipy/_lib/tests/test_deprecation.py | import pytest
def test_cython_api_deprecation():
match = ("`scipy._lib._test_deprecation_def.foo_deprecated` "
"is deprecated, use `foo` instead!\n"
"Deprecated in Scipy 42.0.0")
with pytest.warns(DeprecationWarning, match=match):
from .. import _test_deprecation_call
ass... | 364 | 32.181818 | 65 | py |
scipy | scipy-main/scipy/_lib/tests/test__threadsafety.py | import threading
import time
import traceback
from numpy.testing import assert_
from pytest import raises as assert_raises
from scipy._lib._threadsafety import ReentrancyLock, non_reentrant, ReentrancyError
def test_parallel_threads():
# Check that ReentrancyLock serializes work in parallel threads.
#
#... | 1,322 | 24.442308 | 83 | py |
scipy | scipy-main/scipy/_lib/tests/test_bunch.py | import pytest
import pickle
from numpy.testing import assert_equal
from scipy._lib._bunch import _make_tuple_bunch
# `Result` is defined at the top level of the module so it can be
# used to test pickling.
Result = _make_tuple_bunch('Result', ['x', 'y', 'z'], ['w', 'beta'])
class TestMakeTupleBunch:
# - - - - ... | 6,168 | 36.846626 | 75 | py |
scipy | scipy-main/scipy/_lib/tests/test_public_api.py | """
This test script is adopted from:
https://github.com/numpy/numpy/blob/main/numpy/tests/test_public_api.py
"""
import pkgutil
import types
import importlib
import warnings
from importlib import import_module
import pytest
import scipy
def test_dir_testing():
"""Assert that output of dir has only one "te... | 10,973 | 30.534483 | 91 | py |
scipy | scipy-main/scipy/_lib/tests/test__gcutils.py | """ Test for assert_deallocated context manager and gc utilities
"""
import gc
from scipy._lib._gcutils import (set_gc_state, gc_state, assert_deallocated,
ReferenceError, IS_PYPY)
from numpy.testing import assert_equal
import pytest
def test_set_gc_state():
gc_status = gc.isen... | 3,416 | 32.5 | 76 | py |
scipy | scipy-main/scipy/_lib/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/_lib/tests/test_array_api.py | import numpy as np
from numpy.testing import assert_equal
import pytest
from scipy.conftest import array_api_compatible
from scipy._lib._array_api import (
_GLOBAL_CONFIG, array_namespace, as_xparray,
)
if not _GLOBAL_CONFIG["SCIPY_ARRAY_API"]:
pytest.skip(
"Array API test; set environment variable S... | 2,051 | 26.72973 | 79 | py |
scipy | scipy-main/scipy/_lib/tests/test__pep440.py | from pytest import raises as assert_raises
from scipy._lib._pep440 import Version, parse
def test_main_versions():
assert Version('1.8.0') == Version('1.8.0')
for ver in ['1.9.0', '2.0.0', '1.8.1']:
assert Version('1.8.0') < Version(ver)
for ver in ['1.7.0', '1.7.1', '0.9.9']:
assert Vers... | 2,277 | 32.5 | 85 | py |
scipy | scipy-main/scipy/cluster/hierarchy.py | """
Hierarchical clustering (:mod:`scipy.cluster.hierarchy`)
========================================================
.. currentmodule:: scipy.cluster.hierarchy
These functions cut hierarchical clusterings into flat clusterings
or find the roots of the forest formed by a cut by providing the flat
cluster ids of each ... | 148,497 | 34.653782 | 111 | py |
scipy | scipy-main/scipy/cluster/vq.py | """
K-means clustering and vector quantization (:mod:`scipy.cluster.vq`)
====================================================================
Provides routines for k-means clustering, generating code books
from k-means models and quantizing vectors by comparing them with
centroids in a code book.
.. autosummary::
... | 30,365 | 35.986602 | 134 | py |
scipy | scipy-main/scipy/cluster/setup.py | DEFINE_MACROS = [("SCIPY_PY3K", None)]
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs
config = Configuration('cluster', parent_package, top_path)
config.add_data_dir('tests')
config.add_extension('_vq',
sources... | 797 | 27.5 | 79 | py |
scipy | scipy-main/scipy/cluster/__init__.py | """
=========================================
Clustering package (:mod:`scipy.cluster`)
=========================================
.. currentmodule:: scipy.cluster
.. toctree::
:hidden:
cluster.vq
cluster.hierarchy
Clustering algorithms are useful in information theory, target detection,
communications, com... | 876 | 26.40625 | 73 | py |
scipy | scipy-main/scipy/cluster/tests/test_hierarchy.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... | 49,477 | 37.806275 | 100 | py |
scipy | scipy-main/scipy/cluster/tests/test_vq.py | import warnings
import sys
import numpy as np
from numpy.testing import (assert_array_equal, assert_array_almost_equal,
assert_allclose, assert_equal, assert_,
suppress_warnings)
import pytest
from pytest import raises as assert_raises
from scipy.cluster.vq import... | 16,092 | 38.06068 | 80 | py |
scipy | scipy-main/scipy/cluster/tests/test_disjoint_set.py | import pytest
from pytest import raises as assert_raises
import numpy as np
from scipy.cluster.hierarchy import DisjointSet
import string
def generate_random_token():
k = len(string.ascii_letters)
tokens = list(np.arange(k, dtype=int))
tokens += list(np.arange(k, dtype=float))
tokens += list(string.as... | 5,525 | 26.221675 | 77 | py |
scipy | scipy-main/scipy/cluster/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/cluster/tests/hierarchy_test_data.py | from numpy import array
Q_X = array([[5.26563660e-01, 3.14160190e-01, 8.00656370e-02],
[7.50205180e-01, 4.60299830e-01, 8.98696460e-01],
[6.65461230e-01, 6.94011420e-01, 9.10465700e-01],
[9.64047590e-01, 1.43082200e-03, 7.39874220e-01],
[1.08159060e-01, 5.53028790e-... | 6,850 | 45.924658 | 78 | py |
scipy | scipy-main/scipy/odr/setup.py | from os.path import join
from scipy._build_utils import numpy_nodepr_api
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 (uses_blas64, blas_ilp64_pre_build_hook,
... | 1,460 | 29.4375 | 75 | py |
scipy | scipy-main/scipy/odr/odrpack.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.odr` namespace for importing the functions
# included below.
import warnings
from . import _odrpack
__all__ = [ # noqa: F822
'odr', 'OdrWarning', 'OdrError', 'OdrStop',
'Data', 'RealData', 'Model', 'Output', 'ODR',
... | 837 | 26.933333 | 76 | py |
scipy | scipy-main/scipy/odr/_odrpack.py | """
Python wrappers for Orthogonal Distance Regression (ODRPACK).
Notes
=====
* Array formats -- FORTRAN stores its arrays in memory column first, i.e., an
array element A(i, j, k) will be next to A(i+1, j, k). In C and, consequently,
NumPy, arrays are stored row first: A[i, j, k] is next to A[i, j, k+1]. For
e... | 42,457 | 35.823938 | 97 | py |
scipy | scipy-main/scipy/odr/_models.py | """ Collection of Model instances for use with the odrpack fitting package.
"""
import numpy as np
from scipy.odr._odrpack import Model
__all__ = ['Model', 'exponential', 'multilinear', 'unilinear', 'quadratic',
'polynomial']
def _lin_fcn(B, x):
a, b = B[0], B[1:]
b.shape = (b.shape[0], 1)
re... | 7,800 | 23.686709 | 78 | py |
scipy | scipy-main/scipy/odr/_add_newdocs.py | from numpy import add_newdoc
add_newdoc('scipy.odr', 'odr',
"""
odr(fcn, beta0, y, x, we=None, wd=None, fjacb=None, fjacd=None, extra_args=None, ifixx=None, ifixb=None, job=0, iprint=0, errfile=None, rptfile=None, ndigit=0, taufac=0.0, sstol=-1.0, partol=-1.0, maxit=-1, stpb=None, stpd=None, sclb=None, scld=No... | 1,090 | 34.193548 | 292 | py |
scipy | scipy-main/scipy/odr/models.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.odr` namespace for importing the functions
# included below.
import warnings
from . import _models
__all__ = [ # noqa: F822
'Model', 'exponential', 'multilinear', 'unilinear',
'quadratic', 'polynomial'
]
def __dir... | 793 | 26.37931 | 76 | py |
scipy | scipy-main/scipy/odr/__init__.py | """
=================================================
Orthogonal distance regression (:mod:`scipy.odr`)
=================================================
.. currentmodule:: scipy.odr
Package Content
===============
.. autosummary::
:toctree: generated/
Data -- The data to fit.
RealData -- Dat... | 4,325 | 31.772727 | 80 | py |
scipy | scipy-main/scipy/odr/tests/test_odr.py | import tempfile
import shutil
import os
import numpy as np
from numpy import pi
from numpy.testing import (assert_array_almost_equal,
assert_equal, assert_warns)
import pytest
from pytest import raises as assert_raises
from scipy.odr import (Data, Model, ODR, RealData, OdrStop, OdrWarning,
... | 20,931 | 36.179396 | 98 | py |
scipy | scipy-main/scipy/odr/tests/__init__.py | 0 | 0 | 0 | py | |
scipy | scipy-main/scipy/stats/_continuous_distns.py | #
# Author: Travis Oliphant 2002-2011 with contributions from
# SciPy Developers 2004-2011
#
import warnings
from collections.abc import Iterable
from functools import wraps, cached_property
import ctypes
import numpy as np
from numpy.polynomial import Polynomial
from scipy._lib.doccer import (extend_notes_... | 376,025 | 31.207794 | 97 | py |
scipy | scipy-main/scipy/stats/_survival.py | from __future__ import annotations
from dataclasses import dataclass, field
from typing import TYPE_CHECKING
import warnings
import numpy as np
from scipy import special, interpolate, stats
from scipy.stats._censored_data import CensoredData
from scipy.stats._common import ConfidenceInterval
if TYPE_CHECKING:
fr... | 25,965 | 36.741279 | 81 | py |
scipy | scipy-main/scipy/stats/distributions.py | #
# Author: Travis Oliphant 2002-2011 with contributions from
# SciPy Developers 2004-2011
#
# NOTE: To look at history using `git blame`, use `git blame -M -C -C`
# instead of `git blame -Lxxx,+x`.
#
from ._distn_infrastructure import (rv_discrete, rv_continuous, rv_frozen) # noqa: F401
from . impor... | 817 | 31.72 | 88 | py |
scipy | scipy-main/scipy/stats/_hypotests.py | from collections import namedtuple
from dataclasses import dataclass
from math import comb
import numpy as np
import warnings
from itertools import combinations
import scipy.stats
from scipy.optimize import shgo
from . import distributions
from ._common import ConfidenceInterval
from ._continuous_distns import chi2, no... | 78,623 | 37.980664 | 90 | py |
scipy | scipy-main/scipy/stats/_rvs_sampling.py | import warnings
from scipy.stats.sampling import RatioUniforms
def rvs_ratio_uniforms(pdf, umax, vmin, vmax, size=1, c=0, random_state=None):
"""
Generate random samples from a probability density function using the
ratio-of-uniforms method.
.. deprecated:: 1.12.0
`rvs_ratio_uniforms` is depre... | 2,233 | 38.192982 | 79 | py |
scipy | scipy-main/scipy/stats/_generate_pyx.py | import pathlib
import subprocess
import sys
import os
import argparse
def make_boost(outdir, distutils_build=False):
# Call code generator inside _boost directory
code_gen = pathlib.Path(__file__).parent / '_boost/include/code_gen.py'
if distutils_build:
subprocess.run([sys.executable, str(code_ge... | 1,312 | 34.486486 | 77 | py |
scipy | scipy-main/scipy/stats/_binned_statistic.py | import builtins
import numpy as np
from numpy.testing import suppress_warnings
from operator import index
from collections import namedtuple
__all__ = ['binned_statistic',
'binned_statistic_2d',
'binned_statistic_dd']
BinnedStatisticResult = namedtuple('BinnedStatisticResult',
... | 32,704 | 40.086683 | 79 | py |
scipy | scipy-main/scipy/stats/_distr_params.py | """
Sane parameters for stats.distributions.
"""
import numpy as np
distcont = [
['alpha', (3.5704770516650459,)],
['anglit', ()],
['arcsine', ()],
['argus', (1.0,)],
['beta', (2.3098496451481823, 0.62687954300963677)],
['betaprime', (5, 6)],
['bradford', (0.29891359763170633,)],
['burr... | 8,577 | 29.204225 | 79 | py |
scipy | scipy-main/scipy/stats/_morestats.py | from __future__ import annotations
import math
import warnings
from collections import namedtuple
import numpy as np
from numpy import (isscalar, r_, log, around, unique, asarray, zeros,
arange, sort, amin, amax, sqrt, array, atleast_1d, # noqa
compress, pi, exp, ravel, count_non... | 188,458 | 36.669198 | 111 | py |
scipy | scipy-main/scipy/stats/_covariance.py | from functools import cached_property
import numpy as np
from scipy import linalg
from scipy.stats import _multivariate
__all__ = ["Covariance"]
class Covariance:
"""
Representation of a covariance matrix
Calculations involving covariance matrices (e.g. data whitening,
multivariate normal function... | 22,535 | 34.545741 | 79 | py |
scipy | scipy-main/scipy/stats/_odds_ratio.py | import numpy as np
from scipy.special import ndtri
from scipy.optimize import brentq
from ._discrete_distns import nchypergeom_fisher
from ._common import ConfidenceInterval
def _sample_odds_ratio(table):
"""
Given a table [[a, b], [c, d]], compute a*d/(b*c).
Return nan if the numerator and denominator ... | 17,856 | 35.971014 | 79 | py |
scipy | scipy-main/scipy/stats/_censored_data.py | import numpy as np
def _validate_1d(a, name, allow_inf=False):
if np.ndim(a) != 1:
raise ValueError(f'`{name}` must be a one-dimensional sequence.')
if np.isnan(a).any():
raise ValueError(f'`{name}` must not contain nan.')
if not allow_inf and np.isinf(a).any():
raise ValueError(f'... | 18,306 | 38.797826 | 78 | py |
scipy | scipy-main/scipy/stats/setup.py | import os
from os.path import join
from numpy.distutils.misc_util import get_info
def pre_build_hook(build_ext, ext):
from scipy._build_utils.compiler_helper import get_cxx_std_flag
std_flag = get_cxx_std_flag(build_ext._cxx_compiler)
if std_flag is not None:
ext.extra_compile_args.append(std_fla... | 2,936 | 29.278351 | 77 | py |
scipy | scipy-main/scipy/stats/_mstats_extras.py | """
Additional statistics functions with support for masked arrays.
"""
# Original author (2007): Pierre GF Gerard-Marchant
__all__ = ['compare_medians_ms',
'hdquantiles', 'hdmedian', 'hdquantiles_sd',
'idealfourths',
'median_cihs','mjci','mquantiles_cimj',
'rsh',
... | 15,610 | 30.159681 | 81 | py |
scipy | scipy-main/scipy/stats/_page_trend_test.py | from itertools import permutations
import numpy as np
import math
from ._continuous_distns import norm
import scipy.stats
from dataclasses import dataclass
@dataclass
class PageTrendTestResult:
statistic: float
pvalue: float
method: str
def page_trend_test(data, ranked=False, predicted_ranks=None, metho... | 18,999 | 38.583333 | 79 | py |
scipy | scipy-main/scipy/stats/kde.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.stats` namespace for importing the functions
# included below.
import warnings
from . import _kde
__all__ = [ # noqa: F822
'gaussian_kde', 'linalg', 'logsumexp', 'check_random_state',
'atleast_2d', 'reshape', 'newa... | 923 | 27.875 | 76 | py |
scipy | scipy-main/scipy/stats/_stats_py.py | # Copyright 2002 Gary Strangman. All rights reserved
# Copyright 2002-2016 The SciPy Developers
#
# The original code from Gary Strangman was heavily adapted for
# use in SciPy by Travis Oliphant. The original code came with the
# following disclaimer:
#
# This software is provided "as-is". There are no expressed or... | 400,769 | 37.0129 | 109 | py |
scipy | scipy-main/scipy/stats/stats.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.stats` namespace for importing the functions
# included below.
from scipy._lib.deprecation import _sub_module_deprecation
__all__ = [ # noqa: F822
'find_repeats', 'gmean', 'hmean', 'pmean', 'mode', 'tmean', 'tvar',
... | 2,137 | 39.339623 | 76 | py |
scipy | scipy-main/scipy/stats/_qmc.py | """Quasi-Monte Carlo engines and helpers."""
from __future__ import annotations
import copy
import math
import numbers
import os
import warnings
from abc import ABC, abstractmethod
from functools import partial
from typing import (
Callable,
ClassVar,
Literal,
overload,
TYPE_CHECKING,
)
import num... | 93,618 | 34.569529 | 100 | py |
scipy | scipy-main/scipy/stats/_binomtest.py | from math import sqrt
import numpy as np
from scipy._lib._util import _validate_int
from scipy.optimize import brentq
from scipy.special import ndtri
from ._discrete_distns import binom
from ._common import ConfidenceInterval
class BinomTestResult:
"""
Result of `scipy.stats.binomtest`.
Attributes
--... | 13,043 | 33.691489 | 79 | py |
scipy | scipy-main/scipy/stats/_stats_mstats_common.py | import warnings
import numpy as np
import scipy.stats._stats_py
from . import distributions
from .._lib._bunch import _make_tuple_bunch
from ._stats_pythran import siegelslopes as siegelslopes_pythran
__all__ = ['_find_repeats', 'linregress', 'theilslopes', 'siegelslopes']
# This is not a namedtuple for backwards com... | 18,649 | 36.151394 | 79 | py |
scipy | scipy-main/scipy/stats/_qmvnt.py | # Integration of multivariate normal and t distributions.
# Adapted from the MATLAB original implementations by Dr. Alan Genz.
# http://www.math.wsu.edu/faculty/genz/software/software.html
# Copyright (C) 2013, Alan Genz, All rights reserved.
# Python implementation is copyright (C) 2022, Robert Kern, All righ... | 18,767 | 34.146067 | 79 | py |
scipy | scipy-main/scipy/stats/mvn.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.stats` namespace for importing the functions
# included below.
import warnings
from . import _mvn # type: ignore
__all__ = [ # noqa: F822
'mvnun',
'mvnun_weighted',
'mvndst',
'dkblck'
]
def __dir__():
... | 784 | 23.53125 | 76 | py |
scipy | scipy-main/scipy/stats/_mstats_basic.py | """
An extension of scipy.stats._stats_py to support masked arrays
"""
# Original author (2007): Pierre GF Gerard-Marchant
__all__ = ['argstoarray',
'count_tied_groups',
'describe',
'f_oneway', 'find_repeats','friedmanchisquare',
'kendalltau','kendalltau_seasonal','kruskal... | 117,894 | 32.44539 | 84 | py |
scipy | scipy-main/scipy/stats/_multicomp.py | from __future__ import annotations
import warnings
from dataclasses import dataclass, field
from typing import TYPE_CHECKING
import numpy as np
from scipy import stats
from scipy.optimize import minimize_scalar
from scipy.stats._common import ConfidenceInterval
from scipy.stats._qmc import check_random_state
from sc... | 17,282 | 36.571739 | 80 | py |
scipy | scipy-main/scipy/stats/mstats_extras.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.stats` namespace for importing the functions
# included below.
import warnings
from . import _mstats_extras
__all__ = [ # noqa: F822
'compare_medians_ms',
'hdquantiles', 'hdmedian', 'hdquantiles_sd',
'idealfour... | 1,001 | 27.628571 | 77 | py |
scipy | scipy-main/scipy/stats/_relative_risk.py | import operator
from dataclasses import dataclass
import numpy as np
from scipy.special import ndtri
from ._common import ConfidenceInterval
def _validate_int(n, bound, name):
msg = f'{name} must be an integer not less than {bound}, but got {n!r}'
try:
n = operator.index(n)
except TypeError:
... | 9,571 | 35.257576 | 78 | py |
scipy | scipy-main/scipy/stats/sampling.py | """
======================================================
Random Number Generators (:mod:`scipy.stats.sampling`)
======================================================
.. currentmodule:: scipy.stats.sampling
This module contains a collection of random number generators to sample
from univariate continuous and discre... | 1,372 | 23.517857 | 71 | py |
scipy | scipy-main/scipy/stats/_crosstab.py | import numpy as np
from scipy.sparse import coo_matrix
from scipy._lib._bunch import _make_tuple_bunch
CrosstabResult = _make_tuple_bunch(
"CrosstabResult", ["elements", "count"]
)
def crosstab(*args, levels=None, sparse=False):
"""
Return table of counts for each possible unique combination in ``*args`... | 7,355 | 34.882927 | 79 | py |
scipy | scipy-main/scipy/stats/mstats.py | """
===================================================================
Statistical functions for masked arrays (:mod:`scipy.stats.mstats`)
===================================================================
.. currentmodule:: scipy.stats.mstats
This module contains a large number of statistical functions that can
be... | 2,262 | 15.639706 | 79 | py |
scipy | scipy-main/scipy/stats/morestats.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.stats` namespace for importing the functions
# included below.
from scipy._lib.deprecation import _sub_module_deprecation
__all__ = [ # noqa: F822
'mvsdist',
'bayes_mvs', 'kstat', 'kstatvar', 'probplot', 'ppcc_max'... | 1,388 | 38.685714 | 76 | py |
scipy | scipy-main/scipy/stats/_result_classes.py | # This module exists only to allow Sphinx to generate docs
# for the result objects returned by some functions in stats
# _without_ adding them to the main stats documentation page.
"""
Result classes
--------------
.. currentmodule:: scipy.stats._result_classes
.. autosummary::
:toctree: generated/
RelativeR... | 1,085 | 25.487805 | 69 | py |
scipy | scipy-main/scipy/stats/_sensitivity_analysis.py | from __future__ import annotations
import inspect
from dataclasses import dataclass
from typing import (
Callable, Literal, Protocol, TYPE_CHECKING
)
import numpy as np
from scipy.stats._common import ConfidenceInterval
from scipy.stats._qmc import check_random_state
from scipy.stats._resampling import Bootstrap... | 24,753 | 33.718093 | 79 | py |
scipy | scipy-main/scipy/stats/qmc.py | r"""
====================================================
Quasi-Monte Carlo submodule (:mod:`scipy.stats.qmc`)
====================================================
.. currentmodule:: scipy.stats.qmc
This module provides Quasi-Monte Carlo generators and associated helper
functions.
Quasi-Monte Carlo
================... | 11,624 | 48.468085 | 79 | py |
scipy | scipy-main/scipy/stats/biasedurn.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
import warnings
from . import _biasedurn
__all__ = [ # noqa: F822
'_PyFishersNCHypergeometric',
'_PyWalleniusNCHypergeometric',
'_PyStochasticLib3'
]
def __dir__():
return __all__
def __getattr__(name):
if name not... | 690 | 22.033333 | 76 | py |
scipy | scipy-main/scipy/stats/_entropy.py | """
Created on Fri Apr 2 09:06:05 2021
@author: matth
"""
from __future__ import annotations
import math
import numpy as np
from scipy import special
__all__ = ['entropy', 'differential_entropy']
def entropy(pk: np.typing.ArrayLike,
qk: np.typing.ArrayLike | None = None,
base: float | None... | 14,279 | 34.879397 | 79 | py |
scipy | scipy-main/scipy/stats/_bws_test.py | import numpy as np
from functools import partial
from scipy import stats
def _bws_input_validation(x, y, alternative, method):
''' Input validation and standardization for bws test'''
x, y = np.atleast_1d(x, y)
if x.ndim > 1 or y.ndim > 1:
raise ValueError('`x` and `y` must be exactly one-dimensio... | 7,059 | 38.662921 | 81 | py |
scipy | scipy-main/scipy/stats/_axis_nan_policy.py | # Many scipy.stats functions support `axis` and `nan_policy` parameters.
# When the two are combined, it can be tricky to get all the behavior just
# right. This file contains utility functions useful for scipy.stats functions
# that support `axis` and `nan_policy`, including a decorator that
# automatically adds `axis... | 28,384 | 43.984152 | 79 | py |
scipy | scipy-main/scipy/stats/_multivariate.py | #
# Author: Joris Vankerschaver 2013
#
import math
import numpy as np
from numpy import asarray_chkfinite, asarray
from numpy.lib import NumpyVersion
import scipy.linalg
from scipy._lib import doccer
from scipy.special import (gammaln, psi, multigammaln, xlogy, entr, betaln,
ive, loggamma)
fr... | 237,188 | 32.986101 | 122 | py |
scipy | scipy-main/scipy/stats/_tukeylambda_stats.py | import numpy as np
from numpy import poly1d
from scipy.special import beta
# The following code was used to generate the Pade coefficients for the
# Tukey Lambda variance function. Version 0.17 of mpmath was used.
#---------------------------------------------------------------------------
# import mpmath as mp
#
# ... | 6,871 | 33.36 | 79 | py |
scipy | scipy-main/scipy/stats/mstats_basic.py | # This file is not meant for public use and will be removed in SciPy v2.0.0.
# Use the `scipy.stats` namespace for importing the functions
# included below.
import warnings
from . import _mstats_basic
__all__ = [ # noqa: F822
'argstoarray',
'count_tied_groups',
'describe',
'f_oneway', 'find_repeats'... | 2,123 | 35 | 76 | py |
scipy | scipy-main/scipy/stats/_kde.py | #-------------------------------------------------------------------------------
#
# Define classes for (uni/multi)-variate kernel density estimation.
#
# Currently, only Gaussian kernels are implemented.
#
# Written by: Robert Kern
#
# Date: 2004-08-09
#
# Modified: 2005-02-10 by Robert Kern.
# Contr... | 24,989 | 33.421488 | 90 | py |
scipy | scipy-main/scipy/stats/__init__.py | """
.. _statsrefmanual:
==========================================
Statistical functions (:mod:`scipy.stats`)
==========================================
.. currentmodule:: scipy.stats
This module contains a large number of probability distributions,
summary and frequency statistics, correlation functions and statist... | 18,012 | 27.145313 | 100 | py |
scipy | scipy-main/scipy/stats/_stats_pythran.py | import numpy as np
#pythran export _Aij(float[:,:], int, int)
#pythran export _Aij(int[:,:], int, int)
def _Aij(A, i, j):
"""Sum of upper-left and lower right blocks of contingency table."""
# See `somersd` References [2] bottom of page 309
return A[:i, :j].sum() + A[i+1:, j+1:].sum()
#pythran export _D... | 6,306 | 34.038889 | 90 | py |
scipy | scipy-main/scipy/stats/_sampling.py | import numpy as np
from scipy._lib._util import check_random_state
class RatioUniforms:
"""
Generate random samples from a probability density function using the
ratio-of-uniforms method.
Parameters
----------
pdf : callable
A function with signature `pdf(x)` that is proportional to t... | 7,742 | 38.912371 | 79 | py |
scipy | scipy-main/scipy/stats/_mannwhitneyu.py | import numpy as np
from collections import namedtuple
from scipy import special
from scipy import stats
from ._axis_nan_policy import _axis_nan_policy_factory
def _broadcast_concatenate(x, y, axis):
'''Broadcast then concatenate arrays, leaving concatenation axis last'''
x = np.moveaxis(x, axis, -1)
y = n... | 18,965 | 37.392713 | 79 | py |
scipy | scipy-main/scipy/stats/_common.py | from collections import namedtuple
ConfidenceInterval = namedtuple("ConfidenceInterval", ["low", "high"])
ConfidenceInterval. __doc__ = "Class for confidence intervals."
| 172 | 27.833333 | 70 | py |
scipy | scipy-main/scipy/stats/_variation.py | import numpy as np
from scipy._lib._util import _nan_allsame, _contains_nan, normalize_axis_index
from ._stats_py import _chk_asarray
def _nanvariation(a, *, axis=0, ddof=0, keepdims=False):
"""
Private version of `variation` that ignores nan.
`a` must be a numpy array.
`axis` is assumed to be normal... | 8,295 | 36.201794 | 79 | py |
scipy | scipy-main/scipy/stats/_distn_infrastructure.py | #
# Author: Travis Oliphant 2002-2011 with contributions from
# SciPy Developers 2004-2011
#
from scipy._lib._util import getfullargspec_no_self as _getfullargspec
import sys
import keyword
import re
import types
import warnings
from itertools import zip_longest
from scipy._lib import doccer
from ._distr_p... | 145,678 | 34.961244 | 195 | py |
scipy | scipy-main/scipy/stats/_constants.py | """
Statistics-related constants.
"""
import numpy as np
# The smallest representable positive number such that 1.0 + _EPS != 1.0.
_EPS = np.finfo(float).eps
# The largest [in magnitude] usable floating value.
_XMAX = np.finfo(float).max
# The log of the largest usable floating value; useful for knowing
# when exp... | 962 | 23.075 | 74 | py |
scipy | scipy-main/scipy/stats/_warnings_errors.py | # Warnings
class DegenerateDataWarning(RuntimeWarning):
"""Warns when data is degenerate and results may not be reliable."""
def __init__(self, msg=None):
if msg is None:
msg = ("Degenerate data encountered; results may not be reliable.")
self.args = (msg,)
class ConstantInputWar... | 1,196 | 29.692308 | 79 | py |
scipy | scipy-main/scipy/stats/_fit.py | import warnings
from collections import namedtuple
import numpy as np
from scipy import optimize, stats
from scipy._lib._util import check_random_state
def _combine_bounds(name, user_bounds, shape_domain, integral):
"""Intersection of user-defined bounds and distribution PDF/PMF domain"""
user_bounds = np.at... | 58,447 | 43.145015 | 79 | py |
scipy | scipy-main/scipy/stats/_ksstats.py | # Compute the two-sided one-sample Kolmogorov-Smirnov Prob(Dn <= d) where:
# D_n = sup_x{|F_n(x) - F(x)|},
# F_n(x) is the empirical CDF for a sample of size n {x_i: i=1,...,n},
# F(x) is the CDF of a probability distribution.
#
# Exact methods:
# Prob(D_n >= d) can be computed via a matrix algorithm of Durbin... | 20,100 | 32.445923 | 84 | py |
scipy | scipy-main/scipy/stats/_discrete_distns.py | #
# Author: Travis Oliphant 2002-2011 with contributions from
# SciPy Developers 2004-2011
#
from functools import partial
from scipy import special
from scipy.special import entr, logsumexp, betaln, gammaln as gamln, zeta
from scipy._lib._util import _lazywhere, rng_integers
from scipy.interpolate import i... | 55,962 | 29.136241 | 90 | py |
scipy | scipy-main/scipy/stats/contingency.py | """
Contingency table functions (:mod:`scipy.stats.contingency`)
============================================================
Functions for creating and analyzing contingency tables.
.. currentmodule:: scipy.stats.contingency
.. autosummary::
:toctree: generated/
chi2_contingency
relative_risk
odds_rati... | 16,283 | 33.720682 | 86 | py |
scipy | scipy-main/scipy/stats/_resampling.py | from __future__ import annotations
import warnings
import numpy as np
from itertools import combinations, permutations, product
from collections.abc import Sequence
import inspect
from scipy._lib._util import check_random_state, _rename_parameter
from scipy.special import ndtr, ndtri, comb, factorial
from scipy._lib.... | 80,044 | 42.314394 | 79 | py |
scipy | scipy-main/scipy/stats/_boost/setup.py | import pathlib
def pre_build_hook(build_ext, ext):
from scipy._build_utils.compiler_helper import get_cxx_std_flag
std_flag = get_cxx_std_flag(build_ext._cxx_compiler)
if std_flag is not None:
ext.extra_compile_args.append(std_flag)
def configuration(parent_package='', top_path=None):
from s... | 1,818 | 30.362069 | 77 | py |
scipy | scipy-main/scipy/stats/_boost/__init__.py | from scipy.stats._boost.beta_ufunc import (
_beta_pdf, _beta_cdf, _beta_sf, _beta_ppf,
_beta_isf, _beta_mean, _beta_variance,
_beta_skewness, _beta_kurtosis_excess,
)
from scipy.stats._boost.binom_ufunc import (
_binom_pdf, _binom_cdf, _binom_sf, _binom_ppf,
_binom_isf, _binom_mean, _binom_variance... | 1,759 | 31.592593 | 66 | py |
scipy | scipy-main/scipy/stats/_boost/include/gen_func_defs_pxd.py | '''Generate func_defs.pxd'''
import pathlib
def _gen_func_defs_pxd(outfile, x_funcs, no_x_funcs, max_num_inputs=4):
'''
Cython does not support template parameter packs, so to keep it
from freaking out, we'll manually produce all the different template
expansions we need to call in the cython wrapper... | 1,859 | 40.333333 | 76 | py |
scipy | scipy-main/scipy/stats/_boost/include/code_gen.py | '''Generate Cython PYX wrappers for Boost stats distributions.'''
from typing import NamedTuple
from warnings import warn
from textwrap import dedent
from shutil import copyfile
import pathlib
import argparse
from gen_func_defs_pxd import ( # type: ignore
_gen_func_defs_pxd)
from _info import ( # type: ignore
... | 7,233 | 36.481865 | 78 | py |
scipy | scipy-main/scipy/stats/_boost/include/_info.py | from typing import NamedTuple
class _KlassMap(NamedTuple):
scipy_name: str
ctor_args: tuple
# map boost stats classes to scipy class names and
# constructor arguments; b -> (s, ('ctor', 'args', ...))
_klass_mapper = {
'beta': _KlassMap('beta', ('a', 'b')),
'binomial': _KlassMap('binom', ('n', 'p')),... | 956 | 33.178571 | 65 | py |
scipy | scipy-main/scipy/stats/_levy_stable/setup.py | from os.path import join
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('_levy_stable', parent_package, top_path)
config.add_library(
'_levyst',
sources=[join('c_src', 'levyst.c')],
headers=[join('c_... | 594 | 22.8 | 68 | py |
scipy | scipy-main/scipy/stats/_levy_stable/__init__.py | #
import warnings
from functools import partial
import numpy as np
from scipy import optimize
from scipy import integrate
from scipy.integrate._quadrature import _builtincoeffs
from scipy import interpolate
from scipy.interpolate import RectBivariateSpline
import scipy.special as sc
from scipy._lib._util import _laz... | 44,613 | 35.810231 | 93 | py |
scipy | scipy-main/scipy/stats/tests/test_odds_ratio.py | import pytest
import numpy as np
from numpy.testing import assert_equal, assert_allclose
from .._discrete_distns import nchypergeom_fisher, hypergeom
from scipy.stats._odds_ratio import odds_ratio
from .data.fisher_exact_results_from_r import data
class TestOddsRatio:
@pytest.mark.parametrize('parameters, rresul... | 6,705 | 44.310811 | 78 | py |
scipy | scipy-main/scipy/stats/tests/test_survival.py | import pytest
import numpy as np
from numpy.testing import assert_equal, assert_allclose
from scipy import stats
from scipy.stats import _survival
def _kaplan_meier_reference(times, censored):
# This is a very straightforward implementation of the Kaplan-Meier
# estimator that does almost everything different... | 21,992 | 46.094218 | 133 | py |
scipy | scipy-main/scipy/stats/tests/test_binned_statistic.py | import numpy as np
from numpy.testing import assert_allclose
import pytest
from pytest import raises as assert_raises
from scipy.stats import (binned_statistic, binned_statistic_2d,
binned_statistic_dd)
from scipy._lib._util import check_random_state
from .common_tests import check_named_resul... | 18,814 | 32.066784 | 79 | py |
scipy | scipy-main/scipy/stats/tests/test_continuous_fit_censored.py | # Tests for fitting specific distributions to censored data.
import numpy as np
from numpy.testing import assert_allclose
from scipy.optimize import fmin
from scipy.stats import (CensoredData, beta, cauchy, chi2, expon, gamma,
gumbel_l, gumbel_r, invgauss, invweibull, laplace,
... | 24,186 | 34.361111 | 79 | py |
scipy | scipy-main/scipy/stats/tests/test_morestats.py | # Author: Travis Oliphant, 2002
#
# Further enhancements and tests added by numerous SciPy developers.
#
import warnings
import sys
import numpy as np
from numpy.random import RandomState
from numpy.testing import (assert_array_equal, assert_almost_equal,
assert_array_less, assert_array_alm... | 118,674 | 41.70421 | 92 | py |
scipy | scipy-main/scipy/stats/tests/test_relative_risk.py | import pytest
import numpy as np
from numpy.testing import assert_allclose, assert_equal
from scipy.stats.contingency import relative_risk
# Test just the calculation of the relative risk, including edge
# cases that result in a relative risk of 0, inf or nan.
@pytest.mark.parametrize(
'exposed_cases, exposed_tot... | 3,646 | 36.989583 | 78 | py |
scipy | scipy-main/scipy/stats/tests/test_tukeylambda_stats.py | import numpy as np
from numpy.testing import assert_allclose, assert_equal
from scipy.stats._tukeylambda_stats import (tukeylambda_variance,
tukeylambda_kurtosis)
def test_tukeylambda_stats_known_exact():
"""Compare results with some known exact formulas."""
# Some... | 3,231 | 36.581395 | 75 | py |
scipy | scipy-main/scipy/stats/tests/test_sampling.py | import threading
import pickle
import pytest
from copy import deepcopy
import platform
import sys
import math
import numpy as np
from numpy.testing import assert_allclose, assert_equal, suppress_warnings
from scipy.stats.sampling import (
TransformedDensityRejection,
DiscreteAliasUrn,
DiscreteGuideTable,
... | 54,156 | 36.635163 | 99 | py |
scipy | scipy-main/scipy/stats/tests/test_axis_nan_policy.py | # Many scipy.stats functions support `axis` and `nan_policy` parameters.
# When the two are combined, it can be tricky to get all the behavior just
# right. This file contains a suite of common tests for scipy.stats functions
# that support `axis` and `nan_policy` and additional tests for some associated
# functions in... | 47,628 | 41.487957 | 79 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.