repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
numpy
numpy/_core/tests/test_regression.py
.py
import copy import datetime import gc import os import pickle import sys import tempfile import warnings from io import BytesIO from itertools import chain from os import path import pytest import numpy as np from numpy._utils import asbytes, asunicode from numpy.exceptions import AxisError, ComplexWarning from numpy...
2,673
95,478
numpy
numpy/_core/tests/test_print.py
.py
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...
203
6,888
numpy
numpy/_core/tests/test_simd.py
.py
# NOTE: Please avoid the use of numpy.testing since NPYV intrinsics # may be involved in their functionality. import itertools import math import operator import re import pytest from numpy._core._multiarray_umath import __cpu_baseline__ from numpy._core._simd import clear_floatstatus, get_floatstatus, targets def ...
1,346
48,896
numpy
numpy/_core/tests/test_deprecations.py
.py
""" Tests related to deprecation warnings. Also a convenient place to document how deprecations should eventually be turned into errors. """ import contextlib import re import sys import textwrap import warnings from collections.abc import Callable import pytest import numpy as np from numpy._core._multiarray_tests ...
586
22,251
numpy
numpy/_core/tests/test_finfo.py
.py
import pytest import numpy as np from numpy import exp2, log10 from numpy._core import numerictypes as ntypes class MachArLike: """Minimal class to simulate machine arithmetic parameters.""" def __init__(self, dtype, machep, negep, minexp, maxexp, nmant, iexp): self.dtype = dtype self.machep ...
87
2,488
numpy
numpy/_core/tests/test_function_base.py
.py
import platform import sys import warnings 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...
600
21,774
numpy
numpy/_core/tests/test_scalarmath.py
.py
import contextlib import itertools import operator import platform import sys import warnings import pytest import numpy as np from numpy._core._rational_tests import rational, rational2 from numpy._utils import _pep440 from numpy.exceptions import ComplexWarning from numpy.testing import ( _gen_alignment_data, ...
1,177
46,599
numpy
numpy/_core/tests/test_unicode.py
.py
import numpy as np from numpy.testing import assert_, assert_array_equal, assert_equal def buffer_length(arr): if isinstance(arr, str): if not arr: charmax = 0 else: charmax = max(ord(c) for c in arr) if charmax < 256: size = 1 elif charmax < 65...
370
12,987
numpy
numpy/_core/tests/test_item_selection.py
.py
import sys import pytest import numpy as np from numpy.testing import HAS_REFCOUNT, assert_, assert_array_equal, assert_raises class TestTake: def test_simple(self): a = [[1, 2], [3, 4]] a_str = [[b'1', b'2'], [b'3', b'4']] modes = ['raise', 'wrap', 'clip'] indices = [-1, 4] ...
179
7,102
numpy
numpy/_core/tests/test_scalar_ctors.py
.py
""" Test the scalar constructors, which also do type-coercion """ import pytest import numpy as np from numpy.testing import assert_almost_equal, assert_equal class TestFromString: def test_floating(self): # Ticket #640, floats from string fsingle = np.single('1.234') fdouble = np.double(...
204
6,693
numpy
numpy/_core/tests/test_defchararray.py
.py
import pytest import numpy as np from numpy._core.multiarray import _vec_string from numpy.testing import ( assert_, assert_array_equal, assert_equal, assert_raises, assert_raises_regex, ) kw_unicode_true = {'unicode': True} # make 2to3 work properly kw_unicode_false = {'unicode': False} ignore_...
880
31,161
numpy
numpy/_core/tests/test_scalar_methods.py
.py
""" Test the scalar constructors, which also do type-coercion """ import fractions import inspect import sys import types from typing import Any, Literal import pytest import numpy as np from numpy._core import sctypes from numpy.testing import assert_equal, assert_raises from numpy.testing._private.utils import LONG...
370
14,032
numpy
numpy/_core/tests/test_getlimits.py
.py
""" Test functions for limits module. """ import types import warnings import pytest import numpy as np from numpy import double, half, longdouble, single from numpy._core import finfo, iinfo from numpy._core._rational_tests import rational from numpy.testing import assert_, assert_equal, assert_raises ############...
189
6,130
numpy
numpy/_core/tests/_natype.py
.py
# Vendored implementation of pandas.NA, adapted from pandas/_libs/missing.pyx # # This is vendored to avoid adding pandas as a test dependency. __all__ = ["pd_NA"] import numbers import numpy as np def _create_binary_propagating_op(name, is_divmod=False): is_cmp = name.strip("_") in ["eq", "ne", "le", "lt", "g...
145
4,387
numpy
numpy/_core/tests/test_arrayprint.py
.py
import gc import sys import textwrap import pytest import numpy as np from numpy._core._rational_tests import rational, rational2 from numpy._core.arrayprint import _typelessdata from numpy._utils import _pep440 from numpy.testing import ( HAS_REFCOUNT, IS_WASM, assert_, assert_array_equal, assert...
1,364
52,203
numpy
numpy/_core/tests/test_arraymethod.py
.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. """ import types from typing import Any import pytest import numpy as np from numpy._core._multiarray_umath import _get_castingimpl as get_castingimpl # accessing `numpy...
86
3,315
numpy
numpy/_core/tests/test_array_interface.py
.py
import sys import sysconfig import pytest import numpy as np from numpy.testing import HAS_SUBPROCESSES, IS_EDITABLE, extbuild @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 s...
223
7,891
numpy
numpy/_core/tests/test_umath.py
.py
import fnmatch import inspect import itertools import operator import platform import sys import warnings from collections import namedtuple from fractions import Fraction from functools import reduce import pytest import numpy as np import numpy._core.umath as ncu from numpy._core import _umath_tests as ncu_tests, s...
5,245
201,427
numpy
numpy/_core/tests/test_strings.py
.py
import operator import sys import pytest import numpy as np from numpy._core._exceptions import _UFuncNoLoopError from numpy.testing import assert_array_equal, assert_raises from numpy.testing._private.utils import requires_memory COMPARISONS = [ (operator.eq, np.equal, "=="), (operator.ne, np.not_equal, "!=...
1,541
60,412
numpy
numpy/_core/tests/test_dlpack.py
.py
import sys import pytest import numpy as np from numpy.testing import assert_array_equal def new_and_old_dlpack(): class OldDLPack(np.ndarray): # Support only the "old" version def __dlpack__(self, stream=None): return super().__dlpack__(stream=None) return [np.arange(5), np.ar...
354
11,354
numpy
numpy/_core/tests/test_einsum.py
.py
import itertools import warnings import pytest import numpy as np from numpy.testing import ( assert_, assert_allclose, assert_almost_equal, assert_array_equal, assert_equal, assert_raises, assert_raises_regex, ) # Setup for optimize einsum chars = 'abcdefghij' sizes = np.array([2, 3, 4, ...
1,369
58,232
numpy
numpy/_core/tests/test__exceptions.py
.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 TestArrayMemoryEr...
91
2,922
numpy
numpy/_core/tests/test_mem_policy.py
.py
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 HAS_SUBPROCESSES, IS_EDITABLE, extbuild @pytest.fixture def get_module(tmp_path): """ Add a memory policy that returns a ...
449
16,569
numpy
numpy/_core/tests/test_array_coercion.py
.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...
944
35,940
numpy
numpy/_core/tests/test_argparse.py
.py
""" 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...
91
2,824
numpy
numpy/_core/tests/test_reduction_loop.py
.py
import itertools import pytest import numpy as np from numpy._core._reduction_loop_tests import ( minimummaximum as mm, minimummaximum_with_identity as mmi, ) SHAPES = [(12,), (3, 4), (2, 3, 4)] EMPTY_SHAPES = [(0,), (0, 3), (3, 0), (2, 0, 4)] SPECIALS = { "nan": [np.nan], "inf": [np.inf, -np.inf], ...
432
19,229
numpy
numpy/_core/tests/test_longdouble.py
.py
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...
371
12,454
numpy
numpy/_core/tests/test_conversion_utils.py
.py
""" Tests for numpy/_core/src/multiarray/conversion_utils.c """ import re import pytest import numpy._core._multiarray_tests as mt from numpy._core.multiarray import CLIP, RAISE, WRAP from numpy.testing import assert_raises class StringConverterTestCase: allow_bytes = True case_insensitive = True exact_...
216
6,674
numpy
numpy/_core/tests/test_ufunc.py
.py
import ctypes as ct import inspect import itertools import pickle import sys import warnings import pytest from pytest import param import numpy as np import numpy._core._operand_flag_tests as opflag_tests import numpy._core._rational_tests as _rational_tests import numpy._core._umath_tests as umt import numpy._core....
3,479
142,683
numpy
numpy/_core/tests/test_casting_unittests.py
.py
""" The tests exercise the casting machinery in a more low-level manner. The reason is mostly to test a new implementation of the casting machinery. Unlike most tests in NumPy, these are closer to unit-tests rather than integration tests. """ import ctypes import enum import random import textwrap import warnings im...
971
41,497
numpy
numpy/_core/tests/test_half.py
.py
import platform import pytest import numpy as np from numpy import float16, float32, float64, uint16 from numpy.testing import IS_WASM, assert_, assert_equal def assert_raises_fpe(strmatch, callable, *args, **kwargs): try: callable(*args, **kwargs) except FloatingPointError as exc: assert_(s...
590
25,126
numpy
numpy/_core/tests/test_abc.py
.py
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, ...
55
2,221
numpy
numpy/_core/tests/test_scalarbuffer.py
.py
""" Test scalar buffer interface adheres to PEP 3118 """ import pytest import numpy as np from numpy._core._multiarray_tests import get_buffer_info from numpy._core._rational_tests import rational, rational2 from numpy.testing import assert_, assert_equal, assert_raises # PEP3118 format strings for native (standard a...
155
5,716
numpy
numpy/_core/tests/test_extint128.py
.py
import contextlib import itertools import operator import pytest import numpy as np import numpy._core._multiarray_tests as mt 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 ...
218
5,625
numpy
numpy/_core/tests/test_multiarray.py
.py
import builtins import collections.abc import ctypes import functools import gc import importlib import inspect import io import itertools import mmap import operator import os import pathlib import pickle import re import subprocess import sys import tempfile import textwrap import tracemalloc import warnings import w...
11,936
455,911
numpy
numpy/_core/tests/test_cython.py
.py
import os import shutil import subprocess import sys import sysconfig from datetime import datetime import pytest import numpy as np from numpy.testing import HAS_SUBPROCESSES, IS_EDITABLE, assert_array_equal from numpy.testing._private.utils import run_subprocess # This import is copied from random.tests.test_exten...
377
11,000
numpy
numpy/_core/tests/test_hashtable.py
.py
import random from collections import defaultdict from concurrent.futures import ThreadPoolExecutor import pytest from numpy._core._multiarray_tests import ( create_identity_hash, identity_hash_get_item, identity_hash_set_item_default, ) from numpy.testing import IS_WASM @pytest.mark.parametrize("key_le...
157
5,368
numpy
numpy/_core/tests/test_errstate.py
.py
import sysconfig import pytest import numpy as np from numpy.testing import IS_WASM, assert_raises # 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 cases of gh-...
131
4,556
numpy
numpy/_core/tests/test_simd_module.py
.py
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...
106
3,950
numpy
numpy/_core/tests/test_multithreading.py
.py
import concurrent.futures import inspect import random import subprocess import sys import textwrap import threading import pytest import numpy as np from numpy._core import _rational_tests from numpy._core.tests.test_stringdtype import random_unicode_string_list from numpy.testing import HAS_SUBPROCESSES, IS_64BIT, ...
750
23,250
numpy
numpy/_core/tests/test_records.py
.py
import collections.abc import pickle import textwrap from io import BytesIO from os import path from pathlib import Path import pytest import numpy as np from numpy.testing import ( assert_, assert_array_almost_equal, assert_array_equal, assert_equal, assert_raises, temppath, ) class TestFro...
610
23,432
numpy
numpy/_core/tests/examples/limited_api/setup.py
.py
""" Build an example package using the limited Python C API. """ import os from setuptools import Extension, setup import numpy as np macros = [("NPY_NO_DEPRECATED_API", 0), ("Py_LIMITED_API", "0x03060000")] limited_api = Extension( "limited_api", sources=[os.path.join('.', "limited_api.c")], include_d...
25
437
numpy
numpy/_core/tests/examples/cython/setup.py
.py
""" Provide python-space access to the functions exposed in numpy/__init__.pxd for testing. """ import os import Cython from Cython.Build import cythonize from distutils.core import setup from setuptools.extension import Extension import numpy as np from numpy._utils import _pep440 macros = [ ("NPY_NO_DEPRECATE...
40
859
numpy
numpy/_build_utils/conv_template.py
.py
#!/usr/bin/env python3 """ takes templated file .xxx.src and produces .xxx file where .xxx is .i or .c or .h, using the following template rules /**begin repeat -- on a line by itself marks the start of a repeated code segment /**end repeat**/ -- on a line by itself marks it's end After the /**b...
336
9,506
numpy
numpy/_build_utils/tempita.py
.py
#!/usr/bin/env python3 import argparse import importlib.util import os import sys def import_tempita(): init_py = os.path.join(os.path.dirname(__file__), 'tempita/__init__.py') spec = importlib.util.spec_from_file_location('tempita', init_py) tempita = importlib.util.module_from_spec(spec) sys.modules...
69
1,788
numpy
numpy/_build_utils/process_src_template.py
.py
#!/usr/bin/env python3 import argparse import importlib.util import os def get_processor(): # Convoluted because we can't import from numpy # (numpy is not yet built) conv_template_path = os.path.join( os.path.dirname(__file__), 'conv_template.py' ) spec = importlib.util.spec_from_...
67
1,654
numpy
numpy/_build_utils/gitversion.py
.py
#!/usr/bin/env python3 import os import textwrap def init_version(): init = os.path.join(os.path.dirname(__file__), '../../pyproject.toml') with open(init) as fid: data = fid.readlines() version_line = next( line for line in data if line.startswith('version =') ) version = versio...
103
2,731
numpy
numpy/_build_utils/gcc_build_bitness.py
.py
#!python """ Detect bitness (32 or 64) of Mingw-w64 gcc build target on Windows. """ import re from subprocess import run def main(): res = run(['gcc', '-v'], check=True, text=True, capture_output=True) target = re.search(r'^Target: (.*)$', res.stderr, flags=re.M).groups()[0] if target.startswith('i686')...
22
515
numpy
numpy/_build_utils/tempita/_tempita.py
.py
""" A small templating language This implements a small templating language. This language implements if/elif/else, for/continue/break, expressions, and blocks of Python code. The syntax is:: {{any expression (function calls etc)}} {{any expression | filter}} {{for x in y}}...{{endfor}} {{if x}}x{{elif y}}y...
1,117
36,836
numpy
numpy/_build_utils/tempita/_looper.py
.py
""" Helper for looping over sequences, particular in templates. Often in a loop in a template it's handy to know what's next up, previously up, if this is the first or last item in the sequence, etc. These can be awkward to manage in a normal Python loop, but using the looper you can get a better sense of the context....
155
3,968
numpy
numpy/matrixlib/__init__.py
.py
"""Sub-package containing the matrix class and related functions. """ from . import defmatrix from .defmatrix import * __all__ = defmatrix.__all__ from numpy._pytesttester import PytestTester test = PytestTester(__name__) del PytestTester
13
243
numpy
numpy/matrixlib/defmatrix.py
.py
__all__ = ['matrix', 'bmat', 'asmatrix'] import ast import sys import warnings import numpy._core.numeric as N from numpy._core.numeric import concatenate, isscalar from numpy._utils import set_module # While not in __all__, matrix_power used to be defined here, so we import # it for backward compatibility. from num...
1,118
30,834
numpy
numpy/matrixlib/tests/test_numeric.py
.py
import numpy as np from numpy.testing import assert_equal class TestDot: def test_matscalar(self): b1 = np.matrix(np.ones((3, 3), dtype=complex)) assert_equal(b1 * 1.0, b1) def test_diagonal(): b1 = np.matrix([[1, 2], [3, 4]]) diag_b1 = np.matrix([[1, 4]]) array_b1 = np.array([1, 4])...
19
447
numpy
numpy/matrixlib/tests/test_masked_matrix.py
.py
import pickle import numpy as np from numpy.ma.core import ( MaskedArray, MaskType, add, allequal, divide, getmask, hypot, log, masked, masked_array, masked_values, nomask, ) from numpy.ma.extras import mr_ from numpy.ma.testutils import assert_, assert_array_equal, asse...
241
8,822
numpy
numpy/matrixlib/tests/test_regression.py
.py
import numpy as np from numpy.testing import assert_, assert_equal, assert_raises class TestRegression: def test_kron_matrix(self): # Ticket #71 x = np.matrix('[1 0; 1 0]') assert_equal(type(np.kron(x, x)), type(x)) def test_matrix_properties(self): # Ticket #125 a = n...
32
934
numpy
numpy/matrixlib/tests/test_defmatrix.py
.py
import collections.abc import numpy as np from numpy import asmatrix, bmat, matrix from numpy.linalg import matrix_power from numpy.testing import ( assert_, assert_almost_equal, assert_array_almost_equal, assert_array_equal, assert_equal, assert_raises, ) class TestCtor: def test_basic(s...
476
15,778
numpy
numpy/matrixlib/tests/test_multiarray.py
.py
import numpy as np from numpy.testing import assert_, assert_array_equal, assert_equal class TestView: def test_type(self): x = np.array([1, 2, 3]) assert_(isinstance(x.view(np.matrix), np.matrix)) def test_keywords(self): x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])...
18
555
numpy
numpy/matrixlib/tests/test_interaction.py
.py
"""Tests of interaction of matrix with other parts of numpy. Note that tests with MaskedArray and linalg are done in separate files. """ import textwrap import warnings import pytest import numpy as np from numpy.testing import ( assert_, assert_almost_equal, assert_array_almost_equal, assert_array_e...
361
11,874
numpy
numpy/matrixlib/tests/test_matrix_linalg.py
.py
""" Test functions for linalg module using the matrix class.""" import pytest import numpy as np from numpy.linalg.tests.test_linalg import ( CondCases, DetCases, EigCases, EigvalsCases, InvCases, LinalgCase, LinalgTestCase, LstsqCases, PinvCases, SolveCases, SVDCases, T...
111
2,231
numpy
numpy/ma/mrecords.py
.py
""":mod:`numpy.ma..mrecords` Defines the equivalent of :class:`numpy.recarrays` for masked arrays, where fields can be accessed as attributes. Note that :class:`numpy.ma.MaskedArray` already supports structured datatypes and the masking of individual fields. .. moduleauthor:: Pierre Gerard-Marchant """ # We should ...
740
25,571
numpy
numpy/ma/testutils.py
.py
"""Miscellaneous functions for testing masked arrays and subclasses :author: Pierre Gerard-Marchant :contact: pierregm_at_uga_dot_edu """ import operator import numpy as np import numpy._core.umath as umath import numpy.testing from numpy import ndarray from numpy.testing import ( # noqa: F401 assert_, asse...
295
10,213
numpy
numpy/ma/__init__.py
.py
""" ============= Masked Arrays ============= Arrays sometimes contain invalid or missing data. When doing operations on such arrays, we wish to suppress invalid values, which is the purpose masked arrays fulfill (an example of typical use is given below). For example, examine the following array: >>> x = np.array(...
54
1,406
numpy
numpy/ma/extras.py
.py
""" Masked arrays add-ons. A collection of utilities for `numpy.ma`. :author: Pierre Gerard-Marchant :contact: pierregm_at_uga_dot_edu """ __all__ = [ 'apply_along_axis', 'apply_over_axes', 'atleast_1d', 'atleast_2d', 'atleast_3d', 'average', 'clump_masked', 'clump_unmasked', 'column_stack', 'compress_co...
2,458
74,879
numpy
numpy/ma/core.py
.py
""" numpy.ma : a package to handle missing or invalid values. This package was initially written for numarray by Paul F. Dubois at Lawrence Livermore National Laboratory. In 2006, the package was completely rewritten by Pierre Gerard-Marchant (University of Georgia) to make the MaskedArray class a subclass of ndarray,...
9,025
292,627
numpy
numpy/ma/tests/test_core.py
.py
"""Tests suite for MaskedArray & subclassing. :author: Pierre Gerard-Marchant :contact: pierregm_at_uga_dot_edu """ __author__ = "Pierre GF Gerard-Marchant" import copy import datetime as dt import inspect import itertools import operator import pickle import sys import textwrap import warnings from functools import ...
6,113
228,926
numpy
numpy/ma/tests/test_arrayobject.py
.py
import pytest import numpy as np from numpy.ma import masked_array from numpy.testing import assert_array_equal def test_matrix_transpose_raises_error_for_1d(): msg = "matrix transpose with ndim < 2 is undefined" ma_arr = masked_array(data=[1, 2, 3, 4, 5, 6], mask=[1, 0, 1, 1, 1, 0]...
41
1,099
numpy
numpy/ma/tests/test_old_ma.py
.py
import pickle from functools import reduce import pytest import numpy as np import numpy._core.fromnumeric as fromnumeric import numpy._core.umath as umath from numpy.ma import ( MaskedArray, MaskType, absolute, add, all, allclose, allequal, alltrue, arange, arccos, arcsin,...
940
33,103
numpy
numpy/ma/tests/test_regression.py
.py
import numpy as np from numpy.testing import assert_, assert_array_equal class TestRegression: def test_masked_array_create(self): # Ticket #17 x = np.ma.masked_array([0, 1, 2, 3, 0, 4, 5, 6], mask=[0, 0, 0, 1, 1, 1, 0, 0]) assert_array_equal(np.ma.nonzero(x)...
84
2,719
numpy
numpy/ma/tests/test_deprecations.py
.py
"""Test deprecation and future warnings. """ import pytest import numpy as np from numpy.ma.core import MaskedArrayFutureWarning from numpy.ma.testutils import assert_equal class TestArgsort: """ gh-8701 """ def _test_base(self, argsort, cls): arr_0d = np.array(1).view(cls) argsort(arr_0d) ...
74
2,343
numpy
numpy/ma/tests/test_extras.py
.py
"""Tests suite for MaskedArray. Adapted from the original test_ma by Pierre Gerard-Marchant :author: Pierre Gerard-Marchant :contact: pierregm_at_uga_dot_edu """ import inspect import itertools import pytest import numpy as np from numpy._core.numeric import normalize_axis_tuple from numpy.ma.core import ( Mask...
2,158
84,607
numpy
numpy/ma/tests/test_mrecords.py
.py
"""Tests suite for mrecords. :author: Pierre Gerard-Marchant :contact: pierregm_at_uga_dot_edu """ import pickle import numpy as np import numpy.ma as ma from numpy._core.records import ( fromarrays as recfromarrays, fromrecords as recfromrecords, recarray, ) from numpy.ma import masked, nomask from nump...
514
20,382
numpy
numpy/ma/tests/test_subclassing.py
.py
"""Tests suite for MaskedArray & subclassing. :author: Pierre Gerard-Marchant :contact: pierregm_at_uga_dot_edu """ import numpy as np from numpy.lib.mixins import NDArrayOperatorsMixin from numpy.ma.core import ( MaskedArray, add, arange, array, asanyarray, asarray, divide, hypot, ...
470
16,970
numpy
numpy/f2py/_isofenv.py
.py
""" ISO_FORTRAN_ENV maps for f2py2e """ iso_fortran_env_map: dict[str, dict[str, str]] = { 'integer': { 'int8': 'signed_char', 'int16': 'short', 'int32': 'int', 'int64': 'long_long', }, 'real': { 'real32': 'float', 'real64': 'double', } } isof_kindmap: di...
21
496
numpy
numpy/f2py/_src_pyf.py
.py
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...
248
7,695
numpy
numpy/f2py/f2py2e.py
.py
""" f2py2e - Fortran to Python C/API generator. 2nd Edition. See __usage__ below. 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 EXPRE...
756
27,436
numpy
numpy/f2py/func2subr.py
.py
""" 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. ""...
349
10,627
numpy
numpy/f2py/auxfuncs.py
.py
""" Auxiliary functions 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 (BSD style) LICENSE. NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. """ ...
1,028
27,807
numpy
numpy/f2py/rules.py
.py
""" Rules for building C/API module with f2py2e. Here is a skeleton of a new wrapper function (13Dec2001): wrapper_function(args) declarations get_python_arguments, say, `a' and `b' get_a_from_python if (successful) { get_b_from_python if (successful) { callfortran if (successful) { ...
1,681
64,877
numpy
numpy/f2py/common_rules.py
.py
""" 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...
146
5,101
numpy
numpy/f2py/capi_maps.py
.py
""" 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 . import __version__ f2py_version = __v...
814
29,886
numpy
numpy/f2py/__init__.py
.py
"""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_...
81
2,276
numpy
numpy/f2py/_isocbind.py
.py
""" 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...
63
2,360
numpy
numpy/f2py/cfuncs.py
.py
""" C declarations, CPP macros, and C functions 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 Lice...
1,598
54,481
numpy
numpy/f2py/diagnose.py
.py
#!/usr/bin/env python3 import os import sys import tempfile def run(): _path = os.getcwd() os.chdir(tempfile.gettempdir()) print('------') print(f'os.name={os.name!r}') print('------') print(f'sys.platform={sys.platform!r}') print('------') print('sys.version:') print(sys.version) ...
58
1,303
numpy
numpy/f2py/crackfortran.py
.py
""" crackfortran --- read fortran (77,90) code and extract declaration information. 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 ...
3,728
146,915
numpy
numpy/f2py/symbolic.py
.py
"""Fortran/C symbolic expressions References: - J3/21-007: Draft Fortran 202x. https://j3-fortran.org/doc/year/21/21-007.pdf 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 Nu...
1,519
53,320
numpy
numpy/f2py/f90mod_rules.py
.py
""" Build F90 module support 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. """ __versi...
282
10,060
numpy
numpy/f2py/use_rules.py
.py
""" 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...
101
3,413
numpy
numpy/f2py/cb_rules.py
.py
""" Build call-back 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 ....
650
24,522
numpy
numpy/f2py/tests/test_symbolic.py
.py
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...
502
18,579
numpy
numpy/f2py/tests/test_semicolon_split.py
.py
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 ...
77
1,645
numpy
numpy/f2py/tests/test_return_logical.py
.py
import pytest from numpy import array from . import util @pytest.mark.slow 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 ...
67
2,066
numpy
numpy/f2py/tests/test_modules.py
.py
import textwrap import pytest from . import util @pytest.mark.slow class TestModuleFilterPublicEntities(util.F2PyTest): sources = [ util.getpath( "tests", "src", "modules", "gh26920", "two_mods_with_one_public_routine.f90" ) ] # we filter the only public function ...
104
2,988
numpy
numpy/f2py/tests/test_f2py2e.py
.py
import os import platform import re import shlex import subprocess import sys import textwrap from collections import namedtuple from pathlib import Path import pytest from numpy.f2py.f2py2e import get_newer_options, main as f2pycli from numpy.testing._private.utils import NOGIL_BUILD from . import util ###########...
1,038
29,862
numpy
numpy/f2py/tests/test_return_character.py
.py
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("...
49
1,534
numpy
numpy/f2py/tests/test_character.py
.py
import textwrap import pytest import numpy as np from numpy.f2py.tests import util from numpy.testing import assert_array_equal, assert_equal, assert_raises @pytest.mark.slow class TestCharacterString(util.F2PyTest): # options = ['--debug-capi', '--build-dir', '/tmp/test-build-f2py'] suffix = '.f90' fpr...
645
21,981
numpy
numpy/f2py/tests/test_routines.py
.py
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...
30
795
numpy
numpy/f2py/tests/test_return_integer.py
.py
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 ...
56
1,813
numpy
numpy/f2py/tests/util.py
.py
""" 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...
443
12,124
numpy
numpy/f2py/tests/test_string.py
.py
import pytest import numpy as np from . import util @pytest.mark.slow class TestString(util.F2PyTest): sources = [util.getpath("tests", "src", "string", "char.f90")] def test_char(self): strings = np.array(["ab", "cd", "ef"], dtype="c").T inp, out = self.module.char_test.change_strings( ...
103
2,970