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
public_repos/numpy/doc_requirements.txt
# doxygen required, use apt-get or dnf sphinx>=4.5.0 numpydoc==1.4 pydata-sphinx-theme==0.13.3 sphinx-design ipython!=8.1.0 scipy matplotlib pandas breathe>4.33.0 # needed to build release notes towncrier toml
0
public_repos
public_repos/numpy/building_with_meson.md
# Building with Meson _Note: this is for early adopters. It has been tested on Linux and macOS, and with Python 3.9-3.12. Windows will be tested soon. There is one CI job to keep the build stable. This may have rough edges, please open an issue if you run into a problem._ ### Developer build **Install build tools:**...
0
public_repos/numpy
public_repos/numpy/numpy/__init__.pyi
import builtins import sys import os import mmap import ctypes as ct import array as _array import datetime as dt import enum from abc import abstractmethod from types import TracebackType, MappingProxyType, GenericAlias from contextlib import contextmanager from numpy._pytesttester import PytestTester from numpy._cor...
0
public_repos/numpy
public_repos/numpy/numpy/_distributor_init.py
""" Distributor init file Distributors: you can add custom code here to support particular distributions of numpy. For example, this is a good place to put any BLAS/LAPACK initialization code. The numpy standard source distribution will not put code in this file, so you can safely replace this file with your own ver...
0
public_repos/numpy
public_repos/numpy/numpy/dtypes.pyi
import numpy as np __all__: list[str] # Boolean: BoolDType = np.dtype[np.bool_] # Sized integers: Int8DType = np.dtype[np.int8] UInt8DType = np.dtype[np.uint8] Int16DType = np.dtype[np.int16] UInt16DType = np.dtype[np.uint16] Int32DType = np.dtype[np.int32] UInt32DType = np.dtype[np.uint32] Int64DType = np.dtype[np....
0
public_repos/numpy
public_repos/numpy/numpy/meson.build
# We need -lm for all C code (assuming it uses math functions, which is safe to # assume for NumPy). For C++ it isn't needed, because libstdc++/libc++ is # guaranteed to depend on it. m_dep = cc.find_library('m', required : false) mlib_linkflag = '' if m_dep.found() mlib_linkflag = '-lm' add_project_link_arguments(...
0
public_repos/numpy
public_repos/numpy/numpy/exceptions.py
""" Exceptions and Warnings (:mod:`numpy.exceptions`) ================================================= General exceptions used by NumPy. Note that some exceptions may be module specific, such as linear algebra errors. .. versionadded:: NumPy 1.25 The exceptions module is new in NumPy 1.25. Older exceptions re...
0
public_repos/numpy
public_repos/numpy/numpy/matlib.py
import warnings # 2018-05-29, PendingDeprecationWarning added to matrix.__new__ # 2020-01-23, numpy 1.19.0 PendingDeprecatonWarning warnings.warn("Importing from numpy.matlib is deprecated since 1.19.0. " "The matrix subclass is not the recommended way to represent " "matrices or deal with ...
0
public_repos/numpy
public_repos/numpy/numpy/conftest.py
""" Pytest configuration and fixtures for the Numpy test suite. """ import os import tempfile import hypothesis import pytest import numpy from numpy._core._multiarray_tests import get_fpu_mode _old_fpu_mode = None _collect_results = {} # Use a known and persistent tmpdir for hypothesis' caches, which # can be aut...
0
public_repos/numpy
public_repos/numpy/numpy/__init__.pxd
# NumPy static imports for Cython < 3.0 # # If any of the PyArray_* functions are called, import_array must be # called first. # # Author: Dag Sverre Seljebotn # DEF _buffer_format_string_len = 255 cimport cpython.buffer as pybuf from cpython.ref cimport Py_INCREF from cpython.mem cimport PyObject_Malloc, PyObject_Fr...
0
public_repos/numpy
public_repos/numpy/numpy/__config__.py.in
# This file is generated by numpy's build process # It contains system_info results at the time of building this package. from enum import Enum from numpy._core._multiarray_umath import ( __cpu_features__, __cpu_baseline__, __cpu_dispatch__, ) __all__ = ["show"] _built_with_meson = True class DisplayMode...
0
public_repos/numpy
public_repos/numpy/numpy/ctypeslib.pyi
# NOTE: Numpy's mypy plugin is used for importing the correct # platform-specific `ctypes._SimpleCData[int]` sub-type from ctypes import c_int64 as _c_intp import os import ctypes from collections.abc import Iterable, Sequence from typing import ( Literal as L, Any, TypeVar, Generic, overload, ...
0
public_repos/numpy
public_repos/numpy/numpy/ctypeslib.py
""" ============================ ``ctypes`` Utility Functions ============================ See Also -------- load_library : Load a C library. ndpointer : Array restype/argtype with verification. as_ctypes : Create a ctypes array from an ndarray. as_array : Create an ndarray from a ctypes array. References ---------- ...
0
public_repos/numpy
public_repos/numpy/numpy/__init__.cython-30.pxd
# NumPy static imports for Cython >= 3.0 # # If any of the PyArray_* functions are called, import_array must be # called first. This is done automatically by Cython 3.0+ if a call # is not detected inside of the module. # # Author: Dag Sverre Seljebotn # from cpython.ref cimport Py_INCREF from cpython.object cimport ...
0
public_repos/numpy
public_repos/numpy/numpy/_pytesttester.py
""" Pytest test running. This module implements the ``test()`` function for NumPy modules. The usual boiler plate for doing that is to put the following in the module ``__init__.py`` file:: from numpy._pytesttester import PytestTester test = PytestTester(__name__) del PytestTester Warnings filtering and...
0
public_repos/numpy
public_repos/numpy/numpy/_expired_attrs_2_0.py
""" Dict of expired attributes that are discontinued since 2.0 release. Each item is associated with a migration note. """ __expired_attributes__ = { "geterrobj": "Use the np.errstate context manager instead.", "seterrobj": "Use the np.errstate context manager instead.", "cast": "Use `np.asarray(arr, dtype...
0
public_repos/numpy
public_repos/numpy/numpy/_globals.py
""" Module defining global singleton classes. This module raises a RuntimeError if an attempt to reload it is made. In that way the identities of the classes defined here are fixed and will remain so even if numpy itself is reloaded. In particular, a function like the following will still work correctly after numpy is...
0
public_repos/numpy
public_repos/numpy/numpy/exceptions.pyi
from typing import overload __all__: list[str] class ComplexWarning(RuntimeWarning): ... class ModuleDeprecationWarning(DeprecationWarning): ... class VisibleDeprecationWarning(UserWarning): ... class RankWarning(RuntimeWarning): ... class TooHardError(RuntimeError): ... class DTypePromotionError(TypeError): ... cla...
0
public_repos/numpy
public_repos/numpy/numpy/_pytesttester.pyi
from collections.abc import Iterable from typing import Literal as L __all__: list[str] class PytestTester: module_name: str def __init__(self, module_name: str) -> None: ... def __call__( self, label: L["fast", "full"] = ..., verbose: int = ..., extra_argv: None | Iterable...
0
public_repos/numpy
public_repos/numpy/numpy/__init__.py
""" NumPy ===== Provides 1. An array object of arbitrary homogeneous items 2. Fast mathematical operations over arrays 3. Linear Algebra, Fourier Transforms, Random Number Generation How to use the documentation ---------------------------- Documentation is available in two forms: docstrings provided with the c...
0
public_repos/numpy
public_repos/numpy/numpy/dtypes.py
""" DType classes and utility (:mod:`numpy.dtypes`) =============================================== This module is home to specific dtypes related functionality and their classes. For more general information about dtypes, also see `numpy.dtype` and :ref:`arrays.dtypes`. Similar to the builtin ``types`` module, this ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/char/__init__.pyi
from numpy._core.defchararray import ( equal as equal, not_equal as not_equal, greater_equal as greater_equal, less_equal as less_equal, greater as greater, less as less, str_len as str_len, add as add, multiply as multiply, mod as mod, capitalize as capitalize, center as...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/char/__init__.py
from numpy._core.defchararray import __all__, __doc__ from numpy._core.defchararray import *
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/_array_like.py
from __future__ import annotations import sys from collections.abc import Collection, Callable, Sequence from typing import Any, Protocol, Union, TypeVar, runtime_checkable from numpy import ( ndarray, dtype, generic, bool_, unsignedinteger, integer, floating, complexfloating, numb...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/_callable.pyi
""" A module with various ``typing.Protocol`` subclasses that implement the ``__call__`` magic method. See the `Mypy documentation`_ on protocols for more details. .. _`Mypy documentation`: https://mypy.readthedocs.io/en/stable/protocols.html#callback-protocols """ from __future__ import annotations from typing im...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/_dtype_like.py
from collections.abc import Sequence from typing import ( Any, Sequence, Union, TypeVar, Protocol, TypedDict, runtime_checkable, ) import numpy as np from ._shape import _ShapeLike from ._char_codes import ( _BoolCodes, _UInt8Codes, _UInt16Codes, _UInt32Codes, _UInt64C...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/_nested_sequence.py
"""A module containing the `_NestedSequence` protocol.""" from __future__ import annotations from collections.abc import Iterator from typing import ( Any, TypeVar, Protocol, runtime_checkable, ) __all__ = ["_NestedSequence"] _T_co = TypeVar("_T_co", covariant=True) @runtime_checkable class _Neste...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/_nbit.py
"""A module with the precisions of platform-specific `~numpy.number`s.""" from typing import Any # To-be replaced with a `npt.NBitBase` subclass by numpy's mypy plugin _NBitByte = Any _NBitShort = Any _NBitIntC = Any _NBitIntP = Any _NBitInt = Any _NBitLong = Any _NBitLongLong = Any _NBitHalf = Any _NBitSingle = Any...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/_scalars.py
from typing import Union, Any import numpy as np # NOTE: `_StrLike_co` and `_BytesLike_co` are pointless, as `np.str_` and # `np.bytes_` are already subclasses of their builtin counterpart _CharLike_co = Union[str, bytes] # The 6 `<X>Like_co` type-aliases below represent all scalars that can be # coerced into `<X>`...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/_extended_precision.py
"""A module with platform-specific extended precision `numpy.number` subclasses. The subclasses are defined here (instead of ``__init__.pyi``) such that they can be imported conditionally via the numpy's mypy plugin. """ import numpy as np from . import ( _80Bit, _96Bit, _128Bit, _256Bit, ) uint128 =...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/_char_codes.py
from typing import Literal _BoolCodes = Literal["?", "=?", "<?", ">?", "bool", "bool_"] _UInt8Codes = Literal["uint8", "u1", "=u1", "<u1", ">u1"] _UInt16Codes = Literal["uint16", "u2", "=u2", "<u2", ">u2"] _UInt32Codes = Literal["uint32", "u4", "=u4", "<u4", ">u4"] _UInt64Codes = Literal["uint64", "u8", "=u8", "<u8",...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/_add_docstring.py
"""A module for creating docstrings for sphinx ``data`` domains.""" import re import textwrap from ._array_like import NDArray _docstrings_list = [] def add_newdoc(name: str, value: str, doc: str) -> None: """Append ``_docstrings_list`` with a docstring for `name`. Parameters ---------- name : str...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/_shape.py
from collections.abc import Sequence from typing import Union, SupportsIndex _Shape = tuple[int, ...] # Anything that can be coerced to a shape tuple _ShapeLike = Union[SupportsIndex, Sequence[SupportsIndex]]
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/_ufunc.pyi
"""A module with private type-check-only `numpy.ufunc` subclasses. The signatures of the ufuncs are too varied to reasonably type with a single class. So instead, `ufunc` has been expanded into four private subclasses, one for each combination of `~ufunc.nin` and `~ufunc.nout`. """ from typing import ( Any, ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/_typing/__init__.py
"""Private counterpart of ``numpy.typing``.""" from __future__ import annotations from .. import ufunc from .._utils import set_module from typing import TYPE_CHECKING, final @final # Disallow the creation of arbitrary `NBitBase` subclasses @set_module("numpy.typing") class NBitBase: """ A type representin...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/rec/__init__.pyi
from numpy._core.records import ( record as record, recarray as recarray, format_parser as format_parser, fromarrays as fromarrays, fromrecords as fromrecords, fromstring as fromstring, fromfile as fromfile, array as array ) __all__: list[str] __path__: list[str]
0
public_repos/numpy/numpy
public_repos/numpy/numpy/rec/__init__.py
from numpy._core.records import __all__, __doc__ from numpy._core.records import *
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_dtypes.py
import numpy as np # Note: we use dtype objects instead of dtype classes. The spec does not # require any behavior on dtypes other than equality. int8 = np.dtype("int8") int16 = np.dtype("int16") int32 = np.dtype("int32") int64 = np.dtype("int64") uint8 = np.dtype("uint8") uint16 = np.dtype("uint16") uint32 = np.dtype...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_set_functions.py
from __future__ import annotations from ._array_object import Array from typing import NamedTuple import numpy as np # Note: np.unique() is split into four functions in the array API: # unique_all, unique_counts, unique_inverse, and unique_values (this is done # to remove polymorphic return types). # Note: The var...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_sorting_functions.py
from __future__ import annotations from ._array_object import Array from ._dtypes import _real_numeric_dtypes import numpy as np # Note: the descending keyword argument is new in this function def argsort( x: Array, /, *, axis: int = -1, descending: bool = False, stable: bool = True ) -> Array: """ Arra...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_constants.py
import numpy as np e = np.e inf = np.inf nan = np.nan pi = np.pi newaxis = np.newaxis
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_typing.py
""" This file defines the types for type annotations. These names aren't part of the module namespace, but they are used in the annotations in the function signatures. The functions in the module are only valid for inputs that match the given type annotations. """ from __future__ import annotations __all__ = [ "...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_manipulation_functions.py
from __future__ import annotations from ._array_object import Array from ._data_type_functions import result_type from typing import List, Optional, Tuple, Union import numpy as np # Note: the function name is different here def concat( arrays: Union[Tuple[Array, ...], List[Array]], /, *, axis: Optional[int] = ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_indexing_functions.py
from __future__ import annotations from ._array_object import Array from ._dtypes import _integer_dtypes import numpy as np def take(x: Array, indices: Array, /, *, axis: Optional[int] = None) -> Array: """ Array API compatible wrapper for :py:func:`np.take <numpy.take>`. See its docstring for more info...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_utility_functions.py
from __future__ import annotations from ._array_object import Array from typing import Optional, Tuple, Union import numpy as np def all( x: Array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False, ) -> Array: """ Array API compatible wrapper for :py:func...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_elementwise_functions.py
from __future__ import annotations from ._dtypes import ( _boolean_dtypes, _floating_dtypes, _real_floating_dtypes, _complex_floating_dtypes, _integer_dtypes, _integer_or_boolean_dtypes, _real_numeric_dtypes, _numeric_dtypes, _result_type, ) from ._array_object import Array import ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_searching_functions.py
from __future__ import annotations from ._array_object import Array from ._dtypes import _result_type, _real_numeric_dtypes from typing import Optional, Tuple import numpy as np def argmax(x: Array, /, *, axis: Optional[int] = None, keepdims: bool = False) -> Array: """ Array API compatible wrapper for :py...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_array_object.py
""" Wrapper class around the ndarray object for the array API standard. The array API standard defines some behaviors differently than ndarray, in particular, type promotion rules are different (the standard has no value-based casting). The standard also specifies a more limited subset of array methods and functionali...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_statistical_functions.py
from __future__ import annotations from ._dtypes import ( _real_floating_dtypes, _real_numeric_dtypes, _numeric_dtypes, ) from ._array_object import Array from ._dtypes import float32, float64, complex64, complex128 from typing import TYPE_CHECKING, Optional, Tuple, Union if TYPE_CHECKING: from ._typ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/__init__.py
""" A NumPy sub-namespace that conforms to the Python array API standard. This submodule accompanies NEP 47, which proposes its inclusion in NumPy. It is still considered experimental, and will issue a warning when imported. This is a proof-of-concept namespace that wraps the corresponding NumPy functions to give a c...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/linalg.py
from __future__ import annotations from ._dtypes import ( _floating_dtypes, _numeric_dtypes, float32, float64, complex64, complex128 ) from ._manipulation_functions import reshape from ._array_object import Array from .._core.numeric import normalize_axis_tuple from typing import TYPE_CHECKIN...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_creation_functions.py
from __future__ import annotations from typing import TYPE_CHECKING, List, Optional, Tuple, Union if TYPE_CHECKING: from ._typing import ( Array, Device, Dtype, NestedSequence, SupportsBufferProtocol, ) from collections.abc import Sequence from ._dtypes import _all...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/array_api/_data_type_functions.py
from __future__ import annotations from ._array_object import Array from ._dtypes import ( _all_dtypes, _boolean_dtypes, _signed_integer_dtypes, _unsigned_integer_dtypes, _integer_dtypes, _real_floating_dtypes, _complex_floating_dtypes, _numeric_dtypes, _result_type, ) from datacla...
0
public_repos/numpy/numpy/array_api
public_repos/numpy/numpy/array_api/tests/test_elementwise_functions.py
from inspect import getfullargspec from numpy.testing import assert_raises from .. import asarray, _elementwise_functions from .._elementwise_functions import bitwise_left_shift, bitwise_right_shift from .._dtypes import ( _dtype_categories, _boolean_dtypes, _floating_dtypes, _integer_dtypes, ) def ...
0
public_repos/numpy/numpy/array_api
public_repos/numpy/numpy/array_api/tests/test_manipulation_functions.py
from numpy.testing import assert_raises import numpy as np from .. import all from .._creation_functions import asarray from .._dtypes import float64, int8 from .._manipulation_functions import ( concat, reshape, stack ) def test_concat_errors(): assert_raises(TypeError, lambda: concat((1...
0
public_repos/numpy/numpy/array_api
public_repos/numpy/numpy/array_api/tests/test_validation.py
from typing import Callable import pytest from numpy import array_api as xp def p(func: Callable, *args, **kwargs): f_sig = ", ".join( [str(a) for a in args] + [f"{k}={v}" for k, v in kwargs.items()] ) id_ = f"{func.__name__}({f_sig})" return pytest.param(func, args, kwargs, id=id_) @pytes...
0
public_repos/numpy/numpy/array_api
public_repos/numpy/numpy/array_api/tests/test_indexing_functions.py
import pytest from numpy import array_api as xp @pytest.mark.parametrize( "x, indices, axis, expected", [ ([2, 3], [1, 1, 0], 0, [3, 3, 2]), ([2, 3], [1, 1, 0], -1, [3, 3, 2]), ([[2, 3]], [1], -1, [[3]]), ([[2, 3]], [0, 0], 0, [[2, 3], [2, 3]]), ], ) def test_take_functio...
0
public_repos/numpy/numpy/array_api
public_repos/numpy/numpy/array_api/tests/test_array_object.py
import operator from numpy.testing import assert_raises, suppress_warnings import numpy as np import pytest from .. import ones, asarray, reshape, result_type, all, equal from .._array_object import Array from .._dtypes import ( _all_dtypes, _boolean_dtypes, _real_floating_dtypes, _floating_dtypes, ...
0
public_repos/numpy/numpy/array_api
public_repos/numpy/numpy/array_api/tests/test_set_functions.py
import pytest from hypothesis import given from hypothesis.extra.array_api import make_strategies_namespace from numpy import array_api as xp xps = make_strategies_namespace(xp) @pytest.mark.parametrize("func", [xp.unique_all, xp.unique_inverse]) @given(xps.arrays(dtype=xps.scalar_dtypes(), shape=xps.array_shapes()...
0
public_repos/numpy/numpy/array_api
public_repos/numpy/numpy/array_api/tests/test_data_type_functions.py
import pytest from numpy.testing import assert_raises from numpy import array_api as xp import numpy as np @pytest.mark.parametrize( "from_, to, expected", [ (xp.int8, xp.int16, True), (xp.int16, xp.int8, False), (xp.bool, xp.int8, False), (xp.asarray(0, dtype=xp.uint8), xp.int...
0
public_repos/numpy/numpy/array_api
public_repos/numpy/numpy/array_api/tests/test_creation_functions.py
from numpy.testing import assert_raises import numpy as np from .. import all from .._creation_functions import ( asarray, arange, empty, empty_like, eye, full, full_like, linspace, meshgrid, ones, ones_like, zeros, zeros_like, ) from .._dtypes import float32, float6...
0
public_repos/numpy/numpy/array_api
public_repos/numpy/numpy/array_api/tests/__init__.py
""" Tests for the array API namespace. Note, full compliance with the array API can be tested with the official array API test suite https://github.com/data-apis/array-api-tests. This test suite primarily focuses on those things that are not tested by the official test suite. """
0
public_repos/numpy/numpy/array_api
public_repos/numpy/numpy/array_api/tests/test_sorting_functions.py
import pytest from numpy import array_api as xp @pytest.mark.parametrize( "obj, axis, expected", [ ([0, 0], -1, [0, 1]), ([0, 1, 0], -1, [1, 0, 2]), ([[0, 1], [1, 1]], 0, [[1, 0], [0, 1]]), ([[0, 1], [1, 1]], 1, [[1, 0], [0, 1]]), ], ) def test_stable_desc_argsort(obj, axi...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_pcg64.pyx
#cython: binding=True import numpy as np cimport numpy as np from libc.stdint cimport uint32_t, uint64_t from ._common cimport uint64_to_double, wrap_int from numpy.random cimport BitGenerator __all__ = ['PCG64'] cdef extern from "src/pcg64/pcg64.h": # Use int as generic type, actual type read from pcg64.h and ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/__init__.pyi
from numpy._pytesttester import PytestTester from numpy.random._generator import Generator as Generator from numpy.random._generator import default_rng as default_rng from numpy.random._mt19937 import MT19937 as MT19937 from numpy.random._pcg64 import ( PCG64 as PCG64, PCG64DXSM as PCG64DXSM, ) from numpy.rand...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/bit_generator.pyi
import abc from threading import Lock from collections.abc import Callable, Mapping, Sequence from typing import ( Any, NamedTuple, TypedDict, TypeVar, overload, Literal, ) from numpy import dtype, uint32, uint64 from numpy._typing import ( NDArray, _ArrayLikeInt_co, _ShapeLike, ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/bit_generator.pxd
cimport numpy as np from libc.stdint cimport uint32_t, uint64_t cdef extern from "numpy/random/bitgen.h": struct bitgen: void *state uint64_t (*next_uint64)(void *st) nogil uint32_t (*next_uint32)(void *st) nogil double (*next_double)(void *st) nogil uint64_t (*next_raw)(voi...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_bounded_integers.pxd.in
from libc.stdint cimport (uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t, intptr_t) import numpy as np cimport numpy as np ctypedef np.npy_bool bool_t from numpy.random cimport bitgen_t cdef inline uint64_t _gen_mask(uint64_t max_val) nogil: """Mask generator fo...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/meson.build
# Build npyrandom library # ----------------------- npyrandom_sources = [ 'src/distributions/logfactorial.c', 'src/distributions/distributions.c', 'src/distributions/random_mvhg_count.c', 'src/distributions/random_mvhg_marginals.c', 'src/distributions/random_hypergeometric.c', ] npyrandom_lib = static_librar...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_generator.pyx
#!python #cython: wraparound=False, nonecheck=False, boundscheck=False, cdivision=True, language_level=3, binding=True import operator import warnings from collections.abc import Sequence from cpython.pycapsule cimport PyCapsule_IsValid, PyCapsule_GetPointer from cpython cimport (Py_INCREF, PyFloat_AsDouble) from cpyt...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/mtrand.pyx
#!python #cython: wraparound=False, nonecheck=False, boundscheck=False, cdivision=True, language_level=3, binding=True import operator import warnings from collections.abc import Sequence import numpy as np from cpython.pycapsule cimport PyCapsule_IsValid, PyCapsule_GetPointer from cpython cimport (Py_INCREF, PyFloat...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_sfc64.pyi
from typing import TypedDict from numpy import uint64 from numpy.random.bit_generator import BitGenerator, SeedSequence from numpy._typing import NDArray, _ArrayLikeInt_co class _SFC64Internal(TypedDict): state: NDArray[uint64] class _SFC64State(TypedDict): bit_generator: str state: _SFC64Internal ha...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_common.pyx
#!python #cython: wraparound=False, nonecheck=False, boundscheck=False, cdivision=True, language_level=3 from collections import namedtuple from cpython cimport PyFloat_AsDouble import sys import numpy as np cimport numpy as np cimport numpy.math as npmath from libc.stdint cimport uintptr_t cdef extern from "limits.h...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_philox.pyx
#cython: binding=True from cpython.pycapsule cimport PyCapsule_New import numpy as np cimport numpy as np from libc.stdint cimport uint32_t, uint64_t from ._common cimport uint64_to_double, int_to_array, wrap_int from numpy.random cimport BitGenerator __all__ = ['Philox'] np.import_array() cdef int PHILOX_BUFFER_...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/bit_generator.pyx
#cython: binding=True """ BitGenerator base class and SeedSequence used to seed the BitGenerators. SeedSequence is derived from Melissa E. O'Neill's C++11 `std::seed_seq` implementation, as it has a lot of nice properties that we want. https://gist.github.com/imneme/540829265469e673d045 https://www.pcg-random.org/po...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/__init__.pxd
cimport numpy as np from libc.stdint cimport uint32_t, uint64_t cdef extern from "numpy/random/bitgen.h": struct bitgen: void *state uint64_t (*next_uint64)(void *st) nogil uint32_t (*next_uint32)(void *st) nogil double (*next_double)(void *st) nogil uint64_t (*next_raw)(voi...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/c_distributions.pxd
#!python #cython: wraparound=False, nonecheck=False, boundscheck=False, cdivision=True, language_level=3 from numpy cimport npy_intp from libc.stdint cimport (uint64_t, int32_t, int64_t) from numpy.random cimport bitgen_t cdef extern from "numpy/random/distributions.h": struct s_binomial_t: int has_binom...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_mt19937.pyx
#cython: binding=True import operator import numpy as np cimport numpy as np from libc.stdint cimport uint32_t, uint64_t from numpy.random cimport BitGenerator, SeedSequence __all__ = ['MT19937'] np.import_array() cdef extern from "src/mt19937/mt19937.h": struct s_mt19937_state: uint32_t key[624] ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_pickle.py
from .mtrand import RandomState from ._philox import Philox from ._pcg64 import PCG64, PCG64DXSM from ._sfc64 import SFC64 from ._generator import Generator from ._mt19937 import MT19937 BitGenerators = {'MT19937': MT19937, 'PCG64': PCG64, 'PCG64DXSM': PCG64DXSM, 'Ph...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_philox.pyi
from typing import TypedDict from numpy import uint64 from numpy.typing import NDArray from numpy.random.bit_generator import BitGenerator, SeedSequence from numpy._typing import _ArrayLikeInt_co class _PhiloxInternal(TypedDict): counter: NDArray[uint64] key: NDArray[uint64] class _PhiloxState(TypedDict): ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/mtrand.pyi
import builtins from collections.abc import Callable from typing import Any, overload, Literal from numpy import ( bool_, dtype, float32, float64, int8, int16, int32, int64, long, ulong, uint8, uint16, uint32, uint64, ) from numpy.random.bit_generator import BitG...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_pcg64.pyi
from typing import TypedDict from numpy.random.bit_generator import BitGenerator, SeedSequence from numpy._typing import _ArrayLikeInt_co class _PCG64Internal(TypedDict): state: int inc: int class _PCG64State(TypedDict): bit_generator: str state: _PCG64Internal has_uint32: int uinteger: int ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_sfc64.pyx
#cython: binding=True import numpy as np cimport numpy as np from libc.stdint cimport uint32_t, uint64_t from ._common cimport uint64_to_double from numpy.random cimport BitGenerator __all__ = ['SFC64'] cdef extern from "src/sfc64/sfc64.h": struct s_sfc64_state: uint64_t s[4] int has_uint32 ...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_bounded_integers.pyx.in
#!python #cython: wraparound=False, nonecheck=False, boundscheck=False, cdivision=True import numpy as np cimport numpy as np __all__ = [] np.import_array() cdef extern from "numpy/random/distributions.h": # Generate random numbers in closed interval [off, off + rng]. uint64_t random_bounded_uint64(bitgen_...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/LICENSE.md
**This software is dual-licensed under the The University of Illinois/NCSA Open Source License (NCSA) and The 3-Clause BSD License** # NCSA Open Source License **Copyright (c) 2019 Kevin Sheppard. All rights reserved.** Developed by: Kevin Sheppard (<kevin.sheppard@economics.ox.ac.uk>, <kevin.k.sheppard@gmail.com>) [...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_generator.pyi
from collections.abc import Callable from typing import Any, overload, TypeVar, Literal from numpy import ( bool_, dtype, float32, float64, int8, int16, int32, int64, int_, uint, uint8, uint16, uint32, uint64, ) from numpy.random import BitGenerator, SeedSequence...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_mt19937.pyi
from typing import TypedDict from numpy import uint32 from numpy.typing import NDArray from numpy.random.bit_generator import BitGenerator, SeedSequence from numpy._typing import _ArrayLikeInt_co class _MT19937Internal(TypedDict): key: NDArray[uint32] pos: int class _MT19937State(TypedDict): bit_generato...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/_common.pxd
#cython: language_level=3 from libc.stdint cimport uint32_t, uint64_t, int32_t, int64_t import numpy as np cimport numpy as np from numpy.random cimport bitgen_t cdef double POISSON_LAM_MAX cdef double LEGACY_POISSON_LAM_MAX cdef uint64_t MAXSIZE cdef enum ConstraintType: CONS_NONE CONS_NON_NEGATIVE CO...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/random/__init__.py
""" ======================== Random Number Generation ======================== Use ``default_rng()`` to create a `Generator` and call its methods. =============== ========================================================= Generator --------------- --------------------------------------------------------- Generator ...
0
public_repos/numpy/numpy/random
public_repos/numpy/numpy/random/include/aligned_malloc.h
#ifndef _RANDOMDGEN__ALIGNED_MALLOC_H_ #define _RANDOMDGEN__ALIGNED_MALLOC_H_ #include <Python.h> #include "numpy/npy_common.h" #define NPY_MEMALIGN 16 /* 16 for SSE2, 32 for AVX, 64 for Xeon Phi */ static inline void *PyArray_realloc_aligned(void *p, size_t n) { void *p1, **p2, *base; size_t old_offs, offs ...
0
public_repos/numpy/numpy/random
public_repos/numpy/numpy/random/include/legacy-distributions.h
#ifndef _RANDOMDGEN__DISTRIBUTIONS_LEGACY_H_ #define _RANDOMDGEN__DISTRIBUTIONS_LEGACY_H_ #include "numpy/random/distributions.h" typedef struct aug_bitgen { bitgen_t *bit_generator; int has_gauss; double gauss; } aug_bitgen_t; extern double legacy_gauss(aug_bitgen_t *aug_state); extern double legacy_standard...
0
public_repos/numpy/numpy/random/_examples
public_repos/numpy/numpy/random/_examples/cffi/extending.py
""" Use cffi to access any of the underlying C functions from distributions.h """ import os import numpy as np import cffi from .parse import parse_distributions_h ffi = cffi.FFI() inc_dir = os.path.join(np.get_include(), 'numpy') # Basic numpy types ffi.cdef(''' typedef intptr_t npy_intp; typedef unsigned ch...
0
public_repos/numpy/numpy/random/_examples
public_repos/numpy/numpy/random/_examples/cffi/parse.py
import os def parse_distributions_h(ffi, inc_dir): """ Parse distributions.h located in inc_dir for CFFI, filling in the ffi.cdef Read the function declarations without the "#define ..." macros that will be filled in when loading the library. """ with open(os.path.join(inc_dir, 'random', 'bi...
0
public_repos/numpy/numpy/random/_examples
public_repos/numpy/numpy/random/_examples/cython/meson.build
project('random-build-examples', 'c', 'cpp', 'cython') py_mod = import('python') py3 = py_mod.find_installation(pure: false) cc = meson.get_compiler('c') cy = meson.get_compiler('cython') if not cy.version().version_compare('>=0.29.35') error('tests requires Cython >= 0.29.35') endif _numpy_abs = run_command(py3,...
0
public_repos/numpy/numpy/random/_examples
public_repos/numpy/numpy/random/_examples/cython/extending.pyx
#!/usr/bin/env python3 #cython: language_level=3 from libc.stdint cimport uint32_t from cpython.pycapsule cimport PyCapsule_IsValid, PyCapsule_GetPointer import numpy as np cimport numpy as np cimport cython from numpy.random cimport bitgen_t from numpy.random import PCG64 np.import_array() @cython.boundscheck(Fa...
0
public_repos/numpy/numpy/random/_examples
public_repos/numpy/numpy/random/_examples/cython/extending_distributions.pyx
#!/usr/bin/env python3 #cython: language_level=3 """ This file shows how the to use a BitGenerator to create a distribution. """ import numpy as np cimport numpy as np cimport cython from cpython.pycapsule cimport PyCapsule_IsValid, PyCapsule_GetPointer from libc.stdint cimport uint16_t, uint64_t from numpy.random cimp...
0
public_repos/numpy/numpy/random/_examples
public_repos/numpy/numpy/random/_examples/numba/extending.py
import numpy as np import numba as nb from numpy.random import PCG64 from timeit import timeit bit_gen = PCG64() next_d = bit_gen.cffi.next_double state_addr = bit_gen.cffi.state_address def normals(n, state): out = np.empty(n) for i in range((n + 1) // 2): x1 = 2.0 * next_d(state) - 1.0 x2 =...
0
public_repos/numpy/numpy/random/_examples
public_repos/numpy/numpy/random/_examples/numba/extending_distributions.py
r""" Building the required library in this example requires a source distribution of NumPy or clone of the NumPy git repository since distributions.c is not included in binary distributions. On *nix, execute in numpy/random/src/distributions export ${PYTHON_VERSION}=3.8 # Python version export PYTHON_INCLUDE=#path to...
0
public_repos/numpy/numpy/random/src
public_repos/numpy/numpy/random/src/philox/philox.c
#include "philox.h" extern inline uint64_t philox_next64(philox_state *state); extern inline uint32_t philox_next32(philox_state *state); extern void philox_jump(philox_state *state) { /* Advances state as-if 2^128 draws were made */ state->ctr->v[2]++; if (state->ctr->v[2] == 0) { state->ctr->v[3]++; } ...
0
public_repos/numpy/numpy/random/src
public_repos/numpy/numpy/random/src/philox/philox.h
#ifndef _RANDOMDGEN__PHILOX_H_ #define _RANDOMDGEN__PHILOX_H_ #include "numpy/npy_common.h" #include <inttypes.h> #define PHILOX_BUFFER_SIZE 4L struct r123array2x64 { uint64_t v[2]; }; struct r123array4x64 { uint64_t v[4]; }; enum r123_enum_philox4x64 { philox4x64_rounds = 10 }; typedef struct r123array4x64 phi...
0