├── numpy ├── tests │ ├── __init__.py │ └── test_numpy_version.py ├── core │ ├── tests │ │ ├── __init__.py │ │ └── data │ │ │ ├── astype_copy.pkl │ │ │ ├── recarray_from_file.fits │ │ │ └── umath-validation-set-README │ ├── code_generators │ │ └── __init__.py │ ├── src │ │ ├── common │ │ │ ├── npy_pycompat.h │ │ │ ├── cblasfuncs.h │ │ │ ├── umathmodule.h │ │ │ ├── ucsnarrow.h │ │ │ ├── npy_longdouble.h │ │ │ ├── npy_fpmath.h │ │ │ └── npy_import.h │ │ ├── multiarray │ │ │ ├── getset.h │ │ │ ├── hashdescr.h │ │ │ ├── sequence.h │ │ │ ├── convert.h │ │ │ ├── nditer_pywrap.h │ │ │ ├── iterators.h │ │ │ ├── buffer.h │ │ │ ├── refcount.h │ │ │ ├── temp_elide.h │ │ │ ├── strfuncs.h │ │ │ ├── vdot.h │ │ │ ├── arrayfunction_override.h │ │ │ ├── usertypes.h │ │ │ ├── typeinfo.h │ │ │ ├── datetime_busday.h │ │ │ ├── multiarraymodule.h │ │ │ ├── alloc.h │ │ │ ├── arraytypes.h │ │ │ ├── compiled_base.h │ │ │ ├── descriptor.h │ │ │ ├── arrayobject.h │ │ │ ├── item_selection.h │ │ │ ├── methods.h │ │ │ ├── scalartypes.h │ │ │ └── shape.h │ │ ├── npymath │ │ │ ├── npy_math_common.h │ │ │ ├── npy_math.c │ │ │ └── _signbit.c │ │ ├── umath │ │ │ ├── cpuid.h │ │ │ ├── override.h │ │ │ ├── matmul.h.src │ │ │ ├── clip.h.src │ │ │ └── extobj.h │ │ └── dummymodule.c │ ├── mlib.ini.in │ ├── include │ │ └── numpy │ │ │ ├── arrayobject.h │ │ │ ├── random │ │ │ └── bitgen.h │ │ │ ├── npy_no_deprecated_api.h │ │ │ ├── utils.h │ │ │ ├── oldnumeric.h │ │ │ └── npy_os.h │ ├── npymath.ini.in │ ├── cversions.py │ └── umath_tests.py ├── f2py │ ├── tests │ │ ├── __init__.py │ │ ├── src │ │ │ ├── assumed_shape │ │ │ │ ├── .f2py_f2cmap │ │ │ │ ├── precision.f90 │ │ │ │ ├── foo_use.f90 │ │ │ │ ├── foo_free.f90 │ │ │ │ └── foo_mod.f90 │ │ │ ├── mixed │ │ │ │ ├── foo.f │ │ │ │ ├── foo_free.f90 │ │ │ │ └── foo_fixed.f90 │ │ │ ├── common │ │ │ │ └── block.f │ │ │ ├── regression │ │ │ │ └── inout.f90 │ │ │ ├── kind │ │ │ │ └── foo.f90 │ │ │ ├── parameter │ │ │ │ ├── constant_compound.f90 │ │ │ │ ├── constant_integer.f90 │ │ │ │ ├── constant_real.f90 │ │ │ │ └── constant_non_compound.f90 │ │ │ ├── string │ │ │ │ └── char.f90 │ │ │ └── size │ │ │ │ └── foo.f90 │ │ ├── test_block_docstring.py │ │ ├── test_string.py │ │ ├── test_regression.py │ │ ├── test_common.py │ │ ├── test_mixed.py │ │ ├── test_assumed_shape.py │ │ ├── test_quoted_character.py │ │ └── test_kind.py │ ├── setup.cfg │ ├── info.py │ ├── __main__.py │ ├── src │ │ └── test │ │ │ ├── foo90.f90 │ │ │ ├── bar.f │ │ │ └── foo.f │ └── __version__.py ├── fft │ ├── tests │ │ └── __init__.py │ ├── __init__.py │ └── setup.py ├── lib │ ├── tests │ │ ├── __init__.py │ │ └── data │ │ │ ├── python3.npy │ │ │ ├── py2-objarr.npy │ │ │ ├── py2-objarr.npz │ │ │ ├── py3-objarr.npy │ │ │ ├── py3-objarr.npz │ │ │ └── win64python2.npy │ └── setup.py ├── ma │ ├── tests │ │ └── __init__.py │ ├── version.py │ └── setup.py ├── compat │ ├── tests │ │ ├── __init__.py │ │ └── test_compat.py │ ├── setup.py │ └── __init__.py ├── distutils │ ├── tests │ │ └── __init__.py │ ├── mingw │ │ └── gfortran_vs2003_hack.c │ ├── __version__.py │ ├── info.py │ ├── compat.py │ ├── setup.py │ ├── command │ │ ├── develop.py │ │ ├── bdist_rpm.py │ │ ├── sdist.py │ │ ├── install_data.py │ │ ├── egg_info.py │ │ └── install_headers.py │ ├── numpy_distribution.py │ ├── pathccompiler.py │ ├── fcompiler │ │ └── none.py │ └── __init__.py ├── linalg │ ├── tests │ │ ├── __init__.py │ │ └── test_deprecations.py │ └── lapack_lite │ │ ├── f2c_config.c.patch │ │ └── wrapped_routines ├── matrixlib │ ├── tests │ │ ├── __init__.py │ │ ├── test_numeric.py │ │ ├── test_multiarray.py │ │ └── test_regression.py │ ├── __init__.py │ └── setup.py ├── random │ ├── tests │ │ ├── __init__.py │ │ └── data │ │ │ └── __init__.py │ ├── info.py │ ├── src │ │ ├── distributions │ │ │ └── logfactorial.h │ │ ├── aligned_malloc │ │ │ └── aligned_malloc.c │ │ ├── splitmix64 │ │ │ ├── LICENSE.md │ │ │ ├── splitmix64.h │ │ │ └── splitmix64.orig.c │ │ ├── entropy │ │ │ └── entropy.h │ │ ├── mt19937 │ │ │ ├── mt19937-jump.h │ │ │ └── mt19937-benchmark.c │ │ ├── pcg64 │ │ │ └── pcg64.orig.c │ │ ├── philox │ │ │ ├── philox.c │ │ │ └── philox-benchmark.c │ │ └── sfc64 │ │ │ └── sfc64.c │ ├── bit_generator.pxd │ ├── examples │ │ └── cython │ │ │ └── setup.py │ └── bounded_integers.pxd.in ├── testing │ ├── tests │ │ └── __init__.py │ ├── _private │ │ └── __init__.py │ ├── noseclasses.py │ ├── decorators.py │ ├── nosetester.py │ ├── __init__.py │ └── setup.py ├── polynomial │ ├── tests │ │ └── __init__.py │ └── setup.py ├── _build_utils │ ├── __init__.py │ ├── README │ └── apple_accelerate.py ├── _distributor_init.py ├── doc │ └── __init__.py └── setup.py ├── .ctags.d ├── doc ├── neps │ ├── .gitignore │ ├── _static │ │ ├── nep-0000.png │ │ ├── nep0013_image1.png │ │ ├── nep0013_image2.png │ │ └── nep0013_image3.png │ ├── nep-0009-structured_array_extensions.rst │ └── Makefile ├── source │ ├── f2py │ │ ├── var_session.dat │ │ ├── spam_session.dat │ │ ├── var.pyf │ │ ├── calculate_session.dat │ │ ├── ftype.f │ │ ├── callback.f │ │ ├── fib2.pyf │ │ ├── compile_session.dat │ │ ├── scalar.f │ │ ├── calculate.f │ │ ├── common.f │ │ ├── extcallback.f │ │ ├── allocarr.f90 │ │ ├── fib1.f │ │ ├── fib1.pyf │ │ ├── array.f │ │ ├── extcallback_session.dat │ │ ├── fib3.f │ │ ├── moddata.f90 │ │ ├── string.f │ │ ├── callback2.pyf │ │ ├── spam.pyf │ │ ├── callback_session.dat │ │ ├── scalar_session.dat │ │ ├── common_session.dat │ │ ├── ftype_session.dat │ │ ├── run_main_session.dat │ │ ├── setup_example.py │ │ ├── string_session.dat │ │ ├── moddata_session.dat │ │ ├── allocarr_session.dat │ │ └── index.rst │ ├── benchmarking.rst │ ├── reference │ │ ├── routines.fft.rst │ │ ├── constants.rst │ │ ├── routines.polynomials.polyutils.rst │ │ ├── figures │ │ │ ├── dtype-hierarchy.dia │ │ │ ├── dtype-hierarchy.pdf │ │ │ ├── dtype-hierarchy.png │ │ │ ├── threefundamental.pdf │ │ │ └── threefundamental.png │ │ ├── random │ │ │ ├── entropy.rst │ │ │ └── bit_generators │ │ │ │ ├── bitgenerators.rst │ │ │ │ ├── sfc64.rst │ │ │ │ ├── mt19937.rst │ │ │ │ ├── philox.rst │ │ │ │ └── pcg64.rst │ │ ├── testing.rst │ │ ├── routines.padding.rst │ │ ├── distutils_guide.rst │ │ ├── internals.rst │ │ ├── swig.rst │ │ ├── routines.functional.rst │ │ ├── routines.window.rst │ │ ├── routines.financial.rst │ │ ├── routines.emath.rst │ │ ├── routines.help.rst │ │ ├── routines.set.rst │ │ ├── maskedarray.rst │ │ ├── routines.err.rst │ │ ├── routines.datetime.rst │ │ ├── routines.ctypeslib.rst │ │ ├── routines.polynomials.package.rst │ │ ├── routines.bitwise.rst │ │ ├── routines.polynomials.poly1d.rst │ │ ├── routines.sort.rst │ │ ├── routines.dual.rst │ │ ├── routines.matlib.rst │ │ ├── index.rst │ │ ├── routines.statistics.rst │ │ ├── routines.dtype.rst │ │ ├── routines.other.rst │ │ ├── routines.logic.rst │ │ └── routines.polynomials.rst │ ├── dev │ │ ├── pull_button.png │ │ ├── gitwash │ │ │ ├── forking_button.png │ │ │ ├── git_intro.rst │ │ │ ├── dot2_dot3.rst │ │ │ ├── index.rst │ │ │ └── following_latest.rst │ │ ├── governance │ │ │ ├── index.rst │ │ │ └── people.rst │ │ ├── gitwash_links.txt │ │ ├── style_guide.rst │ │ └── releasing.rst │ ├── user │ │ ├── misc.rst │ │ ├── theory.broadcast_1.gif │ │ ├── theory.broadcast_2.gif │ │ ├── theory.broadcast_3.gif │ │ ├── theory.broadcast_4.gif │ │ ├── theory.broadcast_5.png │ │ ├── basics.byteswapping.rst │ │ ├── basics.io.rst │ │ ├── setting-up.rst │ │ ├── basics.types.rst │ │ ├── basics.subclassing.rst │ │ ├── basics.dispatch.rst │ │ ├── c-info.rst │ │ ├── basics.creation.rst │ │ ├── basics.indexing.rst │ │ ├── basics.broadcasting.rst │ │ ├── basics.rec.rst │ │ ├── basics.rst │ │ ├── install.rst │ │ └── index.rst │ ├── glossary.rst │ ├── _static │ │ └── .gitignore │ ├── _templates │ │ ├── autosummary │ │ │ ├── minimal_module.rst │ │ │ ├── method.rst │ │ │ ├── attribute.rst │ │ │ ├── member.rst │ │ │ └── class.rst │ │ ├── indexsidebar.html │ │ ├── layout.html │ │ └── searchbox.html │ ├── docs │ │ └── index.rst │ ├── contents.rst │ └── bugs.rst ├── cdoc │ ├── Makefile │ └── README ├── newdtype_example │ ├── floatint │ │ └── __init__.py │ ├── setup.py │ └── example.py ├── HOWTO_DOCUMENT.rst.txt ├── release │ ├── 1.10.3-notes.rst │ ├── template.rst │ ├── 1.18.0-notes.rst │ ├── 1.6.1-notes.rst │ ├── 1.8.2-notes.rst │ ├── 1.11.3-notes.rst │ ├── 1.14.5-notes.rst │ └── 1.7.1-notes.rst └── changelog │ ├── 1.14.5-changelog.rst │ ├── 1.14.6-changelog.rst │ ├── 1.15.4-changelog.rst │ ├── 1.15.2-changelog.rst │ ├── 1.14.2-changelog.rst │ └── 1.16.2-changelog.rst ├── .github ├── FUNDING.yml ├── CODE_OF_CONDUCT.md ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE.md ├── .coveragerc ├── changelog ├── 14036.expired.rst ├── 14039.expired.rst ├── 14181.deprecation.rst ├── 14100.expired.rst ├── 13899.changes.rst └── template.rst ├── benchmarks └── benchmarks │ ├── __init__.py │ └── bench_import.py ├── tools ├── ci │ └── appveyor │ │ └── requirements.txt ├── allocation_tracking │ ├── sorttable.js │ ├── setup.py │ └── README.md ├── c_coverage │ └── c_coverage_collect.sh ├── travis-upload-wheel.sh ├── swig │ ├── test │ │ ├── Fortran.h │ │ ├── Fortran.cxx │ │ ├── Flat.i │ │ ├── Makefile │ │ ├── Fortran.i │ │ ├── Array1.h │ │ └── Farray.h │ └── Makefile ├── travis-before-install.sh ├── commitstats.py └── npy_tempita │ └── license.txt ├── .gitattributes ├── .gitmodules ├── .codecov.yml ├── .lgtm.yml ├── LICENSES_bundled.txt └── pytest.ini /numpy/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/core/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/f2py/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/fft/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/lib/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/ma/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ctags.d: -------------------------------------------------------------------------------- 1 | --langmaps=c:+.src 2 | -------------------------------------------------------------------------------- /doc/neps/.gitignore: -------------------------------------------------------------------------------- 1 | index.rst 2 | -------------------------------------------------------------------------------- /numpy/compat/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/distutils/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/linalg/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/matrixlib/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/random/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/testing/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/polynomial/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/random/tests/data/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/testing/_private/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc/source/f2py/var_session.dat: -------------------------------------------------------------------------------- 1 | >>> import var 2 | >>> var.BAR 3 | 5 -------------------------------------------------------------------------------- /doc/source/benchmarking.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../benchmarks/README.rst 2 | -------------------------------------------------------------------------------- /numpy/f2py/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_rpm] 2 | doc_files = docs/ 3 | tests/ -------------------------------------------------------------------------------- /numpy/f2py/tests/src/assumed_shape/.f2py_f2cmap: -------------------------------------------------------------------------------- 1 | dict(real=dict(rk="double")) 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | tidelift: pypi/numpy 2 | custom: https://www.numpy.org/#support-numpy 3 | -------------------------------------------------------------------------------- /doc/cdoc/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | doxygen 5 | 6 | .PHONY: all build 7 | 8 | -------------------------------------------------------------------------------- /doc/source/reference/routines.fft.rst: -------------------------------------------------------------------------------- 1 | .. _routines.fft: 2 | .. automodule:: numpy.fft 3 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = True 3 | include = */numpy/* 4 | disable_warnings = include-ignored 5 | -------------------------------------------------------------------------------- /changelog/14036.expired.rst: -------------------------------------------------------------------------------- 1 | * PyArray_As1D, PyArray_As2D have been removed in favor of PyArray_AsCArray -------------------------------------------------------------------------------- /numpy/_build_utils/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | -------------------------------------------------------------------------------- /numpy/core/code_generators/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | -------------------------------------------------------------------------------- /doc/newdtype_example/floatint/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | -------------------------------------------------------------------------------- /doc/neps/_static/nep-0000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/neps/_static/nep-0000.png -------------------------------------------------------------------------------- /doc/source/dev/pull_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/dev/pull_button.png -------------------------------------------------------------------------------- /doc/source/user/misc.rst: -------------------------------------------------------------------------------- 1 | ************* 2 | Miscellaneous 3 | ************* 4 | 5 | .. automodule:: numpy.doc.misc 6 | -------------------------------------------------------------------------------- /doc/source/reference/constants.rst: -------------------------------------------------------------------------------- 1 | ********* 2 | Constants 3 | ********* 4 | 5 | .. automodule:: numpy.doc.constants 6 | -------------------------------------------------------------------------------- /numpy/lib/tests/data/python3.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/numpy/lib/tests/data/python3.npy -------------------------------------------------------------------------------- /doc/neps/_static/nep0013_image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/neps/_static/nep0013_image1.png -------------------------------------------------------------------------------- /doc/neps/_static/nep0013_image2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/neps/_static/nep0013_image2.png -------------------------------------------------------------------------------- /doc/neps/_static/nep0013_image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/neps/_static/nep0013_image3.png -------------------------------------------------------------------------------- /doc/source/glossary.rst: -------------------------------------------------------------------------------- 1 | ******** 2 | Glossary 3 | ******** 4 | 5 | .. toctree:: 6 | 7 | .. automodule:: numpy.doc.glossary 8 | -------------------------------------------------------------------------------- /numpy/lib/tests/data/py2-objarr.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/numpy/lib/tests/data/py2-objarr.npy -------------------------------------------------------------------------------- /numpy/lib/tests/data/py2-objarr.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/numpy/lib/tests/data/py2-objarr.npz -------------------------------------------------------------------------------- /numpy/lib/tests/data/py3-objarr.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/numpy/lib/tests/data/py3-objarr.npy -------------------------------------------------------------------------------- /numpy/lib/tests/data/py3-objarr.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/numpy/lib/tests/data/py3-objarr.npz -------------------------------------------------------------------------------- /benchmarks/benchmarks/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | 3 | from . import common 4 | -------------------------------------------------------------------------------- /numpy/core/tests/data/astype_copy.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/numpy/core/tests/data/astype_copy.pkl -------------------------------------------------------------------------------- /numpy/lib/tests/data/win64python2.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/numpy/lib/tests/data/win64python2.npy -------------------------------------------------------------------------------- /tools/ci/appveyor/requirements.txt: -------------------------------------------------------------------------------- 1 | cython 2 | nose 3 | pytest-timeout 4 | pytest-xdist 5 | pytest-env 6 | pytest-faulthandler 7 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | NumPy has a Code of Conduct, please see: https://www.numpy.org/devdocs/dev/conduct/code_of_conduct.html 2 | -------------------------------------------------------------------------------- /doc/source/reference/routines.polynomials.polyutils.rst: -------------------------------------------------------------------------------- 1 | Polyutils 2 | ========= 3 | 4 | .. automodule:: numpy.polynomial.polyutils 5 | -------------------------------------------------------------------------------- /doc/source/user/theory.broadcast_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/user/theory.broadcast_1.gif -------------------------------------------------------------------------------- /doc/source/user/theory.broadcast_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/user/theory.broadcast_2.gif -------------------------------------------------------------------------------- /doc/source/user/theory.broadcast_3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/user/theory.broadcast_3.gif -------------------------------------------------------------------------------- /doc/source/user/theory.broadcast_4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/user/theory.broadcast_4.gif -------------------------------------------------------------------------------- /doc/source/user/theory.broadcast_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/user/theory.broadcast_5.png -------------------------------------------------------------------------------- /numpy/f2py/tests/src/mixed/foo.f: -------------------------------------------------------------------------------- 1 | subroutine bar11(a) 2 | cf2py intent(out) a 3 | integer a 4 | a = 11 5 | end 6 | -------------------------------------------------------------------------------- /tools/allocation_tracking/sorttable.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/tools/allocation_tracking/sorttable.js -------------------------------------------------------------------------------- /changelog/14039.expired.rst: -------------------------------------------------------------------------------- 1 | * ``np.rank`` has been removed. This was deprecated in NumPy 1.10 2 | and has been replaced by ``np.ndim``. 3 | -------------------------------------------------------------------------------- /doc/HOWTO_DOCUMENT.rst.txt: -------------------------------------------------------------------------------- 1 | This document has been replaced, see https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard 2 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/forking_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/dev/gitwash/forking_button.png -------------------------------------------------------------------------------- /doc/source/user/basics.byteswapping.rst: -------------------------------------------------------------------------------- 1 | ************* 2 | Byte-swapping 3 | ************* 4 | 5 | .. automodule:: numpy.doc.byteswapping 6 | -------------------------------------------------------------------------------- /numpy/core/tests/data/recarray_from_file.fits: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/numpy/core/tests/data/recarray_from_file.fits -------------------------------------------------------------------------------- /numpy/distutils/mingw/gfortran_vs2003_hack.c: -------------------------------------------------------------------------------- 1 | int _get_output_format(void) 2 | { 3 | return 0; 4 | } 5 | 6 | int _imp____lc_codepage = 0; 7 | -------------------------------------------------------------------------------- /numpy/random/info.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | from .. import __doc__ 4 | 5 | depends = ['core'] 6 | -------------------------------------------------------------------------------- /doc/source/_static/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is here to avoid a sphinx warning about a missing _static folder. 2 | # Empty folders are not allowed into git. 3 | -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/reference/figures/dtype-hierarchy.dia -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/reference/figures/dtype-hierarchy.pdf -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/reference/figures/dtype-hierarchy.png -------------------------------------------------------------------------------- /doc/source/reference/figures/threefundamental.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/reference/figures/threefundamental.pdf -------------------------------------------------------------------------------- /doc/source/reference/figures/threefundamental.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/batterseapower/numpy/master/doc/source/reference/figures/threefundamental.png -------------------------------------------------------------------------------- /tools/c_coverage/c_coverage_collect.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | valgrind --tool=callgrind --compress-strings=no --compress-pos=no --collect-jumps=yes "$@" 3 | -------------------------------------------------------------------------------- /doc/source/reference/random/entropy.rst: -------------------------------------------------------------------------------- 1 | System Entropy 2 | ============== 3 | 4 | .. module:: numpy.random.entropy 5 | 6 | .. autofunction:: random_entropy 7 | -------------------------------------------------------------------------------- /doc/source/user/basics.io.rst: -------------------------------------------------------------------------------- 1 | ************** 2 | I/O with NumPy 3 | ************** 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | 8 | basics.io.genfromtxt 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Numerical data files 2 | numpy/lib/tests/data/*.npy binary 3 | 4 | # Release notes, reduce number of conflicts. 5 | doc/release/*.rst merge=union 6 | -------------------------------------------------------------------------------- /changelog/14181.deprecation.rst: -------------------------------------------------------------------------------- 1 | Deprecate `np.alen` 2 | --------------------------------------------------------------- 3 | `np.alen` was deprecated. Use `len` instead. -------------------------------------------------------------------------------- /doc/source/user/setting-up.rst: -------------------------------------------------------------------------------- 1 | ********** 2 | Setting up 3 | ********** 4 | 5 | .. toctree:: 6 | :maxdepth: 1 7 | 8 | whatisnumpy 9 | install 10 | -------------------------------------------------------------------------------- /doc/source/f2py/spam_session.dat: -------------------------------------------------------------------------------- 1 | >>> import spam 2 | >>> status = spam.system('whoami') 3 | pearu 4 | >> status = spam.system('blah') 5 | sh: line 1: blah: command not found -------------------------------------------------------------------------------- /numpy/core/src/common/npy_pycompat.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PYCOMPAT_H_ 2 | #define _NPY_PYCOMPAT_H_ 3 | 4 | #include "numpy/npy_3kcompat.h" 5 | 6 | #endif /* _NPY_COMPAT_H_ */ 7 | -------------------------------------------------------------------------------- /doc/source/reference/testing.rst: -------------------------------------------------------------------------------- 1 | .. _testing-guidelines: 2 | 3 | Testing Guidelines 4 | ================== 5 | 6 | .. include:: ../../TESTS.rst.txt 7 | :start-line: 6 8 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/getset.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_GETSET_H_ 2 | #define _NPY_ARRAY_GETSET_H_ 3 | 4 | extern NPY_NO_EXPORT PyGetSetDef array_getsetlist[]; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /numpy/f2py/info.py: -------------------------------------------------------------------------------- 1 | """Fortran to Python Interface Generator. 2 | 3 | """ 4 | from __future__ import division, absolute_import, print_function 5 | 6 | postpone_import = True 7 | -------------------------------------------------------------------------------- /changelog/14100.expired.rst: -------------------------------------------------------------------------------- 1 | * PyArray_FromDimsAndDataAndDescr has been removed, use PyArray_NewFromDescr instead 2 | * PyArray_FromDims has been removed, use PyArray_SimpleNew instead -------------------------------------------------------------------------------- /doc/source/user/basics.types.rst: -------------------------------------------------------------------------------- 1 | ********** 2 | Data types 3 | ********** 4 | 5 | .. seealso:: :ref:`Data type objects ` 6 | 7 | .. automodule:: numpy.doc.basics 8 | -------------------------------------------------------------------------------- /numpy/f2py/__main__.py: -------------------------------------------------------------------------------- 1 | # See http://cens.ioc.ee/projects/f2py2e/ 2 | from __future__ import division, print_function 3 | 4 | from numpy.f2py.f2py2e import main 5 | 6 | main() 7 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/hashdescr.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_HASHDESCR_H_ 2 | #define _NPY_HASHDESCR_H_ 3 | 4 | NPY_NO_EXPORT npy_hash_t 5 | PyArray_DescrHash(PyObject* odescr); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /doc/source/reference/routines.padding.rst: -------------------------------------------------------------------------------- 1 | Padding Arrays 2 | ============== 3 | 4 | .. currentmodule:: numpy 5 | 6 | .. autosummary:: 7 | :toctree: generated/ 8 | 9 | pad 10 | -------------------------------------------------------------------------------- /doc/source/user/basics.subclassing.rst: -------------------------------------------------------------------------------- 1 | .. _basics.subclassing: 2 | 3 | ******************* 4 | Subclassing ndarray 5 | ******************* 6 | 7 | .. automodule:: numpy.doc.subclassing 8 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/sequence.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_SEQUENCE_H_ 2 | #define _NPY_ARRAY_SEQUENCE_H_ 3 | 4 | extern NPY_NO_EXPORT PySequenceMethods array_as_sequence; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /doc/source/_templates/autosummary/minimal_module.rst: -------------------------------------------------------------------------------- 1 | {{ fullname | escape | underline}} 2 | 3 | .. automodule:: {{ fullname }} 4 | 5 | {% block docstring %} 6 | {% endblock %} 7 | 8 | 9 | -------------------------------------------------------------------------------- /doc/source/_templates/indexsidebar.html: -------------------------------------------------------------------------------- 1 |

Resources

