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/_core | public_repos/numpy/numpy/_core/tests/test_scalarmath.py | import contextlib
import sys
import warnings
import itertools
import operator
import platform
from numpy._utils import _pep440
import pytest
from hypothesis import given, settings
from hypothesis.strategies import sampled_from
from hypothesis.extra import numpy as hynp
import numpy as np
from numpy.exceptions import C... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_scalarbuffer.py | """
Test scalar buffer interface adheres to PEP 3118
"""
import numpy as np
from numpy._core._rational_tests import rational
from numpy._core._multiarray_tests import get_buffer_info
import pytest
from numpy.testing import assert_, assert_equal, assert_raises
# PEP3118 format strings for native (standard alignment an... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_arrayobject.py | import pytest
import numpy as np
from numpy.testing import assert_array_equal
def test_matrix_transpose_raises_error_for_1d():
msg = "matrix transpose with ndim < 2 is undefined"
arr = np.arange(48)
with pytest.raises(ValueError, match=msg):
arr.mT
def test_matrix_transpose_equals_transpose_2d(... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_casting_floatingpoint_errors.py | import pytest
from pytest import param
from numpy.testing import IS_WASM
import numpy as np
def values_and_dtypes():
"""
Generate value+dtype pairs that generate floating point errors during
casts. The invalid casts to integers will generate "invalid" value
warnings, the float casts all generate "ove... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_function_base.py | import sys
import pytest
import numpy as np
from numpy import (
logspace, linspace, geomspace, dtype, array, arange, isnan,
ndarray, sqrt, nextafter, stack, errstate
)
from numpy._core import sctypes
from numpy._core.function_base import add_newdoc
from numpy.testing import (
assert_, assert_equal, as... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_mem_policy.py | import asyncio
import gc
import os
import sys
import threading
import warnings
import pytest
import numpy as np
from numpy.testing import extbuild, assert_warns, IS_WASM
from numpy._core.multiarray import get_handler_name
# FIXME: numpy.testing.extbuild uses `numpy.distutils`, so this won't work on
# Python 3.12 an... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_cython.py | from datetime import datetime
import os
import shutil
import subprocess
import sys
import time
import pytest
import numpy as np
from numpy.testing import IS_WASM
# This import is copied from random.tests.test_extending
try:
import cython
from Cython.Compiler.Version import version as cython_version
except Imp... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_arrayprint.py | import sys
import gc
from hypothesis import given
from hypothesis.extra import numpy as hynp
import pytest
import numpy as np
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_warns, HAS_REFCOUNT,
assert_raises_regex,
)
from numpy._core.arrayprint import _typelessdata
import textwrap... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_multiarray.py | from __future__ import annotations
import collections.abc
import tempfile
import sys
import warnings
import operator
import io
import itertools
import functools
import ctypes
import os
import gc
import re
import weakref
import pytest
from contextlib import contextmanager
import pickle
import pathlib
import builtins
fr... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test__exceptions.py | """
Tests of the ._exceptions module. Primarily for exercising the __str__ methods.
"""
import pickle
import pytest
import numpy as np
from numpy.exceptions import AxisError
_ArrayMemoryError = np._core._exceptions._ArrayMemoryError
_UFuncNoLoopError = np._core._exceptions._UFuncNoLoopError
class TestArrayMemoryErr... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_nditer.py | import sys
import pytest
import textwrap
import subprocess
import numpy as np
import numpy._core.umath as ncu
import numpy._core._multiarray_tests as _multiarray_tests
from numpy import array, arange, nditer, all
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_raises,
IS_WASM, HA... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_records.py | import collections.abc
import textwrap
from io import BytesIO
from os import path
from pathlib import Path
import pickle
import pytest
import numpy as np
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_array_almost_equal,
assert_raises, temppath,
)
class TestFromrecords:
... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_umath.py | import platform
import warnings
import fnmatch
import itertools
import pytest
import sys
import os
import operator
from fractions import Fraction
from functools import reduce
from collections import namedtuple
import numpy._core.umath as ncu
from numpy._core import _umath_tests as ncu_tests, sctypes
import numpy as np... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_scalarprint.py | """ Test printing of scalar types.
"""
import code
import platform
import pytest
import sys
from tempfile import TemporaryFile
import numpy as np
from numpy.testing import assert_, assert_equal, assert_raises, IS_MUSL
class TestRealScalars:
def test_str(self):
svals = [0.0, -0.0, 1, -1, np.inf, -np.inf, ... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_hashtable.py | import pytest
import random
from numpy._core._multiarray_tests import identityhash_tester
@pytest.mark.parametrize("key_length", [1, 3, 6])
@pytest.mark.parametrize("length", [1, 16, 2000])
def test_identity_hashtable(key_length, length):
# use a 30 object pool for everything (duplicates will happen)
pool = ... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_arraymethod.py | """
This file tests the generic aspects of ArrayMethod. At the time of writing
this is private API, but when added, public API may be added here.
"""
from __future__ import annotations
import sys
import types
from typing import Any
import pytest
import numpy as np
from numpy._core._multiarray_umath import _get_cas... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_limited_api.py | import os
import shutil
import subprocess
import sys
import sysconfig
import pytest
from numpy.testing import IS_WASM
@pytest.mark.skipif(IS_WASM, reason="Can't start subprocess")
@pytest.mark.xfail(
sysconfig.get_config_var("Py_DEBUG"),
reason=(
"Py_LIMITED_API is incompatible with Py_DEBUG, Py_TRAC... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_conversion_utils.py | """
Tests for numpy/_core/src/multiarray/conversion_utils.c
"""
import re
import sys
import pytest
import numpy as np
import numpy._core._multiarray_tests as mt
from numpy._core.multiarray import CLIP, WRAP, RAISE
from numpy.testing import assert_warns, IS_PYPY
class StringConverterTestCase:
allow_bytes = True
... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_getlimits.py | """ Test functions for limits module.
"""
import warnings
import numpy as np
import pytest
from numpy._core import finfo, iinfo
from numpy import half, single, double, longdouble
from numpy.testing import assert_equal, assert_, assert_raises
from numpy._core.getlimits import _discovered_machar, _float_ma
############... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_indexing.py | import sys
import warnings
import functools
import operator
import pytest
import numpy as np
from numpy._core._multiarray_tests import array_indexing
from itertools import product
from numpy.exceptions import ComplexWarning, VisibleDeprecationWarning
from numpy.testing import (
assert_, assert_equal, assert_raise... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_machar.py | """
Test machar. Given recent changes to hardcode type data, we might want to get
rid of both MachAr and this test at some point.
"""
from numpy._core._machar import MachAr
import numpy._core.numerictypes as ntypes
from numpy import errstate, array
class TestMachAr:
def _run_machar_highprec(self):
# Inst... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_protocols.py | import pytest
import warnings
import numpy as np
@pytest.mark.filterwarnings("error")
def test_getattr_warning():
# issue gh-14735: make sure we clear only getattr errors, and let warnings
# through
class Wrapper:
def __init__(self, array):
self.array = array
def __len__(self)... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_extint128.py | import itertools
import contextlib
import operator
import pytest
import numpy as np
import numpy._core._multiarray_tests as mt
from numpy.testing import assert_raises, assert_equal
INT64_MAX = np.iinfo(np.int64).max
INT64_MIN = np.iinfo(np.int64).min
INT64_MID = 2**32
# int128 is not two's complement, the sign bit... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_strings.py | import pytest
import operator
import numpy as np
from numpy.testing import assert_array_equal
COMPARISONS = [
(operator.eq, np.equal, "=="),
(operator.ne, np.not_equal, "!="),
(operator.lt, np.less, "<"),
(operator.le, np.less_equal, "<="),
(operator.gt, np.greater, ">"),
(operator.ge, np.gr... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_simd.py | # NOTE: Please avoid the use of numpy.testing since NPYV intrinsics
# may be involved in their functionality.
import pytest, math, re
import itertools
import operator
from numpy._core._simd import targets, clear_floatstatus, get_floatstatus
from numpy._core._multiarray_umath import __cpu_baseline__
def check_floatstat... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_half.py | import platform
import pytest
import numpy as np
from numpy import uint16, float16, float32, float64
from numpy.testing import assert_, assert_equal, _OLD_PROMOTION, IS_WASM
def assert_raises_fpe(strmatch, callable, *args, **kwargs):
try:
callable(*args, **kwargs)
except FloatingPointError as exc:
... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_overrides.py | import inspect
import sys
import os
import tempfile
from io import StringIO
from unittest import mock
import pickle
import pytest
import numpy as np
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_raises_regex)
from numpy._core.overrides import (
_get_implementing_args, array_function... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_scalarinherit.py | """ Test printing of scalar types.
"""
import pytest
import numpy as np
from numpy.testing import assert_, assert_raises
class A:
pass
class B(A, np.float64):
pass
class C(B):
pass
class D(C, B):
pass
class B0(np.float64, A):
pass
class C0(B0):
pass
class HasNew:
def __new__(cls, *arg... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_array_interface.py | import sys
import pytest
import numpy as np
from numpy.testing import extbuild, IS_WASM
@pytest.fixture
def get_module(tmp_path):
""" Some codes to generate data and manage temporary buffers use when
sharing with numpy via the array interface protocol.
"""
if not sys.platform.startswith('linux'):
... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_dtype.py | import sys
import operator
import pytest
import ctypes
import gc
import types
from typing import Any
import pickle
import numpy as np
import numpy.dtypes
from numpy._core._rational_tests import rational
from numpy._core._multiarray_tests import create_custom_field_dtype
from numpy.testing import (
assert_, assert_... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_cpu_dispatcher.py | from numpy._core._multiarray_umath import (
__cpu_features__, __cpu_baseline__, __cpu_dispatch__
)
from numpy._core import _umath_tests
from numpy.testing import assert_equal
def test_dispatcher():
"""
Testing the utilities of the CPU dispatcher
"""
targets = (
"SSE2", "SSE41", "AVX2",
... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_numerictypes.py | import sys
import itertools
import pytest
import numpy as np
from numpy._core.numerictypes import issctype, sctype2char, maximum_sctype
from numpy.testing import assert_, assert_equal, assert_raises, IS_PYPY
# This is the structure of the table used for plain objects:
#
# +-+-+-+
# |x|y|z|
# +-+-+-+
# Structure of a... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_api.py | import sys
import numpy as np
import numpy._core.umath as ncu
from numpy._core._rational_tests import rational
import pytest
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_raises, assert_warns,
HAS_REFCOUNT
)
def test_array_array():
tobj = type(object)
ones11 = np... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_scalar_ctors.py | """
Test the scalar constructors, which also do type-coercion
"""
import pytest
import numpy as np
from numpy.testing import (
assert_equal, assert_almost_equal, assert_warns,
)
class TestFromString:
def test_floating(self):
# Ticket #640, floats from string
fsingle = np.single('1.234')
... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_defchararray.py | import pytest
import numpy as np
from numpy._core.multiarray import _vec_string
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_raises,
assert_raises_regex
)
kw_unicode_true = {'unicode': True} # make 2to3 work properly
kw_unicode_false = {'unicode': False}
class TestBasic:... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_memmap.py | import sys
import os
import mmap
import pytest
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryFile
from numpy import (
memmap, sum, average, prod, ndarray, isscalar, add, subtract, multiply)
from numpy import arange, allclose, asarray
from numpy.testing import (
assert_, assert_equ... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_array_coercion.py | """
Tests for array coercion, mainly through testing `np.array` results directly.
Note that other such tests exist, e.g., in `test_api.py` and many corner-cases
are tested (sometimes indirectly) elsewhere.
"""
from itertools import permutations, product
import pytest
from pytest import param
import numpy as np
impor... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_deprecations.py | """
Tests related to deprecation warnings. Also a convenient place
to document how deprecations should eventually be turned into errors.
"""
import datetime
import operator
import warnings
import pytest
import tempfile
import re
import sys
import numpy as np
from numpy.testing import (
assert_raises, assert_warns... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_datetime.py | import datetime
import pickle
import pytest
import numpy
import numpy as np
from numpy.testing import (
IS_WASM,
assert_, assert_equal, assert_raises, assert_warns, suppress_warnings,
assert_raises_regex, assert_array_equal,
)
# Use pytz to test out various time zones if available
try:
from pytz ... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_umath_accuracy.py | import numpy as np
import os
from os import path
import sys
import pytest
from ctypes import c_longlong, c_double, c_float, c_int, cast, pointer, POINTER
from numpy.testing import assert_array_max_ulp
from numpy.testing._private.utils import _glibc_older_than
from numpy._core._multiarray_umath import __cpu_features__
... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_errstate.py | import pytest
import sysconfig
import numpy as np
from numpy.testing import assert_, assert_raises, IS_WASM
# The floating point emulation on ARM EABI systems lacking a hardware FPU is
# known to be buggy. This is an attempt to identify these hosts. It may not
# catch all possible cases, but it catches the known case... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_numeric.py | import sys
import warnings
import itertools
import platform
import pytest
import math
from decimal import Decimal
import numpy as np
from numpy._core import umath, sctypes
from numpy._core.numerictypes import obj2sctype
from numpy._core.arrayprint import set_string_function
from numpy.exceptions import AxisError
from ... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_ufunc.py | import warnings
import itertools
import sys
import ctypes as ct
import pickle
import pytest
from pytest import param
import numpy as np
import numpy._core.umath as ncu
import numpy._core._umath_tests as umt
import numpy.linalg._umath_linalg as uml
import numpy._core._operand_flag_tests as opflag_tests
import numpy._c... | 0 |
public_repos/numpy/numpy/_core | public_repos/numpy/numpy/_core/tests/test_einsum.py | import itertools
import sys
import platform
import pytest
import numpy as np
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_almost_equal,
assert_raises, suppress_warnings, assert_raises_regex, assert_allclose
)
try:
COMPILERS = np.show_config(mode="dicts")["Compilers"]
... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-log.csv | dtype,input,output,ulperrortol
## +ve denormals ##
np.float32,0x004b4716,0xc2afbc1b,4
np.float32,0x007b2490,0xc2aec01e,4
np.float32,0x007c99fa,0xc2aeba17,4
np.float32,0x00734a0c,0xc2aee1dc,4
np.float32,0x0070de24,0xc2aeecba,4
np.float32,0x007fffff,0xc2aeac50,4
np.float32,0x00000001,0xc2ce8ed0,4
## -ve denormals ##
np.f... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-README.txt | Steps to validate transcendental functions:
1) Add a file 'umath-validation-set-<ufuncname>.txt', where ufuncname is name of
the function in NumPy you want to validate
2) The file should contain 4 columns: dtype,input,expected output,ulperror
a. dtype: one of np.float16, np.float32, np.float64
b. input: floa... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-arctan.csv | dtype,input,output,ulperrortol
np.float32,0x3f338252,0x3f1c8d9c,3
np.float32,0x7e569df2,0x3fc90fdb,3
np.float32,0xbf347e25,0xbf1d361f,3
np.float32,0xbf0a654e,0xbefdbfd2,3
np.float32,0x8070968e,0x8070968e,3
np.float32,0x803cfb27,0x803cfb27,3
np.float32,0x8024362e,0x8024362e,3
np.float32,0xfd55dca0,0xbfc90fdb,3
np.float3... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-log2.csv | dtype,input,output,ulperrortol
np.float32,0x80000000,0xff800000,3
np.float32,0x7f12870a,0x42fe63db,3
np.float32,0x3ef29cf5,0xbf89eb12,3
np.float32,0x3d6ba8fb,0xc083d26c,3
np.float32,0x3d9907e8,0xc06f8230,3
np.float32,0x4ee592,0xc2fd656e,3
np.float32,0x58d8b1,0xc2fd0db3,3
np.float32,0x7ba103,0xc2fc19aa,3
np.float32,0x7f... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-exp2.csv | dtype,input,output,ulperrortol
np.float32,0xbdfe94b0,0x3f6adda6,2
np.float32,0x3f20f8f8,0x3fc5ec69,2
np.float32,0x7040b5,0x3f800000,2
np.float32,0x30ec5,0x3f800000,2
np.float32,0x3eb63070,0x3fa3ce29,2
np.float32,0xff4dda3d,0x0,2
np.float32,0x805b832f,0x3f800000,2
np.float32,0x3e883fb7,0x3f99ed8c,2
np.float32,0x3f14d71f... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-tanh.csv | dtype,input,output,ulperrortol
np.float32,0xbe26ebb0,0xbe25752f,2
np.float32,0xbe22ecc0,0xbe219054,2
np.float32,0x8010a6b3,0x8010a6b3,2
np.float32,0x3135da,0x3135da,2
np.float32,0xbe982afc,0xbe93d727,2
np.float32,0x16a51f,0x16a51f,2
np.float32,0x491e56,0x491e56,2
np.float32,0x4bf7ca,0x4bf7ca,2
np.float32,0x3eebc21c,0x3... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-cbrt.csv | dtype,input,output,ulperrortol
np.float32,0x3ee7054c,0x3f4459ea,2
np.float32,0x7d1e2489,0x54095925,2
np.float32,0x7ee5edf5,0x549b992b,2
np.float32,0x380607,0x2a425e72,2
np.float32,0x34a8f3,0x2a3e6603,2
np.float32,0x3eee2844,0x3f465a45,2
np.float32,0x59e49c,0x2a638d0a,2
np.float32,0xbf72c77a,0xbf7b83d4,2
np.float32,0x7f... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-cosh.csv | dtype,input,output,ulperrortol
np.float32,0xfe0ac238,0x7f800000,3
np.float32,0xbf553b86,0x3faf079b,3
np.float32,0xff4457da,0x7f800000,3
np.float32,0xff7253f3,0x7f800000,3
np.float32,0x5a5802,0x3f800000,3
np.float32,0x3db03413,0x3f80795b,3
np.float32,0x7f6795c9,0x7f800000,3
np.float32,0x805b9142,0x3f800000,3
np.float32,... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-arcsinh.csv | dtype,input,output,ulperrortol
np.float32,0xbf24142a,0xbf1a85ef,2
np.float32,0x3e71cf91,0x3e6f9e37,2
np.float32,0xe52a7,0xe52a7,2
np.float32,0x3ef1e074,0x3ee9add9,2
np.float32,0x806160ac,0x806160ac,2
np.float32,0x7e2d59a2,0x42af4798,2
np.float32,0xbf32cac9,0xbf26bf96,2
np.float32,0x3f081701,0x3f026142,2
np.float32,0x3f... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-cos.csv | dtype,input,output,ulperrortol
## +ve denormals ##
np.float32,0x004b4716,0x3f800000,2
np.float32,0x007b2490,0x3f800000,2
np.float32,0x007c99fa,0x3f800000,2
np.float32,0x00734a0c,0x3f800000,2
np.float32,0x0070de24,0x3f800000,2
np.float32,0x007fffff,0x3f800000,2
np.float32,0x00000001,0x3f800000,2
## -ve denormals ##
np.f... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-exp.csv | dtype,input,output,ulperrortol
## +ve denormals ##
np.float32,0x004b4716,0x3f800000,3
np.float32,0x007b2490,0x3f800000,3
np.float32,0x007c99fa,0x3f800000,3
np.float32,0x00734a0c,0x3f800000,3
np.float32,0x0070de24,0x3f800000,3
np.float32,0x00495d65,0x3f800000,3
np.float32,0x006894f6,0x3f800000,3
np.float32,0x00555a76,0x... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-log1p.csv | dtype,input,output,ulperrortol
np.float32,0x3e10aca8,0x3e075347,2
np.float32,0x3f776e66,0x3f2d2003,2
np.float32,0xbf34e8ce,0xbf9cfd5c,2
np.float32,0xbf0260ee,0xbf363f69,2
np.float32,0x3ed285e8,0x3eb05870,2
np.float32,0x262b88,0x262b88,2
np.float32,0x3eeffd6c,0x3ec4cfdb,2
np.float32,0x3ee86808,0x3ebf9f54,2
np.float32,0x... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-arcsin.csv | dtype,input,output,ulperrortol
np.float32,0xbe7d3a7c,0xbe7fe217,4
np.float32,0x3dc102f0,0x3dc14c60,4
np.float32,0xbe119c28,0xbe121aef,4
np.float32,0xbe51cd68,0xbe534c75,4
np.float32,0x3c04a300,0x3c04a35f,4
np.float32,0xbf4f0b62,0xbf712a69,4
np.float32,0x3ef61a5c,0x3f005cf6,4
np.float32,0xbf13024c,0xbf1c97df,4
np.float3... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-log10.csv | dtype,input,output,ulperrortol
np.float32,0x3f6fd5c8,0xbce80e8e,4
np.float32,0x3ea4ab17,0xbefc3deb,4
np.float32,0x3e87a133,0xbf13b0b7,4
np.float32,0x3f0d9069,0xbe83bb19,4
np.float32,0x3f7b9269,0xbbf84f47,4
np.float32,0x3f7a9ffa,0xbc16fd97,4
np.float32,0x7f535d34,0x4219cb66,4
np.float32,0x3e79ad7c,0xbf1ce857,4
np.float3... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-sinh.csv | dtype,input,output,ulperrortol
np.float32,0xfee27582,0xff800000,2
np.float32,0xff19f092,0xff800000,2
np.float32,0xbf393576,0xbf49cb31,2
np.float32,0x8020fdea,0x8020fdea,2
np.float32,0x455f4e,0x455f4e,2
np.float32,0xff718c35,0xff800000,2
np.float32,0x3f3215e3,0x3f40cce5,2
np.float32,0x19e833,0x19e833,2
np.float32,0xff2d... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-arccosh.csv | dtype,input,output,ulperrortol
np.float32,0x3f83203f,0x3e61d9d6,2
np.float32,0x3f98dea1,0x3f1d1af6,2
np.float32,0x7fa00000,0x7fe00000,2
np.float32,0x7eba99af,0x42b0d032,2
np.float32,0x3fc95a13,0x3f833650,2
np.float32,0x3fce9a45,0x3f8771e1,2
np.float32,0x3fc1bd96,0x3f797811,2
np.float32,0x7eba2391,0x42b0ceed,2
np.float3... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-sin.csv | dtype,input,output,ulperrortol
## +ve denormals ##
np.float32,0x004b4716,0x004b4716,2
np.float32,0x007b2490,0x007b2490,2
np.float32,0x007c99fa,0x007c99fa,2
np.float32,0x00734a0c,0x00734a0c,2
np.float32,0x0070de24,0x0070de24,2
np.float32,0x007fffff,0x007fffff,2
np.float32,0x00000001,0x00000001,2
## -ve denormals ##
np.f... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-expm1.csv | dtype,input,output,ulperrortol
np.float32,0x80606724,0x80606724,3
np.float32,0xbf16790f,0xbee38e14,3
np.float32,0xbf1778a1,0xbee4a97f,3
np.float32,0x7d4fc610,0x7f800000,3
np.float32,0xbec30a20,0xbea230d5,3
np.float32,0x3eae8a36,0x3ecffac5,3
np.float32,0xbf1f08f1,0xbeece93c,3
np.float32,0x80374376,0x80374376,3
np.float3... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/generate_umath_validation_data.cpp | #include <algorithm>
#include <fstream>
#include <iostream>
#include <math.h>
#include <random>
#include <cstdio>
#include <ctime>
#include <vector>
struct ufunc {
std::string name;
double (*f32func)(double);
long double (*f64func)(long double);
float f32ulp;
float f64ulp;
};
template <typename T>... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-arctanh.csv | dtype,input,output,ulperrortol
np.float32,0x3ee82930,0x3efa60fd,2
np.float32,0x3f0aa640,0x3f1b3e13,2
np.float32,0x3ec1a21c,0x3ecbbf8d,2
np.float32,0x3cdb1740,0x3cdb24a1,2
np.float32,0xbf28b6f3,0xbf4a86ac,2
np.float32,0xbe490dcc,0xbe4bb2eb,2
np.float32,0x80000001,0x80000001,2
np.float32,0xbf44f9dd,0xbf826ce1,2
np.float3... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-tan.csv | dtype,input,output,ulperrortol
np.float32,0xfd97ece0,0xc11186e9,4
np.float32,0x8013bb34,0x8013bb34,4
np.float32,0x316389,0x316389,4
np.float32,0x7f7fffff,0xbf1c9eca,4
np.float32,0x3f7674bb,0x3fb7e450,4
np.float32,0x80800000,0x80800000,4
np.float32,0x7f5995e8,0xbf94106c,4
np.float32,0x74527,0x74527,4
np.float32,0x7f08ca... | 0 |
public_repos/numpy/numpy/_core/tests | public_repos/numpy/numpy/_core/tests/data/umath-validation-set-arccos.csv | dtype,input,output,ulperrortol
np.float32,0xbddd7f50,0x3fd6eec2,3
np.float32,0xbe32a20c,0x3fdf8182,3
np.float32,0xbf607c09,0x4028f84f,3
np.float32,0x3f25d906,0x3f5db544,3
np.float32,0x3f01cec8,0x3f84febf,3
np.float32,0x3f1d5c6e,0x3f68a735,3
np.float32,0xbf0cab89,0x4009c36d,3
np.float32,0xbf176b40,0x400d0941,3
np.float3... | 0 |
public_repos/numpy/numpy/_core/tests/examples | public_repos/numpy/numpy/_core/tests/examples/limited_api/limited_api.c | #define Py_LIMITED_API 0x03060000
#include <Python.h>
#include <numpy/arrayobject.h>
#include <numpy/ufuncobject.h>
static PyModuleDef moduledef = {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "limited_api"
};
PyMODINIT_FUNC PyInit_limited_api(void)
{
import_array();
import_umath();
return PyModul... | 0 |
public_repos/numpy/numpy/_core/tests/examples | public_repos/numpy/numpy/_core/tests/examples/limited_api/setup.py | """
Build an example package using the limited Python C API.
"""
import numpy as np
from setuptools import setup, Extension
import os
macros = [("NPY_NO_DEPRECATED_API", 0), ("Py_LIMITED_API", "0x03060000")]
limited_api = Extension(
"limited_api",
sources=[os.path.join('.', "limited_api.c")],
include_dir... | 0 |
public_repos/numpy/numpy/_core/tests/examples | public_repos/numpy/numpy/_core/tests/examples/cython/meson.build | project('checks', 'c', 'cython')
py = import('python').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
npy_include_path = run_command(py, [
'-c',
'import os; os.ch... | 0 |
public_repos/numpy/numpy/_core/tests/examples | public_repos/numpy/numpy/_core/tests/examples/cython/setup.py | """
Provide python-space access to the functions exposed in numpy/__init__.pxd
for testing.
"""
import numpy as np
from distutils.core import setup
from Cython.Build import cythonize
from setuptools.extension import Extension
import os
macros = [
("NPY_NO_DEPRECATED_API", 0),
# Require 1.25+ to test datetime ... | 0 |
public_repos/numpy/numpy/_core/tests/examples | public_repos/numpy/numpy/_core/tests/examples/cython/checks.pyx | #cython: language_level=3
"""
Functions in this module give python-space wrappers for cython functions
exposed in numpy/__init__.pxd, so they can be tested in test_cython.py
"""
cimport numpy as cnp
cnp.import_array()
def is_td64(obj):
return cnp.is_timedelta64_object(obj)
def is_dt64(obj):
return cnp.is_d... | 0 |
public_repos/numpy | public_repos/numpy/benchmarks/asv.conf.json | {
// The version of the config file format. Do not change, unless
// you know what you are doing.
"version": 1,
// The name of the project being benchmarked
"project": "numpy",
// The project's homepage
"project_url": "https://numpy.org",
// The URL or local path of the source code r... | 0 |
public_repos/numpy | public_repos/numpy/benchmarks/README.rst | .. -*- rst -*-
================
NumPy benchmarks
================
Benchmarking NumPy with Airspeed Velocity.
Usage
-----
Airspeed Velocity manages building and Python virtualenvs by itself,
unless told otherwise. To run the benchmarks, you do not need to install a
development version of NumPy to your current Pyth... | 0 |
public_repos/numpy | public_repos/numpy/benchmarks/asv_compare.conf.json.tpl | // This config file is almost similar to 'asv.conf.json' except it contains
// custom tokens that can be substituted by 'runtests.py' and ASV,
// due to the necessity to add custom build options when `--bench-compare`
// is used.
{
// The version of the config file format. Do not change, unless
// you know wha... | 0 |
public_repos/numpy | public_repos/numpy/benchmarks/asv_pip_nopep517.py | """
This file is used by asv_compare.conf.json.tpl.
"""
import subprocess, sys
# pip ignores '--global-option' when pep517 is enabled therefore we disable it.
cmd = [sys.executable, '-mpip', 'wheel', '--no-use-pep517']
try:
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, text=True)
except Exception ... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_array_coercion.py | from .common import Benchmark
import numpy as np
class ArrayCoercionSmall(Benchmark):
# More detailed benchmarks for array coercion,
# some basic benchmarks are in `bench_core.py`.
params = [[range(3), [1], 1, np.array([5], dtype=np.int64), np.int64(5)]]
param_names = ['array_like']
int64 = np.dt... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_indexing.py | from .common import (
Benchmark, get_square_, get_indexes_, get_indexes_rand_, TYPES1)
from os.path import join as pjoin
import shutil
from numpy import memmap, float32, array
import numpy as np
from tempfile import mkdtemp
class Indexing(Benchmark):
params = [TYPES1 + ["object", "O,i"],
["inde... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_strings.py | from .common import Benchmark
import numpy as np
import operator
_OPERATORS = {
'==': operator.eq,
'!=': operator.ne,
'<': operator.lt,
'<=': operator.le,
'>': operator.gt,
'>=': operator.ge,
}
class StringComparisons(Benchmark):
# Basic string comparison speed tests
params = [
... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_io.py | from .common import Benchmark, get_squares, get_squares_
import numpy as np
from io import SEEK_SET, StringIO, BytesIO
class Copy(Benchmark):
params = ["int8", "int16", "float32", "float64",
"complex64", "complex128"]
param_names = ['type']
def setup(self, typename):
dtype = np.dty... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_creation.py | from .common import Benchmark, TYPES1, get_squares_
import numpy as np
class MeshGrid(Benchmark):
""" Benchmark meshgrid generation
"""
params = [[16, 32],
[2, 3, 4],
['ij', 'xy'], TYPES1]
param_names = ['size', 'ndims', 'ind', 'ndtype']
timeout = 10
def setup(sel... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_ma.py | from .common import Benchmark
import numpy as np
class MA(Benchmark):
def setup(self):
self.l100 = range(100)
self.t100 = ([True] * 100)
def time_masked_array(self):
np.ma.masked_array()
def time_masked_array_l100(self):
np.ma.masked_array(self.l100)
def time_masked... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_records.py | from .common import Benchmark
import numpy as np
class Records(Benchmark):
def setup(self):
self.l50 = np.arange(1000)
self.fields_number = 10000
self.arrays = [self.l50 for _ in range(self.fields_number)]
self.formats = [self.l50.dtype.str for _ in range(self.fields_number)]
... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_import.py | from subprocess import call
from sys import executable
from timeit import default_timer
from .common import Benchmark
class Import(Benchmark):
timer = default_timer
def execute(self, command):
call((executable, '-c', command))
def time_numpy(self):
self.execute('import numpy')
def ... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/common.py | import numpy as np
import random
import os
from functools import lru_cache
from pathlib import Path
# Various pre-crafted datasets/variables for testing
# !!! Must not be changed -- only appended !!!
# while testing numpy we better not rely on numpy to produce random
# sequences
random.seed(1)
# but will seed it never... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_itemselection.py | from .common import Benchmark, TYPES1
import numpy as np
class Take(Benchmark):
params = [
[(1000, 1), (2, 1000, 1), (1000, 3)],
["raise", "wrap", "clip"],
TYPES1 + ["O", "i,O"]]
param_names = ["shape", "mode", "dtype"]
def setup(self, shape, mode, dtype):
self.arr = np.o... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_lib.py | """Benchmarks for `numpy.lib`."""
from .common import Benchmark
import numpy as np
class Pad(Benchmark):
"""Benchmarks for `numpy.pad`.
When benchmarking the pad function it is useful to cover scenarios where
the ratio between the size of the input array and the output array differs
significantly ... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_overrides.py | from .common import Benchmark
try:
from numpy._core.overrides import array_function_dispatch
except ImportError:
# Don't fail at import time with old Numpy versions
def array_function_dispatch(*args, **kwargs):
def wrap(*args, **kwargs):
return None
return wrap
import numpy as ... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_app.py | from .common import Benchmark
import numpy as np
class LaplaceInplace(Benchmark):
params = ['inplace', 'normal']
param_names = ['update']
def setup(self, update):
N = 150
Niter = 1000
dx = 0.1
dy = 0.1
dx2 = (dx * dx)
dy2 = (dy * dy)
def num_updat... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_manipulate.py | from .common import Benchmark, get_squares_, TYPES1, DLPACK_TYPES
import numpy as np
from collections import deque
class BroadcastArrays(Benchmark):
params = [[(16, 32), (128, 256), (512, 1024)],
TYPES1]
param_names = ['shape', 'ndtype']
timeout = 10
def setup(self, shape, ndtype):
... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_linalg.py | from .common import Benchmark, get_squares_, get_indexes_rand, TYPES1
import numpy as np
class Eindot(Benchmark):
def setup(self):
self.a = np.arange(60000.0).reshape(150, 400)
self.ac = self.a.copy()
self.at = self.a.T
self.atc = self.a.T.copy()
self.b = np.arange(240000.... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_ufunc.py | from .common import Benchmark, get_squares_, TYPES1, DLPACK_TYPES
import numpy as np
import itertools
from packaging import version
import operator
ufuncs = ['abs', 'absolute', 'add', 'arccos', 'arccosh', 'arcsin', 'arcsinh',
'arctan', 'arctan2', 'arctanh', 'bitwise_and', 'bitwise_count', 'bitwise_not',
... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_ufunc_strides.py | from .common import Benchmark, get_data
import numpy as np
UFUNCS = [obj for obj in np._core.umath.__dict__.values() if
isinstance(obj, np.ufunc)]
UFUNCS_UNARY = [uf for uf in UFUNCS if "O->O" in uf.types]
class _AbstractBinary(Benchmark):
params = []
param_names = ['ufunc', 'stride_in0', 'stride_i... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_random.py | from .common import Benchmark
import numpy as np
try:
from numpy.random import Generator
except ImportError:
pass
class Random(Benchmark):
params = ['normal', 'uniform', 'weibull 1', 'binomial 10 0.5',
'poisson 10']
def setup(self, name):
items = name.split()
name = it... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_trim_zeros.py | from .common import Benchmark
import numpy as np
_FLOAT = np.dtype('float64')
_COMPLEX = np.dtype('complex128')
_INT = np.dtype('int64')
_BOOL = np.dtype('bool')
class TrimZeros(Benchmark):
param_names = ["dtype", "size"]
params = [
[_INT, _FLOAT, _COMPLEX, _BOOL],
[3000, 30_000, 300_000]
... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_scalar.py | from .common import Benchmark, TYPES1
import numpy as np
class ScalarMath(Benchmark):
# Test scalar math, note that each of these is run repeatedly to offset
# the function call overhead to some degree.
params = [TYPES1]
param_names = ["type"]
def setup(self, typename):
self.num = np.dtyp... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_reduce.py | from .common import Benchmark, TYPES1, get_squares
import numpy as np
class AddReduce(Benchmark):
def setup(self):
self.squares = get_squares().values()
def time_axis_0(self):
[np.add.reduce(a, axis=0) for a in self.squares]
def time_axis_1(self):
[np.add.reduce(a, axis=1) for a... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_function_base.py | from .common import Benchmark
import numpy as np
try:
# SkipNotImplemented is available since 6.0
from asv_runner.benchmarks.mark import SkipNotImplemented
except ImportError:
SkipNotImplemented = NotImplementedError
class Linspace(Benchmark):
def setup(self):
self.d = np.array([1, 2, 3])
... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_core.py | from .common import Benchmark
import numpy as np
class Core(Benchmark):
def setup(self):
self.l100 = range(100)
self.l50 = range(50)
self.float_l1000 = [float(i) for i in range(1000)]
self.float64_l1000 = [np.float64(i) for i in range(1000)]
self.int_l1000 = list(range(100... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/__init__.py | from . import common
import sys
import os
def show_cpu_features():
from numpy.lib._utils_impl import _opt_info
info = _opt_info()
info = "NumPy CPU features: " + (info if info else 'nothing enabled')
# ASV wrapping stdout & stderr, so we assume having a tty here
if 'SHELL' in os.environ and sys.pla... | 0 |
public_repos/numpy/benchmarks | public_repos/numpy/benchmarks/benchmarks/bench_shape_base.py | from .common import Benchmark
import numpy as np
class Block(Benchmark):
params = [1, 10, 100]
param_names = ['size']
def setup(self, n):
self.a_2d = np.ones((2 * n, 2 * n))
self.b_1d = np.ones(2 * n)
self.b_2d = 2 * self.a_2d
self.a = np.ones(3 * n)
self.b = np.... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.