text
stringlengths
0
20k
""" Build 'use others module data' mechanism for f2py2e. Copyright 1999 -- 2011 Pearu Peterson all rights reserved. Copyright 2011 -- present NumPy Developers. Permission to use, modify, and distribute this software is given under the terms of the NumPy License. NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN R...
""" Rules for building C/API module with f2py2e. Copyright 1999 -- 2011 Pearu Peterson all rights reserved. Copyright 2011 -- present NumPy Developers. Permission to use, modify, and distribute this software is given under the terms of the NumPy License. NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. ""...
"""Fortran to Python Interface Generator. Copyright 1999 -- 2011 Pearu Peterson all rights reserved. Copyright 2011 -- present NumPy Developers. Permission to use, modify, and distribute this software is given under the terms of the NumPy License. NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. """ __all_...
[bdist_rpm] doc_files = docs/ tests/
# See: # https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e from numpy.f2py.f2py2e import main main()
""" ISO_C_BINDING maps for f2py2e. Only required declarations/macros/functions will be used. Copyright 1999 -- 2011 Pearu Peterson all rights reserved. Copyright 2011 -- present NumPy Developers. Permission to use, modify, and distribute this software is given under the terms of the NumPy License. NO WARRANTY IS EXPR...
import os import re # START OF CODE VENDORED FROM `numpy.distutils.from_template` ############################################################# """ process_file(filename) takes templated file .xxx.src and produces .xxx file where .xxx is .pyf .f90 or .f using the following template rules: '<..>' denotes a temp...
import pytest import numpy as np from . import util class TestString(util.F2PyTest): sources = [util.getpath("tests", "src", "string", "char.f90")] @pytest.mark.slow def test_char(self): strings = np.array(["ab", "cd", "ef"], dtype="c").T inp, out = self.module.char_test.change_strings(...
import pytest from . import util @pytest.mark.slow class TestRenamedFunc(util.F2PyTest): sources = [ util.getpath("tests", "src", "routines", "funcfortranname.f"), util.getpath("tests", "src", "routines", "funcfortranname.pyf"), ] module_name = "funcfortranname" def test_gh25799(self...
import textwrap import pytest from numpy.testing import IS_PYPY from . import util class TestMixed(util.F2PyTest): sources = [ util.getpath("tests", "src", "mixed", "foo.f"), util.getpath("tests", "src", "mixed", "foo_fixed.f90"), util.getpath("tests", "src", "mixed", "foo_free.f90"), ...
import platform import pytest from numpy import array from . import util IS_S390X = platform.machine() == "s390x" @pytest.mark.slow class TestReturnCharacter(util.F2PyTest): def check_function(self, t, tname): if tname in ["t0", "t1", "s0", "s1"]: assert t("23") == b"2" r = t("...
import pytest from numpy import array from . import util @pytest.mark.slow class TestReturnComplex(util.F2PyTest): def check_function(self, t, tname): if tname in ["t0", "t8", "s0", "s8"]: err = 1e-5 else: err = 0.0 assert abs(t(234j) - 234.0j) <= err asse...
# This test is ported from numpy.distutils from numpy.f2py._src_pyf import process_str from numpy.testing import assert_equal pyf_src = """ python module foo <_rd=real,double precision> interface subroutine <s,d>foosub(tol) <_rd>, intent(in,out) :: tol end subroutine <s,d>foosub ...
import textwrap import pytest from numpy.testing import IS_PYPY from . import util @pytest.mark.slow class TestModuleFilterPublicEntities(util.F2PyTest): sources = [ util.getpath( "tests", "src", "modules", "gh26920", "two_mods_with_one_public_routine.f90" ) ] # ...
/* * This file was auto-generated with f2py (version:2_1330) and hand edited by * Pearu for testing purposes. Do not edit this file unless you know what you * are doing!!! */ #ifdef __cplusplus extern "C" { #endif /*********************** See f2py2e/cfuncs.py: includes ***********************/ #define PY_SSIZE_...
import math import platform import sys import textwrap import threading import time import traceback import pytest import numpy as np from numpy.testing import IS_PYPY from . import util class TestF77Callback(util.F2PyTest): sources = [util.getpath("tests", "src", "callback", "foo.f")] @pytest.mark.parame...
import pytest import numpy as np from numpy.f2py.crackfortran import crackfortran from . import util class TestData(util.F2PyTest): sources = [util.getpath("tests", "src", "crackfortran", "data_stmts.f90")] # For gh-23276 @pytest.mark.slow def test_data_stmts(self): assert self.module.cmplx...
import pytest import numpy as np from . import util class TestSizeSumExample(util.F2PyTest): sources = [util.getpath("tests", "src", "size", "foo.f90")] @pytest.mark.slow def test_all(self): r = self.module.foo([[]]) assert r == [0] r = self.module.foo([[1, 2]]) assert ...
import platform import pytest from numpy.testing import IS_64BIT from . import util @pytest.mark.skipif( platform.system() == "Darwin", reason="Prone to error when run with numpy/f2py/tests on mac os, " "but not when run in isolation", ) @pytest.mark.skipif( not IS_64BIT, reason="32-bit builds are ...
import pytest from numpy import array from . import util @pytest.mark.slow class TestReturnInteger(util.F2PyTest): def check_function(self, t, tname): assert t(123) == 123 assert t(123.6) == 123 assert t("123") == 123 assert t(-123) == -123 assert t([123]) == 123 ...
import pytest from numpy.testing import IS_EDITABLE, IS_WASM if IS_WASM: pytest.skip( "WASM/Pyodide does not use or support Fortran", allow_module_level=True ) if IS_EDITABLE: pytest.skip( "Editable install doesn't support tests with a compile step", allow_module_level=Tr...
import sys import pytest from numpy.testing import IS_PYPY from . import util @pytest.mark.slow class TestBlockDocString(util.F2PyTest): sources = [util.getpath("tests", "src", "block_docstring", "foo.f")] @pytest.mark.skipif(sys.platform == "win32", reason="Fails with MinGW64 Gfor...
import pytest import numpy as np from numpy.testing import assert_allclose from . import util class TestISOC(util.F2PyTest): sources = [ util.getpath("tests", "src", "isocintrin", "isoCtests.f90"), ] # gh-24553 @pytest.mark.slow def test_c_double(self): out = self.module.coddity...
import pytest import numpy as np from . import util @pytest.mark.slow class TestCommonBlock(util.F2PyTest): sources = [util.getpath("tests", "src", "common", "block.f")] def test_common_block(self): self.module.initcb() assert self.module.block.long_bn == np.array(1.0, dtype=np.float64) ...
import pytest from numpy.f2py.symbolic import ( ArithOp, Expr, Language, Op, as_apply, as_array, as_complex, as_deref, as_eq, as_expr, as_factors, as_ge, as_gt, as_le, as_lt, as_ne, as_number, as_numer_denom, as_ref, as_string, as_symb...
""" Utility functions for - building and importing modules on test time, using a temporary location - detecting if compilers are present - determining paths to tests """ import atexit import concurrent.futures import contextlib import glob import os import shutil import subprocess import sys import tempfile from impo...
import pytest import numpy as np from . import util class TestParameters(util.F2PyTest): # Check that intent(in out) translates as intent(inout) sources = [ util.getpath("tests", "src", "parameter", "constant_real.f90"), util.getpath("tests", "src", "parameter", "constant_integer.f90"), ...
import contextlib import importlib import io import textwrap import time import pytest import numpy as np from numpy.f2py import crackfortran from numpy.f2py.crackfortran import markinnerspaces, nameargspattern from . import util class TestNoSpace(util.F2PyTest): # issue gh-15035: add handling for endsubroutin...
import numpy as np from . import util class TestF2Cmap(util.F2PyTest): sources = [ util.getpath("tests", "src", "f2cmap", "isoFortranEnvMap.f90"), util.getpath("tests", "src", "f2cmap", ".f2py_f2cmap") ] # gh-15095 def test_gh15095(self): inp = np.ones(3) out = self.m...
import os import platform import pytest import numpy as np import numpy.testing as npt from . import util class TestIntentInOut(util.F2PyTest): # Check that intent(in out) translates as intent(inout) sources = [util.getpath("tests", "src", "regression", "inout.f90")] @pytest.mark.slow def test_ino...
import pytest from . import util class TestValueAttr(util.F2PyTest): sources = [util.getpath("tests", "src", "value_attrspec", "gh21665.f90")] # gh-21665 @pytest.mark.slow def test_gh21665(self): inp = 2 out = self.module.fortfuncs.square(inp) exp_out = 4 assert out =...
import pytest from numpy.f2py import crackfortran from numpy.testing import IS_WASM from . import util @pytest.mark.skipif(IS_WASM, reason="Cannot start subprocess") @pytest.mark.slow class TestAbstractInterface(util.F2PyTest): sources = [util.getpath("tests", "src", "abstract_interface", "foo.f90")] skip ...
import platform import sys import pytest from numpy.f2py.crackfortran import ( _selected_int_kind_func as selected_int_kind, ) from numpy.f2py.crackfortran import ( _selected_real_kind_func as selected_real_kind, ) from . import util class TestKind(util.F2PyTest): sources = [util.getpath("tests", "src"...
from pathlib import Path import pytest import numpy as np from numpy.testing import assert_array_equal, assert_equal from . import util def get_docdir(): parents = Path(__file__).resolve().parents try: # Assumes that spin is used to run tests nproot = parents[8] except IndexError: ...
import platform import pytest from numpy import array from numpy.testing import IS_64BIT from . import util @pytest.mark.slow class TestReturnReal(util.F2PyTest): def check_function(self, t, tname): if tname in ["t0", "t4", "s0", "s4"]: err = 1e-5 else: err = 0.0 ...
"""See https://github.com/numpy/numpy/pull/10676. """ import sys import pytest from . import util class TestQuotedCharacter(util.F2PyTest): sources = [util.getpath("tests", "src", "quoted_character", "foo.f")] @pytest.mark.skipif(sys.platform == "win32", reason="Fails with MinGW64 ...
import pytest from numpy import array from . import util class TestReturnLogical(util.F2PyTest): def check_function(self, t): assert t(True) == 1 assert t(False) == 0 assert t(0) == 0 assert t(None) == 0 assert t(0.0) == 0 assert t(0j) == 0 assert t(1j) ==...
import os import tempfile import pytest from . import util class TestAssumedShapeSumExample(util.F2PyTest): sources = [ util.getpath("tests", "src", "assumed_shape", "foo_free.f90"), util.getpath("tests", "src", "assumed_shape", "foo_use.f90"), util.getpath("tests", "src", "assumed_shape...
""" Build common block mechanism for f2py2e. Copyright 1999 -- 2011 Pearu Peterson all rights reserved. Copyright 2011 -- present NumPy Developers. Permission to use, modify, and distribute this software is given under the terms of the NumPy License NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. """ from...
# 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_config"] _built_with_meson = True class Disp...
def __getattr__(attr_name): import warnings from numpy.linalg import _linalg ret = getattr(_linalg, attr_name, None) if ret is None: raise AttributeError( f"module 'numpy.linalg.linalg' has no attribute {attr_name}") warnings.warn( "The numpy.linalg.linalg has been made ...
""" ``numpy.linalg`` ================ The NumPy linear algebra functions rely on BLAS and LAPACK to provide efficient low level implementations of standard linear algebra algorithms. Those libraries may be provided by NumPy itself using C versions of a subset of their reference implementations but, when possible, high...
"""Test deprecation and future warnings. """ import numpy as np from numpy.testing import assert_warns def test_qr_mode_full_future_warning(): """Check mode='full' FutureWarning. In numpy 1.8 the mode options 'full' and 'economic' in linalg.qr were deprecated. The release date will probably be sometime ...
""" Test functions for linalg module """ import pytest import numpy as np from numpy import arange, array, dot, float64, linalg, transpose from numpy.testing import ( assert_, assert_array_almost_equal, assert_array_equal, assert_array_less, assert_equal, assert_raises, ) class TestRegressio...
""" 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 os import sys from numpy._core import dtype from numpy._core import numerictypes as _numerictypes from numpy._core.funct...
""" 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 ...
"""Simple script to compute the api hash of the current API. The API has is defined by numpy_api_order and ufunc_api_order. """ from os.path import dirname from code_generators.genapi import fullapi_hash from code_generators.numpy_api import full_api if __name__ == '__main__': curdir = dirname(__file__) pri...
""" String-handling utilities to avoid locale-dependence. Used primarily to generate type name aliases. """ # "import string" is costly to import! # Construct the translation tables directly # "A" = chr(65), "a" = chr(97) _all_chars = tuple(map(chr, range(256))) _ascii_upper = _all_chars[65:65 + 26] _ascii_lower = _...
""" 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',...
""" Machine arithmetic - determine the parameters of the floating-point arithmetic system Author: Pearu Peterson, September 2003 """ __all__ = ['MachAr'] from ._ufunc_config import errstate from .fromnumeric import any # Need to speed this up...especially for longdouble # Deprecated 2021-10-20, NumPy 1.22 class Ma...
""" Stores and defines the low-level format_options context variable. This is defined in its own file outside of the arrayprint module so we can import it from C while initializing the multiarray C module during import without introducing circular dependencies. """ import sys from contextvars import ContextVar __all...
import functools import operator import types import warnings import numpy as np from numpy._core import overrides from numpy._core._multiarray_umath import _array_converter from numpy._core.multiarray import add_docstring from . import numeric as _nx from .numeric import asanyarray, nan, ndim, result_type __all__ =...
""" Contains the core of NumPy: ndarray, ufuncs, dtypes, etc. Please note that this module is private. All functions and objects are available in the main ``numpy`` namespace - use that instead. """ import os from numpy.version import version as __version__ # disables OpenBLAS affinity setting of the main thread ...
""" Functions for changing global ufunc configuration This provides helpers which wrap `_get_extobj_dict` and `_make_extobj`, and `_extobj_contextvar` from umath. """ import functools from numpy._utils import set_module from .umath import _extobj_contextvar, _get_extobj_dict, _make_extobj __all__ = [ "seterr", ...
""" Array methods which are called by both the C-code for the method and the Python code for the NumPy-namespace function """ import os import pickle import warnings from contextlib import nullcontext import numpy as np from numpy._core import multiarray as mu from numpy._core import numerictypes as nt from numpy._co...
""" Due to compatibility, numpy has a very large number of different naming conventions for the scalar types (those subclassing from `numpy.generic`). This file produces a convoluted set of dictionaries mapping names to types, and sometimes other mappings too. .. data:: allTypes A dictionary of names to types that...
import operator from contextlib import nullcontext import numpy as np from numpy._utils import set_module from .numeric import dtype, ndarray, uint8 __all__ = ['memmap'] dtypedescr = dtype valid_filemodes = ["r", "c", "r+", "w+"] writeable_filemodes = ["r+", "w+"] mode_equivalents = { "readonly": "r", "cop...
""" Functions in the ``as*array`` family that promote array-likes into arrays. `require` fits this category despite its name not matching this pattern. """ from .multiarray import array, asanyarray from .overrides import ( array_function_dispatch, finalize_array_function_like, set_module, ) __all__ = ["re...
/* These pointers will be stored in the C-object for use in other extension modules */ void *PyUFunc_API[] = { (void *) &PyUFunc_Type, (void *) PyUFunc_FromFuncAndData, (void *) PyUFunc_RegisterLoopForType, NULL, (void *) PyUFunc_f_f_As_d_d, (void *) PyUFunc_d_d, ...
zlib License ------------ Copyright (C) 2010 - 2019 ridiculous_fish, <libdivide@ridiculousfish.com> Copyright (C) 2016 - 2019 Kim Walisch, <kim.walisch@gmail.com> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages aris...
/* These pointers will be stored in the C-object for use in other extension modules */ void *PyArray_API[] = { (void *) PyArray_GetNDArrayCVersion, NULL, (void *) &PyArray_Type, (void *) &PyArrayDescr_Type, NULL, (void *) &PyArrayIter_Type, (void *) &PyArray...
""" 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', ...
""" Create the numpy._core.umath namespace for backward compatibility. In v1.16 the multiarray and umath c-extension modules were merged into a single _multiarray_umath extension module. So we replicate the old namespace by importing from the extension module. """ import numpy from . import _multiarray_umath from ._...
"""Implementation of __array_function__ overrides from NEP-18.""" import collections import functools from numpy._core._multiarray_umath import ( _ArrayFunctionDispatcher, _get_implementing_args, add_docstring, ) from numpy._utils import set_module # noqa: F401 from numpy._utils._inspect import getargspec...
""" Various richly-typed exceptions, that also help us deal with string formatting in python where it's easier. By putting the formatting in `__str__`, we also avoid paying the cost for users who silence the exceptions. """ def _unpack_tuple(tup): if len(tup) == 1: return tup[0] else: return t...
#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>...
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...
import os import subprocess import sys import sysconfig import pytest from numpy.testing import IS_EDITABLE, IS_PYPY, IS_WASM, NOGIL_BUILD # This import is copied from random.tests.test_extending try: import cython from Cython.Compiler.Version import version as cython_version except ImportError: cython =...
""" Tests for the private NumPy argument parsing functionality. They mainly exists to ensure good test coverage without having to try the weirder cases on actual numpy functions but test them in one place. The test function is defined in C to be equivalent to (errors may not always match exactly, and could be adjusted...
""" Test machar. Given recent changes to hardcode type data, we might want to get rid of both MachAr and this test at some point. """ import numpy._core.numerictypes as ntypes from numpy import array, errstate from numpy._core._machar import MachAr class TestMachAr: def _run_machar_highprec(self): # Inst...
import contextlib import itertools import operator import numpy._core._multiarray_tests as mt import pytest import numpy as np from numpy.testing import assert_equal, assert_raises 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 ...
import numpy as np from numpy.testing import ( assert_raises, assert_raises_regex, ) class TestIndexErrors: '''Tests to exercise indexerrors not covered by other tests.''' def test_arraytypes_fasttake(self): 'take from a 0-length dimension' x = np.empty((2, 3, 0, 4)) assert_ra...
""" This file adds basic tests to test the NEP 50 style promotion compatibility mode. Most of these test are likely to be simply deleted again once NEP 50 is adopted in the main test suite. A few may be moved elsewhere. """ import operator import hypothesis import pytest from hypothesis import strategies import nu...
import pytest from numpy._core._simd import targets """ This testing unit only for checking the sanity of common functionality, therefore all we need is just to take one submodule that represents any of enabled SIMD extensions to run the test on it and the second submodule required to run only one check related to th...
""" Tests related to deprecation warnings. Also a convenient place to document how deprecations should eventually be turned into errors. """ import contextlib import warnings import numpy._core._struct_ufunc_tests as struct_ufunc import pytest from numpy._core._multiarray_tests import fromstring_null_term_c_api # no...
import warnings import pytest 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__(sel...
"""Provide class for testing in French locale """ import locale import sys import pytest __ALL__ = ['CommaDecimalPointLocale'] def find_comma_decimal_point_locale(): """See if platform has a decimal point as comma locale. Find a locale that uses a comma instead of a period as the decimal point. R...
import platform import sys import pytest import numpy as np from numpy import ( arange, array, dtype, errstate, geomspace, isnan, linspace, logspace, ndarray, nextafter, sqrt, stack, ) from numpy._core import sctypes from numpy._core.function_base import add_newdoc from...
from numpy._core._multiarray_umath import ( __cpu_baseline__, __cpu_dispatch__, __cpu_features__, ) 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", "...
import asyncio import gc import os import sys import sysconfig import threading import pytest import numpy as np from numpy._core.multiarray import get_handler_name from numpy.testing import IS_EDITABLE, IS_WASM, assert_warns, extbuild @pytest.fixture def get_module(tmp_path): """ Add a memory policy that retur...
""" 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...
""" Test printing of scalar types. """ import platform import pytest import numpy as np from numpy.testing import IS_MUSL, assert_, assert_equal, assert_raises class TestRealScalars: def test_str(self): svals = [0.0, -0.0, 1, -1, np.inf, -np.inf, np.nan] styps = [np.float16, np.float32, np.floa...
import pytest import numpy as np info = np.__array_namespace_info__() def test_capabilities(): caps = info.capabilities() assert caps["boolean indexing"] is True assert caps["data-dependent shapes"] is True # This will be added in the 2024.12 release of the array API standard. # assert caps["m...
import os import sys from ctypes import POINTER, c_double, c_float, c_int, c_longlong, cast, pointer from os import path import pytest from numpy._core._multiarray_umath import __cpu_features__ import numpy as np from numpy.testing import assert_array_max_ulp from numpy.testing._private.utils import _glibc_older_than...
""" Test the scalar constructors, which also do type-coercion """ import fractions import platform import types from typing import Any import pytest import numpy as np from numpy._core import sctypes from numpy.testing import assert_equal, assert_raises class TestAsIntegerRatio: # derived in part from the cpyth...
import pytest from pytest import param import numpy as np from numpy.testing import IS_WASM 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 "ov...
import os import subprocess import sys import sysconfig from datetime import datetime import pytest import numpy as np from numpy.testing import IS_EDITABLE, IS_WASM, assert_array_equal # This import is copied from random.tests.test_extending try: import cython from Cython.Compiler.Version import version as ...
import os import pathlib import platform import re import subprocess import sys import pytest from numpy._core._multiarray_umath import ( __cpu_baseline__, __cpu_dispatch__, __cpu_features__, ) def assert_features_equal(actual, desired, fname): __tracebackhide__ = True # Hide traceback for py.test ...
import concurrent.futures import string import threading import pytest import numpy as np from numpy._core import _rational_tests from numpy.testing import IS_64BIT, IS_WASM from numpy.testing._private.utils import run_threaded if IS_WASM: pytest.skip(allow_module_level=True, reason="no threading support in wasm...
import mmap import os import sys from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryFile import pytest from numpy import ( add, allclose, arange, asarray, average, isscalar, memmap, multiply, ndarray, prod, subtract, sum, ) from numpy.testing imp...
import sys import pytest import numpy as np from numpy.testing import IS_PYPY, assert_array_equal def new_and_old_dlpack(): yield np.arange(5) class OldDLPack(np.ndarray): # Support only the "old" version def __dlpack__(self, stream=None): return super().__dlpack__(stream=None) ...
""" Tests for numpy/_core/src/multiarray/conversion_utils.c """ import re import numpy._core._multiarray_tests as mt import pytest from numpy._core.multiarray import CLIP, RAISE, WRAP from numpy.testing import assert_raises class StringConverterTestCase: allow_bytes = True case_insensitive = True exact_...
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(...
""" Test scalar buffer interface adheres to PEP 3118 """ import pytest from numpy._core._multiarray_tests import get_buffer_info from numpy._core._rational_tests import rational import numpy as np from numpy.testing import assert_, assert_equal, assert_raises # PEP3118 format strings for native (standard alignment an...
import sys from io import StringIO import pytest import numpy as np from numpy._core.tests._locales import CommaDecimalPointLocale from numpy.testing import IS_MUSL, assert_, assert_equal _REF = {np.inf: 'inf', -np.inf: '-inf', np.nan: 'nan'} @pytest.mark.parametrize('tp', [np.float32, np.double, np.longdouble]) d...
import platform import warnings import pytest import numpy as np from numpy._core.tests._locales import CommaDecimalPointLocale from numpy.testing import ( IS_MUSL, assert_, assert_array_equal, assert_equal, assert_raises, temppath, ) LD_INFO = np.finfo(np.longdouble) longdouble_longer_than_d...
from tempfile import NamedTemporaryFile import pytest from numpy._core._multiarray_umath import ( _discover_array_parameters as discover_array_params, ) from numpy._core._multiarray_umath import _get_sfloat_dtype import numpy as np from numpy.testing import assert_array_equal SF = _get_sfloat_dtype() class Tes...
import numbers import numpy as np from numpy._core.numerictypes import sctypes from numpy.testing import assert_ class TestABC: def test_abstract(self): assert_(issubclass(np.number, numbers.Number)) assert_(issubclass(np.inexact, numbers.Complex)) assert_(issubclass(np.complexfloating, ...
""" Test the scalar constructors, which also do type-coercion """ import pytest import numpy as np from numpy.testing import ( assert_almost_equal, assert_equal, assert_warns, ) class TestFromString: def test_floating(self): # Ticket #640, floats from string fsingle = np.single('1.234...