Search is not available for this dataset
repo_id
stringlengths
12
110
file_path
stringlengths
24
164
content
stringlengths
3
89.3M
__index_level_0__
int64
0
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_io.py
import sys import gc import gzip import os import threading import time import warnings import re import pytest from pathlib import Path from tempfile import NamedTemporaryFile from io import BytesIO, StringIO from datetime import datetime import locale from multiprocessing import Value, get_context from ctypes import ...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_format.py
# doctest r''' Test the .npy file format. Set up: >>> import sys >>> from io import BytesIO >>> from numpy.lib import format >>> >>> scalars = [ ... np.uint8, ... np.int8, ... np.uint16, ... np.int16, ... np.uint32, ... np.int32, ... np.uint6...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_arraypad.py
"""Tests for the array padding functions. """ import pytest import numpy as np from numpy.testing import assert_array_equal, assert_allclose, assert_equal from numpy.lib._arraypad_impl import _as_pairs _numeric_dtypes = ( np._core.sctypes["uint"] + np._core.sctypes["int"] + np._core.sctypes["float"] ...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_ufunclike.py
import numpy as np from numpy import fix, isposinf, isneginf from numpy.testing import ( assert_, assert_equal, assert_array_equal, assert_raises ) class TestUfunclike: def test_isposinf(self): a = np.array([np.inf, -np.inf, np.nan, 0.0, 3.0, -3.0]) out = np.zeros(a.shape, bool) tgt ...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_loadtxt.py
""" Tests specific to `np.loadtxt` added during the move of loadtxt to be backed by C code. These tests complement those found in `test_io.py`. """ import sys import os import pytest from tempfile import NamedTemporaryFile, mkstemp from io import StringIO import numpy as np from numpy.ma.testutils import assert_equal...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_function_base.py
import operator import warnings import sys import decimal from fractions import Fraction import math import pytest import hypothesis from hypothesis.extra.numpy import arrays import hypothesis.strategies as st from functools import partial import numpy as np from numpy import ( ma, angle, average, bartlett, blackm...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_twodim_base.py
"""Test functions for matrix module """ from numpy.testing import ( assert_equal, assert_array_equal, assert_array_max_ulp, assert_array_almost_equal, assert_raises, assert_ ) from numpy import ( arange, add, fliplr, flipud, zeros, ones, eye, array, diag, histogram2d, tri, mask_indices, triu_indices, t...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_packbits.py
import numpy as np from numpy.testing import assert_array_equal, assert_equal, assert_raises import pytest from itertools import chain def test_packbits(): # Copied from the docstring. a = [[[1, 0, 1], [0, 1, 0]], [[1, 1, 0], [0, 0, 1]]] for dt in '?bBhHiIlLqQ': arr = np.array(a, dtype=dt)...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_nanfunctions.py
import warnings import pytest import inspect import numpy as np from numpy._core.numeric import normalize_axis_tuple from numpy.exceptions import AxisError, ComplexWarning from numpy.lib._nanfunctions_impl import _nan_mask, _replace_nan from numpy.testing import ( assert_, assert_equal, assert_almost_equal, assert...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_polynomial.py
import numpy as np from numpy.testing import ( assert_, assert_equal, assert_array_equal, assert_almost_equal, assert_array_almost_equal, assert_raises, assert_allclose ) import pytest # `poly1d` has some support for `bool_` and `timedelta64`, # but it is limited and they are therefore excluded here TYPE_...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_recfunctions.py
import pytest import numpy as np import numpy.ma as ma from numpy.ma.mrecords import MaskedRecords from numpy.ma.testutils import assert_equal from numpy.testing import assert_, assert_raises from numpy.lib.recfunctions import ( drop_fields, rename_fields, get_fieldstructure, recursive_fill_fields, find_duplic...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_mixins.py
import numbers import operator import numpy as np from numpy.testing import assert_, assert_equal, assert_raises # NOTE: This class should be kept as an exact copy of the example from the # docstring for NDArrayOperatorsMixin. class ArrayLike(np.lib.mixins.NDArrayOperatorsMixin): def __init__(self, value): ...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_arrayterator.py
from operator import mul from functools import reduce import numpy as np from numpy.random import randint from numpy.lib import Arrayterator from numpy.testing import assert_ def test(): np.random.seed(np.arange(10)) # Create a random array ndims = randint(5)+1 shape = tuple(randint(10)+1 for dim in...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_arraysetops.py
"""Test functions for 1D array set operations. """ import numpy as np from numpy import ( ediff1d, intersect1d, setxor1d, union1d, setdiff1d, unique, isin ) from numpy.exceptions import AxisError from numpy.testing import (assert_array_equal, assert_equal, assert_raises, assert_rais...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_utils.py
import pytest import numpy as np from numpy.testing import assert_raises_regex import numpy.lib._utils_impl as _utils_impl from io import StringIO def test_assert_raises_regex_context_manager(): with assert_raises_regex(ValueError, 'no deprecation warning'): raise ValueError('no deprecation warning') ...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test__iotools.py
import time from datetime import date import numpy as np from numpy.testing import ( assert_, assert_equal, assert_allclose, assert_raises, ) from numpy.lib._iotools import ( LineSplitter, NameValidator, StringConverter, has_nested_fields, easy_dtype, flatten_dtype ) class TestLineSplitter: "...
0
public_repos/numpy/numpy/lib
public_repos/numpy/numpy/lib/tests/test_type_check.py
import numpy as np from numpy import ( common_type, mintypecode, isreal, iscomplex, isposinf, isneginf, nan_to_num, isrealobj, iscomplexobj, real_if_close ) from numpy.testing import ( assert_, assert_equal, assert_array_equal, assert_raises ) def assert_all(x): assert_(np.all(x), x) class T...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/tests/test_matlib.py
import numpy as np import numpy.matlib from numpy.testing import assert_array_equal, assert_ def test_empty(): x = numpy.matlib.empty((2,)) assert_(isinstance(x, np.matrix)) assert_(x.shape, (1, 2)) def test_ones(): assert_array_equal(numpy.matlib.ones((2, 3)), np.matrix([[ 1., ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/tests/test__all__.py
import collections import numpy as np def test_no_duplicates_in_np__all__(): # Regression test for gh-10198. dups = {k: v for k, v in collections.Counter(np.__all__).items() if v > 1} assert len(dups) == 0
0
public_repos/numpy/numpy
public_repos/numpy/numpy/tests/test_ctypeslib.py
import sys import sysconfig import weakref from pathlib import Path import pytest import numpy as np from numpy.ctypeslib import ndpointer, load_library, as_array from numpy.testing import assert_, assert_array_equal, assert_raises, assert_equal try: import ctypes except ImportError: ctypes = None else: ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/tests/test_reloading.py
import sys import subprocess import textwrap from importlib import reload import pickle import pytest import numpy.exceptions as ex from numpy.testing import ( assert_raises, assert_warns, assert_, assert_equal, IS_WASM, ) def test_numpy_reloading(): # gh-7844. Also check that relevant globa...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/tests/test_scripts.py
""" Test scripts Test that we can run executable scripts that have been installed with numpy. """ import sys import os import pytest from os.path import join as pathjoin, isfile, dirname import subprocess import numpy as np from numpy.testing import assert_equal, IS_WASM is_inplace = isfile(pathjoin(dirname(np.__fil...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/tests/test_lazyloading.py
import sys import importlib from importlib.util import LazyLoader, find_spec, module_from_spec import pytest # Warning raised by _reload_guard() in numpy/__init__.py @pytest.mark.filterwarnings("ignore:The NumPy module was reloaded") def test_lazy_load(): # gh-22045. lazyload doesn't import submodule names into t...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/tests/test_numpy_version.py
""" Check the numpy version is valid. Note that a development version is marked by the presence of 'dev0' or '+' in the version string, all else is treated as a release. The version string itself is set from the output of ``git describe`` which relies on tags. Examples -------- Valid Development: 1.22.0.dev0 1.22.0....
0
public_repos/numpy/numpy
public_repos/numpy/numpy/tests/test_public_api.py
import sys import sysconfig import subprocess import pkgutil import types import importlib import inspect import warnings import numpy as np import numpy from numpy.testing import IS_WASM import pytest try: import ctypes except ImportError: ctypes = None def check_dir(module, module_name=None): """Retu...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/tests/test_numpy_config.py
""" Check the numpy config is valid. """ import numpy as np import pytest from unittest.mock import Mock, patch pytestmark = pytest.mark.skipif( not hasattr(np.__config__, "_built_with_meson"), reason="Requires Meson builds", ) class TestNumPyConfigs: REQUIRED_CONFIG_KEYS = [ "Compilers", ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/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. """ import pytest from pathlib import Path import ast import tokenize import numpy class ParseCall(ast.NodeVisitor): def __init__(self): self.ls = [] def visit_Attribute(s...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_pyinstaller/hook-numpy.py
"""This hook should collect all binary files and any hidden modules that numpy needs. Our (some-what inadequate) docs for writing PyInstaller hooks are kept here: https://pyinstaller.readthedocs.io/en/stable/hooks.html """ from PyInstaller.compat import is_conda, is_pure_conda from PyInstaller.utils.hooks import coll...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_pyinstaller/pyinstaller-smoke.py
"""A crude *bit of everything* smoke test to verify PyInstaller compatibility. PyInstaller typically goes wrong by forgetting to package modules, extension modules or shared libraries. This script should aim to touch as many of those as possible in an attempt to trip a ModuleNotFoundError or a DLL load failure due to ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_pyinstaller/test_pyinstaller.py
import subprocess from pathlib import Path import pytest # PyInstaller has been very unproactive about replacing 'imp' with 'importlib'. @pytest.mark.filterwarnings('ignore::DeprecationWarning') # It also leaks io.BytesIO()s. @pytest.mark.filterwarnings('ignore::ResourceWarning') @pytest.mark.parametrize("mode", ["-...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_utils/_convertions.py
""" A set of methods retained from np.compat module that are still used across codebase. """ __all__ = ["asunicode", "asbytes"] def asunicode(s): if isinstance(s, bytes): return s.decode('latin1') return str(s) def asbytes(s): if isinstance(s, bytes): return s return str(s).encode('...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_utils/_inspect.py
"""Subset of inspect module from upstream python We use this instead of upstream because upstream inspect is slow to import, and significantly contributes to numpy import times. Importing this copy has almost no overhead. """ import types __all__ = ['getargspec', 'formatargspec'] # ---------------------------------...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_utils/_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...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_utils/__init__.py
""" This is a module for defining private helpers which do not depend on the rest of NumPy. Everything in here must be self-contained so that it can be imported anywhere else without creating circular imports. If a utility requires the import of NumPy, it probably belongs in ``numpy._core``. """ from ._convertions im...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/matrixlib/__init__.pyi
from numpy._pytesttester import PytestTester from numpy import ( matrix as matrix, ) from numpy.matrixlib.defmatrix import ( bmat as bmat, mat as mat, asmatrix as asmatrix, ) __all__: list[str] test: PytestTester
0
public_repos/numpy/numpy
public_repos/numpy/numpy/matrixlib/defmatrix.py
__all__ = ['matrix', 'bmat', 'asmatrix'] import sys import warnings import ast from .._utils import set_module import numpy._core.numeric as N from numpy._core.numeric import concatenate, isscalar # While not in __all__, matrix_power used to be defined here, so we import # it for backward compatibility. from numpy.li...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/matrixlib/defmatrix.pyi
from collections.abc import Sequence, Mapping from typing import Any from numpy import matrix as matrix from numpy._typing import ArrayLike, DTypeLike, NDArray __all__: list[str] def bmat( obj: str | Sequence[ArrayLike] | NDArray[Any], ldict: None | Mapping[str, Any] = ..., gdict: None | Mapping[str, Any]...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/matrixlib/__init__.py
"""Sub-package containing the matrix class and related functions. """ from . import defmatrix from .defmatrix import * __all__ = defmatrix.__all__ from numpy._pytesttester import PytestTester test = PytestTester(__name__) del PytestTester
0
public_repos/numpy/numpy/matrixlib
public_repos/numpy/numpy/matrixlib/tests/test_interaction.py
"""Tests of interaction of matrix with other parts of numpy. Note that tests with MaskedArray and linalg are done in separate files. """ import pytest import textwrap import warnings import numpy as np from numpy.testing import (assert_, assert_equal, assert_raises, assert_raises_regex, as...
0
public_repos/numpy/numpy/matrixlib
public_repos/numpy/numpy/matrixlib/tests/test_masked_matrix.py
import pickle import numpy as np from numpy.testing import assert_warns from numpy.ma.testutils import (assert_, assert_equal, assert_raises, assert_array_equal) from numpy.ma.core import (masked_array, masked_values, masked, allequal, MaskType, getmask, Maske...
0
public_repos/numpy/numpy/matrixlib
public_repos/numpy/numpy/matrixlib/tests/test_regression.py
import numpy as np from numpy.testing import assert_, assert_equal, assert_raises class TestRegression: def test_kron_matrix(self): # Ticket #71 x = np.matrix('[1 0; 1 0]') assert_equal(type(np.kron(x, x)), type(x)) def test_matrix_properties(self): # Ticket #125 a = n...
0
public_repos/numpy/numpy/matrixlib
public_repos/numpy/numpy/matrixlib/tests/test_multiarray.py
import numpy as np from numpy.testing import assert_, assert_equal, assert_array_equal class TestView: def test_type(self): x = np.array([1, 2, 3]) assert_(isinstance(x.view(np.matrix), np.matrix)) def test_keywords(self): x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)]) ...
0
public_repos/numpy/numpy/matrixlib
public_repos/numpy/numpy/matrixlib/tests/test_defmatrix.py
import collections.abc import numpy as np from numpy import matrix, asmatrix, bmat from numpy.testing import ( assert_, assert_equal, assert_almost_equal, assert_array_equal, assert_array_almost_equal, assert_raises ) from numpy.linalg import matrix_power class TestCtor: def test_basic(self): ...
0
public_repos/numpy/numpy/matrixlib
public_repos/numpy/numpy/matrixlib/tests/test_matrix_linalg.py
""" Test functions for linalg module using the matrix class.""" import numpy as np from numpy.linalg.tests.test_linalg import ( LinalgCase, apply_tag, TestQR as _TestQR, LinalgTestCase, _TestNorm2D, _TestNormDoubleBase, _TestNormSingleBase, _TestNormInt64Base, SolveCases, InvCases, EigvalsCases, EigCases, ...
0
public_repos/numpy/numpy/matrixlib
public_repos/numpy/numpy/matrixlib/tests/test_numeric.py
import numpy as np from numpy.testing import assert_equal class TestDot: def test_matscalar(self): b1 = np.matrix(np.ones((3, 3), dtype=complex)) assert_equal(b1*1.0, b1) def test_diagonal(): b1 = np.matrix([[1,2],[3,4]]) diag_b1 = np.matrix([[1, 4]]) array_b1 = np.array([1, 4]) ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/__init__.pyi
from numpy._pytesttester import PytestTester from numpy.polynomial import ( chebyshev as chebyshev, hermite as hermite, hermite_e as hermite_e, laguerre as laguerre, legendre as legendre, polynomial as polynomial, ) from numpy.polynomial.chebyshev import Chebyshev as Chebyshev from numpy.polyno...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/chebyshev.pyi
from typing import Any from numpy import int_ from numpy.typing import NDArray from numpy.polynomial._polybase import ABCPolyBase from numpy.polynomial.polyutils import trimcoef __all__: list[str] chebtrim = trimcoef def poly2cheb(pol): ... def cheb2poly(c): ... chebdomain: NDArray[int_] chebzero: NDArray[int_] ch...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/polynomial.pyi
from typing import Any from numpy import int_ from numpy.typing import NDArray from numpy.polynomial._polybase import ABCPolyBase from numpy.polynomial.polyutils import trimcoef __all__: list[str] polytrim = trimcoef polydomain: NDArray[int_] polyzero: NDArray[int_] polyone: NDArray[int_] polyx: NDArray[int_] def ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/hermite_e.py
""" =================================================================== HermiteE Series, "Probabilists" (:mod:`numpy.polynomial.hermite_e`) =================================================================== This module provides a number of objects (mostly functions) useful for dealing with Hermite_e series, including...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/polyutils.pyi
__all__: list[str] def trimseq(seq): ... def as_series(alist, trim=...): ... def trimcoef(c, tol=...): ... def getdomain(x): ... def mapparms(old, new): ... def mapdomain(x, old, new): ... def format_float(x, parens=...): ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/legendre.pyi
from typing import Any from numpy import int_ from numpy.typing import NDArray from numpy.polynomial._polybase import ABCPolyBase from numpy.polynomial.polyutils import trimcoef __all__: list[str] legtrim = trimcoef def poly2leg(pol): ... def leg2poly(c): ... legdomain: NDArray[int_] legzero: NDArray[int_] legone:...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/legendre.py
""" ================================================== Legendre Series (:mod:`numpy.polynomial.legendre`) ================================================== This module provides a number of objects (mostly functions) useful for dealing with Legendre series, including a `Legendre` class that encapsulates the usual arit...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/chebyshev.py
""" ==================================================== Chebyshev Series (:mod:`numpy.polynomial.chebyshev`) ==================================================== This module provides a number of objects (mostly functions) useful for dealing with Chebyshev series, including a `Chebyshev` class that encapsulates the us...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/_polybase.py
""" Abstract base class for the various polynomial Classes. The ABCPolyBase class provides the methods needed to implement the common API for the various polynomial classes. It operates as a mixin, but uses the abc module from the stdlib, hence it is only available for Python >= 2.6. """ import os import abc import n...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/hermite.py
""" ============================================================== Hermite Series, "Physicists" (:mod:`numpy.polynomial.hermite`) ============================================================== This module provides a number of objects (mostly functions) useful for dealing with Hermite series, including a `Hermite` clas...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/polynomial.py
""" ================================================= Power Series (:mod:`numpy.polynomial.polynomial`) ================================================= This module provides a number of objects (mostly functions) useful for dealing with polynomials, including a `Polynomial` class that encapsulates the usual arithmeti...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/polyutils.py
""" Utility classes and functions for the polynomial modules. This module provides: error and warning objects; a polynomial base class; and some routines used in both the `polynomial` and `chebyshev` modules. Functions --------- .. autosummary:: :toctree: generated/ as_series convert list of array_likes in...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/_polybase.pyi
import abc from typing import Any, ClassVar __all__: list[str] class ABCPolyBase(abc.ABC): __hash__: ClassVar[None] # type: ignore[assignment] __array_ufunc__: ClassVar[None] maxpower: ClassVar[int] coef: Any @property def symbol(self) -> str: ... @property @abc.abstractmethod def...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/laguerre.pyi
from typing import Any from numpy import int_ from numpy.typing import NDArray from numpy.polynomial._polybase import ABCPolyBase from numpy.polynomial.polyutils import trimcoef __all__: list[str] lagtrim = trimcoef def poly2lag(pol): ... def lag2poly(c): ... lagdomain: NDArray[int_] lagzero: NDArray[int_] lagone:...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/hermite.pyi
from typing import Any from numpy import int_, float64 from numpy.typing import NDArray from numpy.polynomial._polybase import ABCPolyBase from numpy.polynomial.polyutils import trimcoef __all__: list[str] hermtrim = trimcoef def poly2herm(pol): ... def herm2poly(c): ... hermdomain: NDArray[int_] hermzero: NDArray...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/hermite_e.pyi
from typing import Any from numpy import int_ from numpy.typing import NDArray from numpy.polynomial._polybase import ABCPolyBase from numpy.polynomial.polyutils import trimcoef __all__: list[str] hermetrim = trimcoef def poly2herme(pol): ... def herme2poly(c): ... hermedomain: NDArray[int_] hermezero: NDArray[int...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/laguerre.py
""" ================================================== Laguerre Series (:mod:`numpy.polynomial.laguerre`) ================================================== This module provides a number of objects (mostly functions) useful for dealing with Laguerre series, including a `Laguerre` class that encapsulates the usual arit...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/polynomial/__init__.py
""" A sub-package for efficiently dealing with polynomials. Within the documentation for this sub-package, a "finite power series," i.e., a polynomial (also referred to simply as a "series") is represented by a 1-D numpy array of the polynomial's coefficients, ordered from lowest order term to highest. For example, a...
0
public_repos/numpy/numpy/polynomial
public_repos/numpy/numpy/polynomial/tests/test_hermite.py
"""Tests for hermite module. """ from functools import reduce import numpy as np import numpy.polynomial.hermite as herm from numpy.polynomial.polynomial import polyval from numpy.testing import ( assert_almost_equal, assert_raises, assert_equal, assert_, ) H0 = np.array([1]) H1 = np.array([0, 2]) H2 = np.ar...
0
public_repos/numpy/numpy/polynomial
public_repos/numpy/numpy/polynomial/tests/test_chebyshev.py
"""Tests for chebyshev module. """ from functools import reduce import numpy as np import numpy.polynomial.chebyshev as cheb from numpy.polynomial.polynomial import polyval from numpy.testing import ( assert_almost_equal, assert_raises, assert_equal, assert_, ) def trim(x): return cheb.chebtrim(x, tol=1...
0
public_repos/numpy/numpy/polynomial
public_repos/numpy/numpy/polynomial/tests/test_laguerre.py
"""Tests for laguerre module. """ from functools import reduce import numpy as np import numpy.polynomial.laguerre as lag from numpy.polynomial.polynomial import polyval from numpy.testing import ( assert_almost_equal, assert_raises, assert_equal, assert_, ) L0 = np.array([1])/1 L1 = np.array([1, -1])/1 L2 =...
0
public_repos/numpy/numpy/polynomial
public_repos/numpy/numpy/polynomial/tests/test_hermite_e.py
"""Tests for hermite_e module. """ from functools import reduce import numpy as np import numpy.polynomial.hermite_e as herme from numpy.polynomial.polynomial import polyval from numpy.testing import ( assert_almost_equal, assert_raises, assert_equal, assert_, ) He0 = np.array([1]) He1 = np.array([0, 1]) He2...
0
public_repos/numpy/numpy/polynomial
public_repos/numpy/numpy/polynomial/tests/test_classes.py
"""Test inter-conversion of different polynomial classes. This tests the convert and cast methods of all the polynomial classes. """ import operator as op from numbers import Number import pytest import numpy as np from numpy.polynomial import ( Polynomial, Legendre, Chebyshev, Laguerre, Hermite, HermiteE) from ...
0
public_repos/numpy/numpy/polynomial
public_repos/numpy/numpy/polynomial/tests/test_printing.py
from math import nan, inf import pytest from numpy._core import array, arange, printoptions import numpy.polynomial as poly from numpy.testing import assert_equal, assert_ # For testing polynomial printing with object arrays from fractions import Fraction from decimal import Decimal class TestStrUnicodeSuperSubscrip...
0
public_repos/numpy/numpy/polynomial
public_repos/numpy/numpy/polynomial/tests/test_polynomial.py
"""Tests for polynomial module. """ from functools import reduce from fractions import Fraction import numpy as np import numpy.polynomial.polynomial as poly import pickle from copy import deepcopy from numpy.testing import ( assert_almost_equal, assert_raises, assert_equal, assert_, assert_array_equal, assert...
0
public_repos/numpy/numpy/polynomial
public_repos/numpy/numpy/polynomial/tests/test_symbol.py
""" Tests related to the ``symbol`` attribute of the ABCPolyBase class. """ import pytest import numpy.polynomial as poly from numpy._core import array from numpy.testing import assert_equal, assert_raises, assert_ class TestInit: """ Test polynomial creation with symbol kwarg. """ c = [1, 2, 3] ...
0
public_repos/numpy/numpy/polynomial
public_repos/numpy/numpy/polynomial/tests/test_legendre.py
"""Tests for legendre module. """ from functools import reduce import numpy as np import numpy.polynomial.legendre as leg from numpy.polynomial.polynomial import polyval from numpy.testing import ( assert_almost_equal, assert_raises, assert_equal, assert_, ) L0 = np.array([1]) L1 = np.array([0, 1]) L2 = np.a...
0
public_repos/numpy/numpy/polynomial
public_repos/numpy/numpy/polynomial/tests/test_polyutils.py
"""Tests for polyutils module. """ import numpy as np import numpy.polynomial.polyutils as pu from numpy.testing import ( assert_almost_equal, assert_raises, assert_equal, assert_, ) class TestMisc: def test_trimseq(self): tgt = [1] for num_trailing_zeros in range(5): res = p...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/testing/__init__.pyi
from numpy._pytesttester import PytestTester from unittest import ( TestCase as TestCase, ) from numpy.testing._private.utils import ( assert_equal as assert_equal, assert_almost_equal as assert_almost_equal, assert_approx_equal as assert_approx_equal, assert_array_equal as assert_array_equal, ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/testing/print_coercion_tables.py
#!/usr/bin/env python3 """Prints type-coercion tables for the built-in NumPy types """ import numpy as np from numpy._core.numerictypes import obj2sctype from collections import namedtuple # Generic object that can be added, but doesn't do anything else class GenericObject: def __init__(self, v): self.v =...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/testing/overrides.py
"""Tools for testing implementations of __array_function__ and ufunc overrides """ from numpy._core.overrides import ARRAY_FUNCTIONS as _array_functions from numpy import ufunc as _ufunc import numpy._core.umath as _umath def get_overridable_numpy_ufuncs(): """List all numpy ufuncs overridable via `__array_ufun...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/testing/__init__.py
"""Common test support for all numpy test scripts. This single module should provide all the common functionality for numpy tests in a single location, so that test scripts can just import it and work right away. """ from unittest import TestCase from . import _private from ._private.utils import * from ._private.ut...
0
public_repos/numpy/numpy/testing
public_repos/numpy/numpy/testing/tests/test_utils.py
import warnings import sys import os import itertools import pytest import weakref import re import numpy as np import numpy._core._multiarray_umath as ncu from numpy.testing import ( assert_equal, assert_array_equal, assert_almost_equal, assert_array_almost_equal, assert_array_less, build_err_msg, assert_...
0
public_repos/numpy/numpy/testing
public_repos/numpy/numpy/testing/_private/utils.py
""" Utility function to facilitate testing. """ import os import sys import platform import re import gc import operator import warnings from functools import partial, wraps import shutil import contextlib from tempfile import mkdtemp, mkstemp from unittest.case import SkipTest from warnings import WarningMessage impo...
0
public_repos/numpy/numpy/testing
public_repos/numpy/numpy/testing/_private/utils.pyi
import os import sys import ast import types import warnings import unittest import contextlib from re import Pattern from collections.abc import Callable, Iterable, Sequence from typing import ( Literal as L, Any, AnyStr, ClassVar, NoReturn, overload, type_check_only, TypeVar, Final...
0
public_repos/numpy/numpy/testing
public_repos/numpy/numpy/testing/_private/extbuild.py
""" Build a c-extension module on-the-fly in tests. See build_and_import_extensions for usage hints """ import os import pathlib import subprocess import sys import sysconfig import textwrap __all__ = ['build_and_import_extension', 'compile_extension_module'] def build_and_import_extension( modname, functi...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/einsumfunc.py
""" Implementation of optimized einsum. """ import itertools import operator from numpy._core.multiarray import c_einsum from numpy._core.numeric import asanyarray, tensordot from numpy._core.overrides import array_function_dispatch __all__ = ['einsum', 'einsum_path'] # importing string for string.ascii_letters wou...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/_asarray.pyi
from collections.abc import Iterable from typing import Any, TypeVar, overload, Literal from numpy._typing import NDArray, DTypeLike, _SupportsArrayFunc _ArrayType = TypeVar("_ArrayType", bound=NDArray[Any]) _Requirements = Literal[ "C", "C_CONTIGUOUS", "CONTIGUOUS", "F", "F_CONTIGUOUS", "FORTRAN", "A", ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/__init__.pyi
# NOTE: The `np._core` namespace is deliberately kept empty due to it # being private
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/config.h.in
#mesondefine SIZEOF_PY_INTPTR_T #mesondefine SIZEOF_OFF_T #mesondefine SIZEOF_PY_LONG_LONG #mesondefine HAVE_BACKTRACE #mesondefine HAVE_MADVISE #mesondefine HAVE_FTELLO #mesondefine HAVE_FSEEKO #mesondefine HAVE_FALLOCATE #mesondefine HAVE_STRTOLD_L #mesondefine HAVE__THREAD #mesondefine HAVE___DECLSPEC_THREAD_ /* O...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/_dtype_ctypes.py
""" Conversion from ctypes to dtype. In an ideal world, we could achieve this through the PEP3118 buffer protocol, something like:: def dtype_from_ctypes_type(t): # needed to ensure that the shape of `t` is within memoryview.format class DummyStruct(ctypes.Structure): _fields_ = [('a',...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/_ufunc_config.py
""" Functions for changing global ufunc configuration This provides helpers which wrap `_get_extobj_dict` and `_make_extobj`, and `_extobj_contextvar` from umath. """ import collections.abc import contextlib import contextvars import functools from .._utils import set_module from .umath import _make_extobj, _get_exto...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/check_longdouble.c
/* "before" is 16 bytes to ensure there's no padding between it and "x". * We're not expecting any "long double" bigger than 16 bytes or with * alignment requirements stricter than 16 bytes. */ typedef long double test_type; struct { char before[16]; test_type x; char ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/numerictypes.py
""" numerictypes: Define the numeric type objects This module is designed so "from numerictypes import \\*" is safe. Exported symbols include: Dictionary with all registered number types (including aliases): sctypeDict Type objects (not all will be available, depends on platform): see variable sctypes ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/_dtype.py
""" A place for code to be called from the implementation of np.dtype String handling is much easier to do correctly in python. """ import numpy as np _kind_to_stem = { 'u': 'uint', 'i': 'int', 'c': 'complex', 'f': 'float', 'b': 'bool', 'V': 'void', 'O': 'object', 'M': 'datetime', ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/fromnumeric.pyi
from collections.abc import Sequence from typing import Any, overload, TypeVar, Literal, SupportsIndex from numpy import ( number, uint64, int_, int64, intp, float16, bool_, floating, complexfloating, object_, generic, _OrderKACF, _OrderACF, _ModeKind, _Parti...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/_type_aliases.pyi
from typing import Any, TypedDict from numpy import generic, signedinteger, unsignedinteger, floating, complexfloating class _SCTypes(TypedDict): int: list[type[signedinteger[Any]]] uint: list[type[unsignedinteger[Any]]] float: list[type[floating[Any]]] complex: list[type[complexfloating[Any, Any]]] ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/numerictypes.pyi
import sys import types from typing import ( Literal as L, overload, Any, TypeVar, Protocol, TypedDict, ) from numpy import ( ndarray, dtype, generic, bool_, ubyte, ushort, uintc, ulong, ulonglong, byte, short, intc, long, longlong, ha...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/defchararray.pyi
from typing import ( Literal as L, overload, TypeVar, Any, SupportsIndex, SupportsInt, ) from numpy import ( ndarray, dtype, str_, bytes_, int_, bool_, object_, _OrderKACF, _ShapeType, _CharDType, _SupportsBuffer, ) from numpy._typing import ( ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/memmap.pyi
from numpy import memmap as memmap __all__: list[str]
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/meson.build
# Potential issues to address or keep track of: # - sincos detection incorrect on NetBSD: https://github.com/mesonbuild/meson/issues/10641 # Versioning support #------------------- # # How to change C_API_VERSION ? # - increase C_API_VERSION value # - record the hash for the new C API with the cversions.py scrip...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/numeric.pyi
from collections.abc import Callable, Sequence from typing import ( Any, overload, TypeVar, Literal, SupportsAbs, SupportsIndex, NoReturn, ) if sys.version_info >= (3, 10): from typing import TypeGuard else: from typing_extensions import TypeGuard from numpy import ( ComplexWarn...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/_add_newdocs_scalars.py
""" This file is separate from ``_add_newdocs.py`` so that it can be mocked out by our sphinx ``conf.py`` during doc builds, where we want to avoid showing platform-dependent information. """ import sys import os from numpy._core import dtype from numpy._core import numerictypes as _numerictypes from numpy._core.functi...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/_internal.py
""" A place for internal code Some things are more easily handled Python. """ import ast import re import sys import warnings from ..exceptions import DTypePromotionError from .multiarray import dtype, array, ndarray, promote_types try: import ctypes except ImportError: ctypes = None IS_PYPY = sys.implement...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_core/shape_base.pyi
from collections.abc import Sequence from typing import TypeVar, overload, Any, SupportsIndex from numpy import generic, _CastingKind from numpy._typing import ( NDArray, ArrayLike, DTypeLike, _ArrayLike, _DTypeLike, ) _SCT = TypeVar("_SCT", bound=generic) _ArrayType = TypeVar("_ArrayType", bound=...
0