2 | 5 | -------------------------------------------------------------------------------- /doc/source/dev/governance/index.rst: -------------------------------------------------------------------------------- 1 | ##################### 2 | NumPy governance 3 | ##################### 4 | 5 | .. toctree:: 6 | :maxdepth: 3 7 | 8 | governance 9 | people 10 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/assumed_shape/precision.f90: -------------------------------------------------------------------------------- 1 | module precision 2 | integer, parameter :: rk = selected_real_kind(8) 3 | integer, parameter :: ik = selected_real_kind(4) 4 | end module 5 | -------------------------------------------------------------------------------- /doc/release/1.10.3-notes.rst: -------------------------------------------------------------------------------- 1 | ========================== 2 | NumPy 1.10.3 Release Notes 3 | ========================== 4 | 5 | N/A this release did not happen due to various screwups involving PyPi. 6 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash_links.txt: -------------------------------------------------------------------------------- 1 | .. _NumPy: https://www.numpy.org 2 | .. _`NumPy github`: https://github.com/numpy/numpy 3 | .. _`NumPy mailing list`: https://scipy.org/scipylib/mailing-lists.html 4 | -------------------------------------------------------------------------------- /doc/source/dev/style_guide.rst: -------------------------------------------------------------------------------- 1 | .. _style_guide: 2 | 3 | =================== 4 | NumPy C Style Guide 5 | =================== 6 | 7 | .. include:: ../../C_STYLE_GUIDE.rst.txt 8 | :start-line: 4 9 | -------------------------------------------------------------------------------- /numpy/random/src/distributions/logfactorial.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LOGFACTORIAL_H 3 | #define LOGFACTORIAL_H 4 | 5 | #include 6 | 7 | double logfactorial(int64_t k); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /numpy/distutils/__version__.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | major = 0 4 | minor = 4 5 | micro = 0 6 | version = '%(major)d.%(minor)d.%(micro)d' % (locals()) 7 | -------------------------------------------------------------------------------- /numpy/distutils/info.py: -------------------------------------------------------------------------------- 1 | """ 2 | Enhanced distutils with Fortran compilers support and more. 3 | """ 4 | from __future__ import division, absolute_import, print_function 5 | 6 | postpone_import = True 7 | -------------------------------------------------------------------------------- /doc/source/reference/distutils_guide.rst: -------------------------------------------------------------------------------- 1 | .. _distutils-user-guide: 2 | 3 | NumPy Distutils - Users Guide 4 | ============================= 5 | 6 | .. include:: ../../DISTUTILS.rst.txt 7 | :start-line: 6 8 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/mixed/foo_free.f90: -------------------------------------------------------------------------------- 1 | module foo_free 2 | contains 3 | subroutine bar13(a) 4 | !f2py intent(out) a 5 | integer a 6 | a = 13 7 | end subroutine bar13 8 | end module foo_free 9 | -------------------------------------------------------------------------------- /doc/source/_templates/autosummary/method.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | {{ fullname | escape | underline}} 4 | 5 | .. currentmodule:: {{ module }} 6 | 7 | method 8 | 9 | .. auto{{ objtype }}:: {{ objname }} 10 | 11 | -------------------------------------------------------------------------------- /doc/source/docs/index.rst: -------------------------------------------------------------------------------- 1 | .. _documentation: 2 | 3 | NumPy's Documentation 4 | ===================== 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | howto_document 10 | howto_build_docs 11 | 12 | -------------------------------------------------------------------------------- /doc/source/user/basics.dispatch.rst: -------------------------------------------------------------------------------- 1 | .. _basics.dispatch: 2 | 3 | ******************************* 4 | Writing custom array containers 5 | ******************************* 6 | 7 | .. automodule:: numpy.doc.dispatch 8 | 9 | -------------------------------------------------------------------------------- /doc/source/_templates/autosummary/attribute.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | {{ fullname | escape | underline}} 4 | 5 | .. currentmodule:: {{ module }} 6 | 7 | attribute 8 | 9 | .. auto{{ objtype }}:: {{ objname }} 10 | 11 | -------------------------------------------------------------------------------- /doc/source/_templates/autosummary/member.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | {{ fullname | escape | underline}} 4 | 5 | .. currentmodule:: {{ module }} 6 | 7 | member 8 | 9 | .. auto{{ objtype }}:: {{ objname }} 10 | 11 | 12 | -------------------------------------------------------------------------------- /numpy/core/src/common/cblasfuncs.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_CBLASFUNCS_H_ 2 | #define _NPY_CBLASFUNCS_H_ 3 | 4 | NPY_NO_EXPORT PyObject * 5 | cblas_matrixproduct(int, PyArrayObject *, PyArrayObject *, PyArrayObject *); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /doc/source/reference/internals.rst: -------------------------------------------------------------------------------- 1 | *************** 2 | NumPy internals 3 | *************** 4 | 5 | .. toctree:: 6 | 7 | internals.code-explanations 8 | alignment 9 | 10 | .. automodule:: numpy.doc.internals 11 | -------------------------------------------------------------------------------- /doc/source/reference/swig.rst: -------------------------------------------------------------------------------- 1 | ************** 2 | NumPy and SWIG 3 | ************** 4 | 5 | .. sectionauthor:: Bill Spotz 6 | 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | swig.interface-file 12 | swig.testing 13 | -------------------------------------------------------------------------------- /doc/source/user/c-info.rst: -------------------------------------------------------------------------------- 1 | ################# 2 | Using NumPy C-API 3 | ################# 4 | 5 | .. toctree:: 6 | 7 | c-info.how-to-extend 8 | c-info.python-as-glue 9 | c-info.ufunc-tutorial 10 | c-info.beyond-basics 11 | -------------------------------------------------------------------------------- /numpy/f2py/src/test/foo90.f90: -------------------------------------------------------------------------------- 1 | subroutine foo() 2 | integer a 3 | real*8 b,c(3) 4 | common /foodata/ a,b,c 5 | print*, " F: in foo" 6 | a = 5 7 | b = 6.3 8 | c(2) = 9.1 9 | end subroutine foo 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "doc/scipy-sphinx-theme"] 2 | path = doc/scipy-sphinx-theme 3 | url = https://github.com/scipy/scipy-sphinx-theme.git 4 | [submodule "doc/sphinxext"] 5 | path = doc/sphinxext 6 | url = https://github.com/numpy/numpydoc.git 7 | -------------------------------------------------------------------------------- /numpy/core/mlib.ini.in: -------------------------------------------------------------------------------- 1 | [meta] 2 | Name = mlib 3 | Description = Math library used with this version of numpy 4 | Version = 1.0 5 | 6 | [default] 7 | Libs=@posix_mathlib@ 8 | Cflags= 9 | 10 | [msvc] 11 | Libs=@msvc_mathlib@ 12 | Cflags= 13 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/convert.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAYOBJECT_CONVERT_H_ 2 | #define _NPY_ARRAYOBJECT_CONVERT_H_ 3 | 4 | NPY_NO_EXPORT int 5 | PyArray_AssignZero(PyArrayObject *dst, 6 | PyArrayObject *wheremask); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/mixed/foo_fixed.f90: -------------------------------------------------------------------------------- 1 | module foo_fixed 2 | contains 3 | subroutine bar12(a) 4 | !f2py intent(out) a 5 | integer a 6 | a = 12 7 | end subroutine bar12 8 | end module foo_fixed 9 | -------------------------------------------------------------------------------- /doc/source/user/basics.creation.rst: -------------------------------------------------------------------------------- 1 | .. _arrays.creation: 2 | 3 | ************** 4 | Array creation 5 | ************** 6 | 7 | .. seealso:: :ref:`Array creation routines ` 8 | 9 | .. automodule:: numpy.doc.creation 10 | -------------------------------------------------------------------------------- /numpy/core/include/numpy/arrayobject.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_ARRAYOBJECT_H 2 | #define Py_ARRAYOBJECT_H 3 | 4 | #include "ndarrayobject.h" 5 | #include "npy_interrupt.h" 6 | 7 | #ifdef NPY_NO_PREFIX 8 | #include "noprefix.h" 9 | #endif 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /doc/source/reference/random/bit_generators/bitgenerators.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | BitGenerator 4 | ------------ 5 | 6 | .. currentmodule:: numpy.random.bit_generator 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | BitGenerator 12 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/nditer_pywrap.h: -------------------------------------------------------------------------------- 1 | #ifndef __NDITER_PYWRAP_H 2 | #define __NDITER_PYWRAP_H 3 | 4 | NPY_NO_EXPORT PyObject * 5 | NpyIter_NestedIters(PyObject *NPY_UNUSED(self), 6 | PyObject *args, PyObject *kwds); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /numpy/core/src/npymath/npy_math_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Common headers needed by every npy math compilation unit 3 | */ 4 | #include 5 | #include 6 | #include 7 | 8 | #include "npy_config.h" 9 | #include "numpy/npy_math.h" 10 | -------------------------------------------------------------------------------- /numpy/core/src/umath/cpuid.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE__CPUID_H_ 2 | #define _NPY_PRIVATE__CPUID_H_ 3 | 4 | #include /* for NPY_NO_EXPORT */ 5 | 6 | NPY_NO_EXPORT int 7 | npy_cpu_supports(const char * feature); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/git_intro.rst: -------------------------------------------------------------------------------- 1 | Install git 2 | =========== 3 | 4 | Developing with git can be done entirely without github. Git is a distributed 5 | version control system. In order to use git on your machine you must `install 6 | it`_. 7 | 8 | .. include:: git_links.inc 9 | -------------------------------------------------------------------------------- /doc/source/f2py/var.pyf: -------------------------------------------------------------------------------- 1 | ! -*- f90 -*- 2 | python module var 3 | usercode ''' 4 | int BAR = 5; 5 | ''' 6 | interface 7 | usercode ''' 8 | PyDict_SetItemString(d,"BAR",PyInt_FromLong(BAR)); 9 | ''' 10 | end interface 11 | end python module 12 | -------------------------------------------------------------------------------- /doc/source/user/basics.indexing.rst: -------------------------------------------------------------------------------- 1 | .. _basics.indexing: 2 | 3 | ******** 4 | Indexing 5 | ******** 6 | 7 | .. seealso:: 8 | 9 | :ref:`Indexing ` 10 | 11 | :ref:`Indexing routines ` 12 | 13 | .. automodule:: numpy.doc.indexing 14 | -------------------------------------------------------------------------------- /doc/source/f2py/calculate_session.dat: -------------------------------------------------------------------------------- 1 | >>> import foo 2 | >>> foo.calculate(range(5), lambda x: x*x) 3 | array([ 0., 1., 4., 9., 16.]) 4 | >>> import math 5 | >>> foo.calculate(range(5), math.exp) 6 | array([ 1. , 2.71828175, 7.38905621, 20.08553696, 54.59814835]) 7 | -------------------------------------------------------------------------------- /numpy/distutils/compat.py: -------------------------------------------------------------------------------- 1 | """Small modules to cope with python 2 vs 3 incompatibilities inside 2 | numpy.distutils 3 | 4 | """ 5 | from __future__ import division, absolute_import, print_function 6 | 7 | import sys 8 | 9 | def get_exception(): 10 | return sys.exc_info()[1] 11 | -------------------------------------------------------------------------------- /doc/source/f2py/ftype.f: -------------------------------------------------------------------------------- 1 | C FILE: FTYPE.F 2 | SUBROUTINE FOO(N) 3 | INTEGER N 4 | Cf2py integer optional,intent(in) :: n = 13 5 | REAL A,X 6 | COMMON /DATA/ A,X(3) 7 | PRINT*, "IN FOO: N=",N," A=",A," X=[",X(1),X(2),X(3),"]" 8 | END 9 | C END OF FTYPE.F 10 | -------------------------------------------------------------------------------- /doc/source/f2py/callback.f: -------------------------------------------------------------------------------- 1 | C FILE: CALLBACK.F 2 | SUBROUTINE FOO(FUN,R) 3 | EXTERNAL FUN 4 | INTEGER I 5 | REAL*8 R 6 | Cf2py intent(out) r 7 | R = 0D0 8 | DO I=-5,5 9 | R = R + FUN(I) 10 | ENDDO 11 | END 12 | C END OF FILE CALLBACK.F 13 | -------------------------------------------------------------------------------- /doc/source/reference/routines.functional.rst: -------------------------------------------------------------------------------- 1 | Functional programming 2 | ********************** 3 | 4 | .. currentmodule:: numpy 5 | 6 | .. autosummary:: 7 | :toctree: generated/ 8 | 9 | apply_along_axis 10 | apply_over_axes 11 | vectorize 12 | frompyfunc 13 | piecewise 14 | -------------------------------------------------------------------------------- /numpy/f2py/src/test/bar.f: -------------------------------------------------------------------------------- 1 | subroutine bar() 2 | integer a 3 | real*8 b,c(3) 4 | common /foodata/ a,b,c 5 | a = 4 6 | b = 6.7 7 | c(2) = 3.0 8 | write(*,*) "bar:a=",a 9 | write(*,*) "bar:b=",b 10 | write(*,*) "bar:c=",c 11 | end 12 | -------------------------------------------------------------------------------- /numpy/f2py/src/test/foo.f: -------------------------------------------------------------------------------- 1 | subroutine bar() 2 | integer a 3 | real*8 b,c(3) 4 | common /foodata/ a,b,c 5 | a = 4 6 | b = 6.7 7 | c(2) = 3.0 8 | write(*,*) "bar:a=",a 9 | write(*,*) "bar:b=",b 10 | write(*,*) "bar:c=",c 11 | end 12 | -------------------------------------------------------------------------------- /doc/source/contents.rst: -------------------------------------------------------------------------------- 1 | ##################### 2 | NumPy manual contents 3 | ##################### 4 | 5 | .. toctree:: 6 | 7 | user/index 8 | reference/index 9 | f2py/index 10 | dev/index 11 | docs/index 12 | release 13 | about 14 | bugs 15 | license 16 | glossary 17 | -------------------------------------------------------------------------------- /doc/source/f2py/fib2.pyf: -------------------------------------------------------------------------------- 1 | ! -*- f90 -*- 2 | python module fib2 3 | interface 4 | subroutine fib(a,n) 5 | real*8 dimension(n),intent(out),depend(n) :: a 6 | integer intent(in) :: n 7 | end subroutine fib 8 | end interface 9 | end python module fib2 10 | -------------------------------------------------------------------------------- /doc/source/reference/routines.window.rst: -------------------------------------------------------------------------------- 1 | Window functions 2 | ================ 3 | 4 | .. currentmodule:: numpy 5 | 6 | Various windows 7 | --------------- 8 | 9 | .. autosummary:: 10 | :toctree: generated/ 11 | 12 | bartlett 13 | blackman 14 | hamming 15 | hanning 16 | kaiser 17 | -------------------------------------------------------------------------------- /doc/source/user/basics.broadcasting.rst: -------------------------------------------------------------------------------- 1 | ************ 2 | Broadcasting 3 | ************ 4 | 5 | .. seealso:: 6 | :class:`numpy.broadcast` 7 | 8 | :ref:`array-broadcasting-in-numpy` 9 | An introduction to the concepts discussed here 10 | 11 | .. automodule:: numpy.doc.broadcasting 12 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/common/block.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE INITCB 2 | DOUBLE PRECISION LONG 3 | CHARACTER STRING 4 | INTEGER OK 5 | 6 | COMMON /BLOCK/ LONG, STRING, OK 7 | LONG = 1.0 8 | STRING = '2' 9 | OK = 3 10 | RETURN 11 | END 12 | -------------------------------------------------------------------------------- /numpy/_build_utils/README: -------------------------------------------------------------------------------- 1 | ======= 2 | WARNING 3 | ======= 4 | 5 | This directory (numpy/_build_utils) is *not* part of the public numpy API, 6 | - it is internal build support for numpy. 7 | - it is only present in source distributions or during an in place build 8 | - it is *not* installed with the rest of numpy 9 | -------------------------------------------------------------------------------- /doc/source/f2py/compile_session.dat: -------------------------------------------------------------------------------- 1 | >>> import numpy.f2py 2 | >>> fsource = ''' 3 | ... subroutine foo 4 | ... print*, "Hello world!" 5 | ... end 6 | ... ''' 7 | >>> numpy.f2py.compile(fsource, modulename='hello', verbose=0) 8 | 0 9 | >>> import hello 10 | >>> hello.foo() 11 | Hello world! 12 | -------------------------------------------------------------------------------- /doc/source/user/basics.rec.rst: -------------------------------------------------------------------------------- 1 | .. _structured_arrays: 2 | 3 | ***************** 4 | Structured arrays 5 | ***************** 6 | 7 | .. automodule:: numpy.doc.structured_arrays 8 | 9 | Recarray Helper Functions 10 | ************************* 11 | 12 | .. automodule:: numpy.lib.recfunctions 13 | :members: 14 | -------------------------------------------------------------------------------- /numpy/core/src/common/umathmodule.h: -------------------------------------------------------------------------------- 1 | #include "__umath_generated.c" 2 | #include "__ufunc_api.c" 3 | 4 | PyObject * add_newdoc_ufunc(PyObject *NPY_UNUSED(dummy), PyObject *args); 5 | PyObject * ufunc_frompyfunc(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *NPY_UNUSED(kwds)); 6 | int initumath(PyObject *m); 7 | 8 | 9 | -------------------------------------------------------------------------------- /numpy/f2py/__version__.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | major = 2 4 | 5 | try: 6 | from __svn_version__ import version 7 | version_info = (major, version) 8 | version = '%s_%s' % version_info 9 | except (ImportError, ValueError): 10 | version = str(major) 11 | -------------------------------------------------------------------------------- /numpy/fft/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | # To get sub-modules 4 | from .info import __doc__ 5 | 6 | from .pocketfft import * 7 | from .helper import * 8 | 9 | from numpy._pytesttester import PytestTester 10 | test = PytestTester(__name__) 11 | del PytestTester 12 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | ci: 3 | - !appveyor 4 | notify: 5 | require_ci_to_pass: no 6 | after_n_builds: 1 7 | coverage: 8 | status: 9 | project: 10 | default: 11 | # Require 1% coverage, i.e., always succeed 12 | target: 1 13 | patch: false 14 | changes: false 15 | comment: off 16 | -------------------------------------------------------------------------------- /doc/source/user/basics.rst: -------------------------------------------------------------------------------- 1 | ************ 2 | NumPy basics 3 | ************ 4 | 5 | .. toctree:: 6 | :maxdepth: 1 7 | 8 | basics.types 9 | basics.creation 10 | basics.io 11 | basics.indexing 12 | basics.broadcasting 13 | basics.byteswapping 14 | basics.rec 15 | basics.dispatch 16 | basics.subclassing 17 | -------------------------------------------------------------------------------- /numpy/core/src/npymath/npy_math.c: -------------------------------------------------------------------------------- 1 | /* 2 | * vim:syntax=c 3 | * This file is compiled into the npy_math library with externally visible 4 | * symbols, and the static and inline specifiers utilized in the npy_math 5 | * function definitions are switched off. 6 | */ 7 | 8 | #define NPY_INLINE_MATH 0 9 | #include "npy_math_internal.h" 10 | -------------------------------------------------------------------------------- /doc/source/f2py/scalar.f: -------------------------------------------------------------------------------- 1 | C FILE: SCALAR.F 2 | SUBROUTINE FOO(A,B) 3 | REAL*8 A, B 4 | Cf2py intent(in) a 5 | Cf2py intent(inout) b 6 | PRINT*, " A=",A," B=",B 7 | PRINT*, "INCREMENT A AND B" 8 | A = A + 1D0 9 | B = B + 1D0 10 | PRINT*, "NEW A=",A," B=",B 11 | END 12 | C END OF FILE SCALAR.F 13 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /numpy/random/src/aligned_malloc/aligned_malloc.c: -------------------------------------------------------------------------------- 1 | #include "aligned_malloc.h" 2 | 3 | static NPY_INLINE void *PyArray_realloc_aligned(void *p, size_t n); 4 | 5 | static NPY_INLINE void *PyArray_malloc_aligned(size_t n); 6 | 7 | static NPY_INLINE void *PyArray_calloc_aligned(size_t n, size_t s); 8 | 9 | static NPY_INLINE void PyArray_free_aligned(void *p); -------------------------------------------------------------------------------- /numpy/f2py/tests/src/regression/inout.f90: -------------------------------------------------------------------------------- 1 | ! Check that intent(in out) translates as intent(inout). 2 | ! The separation seems to be a common usage. 3 | subroutine foo(x) 4 | implicit none 5 | real(4), intent(in out) :: x 6 | dimension x(3) 7 | x(1) = x(1) + x(2) + x(3) 8 | return 9 | end 10 | -------------------------------------------------------------------------------- /changelog/13899.changes.rst: -------------------------------------------------------------------------------- 1 | Incorrect ``threshold`` in ``np.set_printoptions`` raises ``TypeError`` or ``ValueError`` 2 | ----------------------------------------------------------------------------------------- 3 | Previously an incorrect ``threshold`` raised ``ValueError``; it now raises ``TypeError`` 4 | for non-numeric types and ``ValueError`` for ``nan`` values. 5 | -------------------------------------------------------------------------------- /numpy/matrixlib/__init__.py: -------------------------------------------------------------------------------- 1 | """Sub-package containing the matrix class and related functions. 2 | 3 | """ 4 | from __future__ import division, absolute_import, print_function 5 | 6 | from .defmatrix import * 7 | 8 | __all__ = defmatrix.__all__ 9 | 10 | from numpy._pytesttester import PytestTester 11 | test = PytestTester(__name__) 12 | del PytestTester 13 | -------------------------------------------------------------------------------- /numpy/core/src/umath/override.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_UMATH_OVERRIDE_H 2 | #define _NPY_UMATH_OVERRIDE_H 3 | 4 | #include "npy_config.h" 5 | #include "numpy/ufuncobject.h" 6 | 7 | NPY_NO_EXPORT int 8 | PyUFunc_CheckOverride(PyUFuncObject *ufunc, char *method, 9 | PyObject *args, PyObject *kwds, 10 | PyObject **result); 11 | #endif 12 | -------------------------------------------------------------------------------- /doc/source/reference/routines.financial.rst: -------------------------------------------------------------------------------- 1 | Financial functions 2 | ******************* 3 | 4 | .. currentmodule:: numpy 5 | 6 | Simple financial functions 7 | -------------------------- 8 | 9 | .. autosummary:: 10 | :toctree: generated/ 11 | 12 | fv 13 | pv 14 | npv 15 | pmt 16 | ppmt 17 | ipmt 18 | irr 19 | mirr 20 | nper 21 | rate 22 | -------------------------------------------------------------------------------- /numpy/random/src/splitmix64/LICENSE.md: -------------------------------------------------------------------------------- 1 | # SPLITMIX64 2 | 3 | Written in 2015 by Sebastiano Vigna (vigna@acm.org) 4 | 5 | To the extent possible under law, the author has dedicated all copyright 6 | and related and neighboring rights to this software to the public domain 7 | worldwide. This software is distributed without any warranty. 8 | 9 | See . -------------------------------------------------------------------------------- /doc/source/f2py/calculate.f: -------------------------------------------------------------------------------- 1 | subroutine calculate(x,n) 2 | cf2py intent(callback) func 3 | external func 4 | c The following lines define the signature of func for F2PY: 5 | cf2py real*8 y 6 | cf2py y = func(y) 7 | c 8 | cf2py intent(in,out,copy) x 9 | integer n,i 10 | real*8 x(n) 11 | do i=1,n 12 | x(i) = func(x(i)) 13 | end do 14 | end 15 | -------------------------------------------------------------------------------- /doc/source/f2py/common.f: -------------------------------------------------------------------------------- 1 | C FILE: COMMON.F 2 | SUBROUTINE FOO 3 | INTEGER I,X 4 | REAL A 5 | COMMON /DATA/ I,X(4),A(2,3) 6 | PRINT*, "I=",I 7 | PRINT*, "X=[",X,"]" 8 | PRINT*, "A=[" 9 | PRINT*, "[",A(1,1),",",A(1,2),",",A(1,3),"]" 10 | PRINT*, "[",A(2,1),",",A(2,2),",",A(2,3),"]" 11 | PRINT*, "]" 12 | END 13 | C END OF COMMON.F 14 | -------------------------------------------------------------------------------- /doc/source/f2py/extcallback.f: -------------------------------------------------------------------------------- 1 | subroutine f1() 2 | print *, "in f1, calling f2 twice.." 3 | call f2() 4 | call f2() 5 | return 6 | end 7 | 8 | subroutine f2() 9 | cf2py intent(callback, hide) fpy 10 | external fpy 11 | print *, "in f2, calling f2py.." 12 | call fpy() 13 | return 14 | end 15 | -------------------------------------------------------------------------------- /numpy/_distributor_init.py: -------------------------------------------------------------------------------- 1 | """ Distributor init file 2 | 3 | Distributors: you can add custom code here to support particular distributions 4 | of numpy. 5 | 6 | For example, this is a good place to put any checks for hardware requirements. 7 | 8 | The numpy standard source distribution will not put code in this file, so you 9 | can safely replace this file with your own version. 10 | """ 11 | -------------------------------------------------------------------------------- /doc/source/dev/releasing.rst: -------------------------------------------------------------------------------- 1 | =================== 2 | Releasing a Version 3 | =================== 4 | 5 | ------------------------ 6 | How to Prepare a Release 7 | ------------------------ 8 | 9 | .. include:: ../../HOWTO_RELEASE.rst.txt 10 | 11 | ----------------------- 12 | Step-by-Step Directions 13 | ----------------------- 14 | 15 | .. include:: ../../RELEASE_WALKTHROUGH.rst.txt 16 | 17 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/assumed_shape/foo_use.f90: -------------------------------------------------------------------------------- 1 | subroutine sum_with_use(x, res) 2 | use precision 3 | 4 | implicit none 5 | 6 | real(kind=rk), intent(in) :: x(:) 7 | real(kind=rk), intent(out) :: res 8 | 9 | integer :: i 10 | 11 | !print *, "size(x) = ", size(x) 12 | 13 | res = 0.0 14 | 15 | do i = 1, size(x) 16 | res = res + x(i) 17 | enddo 18 | 19 | end subroutine 20 | -------------------------------------------------------------------------------- /numpy/random/src/entropy/entropy.h: -------------------------------------------------------------------------------- 1 | #ifndef _RANDOMDGEN__ENTROPY_H_ 2 | #define _RANDOMDGEN__ENTROPY_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | extern void entropy_fill(void *dest, size_t size); 9 | 10 | extern bool entropy_getbytes(void *dest, size_t size); 11 | 12 | extern bool entropy_fallback_getbytes(void *dest, size_t size); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /doc/source/reference/routines.emath.rst: -------------------------------------------------------------------------------- 1 | Mathematical functions with automatic domain (:mod:`numpy.emath`) 2 | *********************************************************************** 3 | 4 | .. currentmodule:: numpy 5 | 6 | .. note:: :mod:`numpy.emath` is a preferred alias for :mod:`numpy.lib.scimath`, 7 | available after :mod:`numpy` is imported. 8 | 9 | .. automodule:: numpy.lib.scimath 10 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/iterators.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAYITERATORS_H_ 2 | #define _NPY_ARRAYITERATORS_H_ 3 | 4 | NPY_NO_EXPORT PyObject 5 | *iter_subscript(PyArrayIterObject *, PyObject *); 6 | 7 | NPY_NO_EXPORT int 8 | iter_ass_subscript(PyArrayIterObject *, PyObject *, PyObject *); 9 | 10 | NPY_NO_EXPORT void 11 | PyArray_RawIterBaseInit(PyArrayIterObject *it, PyArrayObject *ao); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /doc/source/f2py/allocarr.f90: -------------------------------------------------------------------------------- 1 | module mod 2 | real, allocatable, dimension(:,:) :: b 3 | contains 4 | subroutine foo 5 | integer k 6 | if (allocated(b)) then 7 | print*, "b=[" 8 | do k = 1,size(b,1) 9 | print*, b(k,1:size(b,2)) 10 | enddo 11 | print*, "]" 12 | else 13 | print*, "b is not allocated" 14 | endif 15 | end subroutine foo 16 | end module mod 17 | -------------------------------------------------------------------------------- /doc/source/reference/routines.help.rst: -------------------------------------------------------------------------------- 1 | .. _routines.help: 2 | 3 | NumPy-specific help functions 4 | ============================= 5 | 6 | .. currentmodule:: numpy 7 | 8 | Finding help 9 | ------------ 10 | 11 | .. autosummary:: 12 | :toctree: generated/ 13 | 14 | lookfor 15 | 16 | 17 | Reading help 18 | ------------ 19 | 20 | .. autosummary:: 21 | :toctree: generated/ 22 | 23 | info 24 | source 25 | -------------------------------------------------------------------------------- /doc/source/reference/routines.set.rst: -------------------------------------------------------------------------------- 1 | Set routines 2 | ============ 3 | 4 | .. currentmodule:: numpy 5 | 6 | Making proper sets 7 | ------------------ 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | unique 12 | 13 | Boolean operations 14 | ------------------ 15 | .. autosummary:: 16 | :toctree: generated/ 17 | 18 | in1d 19 | intersect1d 20 | isin 21 | setdiff1d 22 | setxor1d 23 | union1d 24 | -------------------------------------------------------------------------------- /tools/allocation_tracking/setup.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, print_function 2 | 3 | from distutils.core import setup 4 | from distutils.extension import Extension 5 | from Cython.Distutils import build_ext 6 | import numpy 7 | 8 | setup( 9 | cmdclass = {'build_ext': build_ext}, 10 | ext_modules = [Extension("alloc_hook", ["alloc_hook.pyx"], 11 | include_dirs=[numpy.get_include()])]) 12 | -------------------------------------------------------------------------------- /tools/travis-upload-wheel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | set -ex 4 | 5 | export CLOUD_CONTAINER_NAME=travis-dev-wheels 6 | 7 | if [[ ( ${USE_WHEEL} == 1 ) \ 8 | && ( "${TRAVIS_BRANCH}" == "master" ) \ 9 | && ( "${TRAVIS_PULL_REQUEST}" == "false" ) ]]; then 10 | pip install wheelhouse_uploader 11 | python -m wheelhouse_uploader upload --local-folder \ 12 | ${TRAVIS_BUILD_DIR}/dist/ ${CLOUD_CONTAINER_NAME} 13 | fi 14 | -------------------------------------------------------------------------------- /doc/source/user/install.rst: -------------------------------------------------------------------------------- 1 | **************** 2 | Installing NumPy 3 | **************** 4 | 5 | In most use cases the best way to install NumPy on your system is by using a 6 | pre-built package for your operating system. Please see 7 | https://scipy.org/install.html for links to available options. 8 | 9 | For instructions on building for source package, see 10 | :doc:`building`. This information is useful mainly for advanced users. 11 | -------------------------------------------------------------------------------- /numpy/core/src/common/ucsnarrow.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_UCSNARROW_H_ 2 | #define _NPY_UCSNARROW_H_ 3 | 4 | NPY_NO_EXPORT int 5 | PyUCS2Buffer_FromUCS4(Py_UNICODE *ucs2, npy_ucs4 *ucs4, int ucs4length); 6 | 7 | NPY_NO_EXPORT int 8 | PyUCS2Buffer_AsUCS4(Py_UNICODE *ucs2, npy_ucs4 *ucs4, int ucs2len, int ucs4len); 9 | 10 | NPY_NO_EXPORT PyUnicodeObject * 11 | PyUnicode_FromUCS4(char *src, Py_ssize_t size, int swap, int align); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE_BUFFER_H_ 2 | #define _NPY_PRIVATE_BUFFER_H_ 3 | 4 | extern NPY_NO_EXPORT PyBufferProcs array_as_buffer; 5 | 6 | NPY_NO_EXPORT void 7 | _dealloc_cached_buffer_info(PyObject *self); 8 | 9 | NPY_NO_EXPORT PyArray_Descr* 10 | _descriptor_from_pep3118_format(char *s); 11 | 12 | NPY_NO_EXPORT int 13 | gentype_getbuffer(PyObject *obj, Py_buffer *view, int flags); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /numpy/core/src/umath/matmul.h.src: -------------------------------------------------------------------------------- 1 | /**begin repeat 2 | * #TYPE = FLOAT, DOUBLE, LONGDOUBLE, HALF, 3 | * CFLOAT, CDOUBLE, CLONGDOUBLE, 4 | * UBYTE, USHORT, UINT, ULONG, ULONGLONG, 5 | * BYTE, SHORT, INT, LONG, LONGLONG, 6 | * BOOL, OBJECT# 7 | **/ 8 | NPY_NO_EXPORT void 9 | @TYPE@_matmul(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func)); 10 | /**end repeat**/ 11 | 12 | 13 | -------------------------------------------------------------------------------- /numpy/lib/setup.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, print_function 2 | 3 | def configuration(parent_package='',top_path=None): 4 | from numpy.distutils.misc_util import Configuration 5 | 6 | config = Configuration('lib', parent_package, top_path) 7 | config.add_data_dir('tests') 8 | return config 9 | 10 | if __name__ == '__main__': 11 | from numpy.distutils.core import setup 12 | setup(configuration=configuration) 13 | -------------------------------------------------------------------------------- /doc/source/f2py/fib1.f: -------------------------------------------------------------------------------- 1 | C FILE: FIB1.F 2 | SUBROUTINE FIB(A,N) 3 | C 4 | C CALCULATE FIRST N FIBONACCI NUMBERS 5 | C 6 | INTEGER N 7 | REAL*8 A(N) 8 | DO I=1,N 9 | IF (I.EQ.1) THEN 10 | A(I) = 0.0D0 11 | ELSEIF (I.EQ.2) THEN 12 | A(I) = 1.0D0 13 | ELSE 14 | A(I) = A(I-1) + A(I-2) 15 | ENDIF 16 | ENDDO 17 | END 18 | C END FILE FIB1.F 19 | -------------------------------------------------------------------------------- /numpy/linalg/lapack_lite/f2c_config.c.patch: -------------------------------------------------------------------------------- 1 | @@ -696,7 +696,7 @@ 2 | doublereal dlamc3_(doublereal *a, doublereal *b) 3 | { 4 | /* System generated locals */ 5 | - doublereal ret_val; 6 | + volatile doublereal ret_val; 7 | 8 | 9 | /* 10 | @@ -1773,7 +1773,7 @@ 11 | doublereal slamc3_(real *a, real *b) 12 | { 13 | /* System generated locals */ 14 | - real ret_val; 15 | + volatile real ret_val; 16 | 17 | 18 | /* 19 | -------------------------------------------------------------------------------- /numpy/compat/setup.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, print_function 2 | 3 | def configuration(parent_package='',top_path=None): 4 | from numpy.distutils.misc_util import Configuration 5 | 6 | config = Configuration('compat', parent_package, top_path) 7 | config.add_data_dir('tests') 8 | return config 9 | 10 | if __name__ == '__main__': 11 | from numpy.distutils.core import setup 12 | setup(configuration=configuration) 13 | -------------------------------------------------------------------------------- /numpy/polynomial/setup.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, print_function 2 | 3 | def configuration(parent_package='',top_path=None): 4 | from numpy.distutils.misc_util import Configuration 5 | config = Configuration('polynomial', parent_package, top_path) 6 | config.add_data_dir('tests') 7 | return config 8 | 9 | if __name__ == '__main__': 10 | from numpy.distutils.core import setup 11 | setup(configuration=configuration) 12 | -------------------------------------------------------------------------------- /numpy/ma/version.py: -------------------------------------------------------------------------------- 1 | """Version number 2 | 3 | """ 4 | from __future__ import division, absolute_import, print_function 5 | 6 | version = '1.00' 7 | release = False 8 | 9 | if not release: 10 | from . import core 11 | from . import extras 12 | revision = [core.__revision__.split(':')[-1][:-1].strip(), 13 | extras.__revision__.split(':')[-1][:-1].strip(),] 14 | version += '.dev%04i' % max([int(rev) for rev in revision]) 15 | -------------------------------------------------------------------------------- /doc/source/f2py/fib1.pyf: -------------------------------------------------------------------------------- 1 | ! -*- f90 -*- 2 | python module fib2 ! in 3 | interface ! in :fib2 4 | subroutine fib(a,n) ! in :fib2:fib1.f 5 | real*8 dimension(n) :: a 6 | integer optional,check(len(a)>=n),depend(a) :: n=len(a) 7 | end subroutine fib 8 | end interface 9 | end python module fib2 10 | 11 | ! This file was auto-generated with f2py (version:2.28.198-1366). 12 | ! See http://cens.ioc.ee/projects/f2py2e/ 13 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/kind/foo.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | subroutine selectedrealkind(p, r, res) 4 | implicit none 5 | 6 | integer, intent(in) :: p, r 7 | !f2py integer :: r=0 8 | integer, intent(out) :: res 9 | res = selected_real_kind(p, r) 10 | 11 | end subroutine 12 | 13 | subroutine selectedintkind(p, res) 14 | implicit none 15 | 16 | integer, intent(in) :: p 17 | integer, intent(out) :: res 18 | res = selected_int_kind(p) 19 | 20 | end subroutine 21 | -------------------------------------------------------------------------------- /numpy/core/npymath.ini.in: -------------------------------------------------------------------------------- 1 | [meta] 2 | Name=npymath 3 | Description=Portable, core math library implementing C99 standard 4 | Version=0.1 5 | 6 | [variables] 7 | pkgname=@pkgname@ 8 | prefix=${pkgdir} 9 | libdir=${prefix}@sep@lib 10 | includedir=${prefix}@sep@include 11 | 12 | [default] 13 | Libs=-L${libdir} -lnpymath 14 | Cflags=-I${includedir} 15 | Requires=mlib 16 | 17 | [msvc] 18 | Libs=/LIBPATH:${libdir} npymath.lib 19 | Cflags=/INCLUDE:${includedir} 20 | Requires=mlib 21 | -------------------------------------------------------------------------------- /doc/newdtype_example/setup.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, print_function 2 | 3 | from numpy.distutils.core import setup 4 | 5 | def configuration(parent_package = '', top_path=None): 6 | from numpy.distutils.misc_util import Configuration 7 | config = Configuration('floatint', parent_package, top_path) 8 | 9 | config.add_extension('floatint', 10 | sources = ['floatint.c']) 11 | return config 12 | 13 | setup(configuration=configuration) 14 | -------------------------------------------------------------------------------- /doc/source/f2py/array.f: -------------------------------------------------------------------------------- 1 | C FILE: ARRAY.F 2 | SUBROUTINE FOO(A,N,M) 3 | C 4 | C INCREMENT THE FIRST ROW AND DECREMENT THE FIRST COLUMN OF A 5 | C 6 | INTEGER N,M,I,J 7 | REAL*8 A(N,M) 8 | Cf2py intent(in,out,copy) a 9 | Cf2py integer intent(hide),depend(a) :: n=shape(a,0), m=shape(a,1) 10 | DO J=1,M 11 | A(1,J) = A(1,J) + 1D0 12 | ENDDO 13 | DO I=1,N 14 | A(I,1) = A(I,1) - 1D0 15 | ENDDO 16 | END 17 | C END OF FILE ARRAY.F 18 | -------------------------------------------------------------------------------- /doc/source/reference/maskedarray.rst: -------------------------------------------------------------------------------- 1 | .. _maskedarray: 2 | 3 | ************* 4 | Masked arrays 5 | ************* 6 | 7 | Masked arrays are arrays that may have missing or invalid entries. 8 | The :mod:`numpy.ma` module provides a nearly work-alike replacement for numpy 9 | that supports data arrays with masks. 10 | 11 | .. index:: 12 | single: masked arrays 13 | 14 | .. toctree:: 15 | :maxdepth: 2 16 | 17 | maskedarray.generic 18 | maskedarray.baseclass 19 | routines.ma 20 | -------------------------------------------------------------------------------- /numpy/core/cversions.py: -------------------------------------------------------------------------------- 1 | """Simple script to compute the api hash of the current API. 2 | 3 | The API has is defined by numpy_api_order and ufunc_api_order. 4 | 5 | """ 6 | from __future__ import division, absolute_import, print_function 7 | 8 | from os.path import dirname 9 | 10 | from code_generators.genapi import fullapi_hash 11 | from code_generators.numpy_api import full_api 12 | 13 | if __name__ == '__main__': 14 | curdir = dirname(__file__) 15 | print(fullapi_hash(full_api)) 16 | -------------------------------------------------------------------------------- /numpy/ma/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import division, print_function 3 | 4 | def configuration(parent_package='',top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | config = Configuration('ma', parent_package, top_path) 7 | config.add_data_dir('tests') 8 | return config 9 | 10 | if __name__ == "__main__": 11 | from numpy.distutils.core import setup 12 | config = configuration(top_path='').todict() 13 | setup(**config) 14 | -------------------------------------------------------------------------------- /numpy/random/src/mt19937/mt19937-jump.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "mt19937.h" 3 | #include 4 | 5 | /* parameters for computing Jump */ 6 | #define W_SIZE 32 /* size of unsigned long */ 7 | #define MEXP 19937 8 | #define P_SIZE ((MEXP / W_SIZE) + 1) 9 | #define LSB 0x00000001UL 10 | #define QQ 7 11 | #define LL 128 /* LL = 2^(QQ) */ 12 | 13 | void mt19937_jump_state(mt19937_state *state, const char *jump_str); 14 | 15 | void set_coef(unsigned long *pf, unsigned int deg, unsigned long v); -------------------------------------------------------------------------------- /numpy/testing/noseclasses.py: -------------------------------------------------------------------------------- 1 | """ 2 | Back compatibility noseclasses module. It will import the appropriate 3 | set of tools 4 | """ 5 | from __future__ import division, absolute_import, print_function 6 | 7 | import warnings 8 | 9 | # 2018-04-04, numpy 1.15.0 10 | warnings.warn("Importing from numpy.testing.noseclasses is deprecated " 11 | "since 1.15.0, import from numpy.testing instead", 12 | DeprecationWarning, stacklevel=2) 13 | 14 | from ._private.noseclasses import * 15 | -------------------------------------------------------------------------------- /doc/source/f2py/extcallback_session.dat: -------------------------------------------------------------------------------- 1 | >>> import pfromf 2 | >>> pfromf.f2() 3 | Traceback (most recent call last): 4 | File "", line 1, in ? 5 | pfromf.error: Callback fpy not defined (as an argument or module pfromf attribute). 6 | 7 | >>> def f(): print "python f" 8 | ... 9 | >>> pfromf.fpy = f 10 | >>> pfromf.f2() 11 | in f2, calling f2py.. 12 | python f 13 | >>> pfromf.f1() 14 | in f1, calling f2 twice.. 15 | in f2, calling f2py.. 16 | python f 17 | in f2, calling f2py.. 18 | python f 19 | >>> -------------------------------------------------------------------------------- /numpy/matrixlib/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import division, print_function 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | config = Configuration('matrixlib', parent_package, top_path) 7 | config.add_data_dir('tests') 8 | return config 9 | 10 | if __name__ == "__main__": 11 | from numpy.distutils.core import setup 12 | config = configuration(top_path='').todict() 13 | setup(**config) 14 | -------------------------------------------------------------------------------- /doc/source/f2py/fib3.f: -------------------------------------------------------------------------------- 1 | C FILE: FIB3.F 2 | SUBROUTINE FIB(A,N) 3 | C 4 | C CALCULATE FIRST N FIBONACCI NUMBERS 5 | C 6 | INTEGER N 7 | REAL*8 A(N) 8 | Cf2py intent(in) n 9 | Cf2py intent(out) a 10 | Cf2py depend(n) a 11 | DO I=1,N 12 | IF (I.EQ.1) THEN 13 | A(I) = 0.0D0 14 | ELSEIF (I.EQ.2) THEN 15 | A(I) = 1.0D0 16 | ELSE 17 | A(I) = A(I-1) + A(I-2) 18 | ENDIF 19 | ENDDO 20 | END 21 | C END FILE FIB3.F 22 | -------------------------------------------------------------------------------- /doc/source/reference/routines.err.rst: -------------------------------------------------------------------------------- 1 | Floating point error handling 2 | ***************************** 3 | 4 | .. currentmodule:: numpy 5 | 6 | Setting and getting error handling 7 | ---------------------------------- 8 | 9 | .. autosummary:: 10 | :toctree: generated/ 11 | 12 | seterr 13 | geterr 14 | seterrcall 15 | geterrcall 16 | errstate 17 | 18 | Internal functions 19 | ------------------ 20 | 21 | .. autosummary:: 22 | :toctree: generated/ 23 | 24 | seterrobj 25 | geterrobj 26 | -------------------------------------------------------------------------------- /numpy/core/include/numpy/random/bitgen.h: -------------------------------------------------------------------------------- 1 | #ifndef _RANDOM_BITGEN_H 2 | #define _RANDOM_BITGEN_H 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | 9 | /* Must match the declaration in numpy/random/common.pxd */ 10 | 11 | typedef struct bitgen { 12 | void *state; 13 | uint64_t (*next_uint64)(void *st); 14 | uint32_t (*next_uint32)(void *st); 15 | double (*next_double)(void *st); 16 | uint64_t (*next_raw)(void *st); 17 | } bitgen_t; 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /numpy/testing/decorators.py: -------------------------------------------------------------------------------- 1 | """ 2 | Back compatibility decorators module. It will import the appropriate 3 | set of tools 4 | 5 | """ 6 | from __future__ import division, absolute_import, print_function 7 | 8 | import warnings 9 | 10 | # 2018-04-04, numpy 1.15.0 11 | warnings.warn("Importing from numpy.testing.decorators is deprecated " 12 | "since numpy 1.15.0, import from numpy.testing instead.", 13 | DeprecationWarning, stacklevel=2) 14 | 15 | from ._private.decorators import * 16 | -------------------------------------------------------------------------------- /doc/source/f2py/moddata.f90: -------------------------------------------------------------------------------- 1 | module mod 2 | integer i 3 | integer :: x(4) 4 | real, dimension(2,3) :: a 5 | real, allocatable, dimension(:,:) :: b 6 | contains 7 | subroutine foo 8 | integer k 9 | print*, "i=",i 10 | print*, "x=[",x,"]" 11 | print*, "a=[" 12 | print*, "[",a(1,1),",",a(1,2),",",a(1,3),"]" 13 | print*, "[",a(2,1),",",a(2,2),",",a(2,3),"]" 14 | print*, "]" 15 | print*, "Setting a(1,2)=a(1,2)+3" 16 | a(1,2) = a(1,2)+3 17 | end subroutine foo 18 | end module mod 19 | -------------------------------------------------------------------------------- /doc/source/reference/random/bit_generators/sfc64.rst: -------------------------------------------------------------------------------- 1 | SFC64 Small Fast Chaotic PRNG 2 | ----------------------------- 3 | 4 | .. module:: numpy.random.sfc64 5 | 6 | .. currentmodule:: numpy.random.sfc64 7 | 8 | .. autoclass:: SFC64 9 | :exclude-members: 10 | 11 | State 12 | ===== 13 | 14 | .. autosummary:: 15 | :toctree: generated/ 16 | 17 | ~SFC64.state 18 | 19 | Extending 20 | ========= 21 | .. autosummary:: 22 | :toctree: generated/ 23 | 24 | ~SFC64.cffi 25 | ~SFC64.ctypes 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /doc/source/reference/routines.datetime.rst: -------------------------------------------------------------------------------- 1 | .. _routines.datetime: 2 | 3 | Datetime Support Functions 4 | ************************** 5 | 6 | .. currentmodule:: numpy 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | datetime_as_string 12 | datetime_data 13 | 14 | 15 | Business Day Functions 16 | ====================== 17 | 18 | .. currentmodule:: numpy 19 | 20 | .. autosummary:: 21 | :toctree: generated/ 22 | 23 | busdaycalendar 24 | is_busday 25 | busday_offset 26 | busday_count 27 | -------------------------------------------------------------------------------- /doc/source/reference/routines.ctypeslib.rst: -------------------------------------------------------------------------------- 1 | .. module:: numpy.ctypeslib 2 | 3 | *********************************************************** 4 | C-Types Foreign Function Interface (:mod:`numpy.ctypeslib`) 5 | *********************************************************** 6 | 7 | .. currentmodule:: numpy.ctypeslib 8 | 9 | .. autofunction:: as_array 10 | .. autofunction:: as_ctypes 11 | .. autofunction:: as_ctypes_type 12 | .. autofunction:: ctypes_load_library 13 | .. autofunction:: load_library 14 | .. autofunction:: ndpointer 15 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/refcount.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE_REFCOUNT_H_ 2 | #define _NPY_PRIVATE_REFCOUNT_H_ 3 | 4 | NPY_NO_EXPORT void 5 | PyArray_Item_INCREF(char *data, PyArray_Descr *descr); 6 | 7 | NPY_NO_EXPORT void 8 | PyArray_Item_XDECREF(char *data, PyArray_Descr *descr); 9 | 10 | NPY_NO_EXPORT int 11 | PyArray_INCREF(PyArrayObject *mp); 12 | 13 | NPY_NO_EXPORT int 14 | PyArray_XDECREF(PyArrayObject *mp); 15 | 16 | NPY_NO_EXPORT void 17 | PyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/temp_elide.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_TEMP_AVOID_H_ 2 | #define _NPY_ARRAY_TEMP_AVOID_H_ 3 | #define NPY_NO_DEPRECATED_API NPY_API_VERSION 4 | #define _MULTIARRAYMODULE 5 | #include 6 | 7 | NPY_NO_EXPORT int 8 | can_elide_temp_unary(PyArrayObject * m1); 9 | 10 | NPY_NO_EXPORT int 11 | try_binary_elide(PyArrayObject * m1, PyObject * m2, 12 | PyObject * (inplace_op)(PyArrayObject * m1, PyObject * m2), 13 | PyObject ** res, int commutative); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /numpy/core/umath_tests.py: -------------------------------------------------------------------------------- 1 | """ 2 | Shim for _umath_tests to allow a deprecation period for the new name. 3 | 4 | """ 5 | from __future__ import division, absolute_import, print_function 6 | 7 | import warnings 8 | 9 | # 2018-04-04, numpy 1.15.0 10 | warnings.warn(("numpy.core.umath_tests is an internal NumPy " 11 | "module and should not be imported. It will " 12 | "be removed in a future NumPy release."), 13 | category=DeprecationWarning, stacklevel=2) 14 | 15 | from ._umath_tests import * 16 | -------------------------------------------------------------------------------- /doc/neps/nep-0009-structured_array_extensions.rst: -------------------------------------------------------------------------------- 1 | =================================== 2 | NEP 9 — Structured array extensions 3 | =================================== 4 | 5 | :Status: Deferred 6 | 7 | 1. Create with-style context that makes "named-columns" available as names in the namespace. 8 | 9 | with np.columns(array): 10 | price = unit * quantityt 11 | 12 | 13 | 2. Allow structured arrays to be sliced by their column (i.e. one additional indexing option for structured arrays) so that a[:4, 'foo':'bar'] would be allowed. 14 | -------------------------------------------------------------------------------- /numpy/core/src/umath/clip.h.src: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_UMATH_CLIP_H_ 2 | #define _NPY_UMATH_CLIP_H_ 3 | 4 | 5 | /**begin repeat 6 | * 7 | * #name = BOOL, 8 | * BYTE, UBYTE, SHORT, USHORT, INT, UINT, 9 | * LONG, ULONG, LONGLONG, ULONGLONG, 10 | * HALF, FLOAT, DOUBLE, LONGDOUBLE, 11 | * CFLOAT, CDOUBLE, CLONGDOUBLE, 12 | * DATETIME, TIMEDELTA# 13 | */ 14 | NPY_NO_EXPORT void 15 | @name@_clip(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func)); 16 | /**end repeat**/ 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/strfuncs.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_STRFUNCS_H_ 2 | #define _NPY_ARRAY_STRFUNCS_H_ 3 | 4 | NPY_NO_EXPORT void 5 | PyArray_SetStringFunction(PyObject *op, int repr); 6 | 7 | NPY_NO_EXPORT PyObject * 8 | array_repr(PyArrayObject *self); 9 | 10 | NPY_NO_EXPORT PyObject * 11 | array_str(PyArrayObject *self); 12 | 13 | NPY_NO_EXPORT PyObject * 14 | array_format(PyArrayObject *self, PyObject *args); 15 | 16 | #ifndef NPY_PY3K 17 | NPY_NO_EXPORT PyObject * 18 | array_unicode(PyArrayObject *self); 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /doc/changelog/1.14.5-changelog.rst: -------------------------------------------------------------------------------- 1 | 2 | Contributors 3 | ============ 4 | 5 | A total of 1 person contributed to this release. People with a "+" by their 6 | names contributed a patch for the first time. 7 | 8 | * Charles Harris 9 | 10 | Pull requests merged 11 | ==================== 12 | 13 | A total of 2 pull requests were merged for this release. 14 | 15 | * `#11274 `__: BUG: Correct use of NPY_UNUSED. 16 | * `#11294 `__: BUG: Remove extra trailing parentheses. 17 | -------------------------------------------------------------------------------- /doc/source/f2py/string.f: -------------------------------------------------------------------------------- 1 | C FILE: STRING.F 2 | SUBROUTINE FOO(A,B,C,D) 3 | CHARACTER*5 A, B 4 | CHARACTER*(*) C,D 5 | Cf2py intent(in) a,c 6 | Cf2py intent(inout) b,d 7 | PRINT*, "A=",A 8 | PRINT*, "B=",B 9 | PRINT*, "C=",C 10 | PRINT*, "D=",D 11 | PRINT*, "CHANGE A,B,C,D" 12 | A(1:1) = 'A' 13 | B(1:1) = 'B' 14 | C(1:1) = 'C' 15 | D(1:1) = 'D' 16 | PRINT*, "A=",A 17 | PRINT*, "B=",B 18 | PRINT*, "C=",C 19 | PRINT*, "D=",D 20 | END 21 | C END OF FILE STRING.F 22 | -------------------------------------------------------------------------------- /.lgtm.yml: -------------------------------------------------------------------------------- 1 | path_classifiers: 2 | library: 3 | - tools 4 | generated: 5 | # The exports defined in __init__.py are defined in the Cython module 6 | # np.random.mtrand. By excluding this file we suppress a number of 7 | # "undefined export" alerts 8 | - numpy/random/__init__.py 9 | 10 | extraction: 11 | python: 12 | python_setup: 13 | requirements: 14 | - cython>=0.29 15 | cpp: 16 | index: 17 | build_command: 18 | - python3 setup.py build 19 | 20 | queries: 21 | - include: py/file-not-closed 22 | -------------------------------------------------------------------------------- /doc/source/reference/routines.polynomials.package.rst: -------------------------------------------------------------------------------- 1 | .. module:: numpy.polynomial 2 | 3 | Polynomial Package 4 | ================== 5 | 6 | .. versionadded:: 1.4.0 7 | 8 | .. currentmodule:: numpy.polynomial 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | routines.polynomials.classes 14 | routines.polynomials.polynomial 15 | routines.polynomials.chebyshev 16 | routines.polynomials.legendre 17 | routines.polynomials.laguerre 18 | routines.polynomials.hermite 19 | routines.polynomials.hermite_e 20 | routines.polynomials.polyutils 21 | -------------------------------------------------------------------------------- /doc/source/user/index.rst: -------------------------------------------------------------------------------- 1 | .. _user: 2 | 3 | ################ 4 | NumPy User Guide 5 | ################ 6 | 7 | This guide is intended as an introductory overview of NumPy and 8 | explains how to install and make use of the most important features of 9 | NumPy. For detailed reference documentation of the functions and 10 | classes contained in the package, see the :ref:`reference`. 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | setting-up 16 | quickstart 17 | basics 18 | misc 19 | numpy-for-matlab-users 20 | building 21 | c-info 22 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/vdot.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_VDOT_H_ 2 | #define _NPY_VDOT_H_ 3 | 4 | #include "common.h" 5 | 6 | NPY_NO_EXPORT void 7 | CFLOAT_vdot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 8 | 9 | NPY_NO_EXPORT void 10 | CDOUBLE_vdot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 11 | 12 | NPY_NO_EXPORT void 13 | CLONGDOUBLE_vdot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 14 | 15 | NPY_NO_EXPORT void 16 | OBJECT_vdot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /doc/source/f2py/callback2.pyf: -------------------------------------------------------------------------------- 1 | ! -*- f90 -*- 2 | python module __user__routines 3 | interface 4 | function fun(i) result (r) 5 | integer :: i 6 | real*8 :: r 7 | end function fun 8 | end interface 9 | end python module __user__routines 10 | 11 | python module callback2 12 | interface 13 | subroutine foo(f,r) 14 | use __user__routines, f=>fun 15 | external f 16 | real*8 intent(out) :: r 17 | end subroutine foo 18 | end interface 19 | end python module callback2 20 | -------------------------------------------------------------------------------- /doc/source/f2py/spam.pyf: -------------------------------------------------------------------------------- 1 | ! -*- f90 -*- 2 | python module spam 3 | usercode ''' 4 | static char doc_spam_system[] = "Execute a shell command."; 5 | static PyObject *spam_system(PyObject *self, PyObject *args) 6 | { 7 | char *command; 8 | int sts; 9 | 10 | if (!PyArg_ParseTuple(args, "s", &command)) 11 | return NULL; 12 | sts = system(command); 13 | return Py_BuildValue("i", sts); 14 | } 15 | ''' 16 | pymethoddef ''' 17 | {"system", spam_system, METH_VARARGS, doc_spam_system}, 18 | ''' 19 | end python module spam 20 | -------------------------------------------------------------------------------- /numpy/random/src/pcg64/pcg64.orig.c: -------------------------------------------------------------------------------- 1 | #include "pcg64.orig.h" 2 | 3 | extern inline void pcg_setseq_128_srandom_r(pcg64_random_t *rng, 4 | pcg128_t initstate, 5 | pcg128_t initseq); 6 | 7 | extern uint64_t pcg_rotr_64(uint64_t value, unsigned int rot); 8 | extern inline uint64_t pcg_output_xsl_rr_128_64(pcg128_t state); 9 | extern void pcg_setseq_128_step_r(struct pcg_state_setseq_128 *rng); 10 | extern uint64_t 11 | pcg_setseq_128_xsl_rr_64_random_r(struct pcg_state_setseq_128 *rng); 12 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/parameter/constant_compound.f90: -------------------------------------------------------------------------------- 1 | ! Check that parameters are correct intercepted. 2 | ! Constants with comma separations are commonly 3 | ! used, for instance Pi = 3._dp 4 | subroutine foo_compound_int(x) 5 | implicit none 6 | integer, parameter :: ii = selected_int_kind(9) 7 | integer(ii), intent(inout) :: x 8 | dimension x(3) 9 | integer(ii), parameter :: three = 3_ii 10 | integer(ii), parameter :: two = 2_ii 11 | integer(ii), parameter :: six = three * 1_ii * two 12 | 13 | x(1) = x(1) + x(2) + x(3) * six 14 | return 15 | end subroutine 16 | -------------------------------------------------------------------------------- /doc/source/f2py/callback_session.dat: -------------------------------------------------------------------------------- 1 | >>> import callback 2 | >>> print callback.foo.__doc__ 3 | foo - Function signature: 4 | r = foo(fun,[fun_extra_args]) 5 | Required arguments: 6 | fun : call-back function 7 | Optional arguments: 8 | fun_extra_args := () input tuple 9 | Return objects: 10 | r : float 11 | Call-back functions: 12 | def fun(i): return r 13 | Required arguments: 14 | i : input int 15 | Return objects: 16 | r : float 17 | 18 | >>> def f(i): return i*i 19 | ... 20 | >>> print callback.foo(f) 21 | 110.0 22 | >>> print callback.foo(lambda i:1) 23 | 11.0 24 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/arrayfunction_override.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE__ARRAYFUNCTION_OVERRIDE_H 2 | #define _NPY_PRIVATE__ARRAYFUNCTION_OVERRIDE_H 3 | 4 | NPY_NO_EXPORT PyObject * 5 | array_implement_array_function( 6 | PyObject *NPY_UNUSED(dummy), PyObject *positional_args); 7 | 8 | NPY_NO_EXPORT PyObject * 9 | array__get_implementing_args( 10 | PyObject *NPY_UNUSED(dummy), PyObject *positional_args); 11 | 12 | NPY_NO_EXPORT PyObject * 13 | array_function_method_impl(PyObject *func, PyObject *types, PyObject *args, 14 | PyObject *kwargs); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /doc/source/f2py/scalar_session.dat: -------------------------------------------------------------------------------- 1 | >>> import scalar 2 | >>> print scalar.foo.__doc__ 3 | foo - Function signature: 4 | foo(a,b) 5 | Required arguments: 6 | a : input float 7 | b : in/output rank-0 array(float,'d') 8 | 9 | >>> scalar.foo(2,3) 10 | A= 2. B= 3. 11 | INCREMENT A AND B 12 | NEW A= 3. B= 4. 13 | >>> import numpy 14 | >>> a=numpy.array(2) # these are integer rank-0 arrays 15 | >>> b=numpy.array(3) 16 | >>> scalar.foo(a,b) 17 | A= 2. B= 3. 18 | INCREMENT A AND B 19 | NEW A= 3. B= 4. 20 | >>> print a,b # note that only b is changed in situ 21 | 2 4 22 | -------------------------------------------------------------------------------- /numpy/compat/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Compatibility module. 3 | 4 | This module contains duplicated code from Python itself or 3rd party 5 | extensions, which may be included for the following reasons: 6 | 7 | * compatibility 8 | * we may only need a small subset of the copied library/module 9 | 10 | """ 11 | from __future__ import division, absolute_import, print_function 12 | 13 | from . import _inspect 14 | from . import py3k 15 | from ._inspect import getargspec, formatargspec 16 | from .py3k import * 17 | 18 | __all__ = [] 19 | __all__.extend(_inspect.__all__) 20 | __all__.extend(py3k.__all__) 21 | -------------------------------------------------------------------------------- /doc/release/template.rst: -------------------------------------------------------------------------------- 1 | ========================== 2 | NumPy 1.xx.x Release Notes 3 | ========================== 4 | 5 | 6 | Highlights 7 | ========== 8 | 9 | 10 | New functions 11 | ============= 12 | 13 | 14 | Deprecations 15 | ============ 16 | 17 | 18 | Future Changes 19 | ============== 20 | 21 | 22 | Expired deprecations 23 | ==================== 24 | 25 | 26 | Compatibility notes 27 | =================== 28 | 29 | 30 | C API changes 31 | ============= 32 | 33 | 34 | New Features 35 | ============ 36 | 37 | 38 | Improvements 39 | ============ 40 | 41 | 42 | Changes 43 | ======= 44 | -------------------------------------------------------------------------------- /doc/source/reference/routines.bitwise.rst: -------------------------------------------------------------------------------- 1 | Binary operations 2 | ***************** 3 | 4 | .. currentmodule:: numpy 5 | 6 | Elementwise bit operations 7 | -------------------------- 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | bitwise_and 12 | bitwise_or 13 | bitwise_xor 14 | invert 15 | left_shift 16 | right_shift 17 | 18 | Bit packing 19 | ----------- 20 | .. autosummary:: 21 | :toctree: generated/ 22 | 23 | packbits 24 | unpackbits 25 | 26 | Output formatting 27 | ----------------- 28 | .. autosummary:: 29 | :toctree: generated/ 30 | 31 | binary_repr 32 | -------------------------------------------------------------------------------- /doc/release/1.18.0-notes.rst: -------------------------------------------------------------------------------- 1 | ========================== 2 | NumPy 1.18.0 Release Notes 3 | ========================== 4 | 5 | 6 | Highlights 7 | ========== 8 | 9 | 10 | New functions 11 | ============= 12 | 13 | 14 | Deprecations 15 | ============ 16 | 17 | 18 | Future Changes 19 | ============== 20 | 21 | 22 | Expired deprecations 23 | ==================== 24 | 25 | 26 | Compatibility notes 27 | =================== 28 | 29 | 30 | C API changes 31 | ============= 32 | 33 | 34 | New Features 35 | ============ 36 | 37 | 38 | Improvements 39 | ============ 40 | 41 | 42 | Changes 43 | ======= 44 | -------------------------------------------------------------------------------- /numpy/core/src/npymath/_signbit.c: -------------------------------------------------------------------------------- 1 | /* Adapted from cephes */ 2 | 3 | int 4 | _npy_signbit_d(double x) 5 | { 6 | union 7 | { 8 | double d; 9 | short s[4]; 10 | int i[2]; 11 | } u; 12 | 13 | u.d = x; 14 | 15 | #if NPY_SIZEOF_INT == 4 16 | 17 | #ifdef WORDS_BIGENDIAN /* defined in pyconfig.h */ 18 | return u.i[0] < 0; 19 | #else 20 | return u.i[1] < 0; 21 | #endif 22 | 23 | #else /* NPY_SIZEOF_INT != 4 */ 24 | 25 | #ifdef WORDS_BIGENDIAN 26 | return u.s[0] < 0; 27 | #else 28 | return u.s[3] < 0; 29 | #endif 30 | 31 | #endif /* NPY_SIZEOF_INT */ 32 | } 33 | -------------------------------------------------------------------------------- /tools/allocation_tracking/README.md: -------------------------------------------------------------------------------- 1 | Example for using the `PyDataMem_SetEventHook` to track allocations inside numpy. 2 | 3 | `alloc_hook.pyx` implements a hook in Cython that calls back into a python 4 | function. `track_allocations.py` uses it for a simple listing of allocations. 5 | It can be built with the `setup.py` file in this folder. 6 | 7 | Note that since Python 3.6 the builtin tracemalloc module can be used to 8 | track allocations inside numpy. 9 | Numpy places its CPU memory allocations into the `np.lib.tracemalloc_domain` 10 | domain. 11 | See https://docs.python.org/3/library/tracemalloc.html. 12 | -------------------------------------------------------------------------------- /numpy/matrixlib/tests/test_numeric.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import numpy as np 4 | from numpy.testing import assert_equal 5 | 6 | class TestDot(object): 7 | def test_matscalar(self): 8 | b1 = np.matrix(np.ones((3, 3), dtype=complex)) 9 | assert_equal(b1*1.0, b1) 10 | 11 | 12 | def test_diagonal(): 13 | b1 = np.matrix([[1,2],[3,4]]) 14 | diag_b1 = np.matrix([[1, 4]]) 15 | array_b1 = np.array([1, 4]) 16 | 17 | assert_equal(b1.diagonal(), diag_b1) 18 | assert_equal(np.diagonal(b1), array_b1) 19 | assert_equal(np.diag(b1), array_b1) 20 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/usertypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE_USERTYPES_H_ 2 | #define _NPY_PRIVATE_USERTYPES_H_ 3 | 4 | extern NPY_NO_EXPORT PyArray_Descr **userdescrs; 5 | 6 | NPY_NO_EXPORT void 7 | PyArray_InitArrFuncs(PyArray_ArrFuncs *f); 8 | 9 | NPY_NO_EXPORT int 10 | PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, 11 | NPY_SCALARKIND scalar); 12 | 13 | NPY_NO_EXPORT int 14 | PyArray_RegisterDataType(PyArray_Descr *descr); 15 | 16 | NPY_NO_EXPORT int 17 | PyArray_RegisterCastFunc(PyArray_Descr *descr, int totype, 18 | PyArray_VectorUnaryFunc *castfunc); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /numpy/fft/setup.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, print_function 2 | 3 | 4 | def configuration(parent_package='',top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | config = Configuration('fft', parent_package, top_path) 7 | 8 | config.add_data_dir('tests') 9 | 10 | # Configure pocketfft_internal 11 | config.add_extension('pocketfft_internal', 12 | sources=['pocketfft.c'] 13 | ) 14 | 15 | return config 16 | 17 | if __name__ == '__main__': 18 | from numpy.distutils.core import setup 19 | setup(configuration=configuration) 20 | -------------------------------------------------------------------------------- /doc/source/f2py/common_session.dat: -------------------------------------------------------------------------------- 1 | >>> import common 2 | >>> print common.data.__doc__ 3 | i - 'i'-scalar 4 | x - 'i'-array(4) 5 | a - 'f'-array(2,3) 6 | 7 | >>> common.data.i = 5 8 | >>> common.data.x[1] = 2 9 | >>> common.data.a = [[1,2,3],[4,5,6]] 10 | >>> common.foo() 11 | I= 5 12 | X=[ 0 2 0 0] 13 | A=[ 14 | [ 1., 2., 3.] 15 | [ 4., 5., 6.] 16 | ] 17 | >>> common.data.a[1] = 45 18 | >>> common.foo() 19 | I= 5 20 | X=[ 0 2 0 0] 21 | A=[ 22 | [ 1., 2., 3.] 23 | [ 45., 45., 45.] 24 | ] 25 | >>> common.data.a # a is Fortran-contiguous 26 | array([[ 1., 2., 3.], 27 | [ 45., 45., 45.]],'f') 28 | -------------------------------------------------------------------------------- /doc/source/f2py/ftype_session.dat: -------------------------------------------------------------------------------- 1 | >>> import ftype 2 | >>> print ftype.__doc__ 3 | This module 'ftype' is auto-generated with f2py (version:2.28.198-1366). 4 | Functions: 5 | foo(n=13) 6 | COMMON blocks: 7 | /data/ a,x(3) 8 | . 9 | >>> type(ftype.foo),type(ftype.data) 10 | (, ) 11 | >>> ftype.foo() 12 | IN FOO: N= 13 A= 0. X=[ 0. 0. 0.] 13 | >>> ftype.data.a = 3 14 | >>> ftype.data.x = [1,2,3] 15 | >>> ftype.foo() 16 | IN FOO: N= 13 A= 3. X=[ 1. 2. 3.] 17 | >>> ftype.data.x[1] = 45 18 | >>> ftype.foo(24) 19 | IN FOO: N= 24 A= 3. X=[ 1. 45. 3.] 20 | >>> ftype.data.x 21 | array([ 1., 45., 3.],'f') 22 | -------------------------------------------------------------------------------- /doc/source/reference/random/bit_generators/mt19937.rst: -------------------------------------------------------------------------------- 1 | Mersenne Twister (MT19937) 2 | -------------------------- 3 | 4 | .. module:: numpy.random.mt19937 5 | 6 | .. currentmodule:: numpy.random.mt19937 7 | 8 | .. autoclass:: MT19937 9 | :exclude-members: 10 | 11 | State 12 | ===== 13 | 14 | .. autosummary:: 15 | :toctree: generated/ 16 | 17 | ~MT19937.state 18 | 19 | Parallel generation 20 | =================== 21 | .. autosummary:: 22 | :toctree: generated/ 23 | 24 | ~MT19937.jumped 25 | 26 | Extending 27 | ========= 28 | .. autosummary:: 29 | :toctree: generated/ 30 | 31 | ~MT19937.cffi 32 | ~MT19937.ctypes 33 | 34 | 35 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/typeinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE_TYPEINFO_H_ 2 | #define _NPY_PRIVATE_TYPEINFO_H_ 3 | 4 | #define PY_SSIZE_T_CLEAN 5 | #include 6 | #include "npy_config.h" 7 | 8 | NPY_VISIBILITY_HIDDEN int 9 | typeinfo_init_structsequences(PyObject *multiarray_dict); 10 | 11 | NPY_VISIBILITY_HIDDEN PyObject * 12 | PyArray_typeinfo( 13 | char typechar, int typenum, int nbits, int align, 14 | PyTypeObject *type_obj); 15 | 16 | NPY_VISIBILITY_HIDDEN PyObject * 17 | PyArray_typeinforanged( 18 | char typechar, int typenum, int nbits, int align, 19 | PyObject *max, PyObject *min, PyTypeObject *type_obj); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/assumed_shape/foo_free.f90: -------------------------------------------------------------------------------- 1 | 2 | subroutine sum(x, res) 3 | implicit none 4 | real, intent(in) :: x(:) 5 | real, intent(out) :: res 6 | 7 | integer :: i 8 | 9 | !print *, "sum: size(x) = ", size(x) 10 | 11 | res = 0.0 12 | 13 | do i = 1, size(x) 14 | res = res + x(i) 15 | enddo 16 | 17 | end subroutine sum 18 | 19 | function fsum(x) result (res) 20 | implicit none 21 | real, intent(in) :: x(:) 22 | real :: res 23 | 24 | integer :: i 25 | 26 | !print *, "fsum: size(x) = ", size(x) 27 | 28 | res = 0.0 29 | 30 | do i = 1, size(x) 31 | res = res + x(i) 32 | enddo 33 | 34 | end function fsum 35 | -------------------------------------------------------------------------------- /doc/source/f2py/run_main_session.dat: -------------------------------------------------------------------------------- 1 | >>> import numpy.f2py 2 | >>> r = numpy.f2py.run_main(['-m','scalar','doc/source/f2py/scalar.f']) 3 | Reading fortran codes... 4 | Reading file 'doc/source/f2py/scalar.f' (format:fix,strict) 5 | Post-processing... 6 | Block: scalar 7 | Block: FOO 8 | Building modules... 9 | Building module "scalar"... 10 | Wrote C/API module "scalar" to file "./scalarmodule.c" 11 | >>> print(r) 12 | {'scalar': {'h': ['/home/users/pearu/src_cvs/f2py/src/fortranobject.h'], 13 | 'csrc': ['./scalarmodule.c', 14 | '/home/users/pearu/src_cvs/f2py/src/fortranobject.c']}} 15 | -------------------------------------------------------------------------------- /numpy/compat/tests/test_compat.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | from os.path import join 4 | 5 | from numpy.compat import isfileobj 6 | from numpy.testing import assert_ 7 | from numpy.testing import tempdir 8 | 9 | 10 | def test_isfileobj(): 11 | with tempdir(prefix="numpy_test_compat_") as folder: 12 | filename = join(folder, 'a.bin') 13 | 14 | with open(filename, 'wb') as f: 15 | assert_(isfileobj(f)) 16 | 17 | with open(filename, 'ab') as f: 18 | assert_(isfileobj(f)) 19 | 20 | with open(filename, 'rb') as f: 21 | assert_(isfileobj(f)) 22 | -------------------------------------------------------------------------------- /doc/source/reference/random/bit_generators/philox.rst: -------------------------------------------------------------------------------- 1 | Philox Counter-based RNG 2 | ------------------------ 3 | 4 | .. module:: numpy.random.philox 5 | 6 | .. currentmodule:: numpy.random.philox 7 | 8 | .. autoclass:: Philox 9 | :exclude-members: 10 | 11 | State 12 | ===== 13 | 14 | .. autosummary:: 15 | :toctree: generated/ 16 | 17 | ~Philox.state 18 | 19 | Parallel generation 20 | =================== 21 | .. autosummary:: 22 | :toctree: generated/ 23 | 24 | ~Philox.advance 25 | ~Philox.jumped 26 | 27 | Extending 28 | ========= 29 | .. autosummary:: 30 | :toctree: generated/ 31 | 32 | ~Philox.cffi 33 | ~Philox.ctypes 34 | 35 | 36 | -------------------------------------------------------------------------------- /doc/newdtype_example/example.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import floatint.floatint as ff 4 | import numpy as np 5 | 6 | # Setting using array is hard because 7 | # The parser doesn't stop at tuples always 8 | # So, the setitem code will be called with scalars on the 9 | # wrong shaped array. 10 | # But we can get a view as an ndarray of the given type: 11 | g = np.array([1, 2, 3, 4, 5, 6, 7, 8]).view(ff.floatint_type) 12 | 13 | # Now, the elements will be the scalar type associated 14 | # with the ndarray. 15 | print(g[0]) 16 | print(type(g[1])) 17 | 18 | # Now, you need to register ufuncs and more arrfuncs to do useful things... 19 | -------------------------------------------------------------------------------- /doc/source/reference/random/bit_generators/pcg64.rst: -------------------------------------------------------------------------------- 1 | Parallel Congruent Generator (64-bit, PCG64) 2 | -------------------------------------------- 3 | 4 | .. module:: numpy.random.pcg64 5 | 6 | .. currentmodule:: numpy.random.pcg64 7 | 8 | .. autoclass:: PCG64 9 | :exclude-members: 10 | 11 | State 12 | ===== 13 | 14 | .. autosummary:: 15 | :toctree: generated/ 16 | 17 | ~PCG64.state 18 | 19 | Parallel generation 20 | =================== 21 | .. autosummary:: 22 | :toctree: generated/ 23 | 24 | ~PCG64.advance 25 | ~PCG64.jumped 26 | 27 | Extending 28 | ========= 29 | .. autosummary:: 30 | :toctree: generated/ 31 | 32 | ~PCG64.cffi 33 | ~PCG64.ctypes 34 | -------------------------------------------------------------------------------- /numpy/testing/nosetester.py: -------------------------------------------------------------------------------- 1 | """ 2 | Back compatibility nosetester module. It will import the appropriate 3 | set of tools 4 | 5 | """ 6 | from __future__ import division, absolute_import, print_function 7 | 8 | import warnings 9 | 10 | # 2018-04-04, numpy 1.15.0 11 | warnings.warn("Importing from numpy.testing.nosetester is deprecated " 12 | "since 1.15.0, import from numpy.testing instead.", 13 | DeprecationWarning, stacklevel=2) 14 | 15 | from ._private.nosetester import * 16 | 17 | __all__ = ['get_package_name', 'run_module_suite', 'NoseTester', 18 | '_numpy_tester', 'get_package_name', 'import_nose', 19 | 'suppress_warnings'] 20 | -------------------------------------------------------------------------------- /numpy/core/include/numpy/npy_no_deprecated_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This include file is provided for inclusion in Cython *.pyd files where 3 | * one would like to define the NPY_NO_DEPRECATED_API macro. It can be 4 | * included by 5 | * 6 | * cdef extern from "npy_no_deprecated_api.h": pass 7 | * 8 | */ 9 | #ifndef NPY_NO_DEPRECATED_API 10 | 11 | /* put this check here since there may be multiple includes in C extensions. */ 12 | #if defined(NDARRAYTYPES_H) || defined(_NPY_DEPRECATED_API_H) || \ 13 | defined(OLD_DEFINES_H) 14 | #error "npy_no_deprecated_api.h" must be first among numpy includes. 15 | #else 16 | #define NPY_NO_DEPRECATED_API NPY_API_VERSION 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /numpy/linalg/lapack_lite/wrapped_routines: -------------------------------------------------------------------------------- 1 | ccopy 2 | cgeev 3 | cgelsd 4 | cgemm 5 | cgesdd 6 | cgesv 7 | cgetrf 8 | cheevd 9 | cpotrf 10 | cpotri 11 | cpotrs 12 | dcopy 13 | dgeev 14 | dgelsd 15 | dgemm 16 | dgeqrf 17 | dgesdd 18 | dgesv 19 | dgetrf 20 | dorgqr 21 | dpotrf 22 | dpotri 23 | dpotrs 24 | dsyevd 25 | scopy 26 | sgeev 27 | sgelsd 28 | sgemm 29 | sgesdd 30 | sgesv 31 | sgetrf 32 | spotrf 33 | spotri 34 | spotrs 35 | ssyevd 36 | zcopy 37 | zgeev 38 | zgelsd 39 | zgemm 40 | zgeqrf 41 | zgesdd 42 | zgesv 43 | zgetrf 44 | zheevd 45 | zpotrf 46 | zpotri 47 | zpotrs 48 | zungqr 49 | # need this b/c it's not properly declared as external in the BLAS source 50 | dcabs1 51 | IGNORE: xerbla 52 | -------------------------------------------------------------------------------- /numpy/distutils/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import division, print_function 3 | 4 | def configuration(parent_package='',top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | config = Configuration('distutils', parent_package, top_path) 7 | config.add_subpackage('command') 8 | config.add_subpackage('fcompiler') 9 | config.add_data_dir('tests') 10 | config.add_data_files('site.cfg') 11 | config.add_data_files('mingw/gfortran_vs2003_hack.c') 12 | config.make_config_py() 13 | return config 14 | 15 | if __name__ == '__main__': 16 | from numpy.distutils.core import setup 17 | setup(configuration=configuration) 18 | -------------------------------------------------------------------------------- /doc/source/f2py/setup_example.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | from numpy.distutils.core import Extension 4 | 5 | ext1 = Extension(name = 'scalar', 6 | sources = ['scalar.f']) 7 | ext2 = Extension(name = 'fib2', 8 | sources = ['fib2.pyf', 'fib1.f']) 9 | 10 | if __name__ == "__main__": 11 | from numpy.distutils.core import setup 12 | setup(name = 'f2py_example', 13 | description = "F2PY Users Guide examples", 14 | author = "Pearu Peterson", 15 | author_email = "pearu@cens.ioc.ee", 16 | ext_modules = [ext1, ext2] 17 | ) 18 | # End of setup_example.py 19 | -------------------------------------------------------------------------------- /doc/source/f2py/string_session.dat: -------------------------------------------------------------------------------- 1 | >>> import mystring 2 | >>> print mystring.foo.__doc__ 3 | foo - Function signature: 4 | foo(a,b,c,d) 5 | Required arguments: 6 | a : input string(len=5) 7 | b : in/output rank-0 array(string(len=5),'c') 8 | c : input string(len=-1) 9 | d : in/output rank-0 array(string(len=-1),'c') 10 | 11 | >>> import numpy 12 | >>> a=numpy.array('123') 13 | >>> b=numpy.array('123') 14 | >>> c=numpy.array('123') 15 | >>> d=numpy.array('123') 16 | >>> mystring.foo(a,b,c,d) 17 | A=123 18 | B=123 19 | C=123 20 | D=123 21 | CHANGE A,B,C,D 22 | A=A23 23 | B=B23 24 | C=C23 25 | D=D23 26 | >>> a.tostring(),b.tostring(),c.tostring(),d.tostring() 27 | ('123', 'B23', '123', 'D23') 28 | -------------------------------------------------------------------------------- /numpy/doc/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | 5 | ref_dir = os.path.join(os.path.dirname(__file__)) 6 | 7 | __all__ = sorted(f[:-3] for f in os.listdir(ref_dir) if f.endswith('.py') and 8 | not f.startswith('__')) 9 | 10 | for f in __all__: 11 | __import__(__name__ + '.' + f) 12 | 13 | del f, ref_dir 14 | 15 | __doc__ = """\ 16 | Topical documentation 17 | ===================== 18 | 19 | The following topics are available: 20 | %s 21 | 22 | You can view them by 23 | 24 | >>> help(np.doc.TOPIC) #doctest: +SKIP 25 | 26 | """ % '\n- '.join([''] + __all__) 27 | 28 | __all__.extend(['__doc__']) 29 | -------------------------------------------------------------------------------- /doc/source/f2py/moddata_session.dat: -------------------------------------------------------------------------------- 1 | >>> import moddata 2 | >>> print moddata.mod.__doc__ 3 | i - 'i'-scalar 4 | x - 'i'-array(4) 5 | a - 'f'-array(2,3) 6 | foo - Function signature: 7 | foo() 8 | 9 | 10 | >>> moddata.mod.i = 5 11 | >>> moddata.mod.x[:2] = [1,2] 12 | >>> moddata.mod.a = [[1,2,3],[4,5,6]] 13 | >>> moddata.mod.foo() 14 | i= 5 15 | x=[ 1 2 0 0 ] 16 | a=[ 17 | [ 1.000000 , 2.000000 , 3.000000 ] 18 | [ 4.000000 , 5.000000 , 6.000000 ] 19 | ] 20 | Setting a(1,2)=a(1,2)+3 21 | >>> moddata.mod.a # a is Fortran-contiguous 22 | array([[ 1., 5., 3.], 23 | [ 4., 5., 6.]],'f') 24 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/assumed_shape/foo_mod.f90: -------------------------------------------------------------------------------- 1 | 2 | module mod 3 | 4 | contains 5 | 6 | subroutine sum(x, res) 7 | implicit none 8 | real, intent(in) :: x(:) 9 | real, intent(out) :: res 10 | 11 | integer :: i 12 | 13 | !print *, "sum: size(x) = ", size(x) 14 | 15 | res = 0.0 16 | 17 | do i = 1, size(x) 18 | res = res + x(i) 19 | enddo 20 | 21 | end subroutine sum 22 | 23 | function fsum(x) result (res) 24 | implicit none 25 | real, intent(in) :: x(:) 26 | real :: res 27 | 28 | integer :: i 29 | 30 | !print *, "fsum: size(x) = ", size(x) 31 | 32 | res = 0.0 33 | 34 | do i = 1, size(x) 35 | res = res + x(i) 36 | enddo 37 | 38 | end function fsum 39 | 40 | 41 | end module mod 42 | -------------------------------------------------------------------------------- /doc/source/reference/routines.polynomials.poly1d.rst: -------------------------------------------------------------------------------- 1 | Poly1d 2 | ====== 3 | 4 | .. currentmodule:: numpy 5 | 6 | Basics 7 | ------ 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | poly1d 12 | polyval 13 | poly 14 | roots 15 | 16 | Fitting 17 | ------- 18 | .. autosummary:: 19 | :toctree: generated/ 20 | 21 | polyfit 22 | 23 | Calculus 24 | -------- 25 | .. autosummary:: 26 | :toctree: generated/ 27 | 28 | polyder 29 | polyint 30 | 31 | Arithmetic 32 | ---------- 33 | .. autosummary:: 34 | :toctree: generated/ 35 | 36 | polyadd 37 | polydiv 38 | polymul 39 | polysub 40 | 41 | Warnings 42 | -------- 43 | .. autosummary:: 44 | :toctree: generated/ 45 | 46 | RankWarning 47 | -------------------------------------------------------------------------------- /doc/source/reference/routines.sort.rst: -------------------------------------------------------------------------------- 1 | Sorting, searching, and counting 2 | ================================ 3 | 4 | .. currentmodule:: numpy 5 | 6 | Sorting 7 | ------- 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | sort 12 | lexsort 13 | argsort 14 | ndarray.sort 15 | msort 16 | sort_complex 17 | partition 18 | argpartition 19 | 20 | Searching 21 | --------- 22 | .. autosummary:: 23 | :toctree: generated/ 24 | 25 | argmax 26 | nanargmax 27 | argmin 28 | nanargmin 29 | argwhere 30 | nonzero 31 | flatnonzero 32 | where 33 | searchsorted 34 | extract 35 | 36 | Counting 37 | -------- 38 | .. autosummary:: 39 | :toctree: generated/ 40 | 41 | count_nonzero 42 | -------------------------------------------------------------------------------- /numpy/distutils/command/develop.py: -------------------------------------------------------------------------------- 1 | """ Override the develop command from setuptools so we can ensure that our 2 | generated files (from build_src or build_scripts) are properly converted to real 3 | files with filenames. 4 | 5 | """ 6 | from __future__ import division, absolute_import, print_function 7 | 8 | from setuptools.command.develop import develop as old_develop 9 | 10 | class develop(old_develop): 11 | __doc__ = old_develop.__doc__ 12 | def install_for_development(self): 13 | # Build sources in-place, too. 14 | self.reinitialize_command('build_src', inplace=1) 15 | # Make sure scripts are built. 16 | self.run_command('build_scripts') 17 | old_develop.install_for_development(self) 18 | -------------------------------------------------------------------------------- /numpy/matrixlib/tests/test_multiarray.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import numpy as np 4 | from numpy.testing import assert_, assert_equal, assert_array_equal 5 | 6 | class TestView(object): 7 | def test_type(self): 8 | x = np.array([1, 2, 3]) 9 | assert_(isinstance(x.view(np.matrix), np.matrix)) 10 | 11 | def test_keywords(self): 12 | x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)]) 13 | # We must be specific about the endianness here: 14 | y = x.view(dtype='{{ shorttitle|e }} 6 | {% endif %} 7 | {% endblock %} 8 | 9 | {% block sidebarsearch %} 10 | {%- if sourcename %} 11 | 18 | {%- endif %} 19 | {{ super() }} 20 | {% endblock %} 21 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/string/char.f90: -------------------------------------------------------------------------------- 1 | MODULE char_test 2 | 3 | CONTAINS 4 | 5 | SUBROUTINE change_strings(strings, n_strs, out_strings) 6 | IMPLICIT NONE 7 | 8 | ! Inputs 9 | INTEGER, INTENT(IN) :: n_strs 10 | CHARACTER, INTENT(IN), DIMENSION(2,n_strs) :: strings 11 | CHARACTER, INTENT(OUT), DIMENSION(2,n_strs) :: out_strings 12 | 13 | !f2py INTEGER, INTENT(IN) :: n_strs 14 | !f2py CHARACTER, INTENT(IN), DIMENSION(2,n_strs) :: strings 15 | !f2py CHARACTER, INTENT(OUT), DIMENSION(2,n_strs) :: strings 16 | 17 | ! Misc. 18 | INTEGER*4 :: j 19 | 20 | 21 | DO j=1, n_strs 22 | out_strings(1,j) = strings(1,j) 23 | out_strings(2,j) = 'A' 24 | END DO 25 | 26 | END SUBROUTINE change_strings 27 | 28 | END MODULE char_test 29 | 30 | -------------------------------------------------------------------------------- /doc/neps/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = -W 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = NumPyEnhancementProposals 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile index 16 | 17 | index: 18 | python tools/build_index.py 19 | 20 | # Catch-all target: route all unknown targets to Sphinx using the new 21 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 22 | %: Makefile index 23 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 24 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_block_docstring.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import sys 4 | import pytest 5 | from . import util 6 | 7 | from numpy.testing import assert_equal, IS_PYPY 8 | 9 | class TestBlockDocString(util.F2PyTest): 10 | code = """ 11 | SUBROUTINE FOO() 12 | INTEGER BAR(2, 3) 13 | 14 | COMMON /BLOCK/ BAR 15 | RETURN 16 | END 17 | """ 18 | 19 | @pytest.mark.skipif(sys.platform=='win32', 20 | reason='Fails with MinGW64 Gfortran (Issue #9673)') 21 | @pytest.mark.xfail(IS_PYPY, reason="PyPy does not modify tp_doc") 22 | def test_block_docstring(self): 23 | expected = "'i'-array(2,3)\n" 24 | assert_equal(self.module.block.__doc__, expected) 25 | -------------------------------------------------------------------------------- /numpy/testing/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import division, print_function 3 | 4 | 5 | def configuration(parent_package='',top_path=None): 6 | from numpy.distutils.misc_util import Configuration 7 | config = Configuration('testing', parent_package, top_path) 8 | 9 | config.add_subpackage('_private') 10 | config.add_data_dir('tests') 11 | return config 12 | 13 | if __name__ == '__main__': 14 | from numpy.distutils.core import setup 15 | setup(maintainer="NumPy Developers", 16 | maintainer_email="numpy-dev@numpy.org", 17 | description="NumPy test module", 18 | url="https://www.numpy.org", 19 | license="NumPy License (BSD Style)", 20 | configuration=configuration, 21 | ) 22 | -------------------------------------------------------------------------------- /doc/cdoc/README: -------------------------------------------------------------------------------- 1 | cdoc 2 | ==== 3 | 4 | This is a simple Doxygen project for building NumPy C code documentation, 5 | with docstrings extracted from the C sources themselves. 6 | 7 | The understood syntax for documentation in the C source is 8 | 9 | /* 10 | * Some text in reStructuredText format 11 | */ 12 | int function_to_which_the_text_applies() 13 | { 14 | ... 15 | } 16 | 17 | /* 18 | * More text in reStructuredText format 19 | */ 20 | struct 21 | { 22 | int variable_1; /* Documentation for variable_1 */ 23 | 24 | /* 25 | * Documentation for variable_2 26 | */ 27 | int variable_2; 28 | } struct_name_t; 29 | 30 | Please do not use JavaDoc or Doxygen-specific formatting at the moment. 31 | 32 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_string.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | import pytest 5 | 6 | from numpy.testing import assert_array_equal 7 | import numpy as np 8 | from . import util 9 | 10 | 11 | def _path(*a): 12 | return os.path.join(*((os.path.dirname(__file__),) + a)) 13 | 14 | class TestString(util.F2PyTest): 15 | sources = [_path('src', 'string', 'char.f90')] 16 | 17 | @pytest.mark.slow 18 | def test_char(self): 19 | strings = np.array(['ab', 'cd', 'ef'], dtype='c').T 20 | inp, out = self.module.char_test.change_strings(strings, strings.shape[1]) 21 | assert_array_equal(inp, strings) 22 | expected = strings.copy() 23 | expected[1, :] = 'AAA' 24 | assert_array_equal(out, expected) 25 | -------------------------------------------------------------------------------- /numpy/distutils/numpy_distribution.py: -------------------------------------------------------------------------------- 1 | # XXX: Handle setuptools ? 2 | from __future__ import division, absolute_import, print_function 3 | 4 | from distutils.core import Distribution 5 | 6 | # This class is used because we add new files (sconscripts, and so on) with the 7 | # scons command 8 | class NumpyDistribution(Distribution): 9 | def __init__(self, attrs = None): 10 | # A list of (sconscripts, pre_hook, post_hook, src, parent_names) 11 | self.scons_data = [] 12 | # A list of installable libraries 13 | self.installed_libraries = [] 14 | # A dict of pkg_config files to generate/install 15 | self.installed_pkg_config = {} 16 | Distribution.__init__(self, attrs) 17 | 18 | def has_scons_scripts(self): 19 | return bool(self.scons_data) 20 | -------------------------------------------------------------------------------- /numpy/random/bit_generator.pxd: -------------------------------------------------------------------------------- 1 | 2 | from .common cimport bitgen_t 3 | cimport numpy as np 4 | 5 | cdef class BitGenerator(): 6 | cdef readonly object _seed_seq 7 | cdef readonly object lock 8 | cdef bitgen_t _bitgen 9 | cdef readonly object _ctypes 10 | cdef readonly object _cffi 11 | cdef readonly object capsule 12 | 13 | 14 | cdef class SeedSequence(): 15 | cdef readonly object entropy 16 | cdef readonly tuple spawn_key 17 | cdef readonly int pool_size 18 | cdef readonly object pool 19 | cdef readonly int n_children_spawned 20 | 21 | cdef mix_entropy(self, np.ndarray[np.npy_uint32, ndim=1] mixer, 22 | np.ndarray[np.npy_uint32, ndim=1] entropy_array) 23 | cdef get_assembled_entropy(self) 24 | 25 | cdef class SeedlessSequence(): 26 | pass 27 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/dot2_dot3.rst: -------------------------------------------------------------------------------- 1 | .. _dot2-dot3: 2 | 3 | ======================================== 4 | Two and three dots in difference specs 5 | ======================================== 6 | 7 | Thanks to Yarik Halchenko for this explanation. 8 | 9 | Imagine a series of commits A, B, C, D... Imagine that there are two 10 | branches, *topic* and *master*. You branched *topic* off *master* when 11 | *master* was at commit 'E'. The graph of the commits looks like this:: 12 | 13 | 14 | A---B---C topic 15 | / 16 | D---E---F---G master 17 | 18 | Then:: 19 | 20 | git diff master..topic 21 | 22 | will output the difference from G to C (i.e. with effects of F and G), 23 | while:: 24 | 25 | git diff master...topic 26 | 27 | would output just differences in the topic branch (i.e. only A, B, and 28 | C). 29 | -------------------------------------------------------------------------------- /numpy/linalg/tests/test_deprecations.py: -------------------------------------------------------------------------------- 1 | """Test deprecation and future warnings. 2 | 3 | """ 4 | from __future__ import division, absolute_import, print_function 5 | 6 | import numpy as np 7 | from numpy.testing import assert_warns 8 | 9 | 10 | def test_qr_mode_full_future_warning(): 11 | """Check mode='full' FutureWarning. 12 | 13 | In numpy 1.8 the mode options 'full' and 'economic' in linalg.qr were 14 | deprecated. The release date will probably be sometime in the summer 15 | of 2013. 16 | 17 | """ 18 | a = np.eye(2) 19 | assert_warns(DeprecationWarning, np.linalg.qr, a, mode='full') 20 | assert_warns(DeprecationWarning, np.linalg.qr, a, mode='f') 21 | assert_warns(DeprecationWarning, np.linalg.qr, a, mode='economic') 22 | assert_warns(DeprecationWarning, np.linalg.qr, a, mode='e') 23 | -------------------------------------------------------------------------------- /numpy/core/include/numpy/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __NUMPY_UTILS_HEADER__ 2 | #define __NUMPY_UTILS_HEADER__ 3 | 4 | #ifndef __COMP_NPY_UNUSED 5 | #if defined(__GNUC__) 6 | #define __COMP_NPY_UNUSED __attribute__ ((__unused__)) 7 | # elif defined(__ICC) 8 | #define __COMP_NPY_UNUSED __attribute__ ((__unused__)) 9 | # elif defined(__clang__) 10 | #define __COMP_NPY_UNUSED __attribute__ ((unused)) 11 | #else 12 | #define __COMP_NPY_UNUSED 13 | #endif 14 | #endif 15 | 16 | /* Use this to tag a variable as not used. It will remove unused variable 17 | * warning on support platforms (see __COM_NPY_UNUSED) and mangle the variable 18 | * to avoid accidental use */ 19 | #define NPY_UNUSED(x) (__NPY_UNUSED_TAGGED ## x) __COMP_NPY_UNUSED 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /tools/swig/test/Fortran.h: -------------------------------------------------------------------------------- 1 | #ifndef FORTRAN_H 2 | #define FORTRAN_H 3 | 4 | #define TEST_FUNC_PROTOS(TYPE, SNAME) \ 5 | \ 6 | TYPE SNAME ## SecondElement( TYPE * matrix, int rows, int cols); \ 7 | 8 | TEST_FUNC_PROTOS(signed char , schar ) 9 | TEST_FUNC_PROTOS(unsigned char , uchar ) 10 | TEST_FUNC_PROTOS(short , short ) 11 | TEST_FUNC_PROTOS(unsigned short , ushort ) 12 | TEST_FUNC_PROTOS(int , int ) 13 | TEST_FUNC_PROTOS(unsigned int , uint ) 14 | TEST_FUNC_PROTOS(long , long ) 15 | TEST_FUNC_PROTOS(unsigned long , ulong ) 16 | TEST_FUNC_PROTOS(long long , longLong ) 17 | TEST_FUNC_PROTOS(unsigned long long, ulongLong) 18 | TEST_FUNC_PROTOS(float , float ) 19 | TEST_FUNC_PROTOS(double , double ) 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /numpy/core/include/numpy/oldnumeric.h: -------------------------------------------------------------------------------- 1 | #include "arrayobject.h" 2 | 3 | #ifndef PYPY_VERSION 4 | #ifndef REFCOUNT 5 | # define REFCOUNT NPY_REFCOUNT 6 | # define MAX_ELSIZE 16 7 | #endif 8 | #endif 9 | 10 | #define PyArray_UNSIGNED_TYPES 11 | #define PyArray_SBYTE NPY_BYTE 12 | #define PyArray_CopyArray PyArray_CopyInto 13 | #define _PyArray_multiply_list PyArray_MultiplyIntList 14 | #define PyArray_ISSPACESAVER(m) NPY_FALSE 15 | #define PyScalarArray_Check PyArray_CheckScalar 16 | 17 | #define CONTIGUOUS NPY_CONTIGUOUS 18 | #define OWN_DIMENSIONS 0 19 | #define OWN_STRIDES 0 20 | #define OWN_DATA NPY_OWNDATA 21 | #define SAVESPACE 0 22 | #define SAVESPACEBIT 0 23 | 24 | #undef import_array 25 | #define import_array() { if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); } } 26 | -------------------------------------------------------------------------------- /numpy/core/src/common/npy_longdouble.h: -------------------------------------------------------------------------------- 1 | #ifndef __NPY_LONGDOUBLE_H 2 | #define __NPY_LONGDOUBLE_H 3 | 4 | #include "npy_config.h" 5 | #include "numpy/ndarraytypes.h" 6 | 7 | /* Convert a npy_longdouble to a python `long` integer. 8 | * 9 | * Results are rounded towards zero. 10 | * 11 | * This performs the same task as PyLong_FromDouble, but for long doubles 12 | * which have a greater range. 13 | */ 14 | NPY_VISIBILITY_HIDDEN PyObject * 15 | npy_longdouble_to_PyLong(npy_longdouble ldval); 16 | 17 | /* Convert a python `long` integer to a npy_longdouble 18 | * 19 | * This performs the same task as PyLong_AsDouble, but for long doubles 20 | * which have a greater range. 21 | * 22 | * Returns -1 if an error occurs. 23 | */ 24 | NPY_VISIBILITY_HIDDEN npy_longdouble 25 | npy_longdouble_from_PyLong(PyObject *long_obj); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /doc/source/reference/routines.matlib.rst: -------------------------------------------------------------------------------- 1 | .. module:: numpy.matlib 2 | 3 | Matrix library (:mod:`numpy.matlib`) 4 | ************************************ 5 | 6 | .. currentmodule:: numpy 7 | 8 | This module contains all functions in the :mod:`numpy` namespace, with 9 | the following replacement functions that return :class:`matrices 10 | ` instead of :class:`ndarrays `. 11 | 12 | .. currentmodule:: numpy 13 | 14 | Functions that are also in the numpy namespace and return matrices 15 | 16 | .. autosummary:: 17 | 18 | mat 19 | matrix 20 | asmatrix 21 | bmat 22 | 23 | 24 | Replacement functions in `matlib` 25 | 26 | .. currentmodule:: numpy.matlib 27 | 28 | .. autosummary:: 29 | :toctree: generated/ 30 | 31 | empty 32 | zeros 33 | ones 34 | eye 35 | identity 36 | repmat 37 | rand 38 | randn 39 | -------------------------------------------------------------------------------- /doc/release/1.6.1-notes.rst: -------------------------------------------------------------------------------- 1 | ========================= 2 | NumPy 1.6.1 Release Notes 3 | ========================= 4 | 5 | This is a bugfix only release in the 1.6.x series. 6 | 7 | 8 | Issues Fixed 9 | ============ 10 | 11 | * #1834: einsum fails for specific shapes 12 | * #1837: einsum throws nan or freezes python for specific array shapes 13 | * #1838: object <-> structured type arrays regression 14 | * #1851: regression for SWIG based code in 1.6.0 15 | * #1863: Buggy results when operating on array copied with astype() 16 | * #1870: Fix corner case of object array assignment 17 | * #1843: Py3k: fix error with recarray 18 | * #1885: nditer: Error in detecting double reduction loop 19 | * #1874: f2py: fix --include_paths bug 20 | * #1749: Fix ctypes.load_library() 21 | * #1895/1896: iter: writeonly operands weren't always being buffered correctly 22 | -------------------------------------------------------------------------------- /doc/changelog/1.14.6-changelog.rst: -------------------------------------------------------------------------------- 1 | 2 | Contributors 3 | ============ 4 | 5 | A total of 4 people contributed to this release. People with a "+" by their 6 | names contributed a patch for the first time. 7 | 8 | * Charles Harris 9 | * Eric Wieser 10 | * Julian Taylor 11 | * Matti Picus 12 | 13 | Pull requests merged 14 | ==================== 15 | 16 | A total of 4 pull requests were merged for this release. 17 | 18 | * `#11985 `__: BUG: fix cached allocations without the GIL 19 | * `#11986 `__: BUG: Undo behavior change in ma.masked_values(shrink=True) 20 | * `#11987 `__: BUG: fix refcount leak in PyArray_AdaptFlexibleDType 21 | * `#11995 `__: TST: Add Python 3.7 testing to NumPy 1.14. 22 | -------------------------------------------------------------------------------- /numpy/random/src/philox/philox.c: -------------------------------------------------------------------------------- 1 | #include "philox.h" 2 | 3 | extern NPY_INLINE uint64_t philox_next64(philox_state *state); 4 | 5 | extern NPY_INLINE uint32_t philox_next32(philox_state *state); 6 | 7 | extern void philox_jump(philox_state *state) { 8 | /* Advances state as-if 2^128 draws were made */ 9 | state->ctr->v[2]++; 10 | if (state->ctr->v[2] == 0) { 11 | state->ctr->v[3]++; 12 | } 13 | } 14 | 15 | extern void philox_advance(uint64_t *step, philox_state *state) { 16 | int i, carry = 0; 17 | uint64_t v_orig; 18 | for (i = 0; i < 4; i++) { 19 | if (carry == 1) { 20 | state->ctr->v[i]++; 21 | carry = state->ctr->v[i] == 0 ? 1 : 0; 22 | } 23 | v_orig = state->ctr->v[i]; 24 | state->ctr->v[i] += step[i]; 25 | if (state->ctr->v[i] < v_orig && carry == 0) { 26 | carry = 1; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /doc/changelog/1.15.4-changelog.rst: -------------------------------------------------------------------------------- 1 | 2 | Contributors 3 | ============ 4 | 5 | A total of 4 people contributed to this release. People with a "+" by their 6 | names contributed a patch for the first time. 7 | 8 | * Charles Harris 9 | * Matti Picus 10 | * Sebastian Berg 11 | * bbbbbbbbba + 12 | 13 | Pull requests merged 14 | ==================== 15 | 16 | A total of 4 pull requests were merged for this release. 17 | 18 | * `#12296 `__: BUG: Dealloc cached buffer info (#12249) 19 | * `#12297 `__: BUG: Fix fill value in masked array '==' and '!=' ops. 20 | * `#12307 `__: DOC: Correct the default value of `optimize` in `numpy.einsum` 21 | * `#12320 `__: REL: Prepare for the NumPy 1.15.4 release 22 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/index.rst: -------------------------------------------------------------------------------- 1 | .. _using-git: 2 | .. _git-development: 3 | 4 | ===================== 5 | Git for development 6 | ===================== 7 | 8 | These pages describe a general git_ and github_ workflow. 9 | 10 | This is not a comprehensive git_ reference. It's tailored to the github_ 11 | hosting service. You may well find better or quicker ways of getting stuff done 12 | with git_, but these should get you started. 13 | 14 | For general resources for learning git_ see :ref:`git-resources`. 15 | 16 | Have a look at the github_ install help pages available from `github help`_ 17 | 18 | .. _install-git: 19 | 20 | 21 | Contents: 22 | 23 | .. toctree:: 24 | :maxdepth: 2 25 | 26 | git_intro 27 | following_latest 28 | development_setup 29 | configure_git 30 | dot2_dot3 31 | git_resources 32 | 33 | .. include:: git_links.inc 34 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/datetime_busday.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE__DATETIME_BUSDAY_H_ 2 | #define _NPY_PRIVATE__DATETIME_BUSDAY_H_ 3 | 4 | /* 5 | * This is the 'busday_offset' function exposed for calling 6 | * from Python. 7 | */ 8 | NPY_NO_EXPORT PyObject * 9 | array_busday_offset(PyObject *NPY_UNUSED(self), 10 | PyObject *args, PyObject *kwds); 11 | 12 | /* 13 | * This is the 'busday_count' function exposed for calling 14 | * from Python. 15 | */ 16 | NPY_NO_EXPORT PyObject * 17 | array_busday_count(PyObject *NPY_UNUSED(self), 18 | PyObject *args, PyObject *kwds); 19 | 20 | /* 21 | * This is the 'is_busday' function exposed for calling 22 | * from Python. 23 | */ 24 | NPY_NO_EXPORT PyObject * 25 | array_is_busday(PyObject *NPY_UNUSED(self), 26 | PyObject *args, PyObject *kwds); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /LICENSES_bundled.txt: -------------------------------------------------------------------------------- 1 | The NumPy repository and source distributions bundle several libraries that are 2 | compatibly licensed. We list these here. 3 | 4 | Name: Numpydoc 5 | Files: doc/sphinxext/numpydoc/* 6 | License: 2-clause BSD 7 | For details, see doc/sphinxext/LICENSE.txt 8 | 9 | Name: scipy-sphinx-theme 10 | Files: doc/scipy-sphinx-theme/* 11 | License: 3-clause BSD, PSF and Apache 2.0 12 | For details, see doc/scipy-sphinx-theme/LICENSE.txt 13 | 14 | Name: lapack-lite 15 | Files: numpy/linalg/lapack_lite/* 16 | License: 3-clause BSD 17 | For details, see numpy/linalg/lapack_lite/LICENSE.txt 18 | 19 | Name: tempita 20 | Files: tools/npy_tempita/* 21 | License: BSD derived 22 | For details, see tools/npy_tempita/license.txt 23 | 24 | Name: dragon4 25 | Files: numpy/core/src/multiarray/dragon4.c 26 | License: MIT 27 | For license text, see numpy/core/src/multiarray/dragon4.c 28 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/multiarraymodule.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_MULTIARRAY_H_ 2 | #define _NPY_MULTIARRAY_H_ 3 | 4 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_array; 5 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_array_prepare; 6 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_array_wrap; 7 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_array_finalize; 8 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_ufunc; 9 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_implementation; 10 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_order; 11 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_copy; 12 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_dtype; 13 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_ndmin; 14 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_axis1; 15 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_axis2; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /numpy/distutils/pathccompiler.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | from distutils.unixccompiler import UnixCCompiler 4 | 5 | class PathScaleCCompiler(UnixCCompiler): 6 | 7 | """ 8 | PathScale compiler compatible with an gcc built Python. 9 | """ 10 | 11 | compiler_type = 'pathcc' 12 | cc_exe = 'pathcc' 13 | cxx_exe = 'pathCC' 14 | 15 | def __init__ (self, verbose=0, dry_run=0, force=0): 16 | UnixCCompiler.__init__ (self, verbose, dry_run, force) 17 | cc_compiler = self.cc_exe 18 | cxx_compiler = self.cxx_exe 19 | self.set_executables(compiler=cc_compiler, 20 | compiler_so=cc_compiler, 21 | compiler_cxx=cxx_compiler, 22 | linker_exe=cc_compiler, 23 | linker_so=cc_compiler + ' -shared') 24 | -------------------------------------------------------------------------------- /numpy/distutils/command/bdist_rpm.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | import sys 5 | if 'setuptools' in sys.modules: 6 | from setuptools.command.bdist_rpm import bdist_rpm as old_bdist_rpm 7 | else: 8 | from distutils.command.bdist_rpm import bdist_rpm as old_bdist_rpm 9 | 10 | class bdist_rpm(old_bdist_rpm): 11 | 12 | def _make_spec_file(self): 13 | spec_file = old_bdist_rpm._make_spec_file(self) 14 | 15 | # Replace hardcoded setup.py script name 16 | # with the real setup script name. 17 | setup_py = os.path.basename(sys.argv[0]) 18 | if setup_py == 'setup.py': 19 | return spec_file 20 | new_spec_file = [] 21 | for line in spec_file: 22 | line = line.replace('setup.py', setup_py) 23 | new_spec_file.append(line) 24 | return new_spec_file 25 | -------------------------------------------------------------------------------- /doc/changelog/1.15.2-changelog.rst: -------------------------------------------------------------------------------- 1 | 2 | Contributors 3 | ============ 4 | 5 | A total of 4 people contributed to this release. People with a "+" by their 6 | names contributed a patch for the first time. 7 | 8 | * Charles Harris 9 | * Julian Taylor 10 | * Marten van Kerkwijk 11 | * Matti Picus 12 | 13 | Pull requests merged 14 | ==================== 15 | 16 | A total of 4 pull requests were merged for this release. 17 | 18 | * `#11902 `__: BUG: Fix matrix PendingDeprecationWarning suppression for pytest... 19 | * `#11981 `__: BUG: fix cached allocations without the GIL for 1.15.x 20 | * `#11982 `__: BUG: fix refcount leak in PyArray_AdaptFlexibleDType 21 | * `#11992 `__: BUG: Ensure boolean indexing of subclasses sets base correctly. 22 | -------------------------------------------------------------------------------- /tools/travis-before-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | uname -a 4 | free -m 5 | df -h 6 | ulimit -a 7 | 8 | if [ -n "$PPC64_LE" ]; then 9 | pwd 10 | ls -ltrh 11 | target=$(python tools/openblas_support.py) 12 | sudo cp -r $target/64/lib/* /usr/lib 13 | sudo cp $target/64/include/* /usr/include 14 | fi 15 | 16 | mkdir builds 17 | pushd builds 18 | 19 | # Build into own virtualenv 20 | # We therefore control our own environment, avoid travis' numpy 21 | pip install -U virtualenv 22 | 23 | if [ -n "$USE_DEBUG" ] 24 | then 25 | virtualenv --python=python3-dbg venv 26 | else 27 | virtualenv --python=python venv 28 | fi 29 | 30 | source venv/bin/activate 31 | python -V 32 | 33 | if [ -n "$INSTALL_PICKLE5" ]; then 34 | pip install pickle5 35 | fi 36 | 37 | 38 | pip install --upgrade pip setuptools 39 | pip install pytz cython pytest 40 | if [ -n "$USE_ASV" ]; then pip install asv; fi 41 | popd 42 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_regression.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | import pytest 5 | 6 | import numpy as np 7 | from numpy.testing import assert_raises, assert_equal 8 | 9 | from . import util 10 | 11 | 12 | def _path(*a): 13 | return os.path.join(*((os.path.dirname(__file__),) + a)) 14 | 15 | 16 | class TestIntentInOut(util.F2PyTest): 17 | # Check that intent(in out) translates as intent(inout) 18 | sources = [_path('src', 'regression', 'inout.f90')] 19 | 20 | @pytest.mark.slow 21 | def test_inout(self): 22 | # non-contiguous should raise error 23 | x = np.arange(6, dtype=np.float32)[::2] 24 | assert_raises(ValueError, self.module.foo, x) 25 | 26 | # check values with contiguous array 27 | x = np.arange(3, dtype=np.float32) 28 | self.module.foo(x) 29 | assert_equal(x, [3, 1, 2]) 30 | -------------------------------------------------------------------------------- /doc/source/_templates/searchbox.html: -------------------------------------------------------------------------------- 1 | {# 2 | basic/searchbox.html 3 | ~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Sphinx sidebar template: quick search box. 6 | 7 | :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | #} 10 | {%- if pagename != "search" and builder != "singlehtml" %} 11 | 22 | 23 | {%- endif %} 24 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/alloc.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_ALLOC_H_ 2 | #define _NPY_ARRAY_ALLOC_H_ 3 | #define NPY_NO_DEPRECATED_API NPY_API_VERSION 4 | #define _MULTIARRAYMODULE 5 | #include 6 | 7 | #define NPY_TRACE_DOMAIN 389047 8 | 9 | NPY_NO_EXPORT void * 10 | npy_alloc_cache(npy_uintp sz); 11 | 12 | NPY_NO_EXPORT void * 13 | npy_alloc_cache_zero(npy_uintp sz); 14 | 15 | NPY_NO_EXPORT void 16 | npy_free_cache(void * p, npy_uintp sd); 17 | 18 | NPY_NO_EXPORT void * 19 | npy_alloc_cache_dim(npy_uintp sz); 20 | 21 | NPY_NO_EXPORT void 22 | npy_free_cache_dim(void * p, npy_uintp sd); 23 | 24 | static NPY_INLINE void 25 | npy_free_cache_dim_obj(PyArray_Dims dims) 26 | { 27 | npy_free_cache_dim(dims.ptr, dims.len); 28 | } 29 | 30 | static NPY_INLINE void 31 | npy_free_cache_dim_array(PyArrayObject * arr) 32 | { 33 | npy_free_cache_dim(PyArray_DIMS(arr), PyArray_NDIM(arr)); 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /numpy/random/examples/cython/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Build the demos 4 | 5 | Usage: python setup.py build_ext -i 6 | """ 7 | 8 | import numpy as np 9 | from distutils.core import setup 10 | from Cython.Build import cythonize 11 | from setuptools.extension import Extension 12 | from os.path import join 13 | 14 | extending = Extension("extending", 15 | sources=['extending.pyx'], 16 | include_dirs=[np.get_include()]) 17 | distributions = Extension("extending_distributions", 18 | sources=['extending_distributions.pyx', 19 | join('..', '..', 'src', 20 | 'distributions', 'distributions.c')], 21 | include_dirs=[np.get_include()]) 22 | 23 | extensions = [extending, distributions] 24 | 25 | setup( 26 | ext_modules=cythonize(extensions) 27 | ) 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ### Reproducing code example: 5 | 6 | 8 | 9 | ```python 10 | import numpy as np 11 | << your code here >> 12 | ``` 13 | 14 | 15 | 16 | ### Error message: 17 | 18 | 21 | 22 | 23 | 24 | ### Numpy/Python version information: 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /doc/release/1.8.2-notes.rst: -------------------------------------------------------------------------------- 1 | ========================= 2 | NumPy 1.8.2 Release Notes 3 | ========================= 4 | 5 | This is a bugfix only release in the 1.8.x series. 6 | 7 | Issues fixed 8 | ============ 9 | 10 | * gh-4836: partition produces wrong results for multiple selections in equal ranges 11 | * gh-4656: Make fftpack._raw_fft threadsafe 12 | * gh-4628: incorrect argument order to _copyto in in np.nanmax, np.nanmin 13 | * gh-4642: Hold GIL for converting dtypes types with fields 14 | * gh-4733: fix np.linalg.svd(b, compute_uv=False) 15 | * gh-4853: avoid unaligned simd load on reductions on i386 16 | * gh-4722: Fix seg fault converting empty string to object 17 | * gh-4613: Fix lack of NULL check in array_richcompare 18 | * gh-4774: avoid unaligned access for strided byteswap 19 | * gh-650: Prevent division by zero when creating arrays from some buffers 20 | * gh-4602: ifort has issues with optimization flag O2, use O1 21 | -------------------------------------------------------------------------------- /doc/release/1.11.3-notes.rst: -------------------------------------------------------------------------------- 1 | ========================== 2 | NumPy 1.11.3 Release Notes 3 | ========================== 4 | 5 | Numpy 1.11.3 fixes a bug that leads to file corruption when very large files 6 | opened in append mode are used in ``ndarray.tofile``. It supports Python 7 | versions 2.6 - 2.7 and 3.2 - 3.5. Wheels for Linux, Windows, and OS X can be 8 | found on PyPI. 9 | 10 | 11 | Contributors to maintenance/1.11.3 12 | ================================== 13 | 14 | A total of 2 people contributed to this release. People with a "+" by their 15 | names contributed a patch for the first time. 16 | 17 | - Charles Harris 18 | - Pavel Potocek + 19 | 20 | Pull Requests Merged 21 | ==================== 22 | 23 | - `#8341 `__: BUG: Fix ndarray.tofile large file corruption in append mode. 24 | - `#8346 `__: TST: Fix tests in PR #8341 for NumPy 1.11.x 25 | 26 | -------------------------------------------------------------------------------- /numpy/distutils/command/sdist.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import sys 4 | if 'setuptools' in sys.modules: 5 | from setuptools.command.sdist import sdist as old_sdist 6 | else: 7 | from distutils.command.sdist import sdist as old_sdist 8 | 9 | from numpy.distutils.misc_util import get_data_files 10 | 11 | class sdist(old_sdist): 12 | 13 | def add_defaults (self): 14 | old_sdist.add_defaults(self) 15 | 16 | dist = self.distribution 17 | 18 | if dist.has_data_files(): 19 | for data in dist.data_files: 20 | self.filelist.extend(get_data_files(data)) 21 | 22 | if dist.has_headers(): 23 | headers = [] 24 | for h in dist.headers: 25 | if isinstance(h, str): headers.append(h) 26 | else: headers.append(h[1]) 27 | self.filelist.extend(headers) 28 | 29 | return 30 | -------------------------------------------------------------------------------- /changelog/template.rst: -------------------------------------------------------------------------------- 1 | {% for section, _ in sections.items() %} 2 | {% set underline = underlines[0] %}{% if section %}{{section}} 3 | {{ underline * section|length }}{% set underline = underlines[1] %} 4 | 5 | {% endif %} 6 | 7 | {% if sections[section] %} 8 | {% for category, val in definitions.items() if category in sections[section]%} 9 | {{ definitions[category]['name'] }} 10 | {{ underline * definitions[category]['name']|length }} 11 | 12 | {% if definitions[category]['showcontent'] %} 13 | {% for text, values in sections[section][category].items() %} 14 | {{ text }} ({{ values|join(', ') }}) 15 | {% endfor %} 16 | 17 | {% else %} 18 | - {{ sections[section][category]['']|join(', ') }} 19 | 20 | {% endif %} 21 | {% if sections[section][category]|length == 0 %} 22 | No significant changes. 23 | 24 | {% else %} 25 | {% endif %} 26 | 27 | {% endfor %} 28 | {% else %} 29 | No significant changes. 30 | 31 | 32 | {% endif %} 33 | {% endfor %} 34 | -------------------------------------------------------------------------------- /numpy/random/src/mt19937/mt19937-benchmark.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cl mt19937-benchmark.c mt19937.c /Ox 3 | * Measure-Command { .\mt19937-benchmark.exe } 4 | * 5 | * gcc mt19937-benchmark.c mt19937.c -O3 -o mt19937-benchmark 6 | * time ./mt19937-benchmark 7 | */ 8 | #include "mt19937.h" 9 | #include 10 | #include 11 | #include 12 | 13 | #define Q 1000000000 14 | 15 | int main() { 16 | int i; 17 | uint32_t seed = 0x0; 18 | uint64_t sum = 0, count = 0; 19 | mt19937_state state; 20 | mt19937_seed(&state, seed); 21 | clock_t begin = clock(); 22 | for (i = 0; i < Q; i++) { 23 | sum += mt19937_next64(&state); 24 | count++; 25 | } 26 | clock_t end = clock(); 27 | double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; 28 | printf("0x%" PRIx64 "\ncount: %" PRIu64 "\n", sum, count); 29 | printf("%" PRIu64 " randoms per second\n", 30 | (uint64_t)(Q / time_spent) / 1000000 * 1000000); 31 | } 32 | -------------------------------------------------------------------------------- /numpy/random/src/splitmix64/splitmix64.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef struct s_splitmix64_state { 4 | uint64_t state; 5 | int has_uint32; 6 | uint32_t uinteger; 7 | } splitmix64_state; 8 | 9 | static inline uint64_t splitmix64_next(uint64_t *state) { 10 | uint64_t z = (state[0] += 0x9e3779b97f4a7c15); 11 | z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9; 12 | z = (z ^ (z >> 27)) * 0x94d049bb133111eb; 13 | return z ^ (z >> 31); 14 | } 15 | 16 | static inline uint64_t splitmix64_next64(splitmix64_state *state) { 17 | return splitmix64_next(&state->state); 18 | } 19 | 20 | static inline uint32_t splitmix64_next32(splitmix64_state *state) { 21 | uint64_t next; 22 | if (state->has_uint32) { 23 | state->has_uint32 = 0; 24 | return state->uinteger; 25 | } 26 | next = splitmix64_next64(state); 27 | state->has_uint32 = 1; 28 | state->uinteger = (uint32_t)(next >> 32); 29 | return (uint32_t)(next & 0xffffffff); 30 | } 31 | -------------------------------------------------------------------------------- /tools/swig/Makefile: -------------------------------------------------------------------------------- 1 | # List all of the subdirectories here for recursive make 2 | SUBDIRS = test 3 | 4 | # Default target 5 | .PHONY : default 6 | default: 7 | @echo "There is no default make target for this Makefile" 8 | @echo "Valid make targets are:" 9 | @echo " test - Compile and run tests of numpy.i" 10 | @echo " doc - Generate numpy.i documentation" 11 | @echo " all - make test + doc" 12 | @echo " clean - Remove generated files recursively" 13 | 14 | # Target all 15 | .PHONY : all 16 | all: $(SUBDIRS) 17 | 18 | # Target test 19 | .PHONY : test 20 | test: 21 | cd $@ && make $@ 22 | 23 | # Target clean 24 | .PHONY : clean 25 | clean: 26 | @for dir in $(SUBDIRS); do \ 27 | echo ; \ 28 | echo Running \'make clean\' in $$dir; \ 29 | cd $$dir && make clean && cd ..; \ 30 | done; \ 31 | echo 32 | -------------------------------------------------------------------------------- /numpy/random/bounded_integers.pxd.in: -------------------------------------------------------------------------------- 1 | from libc.stdint cimport (uint8_t, uint16_t, uint32_t, uint64_t, 2 | int8_t, int16_t, int32_t, int64_t, intptr_t) 3 | import numpy as np 4 | cimport numpy as np 5 | ctypedef np.npy_bool bool_t 6 | 7 | from .common cimport bitgen_t 8 | 9 | cdef inline uint64_t _gen_mask(uint64_t max_val) nogil: 10 | """Mask generator for use in bounded random numbers""" 11 | # Smallest bit mask >= max 12 | cdef uint64_t mask = max_val 13 | mask |= mask >> 1 14 | mask |= mask >> 2 15 | mask |= mask >> 4 16 | mask |= mask >> 8 17 | mask |= mask >> 16 18 | mask |= mask >> 32 19 | return mask 20 | {{ 21 | py: 22 | inttypes = ('uint64','uint32','uint16','uint8','bool','int64','int32','int16','int8') 23 | }} 24 | {{for inttype in inttypes}} 25 | cdef object _rand_{{inttype}}(object low, object high, object size, bint use_masked, bint closed, bitgen_t *state, object lock) 26 | {{endfor}} 27 | -------------------------------------------------------------------------------- /numpy/core/include/numpy/npy_os.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_OS_H_ 2 | #define _NPY_OS_H_ 3 | 4 | #if defined(linux) || defined(__linux) || defined(__linux__) 5 | #define NPY_OS_LINUX 6 | #elif defined(__FreeBSD__) || defined(__NetBSD__) || \ 7 | defined(__OpenBSD__) || defined(__DragonFly__) 8 | #define NPY_OS_BSD 9 | #ifdef __FreeBSD__ 10 | #define NPY_OS_FREEBSD 11 | #elif defined(__NetBSD__) 12 | #define NPY_OS_NETBSD 13 | #elif defined(__OpenBSD__) 14 | #define NPY_OS_OPENBSD 15 | #elif defined(__DragonFly__) 16 | #define NPY_OS_DRAGONFLY 17 | #endif 18 | #elif defined(sun) || defined(__sun) 19 | #define NPY_OS_SOLARIS 20 | #elif defined(__CYGWIN__) 21 | #define NPY_OS_CYGWIN 22 | #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 23 | #define NPY_OS_WIN32 24 | #elif defined(__APPLE__) 25 | #define NPY_OS_DARWIN 26 | #else 27 | #define NPY_OS_UNKNOWN 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /numpy/core/src/umath/extobj.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE__EXTOBJ_H_ 2 | #define _NPY_PRIVATE__EXTOBJ_H_ 3 | 4 | #include /* for NPY_NO_EXPORT */ 5 | 6 | NPY_NO_EXPORT int 7 | _error_handler(int method, PyObject *errobj, char *errtype, int retstatus, int *first); 8 | 9 | NPY_NO_EXPORT PyObject * 10 | get_global_ext_obj(void); 11 | 12 | NPY_NO_EXPORT int 13 | _extract_pyvals(PyObject *ref, const char *name, int *bufsize, 14 | int *errmask, PyObject **errobj); 15 | 16 | NPY_NO_EXPORT int 17 | _check_ufunc_fperr(int errmask, PyObject *extobj, const char *ufunc_name); 18 | 19 | NPY_NO_EXPORT int 20 | _get_bufsize_errmask(PyObject * extobj, const char *ufunc_name, 21 | int *buffersize, int *errormask); 22 | 23 | /********************/ 24 | #define USE_USE_DEFAULTS 1 25 | /********************/ 26 | 27 | #if USE_USE_DEFAULTS==1 28 | NPY_NO_EXPORT int 29 | ufunc_update_use_defaults(void); 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /doc/source/reference/index.rst: -------------------------------------------------------------------------------- 1 | .. _reference: 2 | 3 | ############### 4 | NumPy Reference 5 | ############### 6 | 7 | :Release: |version| 8 | :Date: |today| 9 | 10 | 11 | .. module:: numpy 12 | 13 | This reference manual details functions, modules, and objects 14 | included in NumPy, describing what they are and what they do. 15 | For learning how to use NumPy, see also :ref:`user`. 16 | 17 | 18 | .. toctree:: 19 | :maxdepth: 2 20 | 21 | arrays 22 | constants 23 | ufuncs 24 | routines 25 | distutils 26 | distutils_guide 27 | c-api/index 28 | internals 29 | swig 30 | 31 | 32 | Acknowledgements 33 | ================ 34 | 35 | Large parts of this manual originate from Travis E. Oliphant's book 36 | `Guide to NumPy `__ (which generously 37 | entered Public Domain in August 2008). The reference documentation for many of 38 | the functions are written by numerous contributors and developers of 39 | NumPy. 40 | -------------------------------------------------------------------------------- /doc/source/reference/routines.statistics.rst: -------------------------------------------------------------------------------- 1 | Statistics 2 | ========== 3 | 4 | .. currentmodule:: numpy 5 | 6 | 7 | Order statistics 8 | ---------------- 9 | 10 | .. autosummary:: 11 | :toctree: generated/ 12 | 13 | amin 14 | amax 15 | nanmin 16 | nanmax 17 | ptp 18 | percentile 19 | nanpercentile 20 | quantile 21 | nanquantile 22 | 23 | Averages and variances 24 | ---------------------- 25 | 26 | .. autosummary:: 27 | :toctree: generated/ 28 | 29 | median 30 | average 31 | mean 32 | std 33 | var 34 | nanmedian 35 | nanmean 36 | nanstd 37 | nanvar 38 | 39 | Correlating 40 | ----------- 41 | 42 | .. autosummary:: 43 | :toctree: generated/ 44 | 45 | corrcoef 46 | correlate 47 | cov 48 | 49 | Histograms 50 | ---------- 51 | 52 | .. autosummary:: 53 | :toctree: generated/ 54 | 55 | histogram 56 | histogram2d 57 | histogramdd 58 | bincount 59 | histogram_bin_edges 60 | digitize 61 | -------------------------------------------------------------------------------- /numpy/distutils/fcompiler/none.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | from numpy.distutils.fcompiler import FCompiler 4 | from numpy.distutils import customized_fcompiler 5 | 6 | compilers = ['NoneFCompiler'] 7 | 8 | class NoneFCompiler(FCompiler): 9 | 10 | compiler_type = 'none' 11 | description = 'Fake Fortran compiler' 12 | 13 | executables = {'compiler_f77': None, 14 | 'compiler_f90': None, 15 | 'compiler_fix': None, 16 | 'linker_so': None, 17 | 'linker_exe': None, 18 | 'archiver': None, 19 | 'ranlib': None, 20 | 'version_cmd': None, 21 | } 22 | 23 | def find_executables(self): 24 | pass 25 | 26 | 27 | if __name__ == '__main__': 28 | from distutils import log 29 | log.set_verbosity(2) 30 | print(customized_fcompiler(compiler='none').get_version()) 31 | -------------------------------------------------------------------------------- /doc/source/f2py/allocarr_session.dat: -------------------------------------------------------------------------------- 1 | >>> import allocarr 2 | >>> print allocarr.mod.__doc__ 3 | b - 'f'-array(-1,-1), not allocated 4 | foo - Function signature: 5 | foo() 6 | 7 | >>> allocarr.mod.foo() 8 | b is not allocated 9 | >>> allocarr.mod.b = [[1,2,3],[4,5,6]] # allocate/initialize b 10 | >>> allocarr.mod.foo() 11 | b=[ 12 | 1.000000 2.000000 3.000000 13 | 4.000000 5.000000 6.000000 14 | ] 15 | >>> allocarr.mod.b # b is Fortran-contiguous 16 | array([[ 1., 2., 3.], 17 | [ 4., 5., 6.]],'f') 18 | >>> allocarr.mod.b = [[1,2,3],[4,5,6],[7,8,9]] # reallocate/initialize b 19 | >>> allocarr.mod.foo() 20 | b=[ 21 | 1.000000 2.000000 3.000000 22 | 4.000000 5.000000 6.000000 23 | 7.000000 8.000000 9.000000 24 | ] 25 | >>> allocarr.mod.b = None # deallocate array 26 | >>> allocarr.mod.foo() 27 | b is not allocated 28 | -------------------------------------------------------------------------------- /tools/swig/test/Fortran.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "Fortran.h" 5 | 6 | #define TEST_FUNCS(TYPE, SNAME) \ 7 | \ 8 | TYPE SNAME ## SecondElement(TYPE * matrix, int rows, int cols) { \ 9 | TYPE result = matrix[1]; \ 10 | return result; \ 11 | } \ 12 | 13 | TEST_FUNCS(signed char , schar ) 14 | TEST_FUNCS(unsigned char , uchar ) 15 | TEST_FUNCS(short , short ) 16 | TEST_FUNCS(unsigned short , ushort ) 17 | TEST_FUNCS(int , int ) 18 | TEST_FUNCS(unsigned int , uint ) 19 | TEST_FUNCS(long , long ) 20 | TEST_FUNCS(unsigned long , ulong ) 21 | TEST_FUNCS(long long , longLong ) 22 | TEST_FUNCS(unsigned long long, ulongLong) 23 | TEST_FUNCS(float , float ) 24 | TEST_FUNCS(double , double ) 25 | -------------------------------------------------------------------------------- /tools/commitstats.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | # Run svn log -l 4 | 5 | import re 6 | import numpy as np 7 | import os 8 | 9 | names = re.compile(r'r\d+\s[|]\s(.*)\s[|]\s200') 10 | 11 | def get_count(filename, repo): 12 | mystr = open(filename).read() 13 | result = names.findall(mystr) 14 | u = np.unique(result) 15 | count = [(x, result.count(x), repo) for x in u] 16 | return count 17 | 18 | 19 | command = 'svn log -l 2300 > output.txt' 20 | os.chdir('..') 21 | os.system(command) 22 | 23 | count = get_count('output.txt', 'NumPy') 24 | 25 | 26 | os.chdir('../scipy') 27 | os.system(command) 28 | 29 | count.extend(get_count('output.txt', 'SciPy')) 30 | 31 | os.chdir('../scikits') 32 | os.system(command) 33 | count.extend(get_count('output.txt', 'SciKits')) 34 | count.sort() 35 | 36 | 37 | 38 | print("** SciPy and NumPy **") 39 | print("=====================") 40 | for val in count: 41 | print(val) 42 | -------------------------------------------------------------------------------- /doc/changelog/1.14.2-changelog.rst: -------------------------------------------------------------------------------- 1 | 2 | Contributors 3 | ============ 4 | 5 | A total of 4 people contributed to this release. People with a "+" by their 6 | names contributed a patch for the first time. 7 | 8 | * Allan Haldane 9 | * Charles Harris 10 | * Eric Wieser 11 | * Pauli Virtanen 12 | 13 | Pull requests merged 14 | ==================== 15 | 16 | A total of 5 pull requests were merged for this release. 17 | 18 | * `#10674 `__: BUG: Further back-compat fix for subclassed array repr 19 | * `#10725 `__: BUG: dragon4 fractional output mode adds too many trailing zeros 20 | * `#10726 `__: BUG: Fix f2py generated code to work on PyPy 21 | * `#10727 `__: BUG: Fix missing NPY_VISIBILITY_HIDDEN on npy_longdouble_to_PyLong 22 | * `#10729 `__: DOC: Create 1.14.2 notes and changelog. 23 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/arraytypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAYTYPES_H_ 2 | #define _NPY_ARRAYTYPES_H_ 3 | 4 | #include "common.h" 5 | 6 | NPY_NO_EXPORT int 7 | set_typeinfo(PyObject *dict); 8 | 9 | /* needed for blasfuncs */ 10 | NPY_NO_EXPORT void 11 | FLOAT_dot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 12 | 13 | NPY_NO_EXPORT void 14 | CFLOAT_dot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 15 | 16 | NPY_NO_EXPORT void 17 | DOUBLE_dot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 18 | 19 | NPY_NO_EXPORT void 20 | CDOUBLE_dot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 21 | 22 | 23 | /* for _pyarray_correlate */ 24 | NPY_NO_EXPORT int 25 | small_correlate(const char * d_, npy_intp dstride, 26 | npy_intp nd, enum NPY_TYPES dtype, 27 | const char * k_, npy_intp kstride, 28 | npy_intp nk, enum NPY_TYPES ktype, 29 | char * out_, npy_intp ostride); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_common.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | import sys 5 | import pytest 6 | 7 | import numpy as np 8 | from . import util 9 | 10 | from numpy.testing import assert_array_equal 11 | 12 | def _path(*a): 13 | return os.path.join(*((os.path.dirname(__file__),) + a)) 14 | 15 | class TestCommonBlock(util.F2PyTest): 16 | sources = [_path('src', 'common', 'block.f')] 17 | 18 | @pytest.mark.skipif(sys.platform=='win32', 19 | reason='Fails with MinGW64 Gfortran (Issue #9673)') 20 | def test_common_block(self): 21 | self.module.initcb() 22 | assert_array_equal(self.module.block.long_bn, 23 | np.array(1.0, dtype=np.float64)) 24 | assert_array_equal(self.module.block.string_bn, 25 | np.array('2', dtype='|S1')) 26 | assert_array_equal(self.module.block.ok, 27 | np.array(3, dtype=np.int32)) 28 | -------------------------------------------------------------------------------- /doc/source/_templates/autosummary/class.rst: -------------------------------------------------------------------------------- 1 | {% extends "!autosummary/class.rst" %} 2 | 3 | {% block methods %} 4 | {% if methods %} 5 | .. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages. 6 | .. autosummary:: 7 | :toctree: 8 | {% for item in all_methods %} 9 | {%- if not item.startswith('_') or item in ['__call__'] %} 10 | {{ name }}.{{ item }} 11 | {%- endif -%} 12 | {%- endfor %} 13 | {% endif %} 14 | {% endblock %} 15 | 16 | {% block attributes %} 17 | {% if attributes %} 18 | .. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages. 19 | .. autosummary:: 20 | :toctree: 21 | {% for item in all_attributes %} 22 | {%- if not item.startswith('_') %} 23 | {{ name }}.{{ item }} 24 | {%- endif -%} 25 | {%- endfor %} 26 | {% endif %} 27 | {% endblock %} 28 | -------------------------------------------------------------------------------- /doc/source/reference/routines.dtype.rst: -------------------------------------------------------------------------------- 1 | .. _routines.dtype: 2 | 3 | Data type routines 4 | ================== 5 | 6 | .. currentmodule:: numpy 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | can_cast 12 | promote_types 13 | min_scalar_type 14 | result_type 15 | common_type 16 | obj2sctype 17 | 18 | Creating data types 19 | ------------------- 20 | .. autosummary:: 21 | :toctree: generated/ 22 | 23 | dtype 24 | format_parser 25 | 26 | Data type information 27 | --------------------- 28 | .. autosummary:: 29 | :toctree: generated/ 30 | 31 | finfo 32 | iinfo 33 | MachAr 34 | 35 | Data type testing 36 | ----------------- 37 | .. autosummary:: 38 | :toctree: generated/ 39 | 40 | issctype 41 | issubdtype 42 | issubsctype 43 | issubclass_ 44 | find_common_type 45 | 46 | Miscellaneous 47 | ------------- 48 | .. autosummary:: 49 | :toctree: generated/ 50 | 51 | typename 52 | sctype2char 53 | mintypecode 54 | maximum_sctype 55 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/compiled_base.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE__COMPILED_BASE_H_ 2 | #define _NPY_PRIVATE__COMPILED_BASE_H_ 3 | #include 4 | 5 | NPY_NO_EXPORT PyObject * 6 | arr_insert(PyObject *, PyObject *, PyObject *); 7 | NPY_NO_EXPORT PyObject * 8 | arr_bincount(PyObject *, PyObject *, PyObject *); 9 | NPY_NO_EXPORT PyObject * 10 | arr__monotonicity(PyObject *, PyObject *, PyObject *kwds); 11 | NPY_NO_EXPORT PyObject * 12 | arr_interp(PyObject *, PyObject *, PyObject *); 13 | NPY_NO_EXPORT PyObject * 14 | arr_interp_complex(PyObject *, PyObject *, PyObject *); 15 | NPY_NO_EXPORT PyObject * 16 | arr_ravel_multi_index(PyObject *, PyObject *, PyObject *); 17 | NPY_NO_EXPORT PyObject * 18 | arr_unravel_index(PyObject *, PyObject *, PyObject *); 19 | NPY_NO_EXPORT PyObject * 20 | arr_add_docstring(PyObject *, PyObject *); 21 | NPY_NO_EXPORT PyObject * 22 | io_pack(PyObject *, PyObject *, PyObject *); 23 | NPY_NO_EXPORT PyObject * 24 | io_unpack(PyObject *, PyObject *, PyObject *); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /doc/source/reference/routines.other.rst: -------------------------------------------------------------------------------- 1 | Miscellaneous routines 2 | ********************** 3 | 4 | .. toctree:: 5 | 6 | .. currentmodule:: numpy 7 | 8 | Performance tuning 9 | ------------------ 10 | .. autosummary:: 11 | :toctree: generated/ 12 | 13 | setbufsize 14 | getbufsize 15 | 16 | Memory ranges 17 | ------------- 18 | 19 | .. autosummary:: 20 | :toctree: generated/ 21 | 22 | shares_memory 23 | may_share_memory 24 | byte_bounds 25 | 26 | Array mixins 27 | ------------ 28 | .. autosummary:: 29 | :toctree: generated/ 30 | 31 | lib.mixins.NDArrayOperatorsMixin 32 | 33 | NumPy version comparison 34 | ------------------------ 35 | .. autosummary:: 36 | :toctree: generated/ 37 | 38 | lib.NumpyVersion 39 | 40 | Utility 41 | ------- 42 | 43 | .. autosummary:: 44 | :toctree: generated/ 45 | 46 | get_include 47 | deprecate 48 | deprecate_with_doc 49 | 50 | Matlab-like Functions 51 | --------------------- 52 | .. autosummary:: 53 | :toctree: generated/ 54 | 55 | who 56 | disp -------------------------------------------------------------------------------- /numpy/core/src/multiarray/descriptor.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAYDESCR_H_ 2 | #define _NPY_ARRAYDESCR_H_ 3 | 4 | NPY_NO_EXPORT PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *); 5 | NPY_NO_EXPORT PyObject *arraydescr_protocol_descr_get(PyArray_Descr *self); 6 | 7 | NPY_NO_EXPORT PyObject * 8 | array_set_typeDict(PyObject *NPY_UNUSED(ignored), PyObject *args); 9 | 10 | int 11 | _arraydescr_from_dtype_attr(PyObject *obj, PyArray_Descr **newdescr); 12 | 13 | 14 | NPY_NO_EXPORT int 15 | is_dtype_struct_simple_unaligned_layout(PyArray_Descr *dtype); 16 | 17 | /* 18 | * Filter the fields of a dtype to only those in the list of strings, ind. 19 | * 20 | * No type checking is performed on the input. 21 | * 22 | * Raises: 23 | * ValueError - if a field is repeated 24 | * KeyError - if an invalid field name (or any field title) is used 25 | */ 26 | NPY_NO_EXPORT PyArray_Descr * 27 | arraydescr_field_subset_view(PyArray_Descr *self, PyObject *ind); 28 | 29 | extern NPY_NO_EXPORT char *_datetime_strings[]; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /doc/source/f2py/index.rst: -------------------------------------------------------------------------------- 1 | ##################################### 2 | F2PY Users Guide and Reference Manual 3 | ##################################### 4 | 5 | The purpose of the ``F2PY`` --*Fortran to Python interface generator*-- 6 | is to provide a connection between Python and Fortran 7 | languages. F2PY is a part of NumPy_ (``numpy.f2py``) and also available as a 8 | standalone command line tool ``f2py`` when ``numpy`` is installed that 9 | facilitates creating/building Python C/API extension modules that make it 10 | possible 11 | 12 | * to call Fortran 77/90/95 external subroutines and Fortran 90/95 13 | module subroutines as well as C functions; 14 | * to access Fortran 77 ``COMMON`` blocks and Fortran 90/95 module data, 15 | including allocatable arrays 16 | 17 | from Python. 18 | 19 | .. toctree:: 20 | :maxdepth: 2 21 | 22 | getting-started 23 | signature-file 24 | python-usage 25 | usage 26 | distutils 27 | advanced 28 | 29 | .. _Python: https://www.python.org/ 30 | .. _NumPy: https://www.numpy.org/ 31 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/size/foo.f90: -------------------------------------------------------------------------------- 1 | 2 | subroutine foo(a, n, m, b) 3 | implicit none 4 | 5 | real, intent(in) :: a(n, m) 6 | integer, intent(in) :: n, m 7 | real, intent(out) :: b(size(a, 1)) 8 | 9 | integer :: i 10 | 11 | do i = 1, size(b) 12 | b(i) = sum(a(i,:)) 13 | enddo 14 | end subroutine 15 | 16 | subroutine trans(x,y) 17 | implicit none 18 | real, intent(in), dimension(:,:) :: x 19 | real, intent(out), dimension( size(x,2), size(x,1) ) :: y 20 | integer :: N, M, i, j 21 | N = size(x,1) 22 | M = size(x,2) 23 | DO i=1,N 24 | do j=1,M 25 | y(j,i) = x(i,j) 26 | END DO 27 | END DO 28 | end subroutine trans 29 | 30 | subroutine flatten(x,y) 31 | implicit none 32 | real, intent(in), dimension(:,:) :: x 33 | real, intent(out), dimension( size(x) ) :: y 34 | integer :: N, M, i, j, k 35 | N = size(x,1) 36 | M = size(x,2) 37 | k = 1 38 | DO i=1,N 39 | do j=1,M 40 | y(k) = x(i,j) 41 | k = k + 1 42 | END DO 43 | END DO 44 | end subroutine flatten 45 | -------------------------------------------------------------------------------- /numpy/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import division, print_function 3 | 4 | 5 | def configuration(parent_package='',top_path=None): 6 | from numpy.distutils.misc_util import Configuration 7 | config = Configuration('numpy', parent_package, top_path) 8 | 9 | config.add_subpackage('compat') 10 | config.add_subpackage('core') 11 | config.add_subpackage('distutils') 12 | config.add_subpackage('doc') 13 | config.add_subpackage('f2py') 14 | config.add_subpackage('fft') 15 | config.add_subpackage('lib') 16 | config.add_subpackage('linalg') 17 | config.add_subpackage('ma') 18 | config.add_subpackage('matrixlib') 19 | config.add_subpackage('polynomial') 20 | config.add_subpackage('random') 21 | config.add_subpackage('testing') 22 | config.add_data_dir('doc') 23 | config.add_data_dir('tests') 24 | config.make_config_py() # installs __config__.py 25 | return config 26 | 27 | if __name__ == '__main__': 28 | print('This is the wrong setup.py file to run') 29 | -------------------------------------------------------------------------------- /numpy/core/tests/data/umath-validation-set-README: -------------------------------------------------------------------------------- 1 | Steps to validate transcendental functions: 2 | 1) Add a file 'umath-validation-set-', where ufuncname is name of 3 | the function in NumPy you want to validate 4 | 2) The file should contain 4 columns: dtype,input,expected output,ulperror 5 | a. dtype: one of np.float16, np.float32, np.float64 6 | b. input: floating point input to ufunc in hex. Example: 0x414570a4 7 | represents 12.340000152587890625 8 | c. expected output: floating point output for the corresponding input in hex. 9 | This should be computed using a high(er) precision library and then rounded to 10 | same format as the input. 11 | d. ulperror: expected maximum ulp error of the function. This 12 | should be same across all rows of the same dtype. Otherwise, the function is 13 | tested for the maximum ulp error among all entries of that dtype. 14 | 3) Add file umath-validation-set- to the test file test_umath_accuracy.py 15 | which will then validate your ufunc. 16 | -------------------------------------------------------------------------------- /numpy/distutils/command/install_data.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import sys 4 | have_setuptools = ('setuptools' in sys.modules) 5 | 6 | from distutils.command.install_data import install_data as old_install_data 7 | 8 | #data installer with improved intelligence over distutils 9 | #data files are copied into the project directory instead 10 | #of willy-nilly 11 | class install_data (old_install_data): 12 | 13 | def run(self): 14 | old_install_data.run(self) 15 | 16 | if have_setuptools: 17 | # Run install_clib again, since setuptools does not run sub-commands 18 | # of install automatically 19 | self.run_command('install_clib') 20 | 21 | def finalize_options (self): 22 | self.set_undefined_options('install', 23 | ('install_lib', 'install_dir'), 24 | ('root', 'root'), 25 | ('force', 'force'), 26 | ) 27 | -------------------------------------------------------------------------------- /tools/swig/test/Flat.i: -------------------------------------------------------------------------------- 1 | // -*- c++ -*- 2 | %module Flat 3 | 4 | %{ 5 | #define SWIG_FILE_WITH_INIT 6 | #include "Flat.h" 7 | %} 8 | 9 | // Get the NumPy typemaps 10 | %include "../numpy.i" 11 | 12 | %init %{ 13 | import_array(); 14 | %} 15 | 16 | %define %apply_numpy_typemaps(TYPE) 17 | 18 | %apply (TYPE* INPLACE_ARRAY_FLAT, int DIM_FLAT) {(TYPE* array, int size)}; 19 | 20 | %enddef /* %apply_numpy_typemaps() macro */ 21 | 22 | %apply_numpy_typemaps(signed char ) 23 | %apply_numpy_typemaps(unsigned char ) 24 | %apply_numpy_typemaps(short ) 25 | %apply_numpy_typemaps(unsigned short ) 26 | %apply_numpy_typemaps(int ) 27 | %apply_numpy_typemaps(unsigned int ) 28 | %apply_numpy_typemaps(long ) 29 | %apply_numpy_typemaps(unsigned long ) 30 | %apply_numpy_typemaps(long long ) 31 | %apply_numpy_typemaps(unsigned long long) 32 | %apply_numpy_typemaps(float ) 33 | %apply_numpy_typemaps(double ) 34 | 35 | // Include the header file to be wrapped 36 | %include "Flat.h" 37 | -------------------------------------------------------------------------------- /tools/swig/test/Makefile: -------------------------------------------------------------------------------- 1 | # SWIG 2 | INTERFACES = Array.i Farray.i Vector.i Matrix.i Tensor.i Fortran.i Flat.i 3 | WRAPPERS = $(INTERFACES:.i=_wrap.cxx) 4 | PROXIES = $(INTERFACES:.i=.py ) 5 | 6 | # Default target: build the tests 7 | .PHONY : all 8 | all: $(WRAPPERS) Array1.cxx Array1.h Array2.cxx Array2.h ArrayZ.cxx ArrayZ.h \ 9 | Farray.cxx Farray.h Vector.cxx Vector.h \ 10 | Matrix.cxx Matrix.h Tensor.cxx Tensor.h Fortran.h Fortran.cxx \ 11 | Flat.h Flat.cxx 12 | ./setup.py build_ext -i 13 | 14 | # Test target: run the tests 15 | .PHONY : test 16 | test: all 17 | python testVector.py 18 | python testMatrix.py 19 | python testTensor.py 20 | python testArray.py 21 | python testFarray.py 22 | python testFortran.py 23 | python testFlat.py 24 | 25 | # Rule: %.i -> %_wrap.cxx 26 | %_wrap.cxx: %.i %.h ../numpy.i 27 | swig -c++ -python $< 28 | %_wrap.cxx: %.i %1.h %2.h ../numpy.i 29 | swig -c++ -python $< 30 | 31 | # Clean target 32 | .PHONY : clean 33 | clean: 34 | $(RM) -r build 35 | $(RM) *.so 36 | $(RM) $(WRAPPERS) 37 | $(RM) $(PROXIES) 38 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/arrayobject.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_INTERNAL_ARRAYOBJECT_H_ 2 | #define _NPY_INTERNAL_ARRAYOBJECT_H_ 3 | 4 | #ifndef _MULTIARRAYMODULE 5 | #error You should not include this 6 | #endif 7 | 8 | NPY_NO_EXPORT PyObject * 9 | _strings_richcompare(PyArrayObject *self, PyArrayObject *other, int cmp_op, 10 | int rstrip); 11 | 12 | NPY_NO_EXPORT PyObject * 13 | array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op); 14 | 15 | NPY_NO_EXPORT int 16 | array_might_be_written(PyArrayObject *obj); 17 | 18 | /* 19 | * This flag is used to mark arrays which we would like to, in the future, 20 | * turn into views. It causes a warning to be issued on the first attempt to 21 | * write to the array (but the write is allowed to succeed). 22 | * 23 | * This flag is for internal use only, and may be removed in a future release, 24 | * which is why the #define is not exposed to user code. Currently it is set 25 | * on arrays returned by ndarray.diagonal. 26 | */ 27 | static const int NPY_ARRAY_WARN_ON_WRITE = (1 << 31); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /tools/swig/test/Fortran.i: -------------------------------------------------------------------------------- 1 | // -*- c++ -*- 2 | %module Fortran 3 | 4 | %{ 5 | #define SWIG_FILE_WITH_INIT 6 | #include "Fortran.h" 7 | %} 8 | 9 | // Get the NumPy typemaps 10 | %include "../numpy.i" 11 | 12 | %init %{ 13 | import_array(); 14 | %} 15 | 16 | %define %apply_numpy_typemaps(TYPE) 17 | 18 | %apply (TYPE* IN_FARRAY2, int DIM1, int DIM2) {(TYPE* matrix, int rows, int cols)}; 19 | 20 | %enddef /* %apply_numpy_typemaps() macro */ 21 | 22 | %apply_numpy_typemaps(signed char ) 23 | %apply_numpy_typemaps(unsigned char ) 24 | %apply_numpy_typemaps(short ) 25 | %apply_numpy_typemaps(unsigned short ) 26 | %apply_numpy_typemaps(int ) 27 | %apply_numpy_typemaps(unsigned int ) 28 | %apply_numpy_typemaps(long ) 29 | %apply_numpy_typemaps(unsigned long ) 30 | %apply_numpy_typemaps(long long ) 31 | %apply_numpy_typemaps(unsigned long long) 32 | %apply_numpy_typemaps(float ) 33 | %apply_numpy_typemaps(double ) 34 | 35 | // Include the header file to be wrapped 36 | %include "Fortran.h" 37 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/item_selection.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE__ITEM_SELECTION_H_ 2 | #define _NPY_PRIVATE__ITEM_SELECTION_H_ 3 | 4 | /* 5 | * Counts the number of True values in a raw boolean array. This 6 | * is a low-overhead function which does no heap allocations. 7 | * 8 | * Returns -1 on error. 9 | */ 10 | NPY_NO_EXPORT npy_intp 11 | count_boolean_trues(int ndim, char *data, npy_intp *ashape, npy_intp *astrides); 12 | 13 | /* 14 | * Gets a single item from the array, based on a single multi-index 15 | * array of values, which must be of length PyArray_NDIM(self). 16 | */ 17 | NPY_NO_EXPORT PyObject * 18 | PyArray_MultiIndexGetItem(PyArrayObject *self, npy_intp *multi_index); 19 | 20 | /* 21 | * Sets a single item in the array, based on a single multi-index 22 | * array of values, which must be of length PyArray_NDIM(self). 23 | * 24 | * Returns 0 on success, -1 on failure. 25 | */ 26 | NPY_NO_EXPORT int 27 | PyArray_MultiIndexSetItem(PyArrayObject *self, npy_intp *multi_index, 28 | PyObject *obj); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/methods.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_METHODS_H_ 2 | #define _NPY_ARRAY_METHODS_H_ 3 | 4 | #include "npy_import.h" 5 | 6 | extern NPY_NO_EXPORT PyMethodDef array_methods[]; 7 | 8 | NPY_NO_EXPORT const char * 9 | npy_casting_to_string(NPY_CASTING casting); 10 | 11 | /* 12 | * Pathlib support, takes a borrowed reference and returns a new one. 13 | * The new object may be the same as the old. 14 | */ 15 | static inline PyObject * 16 | NpyPath_PathlikeToFspath(PyObject *file) 17 | { 18 | static PyObject *os_PathLike = NULL; 19 | static PyObject *os_fspath = NULL; 20 | npy_cache_import("numpy.compat", "os_PathLike", &os_PathLike); 21 | if (os_PathLike == NULL) { 22 | return NULL; 23 | } 24 | npy_cache_import("numpy.compat", "os_fspath", &os_fspath); 25 | if (os_fspath == NULL) { 26 | return NULL; 27 | } 28 | 29 | if (!PyObject_IsInstance(file, os_PathLike)) { 30 | Py_INCREF(file); 31 | return file; 32 | } 33 | return PyObject_CallFunctionObjArgs(os_fspath, file, NULL); 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_mixed.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | import textwrap 5 | import pytest 6 | 7 | from numpy.testing import assert_, assert_equal 8 | from . import util 9 | 10 | 11 | def _path(*a): 12 | return os.path.join(*((os.path.dirname(__file__),) + a)) 13 | 14 | 15 | class TestMixed(util.F2PyTest): 16 | sources = [_path('src', 'mixed', 'foo.f'), 17 | _path('src', 'mixed', 'foo_fixed.f90'), 18 | _path('src', 'mixed', 'foo_free.f90')] 19 | 20 | @pytest.mark.slow 21 | def test_all(self): 22 | assert_(self.module.bar11() == 11) 23 | assert_(self.module.foo_fixed.bar12() == 12) 24 | assert_(self.module.foo_free.bar13() == 13) 25 | 26 | @pytest.mark.slow 27 | def test_docstring(self): 28 | expected = textwrap.dedent("""\ 29 | a = bar11() 30 | 31 | Wrapper for ``bar11``. 32 | 33 | Returns 34 | ------- 35 | a : int 36 | """) 37 | assert_equal(self.module.bar11.__doc__, expected) 38 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/bench_import.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | 3 | from subprocess import call 4 | from sys import executable 5 | from timeit import default_timer 6 | 7 | from .common import Benchmark 8 | 9 | 10 | class Import(Benchmark): 11 | timer = default_timer 12 | 13 | def execute(self, command): 14 | call((executable, '-c', command)) 15 | 16 | def time_numpy(self): 17 | self.execute('import numpy') 18 | 19 | def time_numpy_inspect(self): 20 | # What are the savings from avoiding to import the inspect module? 21 | self.execute('import numpy, inspect') 22 | 23 | def time_fft(self): 24 | self.execute('from numpy import fft') 25 | 26 | def time_linalg(self): 27 | self.execute('from numpy import linalg') 28 | 29 | def time_ma(self): 30 | self.execute('from numpy import ma') 31 | 32 | def time_matlib(self): 33 | self.execute('from numpy import matlib') 34 | 35 | def time_random(self): 36 | self.execute('from numpy import random') 37 | -------------------------------------------------------------------------------- /numpy/core/src/common/npy_fpmath.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_NPY_FPMATH_H_ 2 | #define _NPY_NPY_FPMATH_H_ 3 | 4 | #include "npy_config.h" 5 | 6 | #include "numpy/npy_os.h" 7 | #include "numpy/npy_cpu.h" 8 | #include "numpy/npy_common.h" 9 | 10 | #if !(defined(HAVE_LDOUBLE_IEEE_QUAD_BE) || \ 11 | defined(HAVE_LDOUBLE_IEEE_QUAD_LE) || \ 12 | defined(HAVE_LDOUBLE_IEEE_DOUBLE_LE) || \ 13 | defined(HAVE_LDOUBLE_IEEE_DOUBLE_BE) || \ 14 | defined(HAVE_LDOUBLE_INTEL_EXTENDED_16_BYTES_LE) || \ 15 | defined(HAVE_LDOUBLE_INTEL_EXTENDED_12_BYTES_LE) || \ 16 | defined(HAVE_LDOUBLE_MOTOROLA_EXTENDED_12_BYTES_BE) || \ 17 | defined(HAVE_LDOUBLE_IBM_DOUBLE_DOUBLE_BE) || \ 18 | defined(HAVE_LDOUBLE_IBM_DOUBLE_DOUBLE_LE)) 19 | #error No long double representation defined 20 | #endif 21 | 22 | /* for back-compat, also keep old name for double-double */ 23 | #ifdef HAVE_LDOUBLE_IBM_DOUBLE_DOUBLE_LE 24 | #define HAVE_LDOUBLE_DOUBLE_DOUBLE_LE 25 | #endif 26 | #ifdef HAVE_LDOUBLE_IBM_DOUBLE_DOUBLE_BE 27 | #define HAVE_LDOUBLE_DOUBLE_DOUBLE_BE 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /numpy/_build_utils/apple_accelerate.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | import sys 5 | import re 6 | 7 | __all__ = ['uses_accelerate_framework', 'get_sgemv_fix'] 8 | 9 | def uses_accelerate_framework(info): 10 | """ Returns True if Accelerate framework is used for BLAS/LAPACK """ 11 | # If we're not building on Darwin (macOS), don't use Accelerate 12 | if sys.platform != "darwin": 13 | return False 14 | # If we're building on macOS, but targeting a different platform, 15 | # don't use Accelerate. 16 | if os.getenv('_PYTHON_HOST_PLATFORM', None): 17 | return False 18 | r_accelerate = re.compile("Accelerate") 19 | extra_link_args = info.get('extra_link_args', '') 20 | for arg in extra_link_args: 21 | if r_accelerate.search(arg): 22 | return True 23 | return False 24 | 25 | def get_sgemv_fix(): 26 | """ Returns source file needed to correct SGEMV """ 27 | path = os.path.abspath(os.path.dirname(__file__)) 28 | return [os.path.join(path, 'src', 'apple_sgemv_fix.c')] 29 | -------------------------------------------------------------------------------- /numpy/core/src/dummymodule.c: -------------------------------------------------------------------------------- 1 | /* -*- c -*- */ 2 | 3 | /* 4 | * This is a dummy module whose purpose is to get distutils to generate the 5 | * configuration files before the libraries are made. 6 | */ 7 | 8 | #define NPY_NO_DEPRECATED_API NPY_API_VERSION 9 | #define NO_IMPORT_ARRAY 10 | 11 | #include 12 | #include 13 | 14 | static struct PyMethodDef methods[] = { 15 | {NULL, NULL, 0, NULL} 16 | }; 17 | 18 | 19 | #if defined(NPY_PY3K) 20 | static struct PyModuleDef moduledef = { 21 | PyModuleDef_HEAD_INIT, 22 | "dummy", 23 | NULL, 24 | -1, 25 | methods, 26 | NULL, 27 | NULL, 28 | NULL, 29 | NULL 30 | }; 31 | #endif 32 | 33 | /* Initialization function for the module */ 34 | #if defined(NPY_PY3K) 35 | PyMODINIT_FUNC PyInit__dummy(void) { 36 | PyObject *m; 37 | m = PyModule_Create(&moduledef); 38 | if (!m) { 39 | return NULL; 40 | } 41 | return m; 42 | } 43 | #else 44 | PyMODINIT_FUNC 45 | init_dummy(void) { 46 | Py_InitModule("_dummy", methods); 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /numpy/core/src/common/npy_import.h: -------------------------------------------------------------------------------- 1 | #ifndef NPY_IMPORT_H 2 | #define NPY_IMPORT_H 3 | 4 | #include 5 | 6 | /*! \brief Fetch and cache Python function. 7 | * 8 | * Import a Python function and cache it for use. The function checks if 9 | * cache is NULL, and if not NULL imports the Python function specified by 10 | * \a module and \a function, increments its reference count, and stores 11 | * the result in \a cache. Usually \a cache will be a static variable and 12 | * should be initialized to NULL. On error \a cache will contain NULL on 13 | * exit, 14 | * 15 | * @param module Absolute module name. 16 | * @param attr module attribute to cache. 17 | * @param cache Storage location for imported function. 18 | */ 19 | NPY_INLINE static void 20 | npy_cache_import(const char *module, const char *attr, PyObject **cache) 21 | { 22 | if (*cache == NULL) { 23 | PyObject *mod = PyImport_ImportModule(module); 24 | 25 | if (mod != NULL) { 26 | *cache = PyObject_GetAttrString(mod, attr); 27 | Py_DECREF(mod); 28 | } 29 | } 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_assumed_shape.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | import pytest 5 | 6 | from numpy.testing import assert_ 7 | from . import util 8 | 9 | 10 | def _path(*a): 11 | return os.path.join(*((os.path.dirname(__file__),) + a)) 12 | 13 | 14 | class TestAssumedShapeSumExample(util.F2PyTest): 15 | sources = [_path('src', 'assumed_shape', 'foo_free.f90'), 16 | _path('src', 'assumed_shape', 'foo_use.f90'), 17 | _path('src', 'assumed_shape', 'precision.f90'), 18 | _path('src', 'assumed_shape', 'foo_mod.f90'), 19 | ] 20 | 21 | @pytest.mark.slow 22 | def test_all(self): 23 | r = self.module.fsum([1, 2]) 24 | assert_(r == 3, repr(r)) 25 | r = self.module.sum([1, 2]) 26 | assert_(r == 3, repr(r)) 27 | r = self.module.sum_with_use([1, 2]) 28 | assert_(r == 3, repr(r)) 29 | 30 | r = self.module.mod.sum([1, 2]) 31 | assert_(r == 3, repr(r)) 32 | r = self.module.mod.fsum([1, 2]) 33 | assert_(r == 3, repr(r)) 34 | -------------------------------------------------------------------------------- /numpy/distutils/command/egg_info.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import sys 4 | 5 | from setuptools.command.egg_info import egg_info as _egg_info 6 | 7 | class egg_info(_egg_info): 8 | def run(self): 9 | if 'sdist' in sys.argv: 10 | import warnings 11 | import textwrap 12 | msg = textwrap.dedent(""" 13 | `build_src` is being run, this may lead to missing 14 | files in your sdist! You want to use distutils.sdist 15 | instead of the setuptools version: 16 | 17 | from distutils.command.sdist import sdist 18 | cmdclass={'sdist': sdist}" 19 | 20 | See numpy's setup.py or gh-7131 for details.""") 21 | warnings.warn(msg, UserWarning, stacklevel=2) 22 | 23 | # We need to ensure that build_src has been executed in order to give 24 | # setuptools' egg_info command real filenames instead of functions which 25 | # generate files. 26 | self.run_command("build_src") 27 | _egg_info.run(self) 28 | -------------------------------------------------------------------------------- /numpy/distutils/command/install_headers.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | from distutils.command.install_headers import install_headers as old_install_headers 5 | 6 | class install_headers (old_install_headers): 7 | 8 | def run (self): 9 | headers = self.distribution.headers 10 | if not headers: 11 | return 12 | 13 | prefix = os.path.dirname(self.install_dir) 14 | for header in headers: 15 | if isinstance(header, tuple): 16 | # Kind of a hack, but I don't know where else to change this... 17 | if header[0] == 'numpy.core': 18 | header = ('numpy', header[1]) 19 | if os.path.splitext(header[1])[1] == '.inc': 20 | continue 21 | d = os.path.join(*([prefix]+header[0].split('.'))) 22 | header = header[1] 23 | else: 24 | d = self.install_dir 25 | self.mkpath(d) 26 | (out, _) = self.copy_file(header, d) 27 | self.outfiles.append(out) 28 | -------------------------------------------------------------------------------- /numpy/random/src/sfc64/sfc64.c: -------------------------------------------------------------------------------- 1 | #include "sfc64.h" 2 | 3 | extern void sfc64_set_seed(sfc64_state *state, uint64_t *seed) { 4 | /* Conservatively stick with the original formula. With SeedSequence, it 5 | * might be fine to just set the state with 4 uint64s and be done. 6 | */ 7 | int i; 8 | 9 | state->s[0] = seed[0]; 10 | state->s[1] = seed[1]; 11 | state->s[2] = seed[2]; 12 | state->s[3] = 1; 13 | 14 | for (i=0; i<12; i++) { 15 | (void)sfc64_next(state->s); 16 | } 17 | } 18 | 19 | extern void sfc64_get_state(sfc64_state *state, uint64_t *state_arr, int *has_uint32, 20 | uint32_t *uinteger) { 21 | int i; 22 | 23 | for (i=0; i<4; i++) { 24 | state_arr[i] = state->s[i]; 25 | } 26 | has_uint32[0] = state->has_uint32; 27 | uinteger[0] = state->uinteger; 28 | } 29 | 30 | extern void sfc64_set_state(sfc64_state *state, uint64_t *state_arr, int has_uint32, 31 | uint32_t uinteger) { 32 | int i; 33 | 34 | for (i=0; i<4; i++) { 35 | state->s[i] = state_arr[i]; 36 | } 37 | state->has_uint32 = has_uint32; 38 | state->uinteger = uinteger; 39 | } 40 | -------------------------------------------------------------------------------- /doc/release/1.14.5-notes.rst: -------------------------------------------------------------------------------- 1 | ========================== 2 | NumPy 1.14.5 Release Notes 3 | ========================== 4 | 5 | This is a bugfix release for bugs reported following the 1.14.4 release. The 6 | most significant fixes are: 7 | 8 | * fixes for compilation errors on alpine and NetBSD 9 | 10 | The Python versions supported in this release are 2.7 and 3.4 - 3.6. The Python 11 | 3.6 wheels available from PIP are built with Python 3.6.2 and should be 12 | compatible with all previous versions of Python 3.6. The source releases were 13 | cythonized with Cython 0.28.2 and should work for the upcoming Python 3.7. 14 | 15 | Contributors 16 | ============ 17 | 18 | A total of 1 person contributed to this release. People with a "+" by their 19 | names contributed a patch for the first time. 20 | 21 | * Charles Harris 22 | 23 | Pull requests merged 24 | ==================== 25 | 26 | A total of 2 pull requests were merged for this release. 27 | 28 | * `#11274 `__: BUG: Correct use of NPY_UNUSED. 29 | * `#11294 `__: BUG: Remove extra trailing parentheses. 30 | 31 | -------------------------------------------------------------------------------- /doc/source/reference/routines.logic.rst: -------------------------------------------------------------------------------- 1 | Logic functions 2 | *************** 3 | 4 | .. currentmodule:: numpy 5 | 6 | Truth value testing 7 | ------------------- 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | all 12 | any 13 | 14 | Array contents 15 | -------------- 16 | .. autosummary:: 17 | :toctree: generated/ 18 | 19 | isfinite 20 | isinf 21 | isnan 22 | isnat 23 | isneginf 24 | isposinf 25 | 26 | Array type testing 27 | ------------------ 28 | .. autosummary:: 29 | :toctree: generated/ 30 | 31 | iscomplex 32 | iscomplexobj 33 | isfortran 34 | isreal 35 | isrealobj 36 | isscalar 37 | 38 | Logical operations 39 | ------------------ 40 | .. autosummary:: 41 | :toctree: generated/ 42 | 43 | logical_and 44 | logical_or 45 | logical_not 46 | logical_xor 47 | 48 | Comparison 49 | ---------- 50 | .. autosummary:: 51 | :toctree: generated/ 52 | 53 | allclose 54 | isclose 55 | array_equal 56 | array_equiv 57 | 58 | .. autosummary:: 59 | :toctree: generated/ 60 | 61 | greater 62 | greater_equal 63 | less 64 | less_equal 65 | equal 66 | not_equal 67 | -------------------------------------------------------------------------------- /tools/swig/test/Array1.h: -------------------------------------------------------------------------------- 1 | #ifndef ARRAY1_H 2 | #define ARRAY1_H 3 | 4 | #include 5 | #include 6 | 7 | class Array1 8 | { 9 | public: 10 | 11 | // Default/length/array constructor 12 | Array1(int length = 0, long* data = 0); 13 | 14 | // Copy constructor 15 | Array1(const Array1 & source); 16 | 17 | // Destructor 18 | ~Array1(); 19 | 20 | // Assignment operator 21 | Array1 & operator=(const Array1 & source); 22 | 23 | // Equals operator 24 | bool operator==(const Array1 & other) const; 25 | 26 | // Length accessor 27 | int length() const; 28 | 29 | // Resize array 30 | void resize(int length, long* data = 0); 31 | 32 | // Set item accessor 33 | long & operator[](int i); 34 | 35 | // Get item accessor 36 | const long & operator[](int i) const; 37 | 38 | // String output 39 | std::string asString() const; 40 | 41 | // Get view 42 | void view(long** data, int* length) const; 43 | 44 | private: 45 | // Members 46 | bool _ownData; 47 | int _length; 48 | long * _buffer; 49 | 50 | // Methods 51 | void allocateMemory(); 52 | void deallocateMemory(); 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/scalartypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_SCALARTYPES_H_ 2 | #define _NPY_SCALARTYPES_H_ 3 | 4 | /* Internal look-up tables */ 5 | extern NPY_NO_EXPORT unsigned char 6 | _npy_can_cast_safely_table[NPY_NTYPES][NPY_NTYPES]; 7 | extern NPY_NO_EXPORT signed char 8 | _npy_scalar_kinds_table[NPY_NTYPES]; 9 | extern NPY_NO_EXPORT signed char 10 | _npy_type_promotion_table[NPY_NTYPES][NPY_NTYPES]; 11 | extern NPY_NO_EXPORT signed char 12 | _npy_smallest_type_of_kind_table[NPY_NSCALARKINDS]; 13 | extern NPY_NO_EXPORT signed char 14 | _npy_next_larger_type_table[NPY_NTYPES]; 15 | 16 | NPY_NO_EXPORT void 17 | initialize_casting_tables(void); 18 | 19 | NPY_NO_EXPORT void 20 | initialize_numeric_types(void); 21 | 22 | #if PY_VERSION_HEX >= 0x03000000 23 | NPY_NO_EXPORT void 24 | gentype_struct_free(PyObject *ptr); 25 | #else 26 | NPY_NO_EXPORT void 27 | gentype_struct_free(void *ptr, void *arg); 28 | #endif 29 | 30 | NPY_NO_EXPORT int 31 | is_anyscalar_exact(PyObject *obj); 32 | 33 | NPY_NO_EXPORT int 34 | _typenum_fromtypeobj(PyObject *type, int user); 35 | 36 | NPY_NO_EXPORT void * 37 | scalar_value(PyObject *scalar, PyArray_Descr *descr); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /doc/source/reference/routines.polynomials.rst: -------------------------------------------------------------------------------- 1 | Polynomials 2 | *********** 3 | 4 | Polynomials in NumPy can be *created*, *manipulated*, and even *fitted* using 5 | the :doc:`routines.polynomials.classes` 6 | of the `numpy.polynomial` package, introduced in NumPy 1.4. 7 | 8 | Prior to NumPy 1.4, `numpy.poly1d` was the class of choice and it is still 9 | available in order to maintain backward compatibility. 10 | However, the newer Polynomial package is more complete than `numpy.poly1d` 11 | and its convenience classes are better behaved in the numpy environment. 12 | Therefore Polynomial is recommended for new coding. 13 | 14 | Transition notice 15 | ----------------- 16 | The various routines in the Polynomial package all deal with 17 | series whose coefficients go from degree zero upward, 18 | which is the *reverse order* of the Poly1d convention. 19 | The easy way to remember this is that indexes 20 | correspond to degree, i.e., coef[i] is the coefficient of the term of 21 | degree i. 22 | 23 | 24 | .. toctree:: 25 | :maxdepth: 2 26 | 27 | routines.polynomials.package 28 | 29 | .. toctree:: 30 | :maxdepth: 2 31 | 32 | routines.polynomials.poly1d 33 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/shape.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_SHAPE_H_ 2 | #define _NPY_ARRAY_SHAPE_H_ 3 | 4 | /* 5 | * Builds a string representation of the shape given in 'vals'. 6 | * A negative value in 'vals' gets interpreted as newaxis. 7 | */ 8 | NPY_NO_EXPORT PyObject * 9 | build_shape_string(npy_intp n, npy_intp *vals); 10 | 11 | /* 12 | * Creates a sorted stride perm matching the KEEPORDER behavior 13 | * of the NpyIter object. Because this operates based on multiple 14 | * input strides, the 'stride' member of the npy_stride_sort_item 15 | * would be useless and we simply argsort a list of indices instead. 16 | * 17 | * The caller should have already validated that 'ndim' matches for 18 | * every array in the arrays list. 19 | */ 20 | NPY_NO_EXPORT void 21 | PyArray_CreateMultiSortedStridePerm(int narrays, PyArrayObject **arrays, 22 | int ndim, int *out_strideperm); 23 | 24 | /* 25 | * Just like PyArray_Squeeze, but allows the caller to select 26 | * a subset of the size-one dimensions to squeeze out. 27 | */ 28 | NPY_NO_EXPORT PyObject * 29 | PyArray_SqueezeSelected(PyArrayObject *self, npy_bool *axis_flags); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | addopts = -l 3 | norecursedirs = doc tools numpy/linalg/lapack_lite numpy/core/code_generators 4 | doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS ALLOW_UNICODE ALLOW_BYTES 5 | 6 | filterwarnings = 7 | error 8 | # Filter out annoying import messages. 9 | ignore:Not importing directory 10 | ignore:numpy.dtype size changed 11 | ignore:numpy.ufunc size changed 12 | ignore::UserWarning:cpuinfo, 13 | # Matrix PendingDeprecationWarning. 14 | ignore:the matrix subclass is not 15 | # Ignore python2.7 -3 warnings 16 | ignore:sys\.exc_clear\(\) not supported in 3\.x:DeprecationWarning 17 | ignore:in 3\.x, __setslice__:DeprecationWarning 18 | ignore:in 3\.x, __getslice__:DeprecationWarning 19 | ignore:buffer\(\) not supported in 3\.x:DeprecationWarning 20 | ignore:CObject type is not supported in 3\.x:DeprecationWarning 21 | ignore:comparing unequal types not supported in 3\.x:DeprecationWarning 22 | ignore:the commands module has been removed in Python 3\.0:DeprecationWarning 23 | ignore:The 'new' module has been removed in Python 3\.0:DeprecationWarning 24 | 25 | env = 26 | PYTHONHASHSEED=0 27 | -------------------------------------------------------------------------------- /doc/release/1.7.1-notes.rst: -------------------------------------------------------------------------------- 1 | ========================= 2 | NumPy 1.7.1 Release Notes 3 | ========================= 4 | 5 | This is a bugfix only release in the 1.7.x series. 6 | It supports Python 2.4 - 2.7 and 3.1 - 3.3 and is the last series that 7 | supports Python 2.4 - 2.5. 8 | 9 | 10 | Issues fixed 11 | ============ 12 | 13 | * gh-2973: Fix `1` is printed during numpy.test() 14 | * gh-2983: BUG: gh-2969: Backport memory leak fix 80b3a34. 15 | * gh-3007: Backport gh-3006 16 | * gh-2984: Backport fix complex polynomial fit 17 | * gh-2982: BUG: Make nansum work with booleans. 18 | * gh-2985: Backport large sort fixes 19 | * gh-3039: Backport object take 20 | * gh-3105: Backport nditer fix op axes initialization 21 | * gh-3108: BUG: npy-pkg-config ini files were missing after Bento build. 22 | * gh-3124: BUG: PyArray_LexSort allocates too much temporary memory. 23 | * gh-3131: BUG: Exported f2py_size symbol prevents linking multiple f2py modules. 24 | * gh-3117: Backport gh-2992 25 | * gh-3135: DOC: Add mention of PyArray_SetBaseObject stealing a reference 26 | * gh-3134: DOC: Fix typo in fft docs (the indexing variable is 'm', not 'n'). 27 | * gh-3136: Backport #3128 28 | -------------------------------------------------------------------------------- /numpy/matrixlib/tests/test_regression.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import numpy as np 4 | from numpy.testing import assert_, assert_equal, assert_raises 5 | 6 | 7 | class TestRegression(object): 8 | def test_kron_matrix(self): 9 | # Ticket #71 10 | x = np.matrix('[1 0; 1 0]') 11 | assert_equal(type(np.kron(x, x)), type(x)) 12 | 13 | def test_matrix_properties(self): 14 | # Ticket #125 15 | a = np.matrix([1.0], dtype=float) 16 | assert_(type(a.real) is np.matrix) 17 | assert_(type(a.imag) is np.matrix) 18 | c, d = np.matrix([0.0]).nonzero() 19 | assert_(type(c) is np.ndarray) 20 | assert_(type(d) is np.ndarray) 21 | 22 | def test_matrix_multiply_by_1d_vector(self): 23 | # Ticket #473 24 | def mul(): 25 | np.mat(np.eye(2))*np.ones(2) 26 | 27 | assert_raises(ValueError, mul) 28 | 29 | def test_matrix_std_argmax(self): 30 | # Ticket #83 31 | x = np.asmatrix(np.random.uniform(0, 1, (3, 3))) 32 | assert_equal(x.std().shape, ()) 33 | assert_equal(x.argmax().shape, ()) 34 | -------------------------------------------------------------------------------- /numpy/random/src/philox/philox-benchmark.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple benchamrk command 3 | * 4 | * cl philox-benchmark.c /Ox 5 | * 6 | * gcc philox-benchmark.c -O3 -o philox-benchmark 7 | * 8 | * Requires the Random123 directory containing header files to be located in the 9 | * same directory (not included). 10 | */ 11 | #include "Random123/philox.h" 12 | #include 13 | #include 14 | #include 15 | 16 | #define N 1000000000 17 | 18 | int main() { 19 | philox4x64_ctr_t ctr = {{0, 0, 0, 0}}; 20 | philox4x64_key_t key = {{0, 0xDEADBEAF}}; 21 | philox4x64_ctr_t out; 22 | uint64_t count = 0, sum = 0; 23 | int i, j; 24 | clock_t begin = clock(); 25 | for (i = 0; i < N / 4UL; i++) { 26 | ctr.v[0]++; 27 | out = philox4x64_R(philox4x64_rounds, ctr, key); 28 | for (j = 0; j < 4; j++) { 29 | sum += out.v[j]; 30 | count++; 31 | } 32 | } 33 | clock_t end = clock(); 34 | double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; 35 | printf("0x%" PRIx64 "\ncount: %" PRIu64 "\n", sum, count); 36 | printf("%" PRIu64 " randoms per second\n", 37 | (uint64_t)(N / time_spent) / 1000000 * 1000000); 38 | } 39 | -------------------------------------------------------------------------------- /tools/swig/test/Farray.h: -------------------------------------------------------------------------------- 1 | #ifndef FARRAY_H 2 | #define FARRAY_H 3 | 4 | #include 5 | #include 6 | 7 | class Farray 8 | { 9 | public: 10 | 11 | // Size constructor 12 | Farray(int nrows, int ncols); 13 | 14 | // Copy constructor 15 | Farray(const Farray & source); 16 | 17 | // Destructor 18 | ~Farray(); 19 | 20 | // Assignment operator 21 | Farray & operator=(const Farray & source); 22 | 23 | // Equals operator 24 | bool operator==(const Farray & other) const; 25 | 26 | // Length accessors 27 | int nrows() const; 28 | int ncols() const; 29 | 30 | // Set item accessor 31 | long & operator()(int i, int j); 32 | 33 | // Get item accessor 34 | const long & operator()(int i, int j) const; 35 | 36 | // String output 37 | std::string asString() const; 38 | 39 | // Get view 40 | void view(int* nrows, int* ncols, long** data) const; 41 | 42 | private: 43 | // Members 44 | int _nrows; 45 | int _ncols; 46 | long * _buffer; 47 | 48 | // Default constructor: not implemented 49 | Farray(); 50 | 51 | // Methods 52 | void allocateMemory(); 53 | int offset(int i, int j) const; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /doc/source/dev/governance/people.rst: -------------------------------------------------------------------------------- 1 | .. _governance-people: 2 | 3 | Current steering council and institutional partners 4 | =================================================== 5 | 6 | Steering council 7 | ---------------- 8 | 9 | * Sebastian Berg 10 | 11 | * Jaime Fernández del Río 12 | 13 | * Ralf Gommers 14 | 15 | * Charles Harris 16 | 17 | * Nathaniel Smith 18 | 19 | * Julian Taylor 20 | 21 | * Pauli Virtanen 22 | 23 | * Eric Wieser 24 | 25 | * Marten van Kerkwijk 26 | 27 | * Stephan Hoyer 28 | 29 | * Allan Haldane 30 | 31 | * Stefan van der Walt 32 | 33 | 34 | Emeritus members 35 | ---------------- 36 | 37 | * Travis Oliphant - Project Founder / Emeritus Leader (served: 2005-2012) 38 | 39 | * Alex Griffing (served: 2015-2017) 40 | 41 | 42 | NumFOCUS Subcommittee 43 | --------------------- 44 | 45 | * Chuck Harris 46 | 47 | * Ralf Gommers 48 | 49 | * Jaime Fernández del Río 50 | 51 | * Sebastian Berg 52 | 53 | * External member: Thomas Caswell 54 | 55 | 56 | Institutional Partners 57 | ---------------------- 58 | 59 | * UC Berkeley (Stefan van der Walt, Matti Picus, Tyler Reddy, Sebastian Berg) 60 | 61 | * Quansight (Ralf Gommers, Hameer Abbasi) 62 | 63 | -------------------------------------------------------------------------------- /tools/npy_tempita/license.txt: -------------------------------------------------------------------------------- 1 | License 2 | ------- 3 | 4 | Copyright (c) 2008 Ian Bicking and Contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/following_latest.rst: -------------------------------------------------------------------------------- 1 | .. _following-latest: 2 | 3 | These are the instructions if you just want to follow the latest 4 | *NumPy* source, but you don't need to do any development for now. 5 | If you do want to contribute a patch (excellent!) or do more extensive 6 | NumPy development, see :ref:`development-workflow`. 7 | 8 | The steps are: 9 | 10 | * :ref:`install-git` 11 | * get local copy of the git repository from Github_ 12 | * update local copy from time to time 13 | 14 | Get the local copy of the code 15 | ============================== 16 | 17 | From the command line:: 18 | 19 | git clone git://github.com/numpy/numpy.git 20 | 21 | You now have a copy of the code tree in the new ``numpy`` directory. 22 | If this doesn't work you can try the alternative read-only url:: 23 | 24 | git clone https://github.com/numpy/numpy.git 25 | 26 | Updating the code 27 | ================= 28 | 29 | From time to time you may want to pull down the latest code. Do this with:: 30 | 31 | cd numpy 32 | git fetch 33 | git merge --ff-only 34 | 35 | The tree in ``numpy`` will now have the latest changes from the initial 36 | repository. 37 | 38 | .. _Github: https://github.com/numpy 39 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_quoted_character.py: -------------------------------------------------------------------------------- 1 | """See https://github.com/numpy/numpy/pull/10676. 2 | 3 | """ 4 | from __future__ import division, absolute_import, print_function 5 | 6 | import sys 7 | from importlib import import_module 8 | import pytest 9 | 10 | from numpy.testing import assert_equal 11 | from . import util 12 | 13 | 14 | class TestQuotedCharacter(util.F2PyTest): 15 | code = """ 16 | SUBROUTINE FOO(OUT1, OUT2, OUT3, OUT4, OUT5, OUT6) 17 | CHARACTER SINGLE, DOUBLE, SEMICOL, EXCLA, OPENPAR, CLOSEPAR 18 | PARAMETER (SINGLE="'", DOUBLE='"', SEMICOL=';', EXCLA="!", 19 | 1 OPENPAR="(", CLOSEPAR=")") 20 | CHARACTER OUT1, OUT2, OUT3, OUT4, OUT5, OUT6 21 | Cf2py intent(out) OUT1, OUT2, OUT3, OUT4, OUT5, OUT6 22 | OUT1 = SINGLE 23 | OUT2 = DOUBLE 24 | OUT3 = SEMICOL 25 | OUT4 = EXCLA 26 | OUT5 = OPENPAR 27 | OUT6 = CLOSEPAR 28 | RETURN 29 | END 30 | """ 31 | 32 | @pytest.mark.skipif(sys.platform=='win32', 33 | reason='Fails with MinGW64 Gfortran (Issue #9673)') 34 | def test_quoted_character(self): 35 | assert_equal(self.module.foo(), (b"'", b'"', b';', b'!', b'(', b')')) 36 | -------------------------------------------------------------------------------- /numpy/random/src/splitmix64/splitmix64.orig.c: -------------------------------------------------------------------------------- 1 | /* Written in 2015 by Sebastiano Vigna (vigna@acm.org) 2 | 3 | To the extent possible under law, the author has dedicated all copyright 4 | and related and neighboring rights to this software to the public domain 5 | worldwide. This software is distributed without any warranty. 6 | 7 | See . */ 8 | 9 | #include 10 | 11 | /* This is a fixed-increment version of Java 8's SplittableRandom generator 12 | See http://dx.doi.org/10.1145/2714064.2660195 and 13 | http://docs.oracle.com/javase/8/docs/api/java/util/SplittableRandom.html 14 | 15 | It is a very fast generator passing BigCrush, and it can be useful if 16 | for some reason you absolutely want 64 bits of state; otherwise, we 17 | rather suggest to use a xoroshiro128+ (for moderately parallel 18 | computations) or xorshift1024* (for massively parallel computations) 19 | generator. */ 20 | 21 | uint64_t x; /* The state can be seeded with any value. */ 22 | 23 | uint64_t next() { 24 | uint64_t z = (x += 0x9e3779b97f4a7c15); 25 | z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9; 26 | z = (z ^ (z >> 27)) * 0x94d049bb133111eb; 27 | return z ^ (z >> 31); 28 | } 29 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_kind.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | import pytest 5 | 6 | from numpy.testing import assert_ 7 | from numpy.f2py.crackfortran import ( 8 | _selected_int_kind_func as selected_int_kind, 9 | _selected_real_kind_func as selected_real_kind 10 | ) 11 | from . import util 12 | 13 | 14 | def _path(*a): 15 | return os.path.join(*((os.path.dirname(__file__),) + a)) 16 | 17 | 18 | class TestKind(util.F2PyTest): 19 | sources = [_path('src', 'kind', 'foo.f90')] 20 | 21 | @pytest.mark.slow 22 | def test_all(self): 23 | selectedrealkind = self.module.selectedrealkind 24 | selectedintkind = self.module.selectedintkind 25 | 26 | for i in range(40): 27 | assert_(selectedintkind(i) in [selected_int_kind(i), -1], 28 | 'selectedintkind(%s): expected %r but got %r' % 29 | (i, selected_int_kind(i), selectedintkind(i))) 30 | 31 | for i in range(20): 32 | assert_(selectedrealkind(i) in [selected_real_kind(i), -1], 33 | 'selectedrealkind(%s): expected %r but got %r' % 34 | (i, selected_real_kind(i), selectedrealkind(i))) 35 | -------------------------------------------------------------------------------- /doc/changelog/1.16.2-changelog.rst: -------------------------------------------------------------------------------- 1 | 2 | Contributors 3 | ============ 4 | 5 | A total of 5 people contributed to this release. People with a "+" by their 6 | names contributed a patch for the first time. 7 | 8 | * Charles Harris 9 | * Eric Wieser 10 | * Matti Picus 11 | * Tyler Reddy 12 | * Tony LaTorre + 13 | 14 | Pull requests merged 15 | ==================== 16 | 17 | A total of 7 pull requests were merged for this release. 18 | 19 | * `#12909 `__: TST: fix vmImage dispatch in Azure 20 | * `#12923 `__: MAINT: remove complicated test of multiarray import failure mode 21 | * `#13020 `__: BUG: fix signed zero behavior in npy_divmod 22 | * `#13026 `__: MAINT: Add functions to parse shell-strings in the platform-native... 23 | * `#13028 `__: BUG: Fix regression in parsing of F90 and F77 environment variables 24 | * `#13038 `__: BUG: parse shell escaping in extra_compile_args and extra_link_args 25 | * `#13041 `__: BLD: Windows absolute path DLL loading 26 | -------------------------------------------------------------------------------- /numpy/distutils/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | from .__version__ import version as __version__ 4 | # Must import local ccompiler ASAP in order to get 5 | # customized CCompiler.spawn effective. 6 | from . import ccompiler 7 | from . import unixccompiler 8 | 9 | from .info import __doc__ 10 | from .npy_pkg_config import * 11 | 12 | # If numpy is installed, add distutils.test() 13 | try: 14 | from . import __config__ 15 | # Normally numpy is installed if the above import works, but an interrupted 16 | # in-place build could also have left a __config__.py. In that case the 17 | # next import may still fail, so keep it inside the try block. 18 | from numpy._pytesttester import PytestTester 19 | test = PytestTester(__name__) 20 | del PytestTester 21 | except ImportError: 22 | pass 23 | 24 | 25 | def customized_fcompiler(plat=None, compiler=None): 26 | from numpy.distutils.fcompiler import new_fcompiler 27 | c = new_fcompiler(plat=plat, compiler=compiler) 28 | c.customize() 29 | return c 30 | 31 | def customized_ccompiler(plat=None, compiler=None): 32 | c = ccompiler.new_compiler(plat=plat, compiler=compiler) 33 | c.customize('') 34 | return c 35 | --------------------------------------------------------------------------------