├── doc ├── 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 │ │ ├── run_main_session.dat │ │ ├── common_session.dat │ │ ├── ftype_session.dat │ │ ├── setup_example.py │ │ ├── string_session.dat │ │ ├── moddata_session.dat │ │ ├── allocarr_session.dat │ │ └── advanced.rst │ ├── neps │ │ ├── warnfix.rst │ │ ├── npy-format.rst │ │ ├── missing-data.rst │ │ ├── newbugtracker.rst │ │ ├── ufunc-overrides.rst │ │ ├── datetime-proposal.rst │ │ ├── groupby_additions.rst │ │ ├── math_config_clean.rst │ │ ├── datetime-proposal3.rst │ │ ├── generalized-ufuncs.rst │ │ ├── new-iterator-ufunc.rst │ │ ├── deferred-ufunc-evaluation.rst │ │ ├── structured_array_extensions.rst │ │ └── index.rst │ ├── reference │ │ ├── routines.fft.rst │ │ ├── figures │ │ │ ├── dtype-hierarchy.dia │ │ │ ├── dtype-hierarchy.pdf │ │ │ ├── dtype-hierarchy.png │ │ │ ├── threefundamental.pdf │ │ │ └── threefundamental.png │ │ ├── routines.numarray.rst │ │ ├── routines.padding.rst │ │ ├── internals.rst │ │ ├── routines.oldnumeric.rst │ │ ├── swig.rst │ │ ├── routines.functional.rst │ │ ├── routines.window.rst │ │ ├── routines.financial.rst │ │ ├── routines.emath.rst │ │ ├── routines.datetime.rst │ │ ├── routines.set.rst │ │ ├── routines.help.rst │ │ ├── routines.ctypeslib.rst │ │ ├── routines.polynomials.package.rst │ │ ├── maskedarray.rst │ │ ├── routines.err.rst │ │ ├── routines.bitwise.rst │ │ ├── routines.polynomials.poly1d.rst │ │ ├── routines.sort.rst │ │ ├── routines.dual.rst │ │ ├── routines.other.rst │ │ ├── routines.matlib.rst │ │ ├── routines.statistics.rst │ │ ├── routines.dtype.rst │ │ ├── routines.logic.rst │ │ ├── routines.polynomials.rst │ │ ├── routines.indexing.rst │ │ ├── index.rst │ │ ├── routines.testing.rst │ │ └── routines.rst │ ├── user │ │ ├── misc.rst │ │ ├── basics.byteswapping.rst │ │ ├── basics.io.rst │ │ ├── setting-up.rst │ │ ├── basics.rec.rst │ │ ├── basics.types.rst │ │ ├── basics.broadcasting.rst │ │ ├── basics.subclassing.rst │ │ ├── basics.indexing.rst │ │ ├── c-info.rst │ │ ├── basics.creation.rst │ │ ├── basics.rst │ │ ├── install.rst │ │ └── index.rst │ ├── dev │ │ ├── gitwash │ │ │ ├── pull_button.png │ │ │ ├── forking_button.png │ │ │ ├── index.rst │ │ │ ├── git_development.rst │ │ │ ├── dot2_dot3.rst │ │ │ ├── git_intro.rst │ │ │ └── following_latest.rst │ │ ├── gitwash_links.txt │ │ ├── governance │ │ │ ├── index.rst │ │ │ └── people.rst │ │ └── index.rst │ ├── _static │ │ └── .gitignore │ ├── _templates │ │ ├── indexsidebar.html │ │ ├── layout.html │ │ └── autosummary │ │ │ └── class.rst │ ├── glossary.rst │ ├── contents.rst │ ├── bugs.rst │ └── release.rst ├── f2py │ ├── FAQ.txt │ ├── TODO.txt │ ├── HISTORY.txt │ ├── README.txt │ ├── THANKS.txt │ ├── ex1 │ │ ├── bar.f │ │ ├── arr.f │ │ ├── foo.f │ │ ├── foobar.f90 │ │ ├── runme │ │ ├── foobar-smart.f90 │ │ └── foobarmodule.tex │ ├── f2python9-final │ │ ├── flow.jpg │ │ ├── structure.jpg │ │ ├── aerostructure.jpg │ │ ├── mk_ps.sh │ │ ├── src │ │ │ └── examples │ │ │ │ ├── foo.pyf │ │ │ │ ├── foom.pyf │ │ │ │ ├── exp1session.txt │ │ │ │ ├── exp1mess.txt │ │ │ │ └── exp1.f │ │ ├── mk_pdf.sh │ │ ├── mk_html.sh │ │ └── README.txt │ ├── pyforttest.pyf │ ├── hello.f │ ├── simple.f │ ├── pytest.py │ ├── multiarray │ │ ├── bar.c │ │ └── foo.f │ ├── docutils.conf │ ├── commands.tex │ └── Release-1.x.txt ├── cdoc │ ├── Makefile │ └── README ├── newdtype_example │ ├── floatint │ │ └── __init__.py │ ├── setup.py │ └── example.py ├── release │ ├── 1.10.3-notes.rst │ ├── 1.6.1-notes.rst │ ├── 1.8.2-notes.rst │ ├── 1.11.3-notes.rst │ └── 1.7.1-notes.rst └── neps │ └── structured_array_extensions.rst ├── numpy ├── f2py │ ├── setup.cfg │ ├── tests │ │ ├── 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 │ │ │ ├── regression │ │ │ │ └── inout.f90 │ │ │ ├── kind │ │ │ │ └── foo.f90 │ │ │ ├── parameter │ │ │ │ ├── constant_integer.f90 │ │ │ │ └── constant_real.f90 │ │ │ └── size │ │ │ │ └── foo.f90 │ │ ├── test_regression.py │ │ ├── test_mixed.py │ │ ├── test_assumed_shape.py │ │ ├── test_kind.py │ │ └── test_size.py │ ├── info.py │ ├── src │ │ └── test │ │ │ ├── foo90.f90 │ │ │ ├── bar.f │ │ │ └── foo.f │ ├── __version__.py │ └── __main__.py ├── _build_utils │ ├── __init__.py │ ├── README │ └── apple_accelerate.py ├── core │ ├── code_generators │ │ └── __init__.py │ ├── tests │ │ ├── data │ │ │ ├── astype_copy.pkl │ │ │ └── recarray_from_file.fits │ │ ├── test_scalarinherit.py │ │ ├── test_scalarprint.py │ │ └── test_machar.py │ ├── src │ │ ├── private │ │ │ ├── npy_pycompat.h │ │ │ ├── npy_import.h │ │ │ └── templ_common.h.src │ │ ├── multiarray │ │ │ ├── getset.h │ │ │ ├── hashdescr.h │ │ │ ├── sequence.h │ │ │ ├── cblasfuncs.h │ │ │ ├── convert.h │ │ │ ├── nditer_pywrap.h │ │ │ ├── methods.h │ │ │ ├── buffer.h │ │ │ ├── ucsnarrow.h │ │ │ ├── refcount.h │ │ │ ├── vdot.h │ │ │ ├── alloc.h │ │ │ ├── usertypes.h │ │ │ ├── iterators.h │ │ │ ├── multiarraymodule.h │ │ │ ├── datetime_busday.h │ │ │ ├── compiled_base.h │ │ │ ├── numpyos.h │ │ │ ├── arrayobject.h │ │ │ ├── item_selection.h │ │ │ ├── arraytypes.h │ │ │ ├── shape.h │ │ │ ├── convert_datatype.h │ │ │ └── scalartypes.h │ │ ├── npymath │ │ │ ├── npy_math_common.h │ │ │ └── _signbit.c │ │ ├── umath │ │ │ └── ufunc_object.h │ │ └── dummymodule.c │ ├── mlib.ini.in │ ├── include │ │ └── numpy │ │ │ ├── arrayobject.h │ │ │ ├── npy_no_deprecated_api.h │ │ │ ├── utils.h │ │ │ ├── oldnumeric.h │ │ │ ├── npy_os.h │ │ │ └── numpyconfig.h │ ├── npymath.ini.in │ └── cversions.py ├── lib │ ├── tests │ │ └── data │ │ │ ├── python3.npy │ │ │ ├── py2-objarr.npy │ │ │ ├── py2-objarr.npz │ │ │ ├── py3-objarr.npy │ │ │ ├── py3-objarr.npz │ │ │ └── win64python2.npy │ ├── setup.py │ └── __init__.py ├── distutils │ ├── mingw │ │ └── gfortran_vs2003_hack.c │ ├── __version__.py │ ├── info.py │ ├── compat.py │ ├── setup.py │ ├── command │ │ ├── develop.py │ │ ├── egg_info.py │ │ ├── bdist_rpm.py │ │ ├── sdist.py │ │ ├── install_data.py │ │ ├── install_headers.py │ │ ├── __init__.py │ │ └── build_py.py │ ├── numpy_distribution.py │ ├── __init__.py │ ├── pathccompiler.py │ ├── fcompiler │ │ ├── none.py │ │ └── pathf95.py │ └── tests │ │ └── test_fcompiler_intel.py ├── random │ └── mtrand │ │ ├── initarray.h │ │ ├── mtrand_py_helper.h │ │ └── Python.pxi ├── linalg │ ├── lapack_lite │ │ └── wrapped_routines │ ├── tests │ │ └── test_deprecations.py │ └── info.py ├── fft │ ├── __init__.py │ ├── setup.py │ └── fftpack.h ├── matrixlib │ ├── __init__.py │ ├── setup.py │ └── tests │ │ ├── test_numeric.py │ │ ├── test_multiarray.py │ │ └── test_regression.py ├── _distributor_init.py ├── compat │ ├── setup.py │ ├── __init__.py │ └── tests │ │ └── test_compat.py ├── polynomial │ ├── setup.py │ └── __init__.py ├── ma │ ├── version.py │ └── setup.py ├── testing │ ├── __init__.py │ └── setup.py ├── doc │ └── __init__.py ├── tests │ ├── test_numpy_version.py │ └── test_reloading.py └── setup.py ├── benchmarks └── benchmarks │ └── __init__.py ├── tools ├── allocation_tracking │ ├── sorttable.js │ └── setup.py ├── numpy-macosx-installer │ ├── dmgbackground.png │ ├── art │ │ └── dmgbackground.png │ └── README.txt ├── c_coverage │ └── c_coverage_collect.sh ├── win32build │ ├── cpuid │ │ ├── SConstruct │ │ ├── cpuid.h │ │ └── test.c │ ├── cpucaps │ │ └── SConstruct │ ├── build-cpucaps.py │ ├── doall.py │ └── misc │ │ └── msvcrt90 │ │ └── yop.sh ├── travis-upload-wheel.sh ├── swig │ ├── test │ │ ├── Fortran.h │ │ ├── Fortran.cxx │ │ ├── Flat.i │ │ ├── Makefile │ │ ├── Fortran.i │ │ ├── Array1.h │ │ ├── Farray.h │ │ ├── ArrayZ.h │ │ ├── Array2.h │ │ ├── Flat.h │ │ └── Flat.cxx │ └── Makefile ├── travis-before-install.sh ├── commitstats.py └── npy_tempita │ ├── license.txt │ └── compat3.py ├── .gitattributes ├── .gitmodules ├── README.md ├── appveyor.yml └── MANIFEST.in /doc/source/f2py/var_session.dat: -------------------------------------------------------------------------------- 1 | >>> import var 2 | >>> var.BAR 3 | 5 -------------------------------------------------------------------------------- /doc/source/neps/warnfix.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/warnfix.rst 2 | -------------------------------------------------------------------------------- /doc/source/neps/npy-format.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/npy-format.rst 2 | -------------------------------------------------------------------------------- /doc/source/neps/missing-data.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/missing-data.rst 2 | -------------------------------------------------------------------------------- /numpy/f2py/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_rpm] 2 | doc_files = docs/ 3 | tests/ -------------------------------------------------------------------------------- /doc/source/neps/newbugtracker.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/newbugtracker.rst 2 | -------------------------------------------------------------------------------- /doc/source/neps/ufunc-overrides.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/ufunc-overrides.rst 2 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/assumed_shape/.f2py_f2cmap: -------------------------------------------------------------------------------- 1 | dict(real=dict(rk="double")) 2 | -------------------------------------------------------------------------------- /doc/f2py/FAQ.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/f2py/FAQ.txt -------------------------------------------------------------------------------- /doc/f2py/TODO.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/f2py/TODO.txt -------------------------------------------------------------------------------- /doc/source/neps/datetime-proposal.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/datetime-proposal.rst 2 | -------------------------------------------------------------------------------- /doc/source/neps/groupby_additions.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/groupby_additions.rst 2 | -------------------------------------------------------------------------------- /doc/source/neps/math_config_clean.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/math_config_clean.rst 2 | -------------------------------------------------------------------------------- /doc/cdoc/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | doxygen 5 | 6 | .PHONY: all build 7 | 8 | -------------------------------------------------------------------------------- /doc/f2py/HISTORY.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/f2py/HISTORY.txt -------------------------------------------------------------------------------- /doc/f2py/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/f2py/README.txt -------------------------------------------------------------------------------- /doc/f2py/THANKS.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/f2py/THANKS.txt -------------------------------------------------------------------------------- /doc/source/neps/datetime-proposal3.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/datetime-proposal3.rst 2 | -------------------------------------------------------------------------------- /doc/source/neps/generalized-ufuncs.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/generalized-ufuncs.rst 2 | -------------------------------------------------------------------------------- /doc/source/neps/new-iterator-ufunc.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/new-iterator-ufunc.rst 2 | -------------------------------------------------------------------------------- /doc/source/reference/routines.fft.rst: -------------------------------------------------------------------------------- 1 | .. _routines.fft: 2 | .. automodule:: numpy.fft 3 | -------------------------------------------------------------------------------- /doc/source/neps/deferred-ufunc-evaluation.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/deferred-ufunc-evaluation.rst 2 | -------------------------------------------------------------------------------- /numpy/_build_utils/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | -------------------------------------------------------------------------------- /doc/f2py/ex1/bar.f: -------------------------------------------------------------------------------- 1 | function bar(a,b) 2 | integer a,b,bar 3 | bar = a + b 4 | end 5 | -------------------------------------------------------------------------------- /doc/source/neps/structured_array_extensions.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../neps/structured_array_extensions.rst 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/f2py/ex1/arr.f: -------------------------------------------------------------------------------- 1 | subroutine arr(l,m,n,a) 2 | integer l,m,n 3 | real*8 a(l,m,n) 4 | end 5 | -------------------------------------------------------------------------------- /doc/source/user/misc.rst: -------------------------------------------------------------------------------- 1 | ************* 2 | Miscellaneous 3 | ************* 4 | 5 | .. automodule:: numpy.doc.misc 6 | -------------------------------------------------------------------------------- /numpy/lib/tests/data/python3.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/numpy/lib/tests/data/python3.npy -------------------------------------------------------------------------------- /doc/f2py/f2python9-final/flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/f2py/f2python9-final/flow.jpg -------------------------------------------------------------------------------- /numpy/lib/tests/data/py2-objarr.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/numpy/lib/tests/data/py2-objarr.npy -------------------------------------------------------------------------------- /numpy/lib/tests/data/py2-objarr.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/numpy/lib/tests/data/py2-objarr.npz -------------------------------------------------------------------------------- /numpy/lib/tests/data/py3-objarr.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/numpy/lib/tests/data/py3-objarr.npy -------------------------------------------------------------------------------- /numpy/lib/tests/data/py3-objarr.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/numpy/lib/tests/data/py3-objarr.npz -------------------------------------------------------------------------------- /numpy/core/tests/data/astype_copy.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/numpy/core/tests/data/astype_copy.pkl -------------------------------------------------------------------------------- /numpy/lib/tests/data/win64python2.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/numpy/lib/tests/data/win64python2.npy -------------------------------------------------------------------------------- /benchmarks/benchmarks/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | 3 | from . import common 4 | -------------------------------------------------------------------------------- /doc/f2py/ex1/foo.f: -------------------------------------------------------------------------------- 1 | subroutine foo(a) 2 | integer a 3 | cf2py intent(in,out) :: a 4 | a = a + 5 5 | end 6 | -------------------------------------------------------------------------------- /doc/f2py/f2python9-final/structure.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/f2py/f2python9-final/structure.jpg -------------------------------------------------------------------------------- /doc/source/dev/gitwash/pull_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/source/dev/gitwash/pull_button.png -------------------------------------------------------------------------------- /tools/allocation_tracking/sorttable.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/tools/allocation_tracking/sorttable.js -------------------------------------------------------------------------------- /doc/f2py/f2python9-final/aerostructure.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/f2py/f2python9-final/aerostructure.jpg -------------------------------------------------------------------------------- /doc/source/dev/gitwash/forking_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/source/dev/gitwash/forking_button.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 | -------------------------------------------------------------------------------- /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/ContinuumIO/numpy/HEAD/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 | -------------------------------------------------------------------------------- /tools/numpy-macosx-installer/dmgbackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/tools/numpy-macosx-installer/dmgbackground.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | tools/win32build/nsis_scripts/*.nsi.in eol=crlf 3 | 4 | # Numerical data files 5 | numpy/lib/tests/data/*.npy binary 6 | -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/source/reference/figures/dtype-hierarchy.dia -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/source/reference/figures/dtype-hierarchy.pdf -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/source/reference/figures/dtype-hierarchy.png -------------------------------------------------------------------------------- /doc/source/reference/figures/threefundamental.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/source/reference/figures/threefundamental.pdf -------------------------------------------------------------------------------- /doc/source/reference/figures/threefundamental.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/doc/source/reference/figures/threefundamental.png -------------------------------------------------------------------------------- /tools/numpy-macosx-installer/art/dmgbackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ContinuumIO/numpy/HEAD/tools/numpy-macosx-installer/art/dmgbackground.png -------------------------------------------------------------------------------- /doc/f2py/pyforttest.pyf: -------------------------------------------------------------------------------- 1 | subroutine foo(a,m,n) 2 | integer m = size(a,1) 3 | integer n = size(a,2) 4 | real, intent(inout) :: a(m,n) 5 | end subroutine foo 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 | -------------------------------------------------------------------------------- /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/user/basics.io.rst: -------------------------------------------------------------------------------- 1 | ************** 2 | I/O with NumPy 3 | ************** 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | 8 | basics.io.genfromtxt 9 | -------------------------------------------------------------------------------- /doc/f2py/hello.f: -------------------------------------------------------------------------------- 1 | C File hello.f 2 | subroutine foo (a) 3 | integer a 4 | print*, "Hello from Fortran!" 5 | print*, "a=",a 6 | end 7 | 8 | -------------------------------------------------------------------------------- /doc/source/user/setting-up.rst: -------------------------------------------------------------------------------- 1 | ********** 2 | Setting up 3 | ********** 4 | 5 | .. toctree:: 6 | :maxdepth: 1 7 | 8 | whatisnumpy 9 | install 10 | -------------------------------------------------------------------------------- /doc/release/1.10.3-notes.rst: -------------------------------------------------------------------------------- 1 | NumPy 1.10.3 Release Notes 2 | ************************** 3 | 4 | N/A this release did not happen due to various screwups involving PyPi. 5 | -------------------------------------------------------------------------------- /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/private/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash_links.txt: -------------------------------------------------------------------------------- 1 | .. _NumPy: http://www.numpy.org 2 | .. _`NumPy github`: http://github.com/numpy/numpy 3 | .. _`NumPy mailing list`: http://scipy.org/Mailing_Lists 4 | -------------------------------------------------------------------------------- /doc/source/reference/routines.numarray.rst: -------------------------------------------------------------------------------- 1 | ********************** 2 | Numarray compatibility 3 | ********************** 4 | 5 | The numarray module was removed in NumPy 1.9.0. 6 | -------------------------------------------------------------------------------- /doc/source/user/basics.rec.rst: -------------------------------------------------------------------------------- 1 | .. _structured_arrays: 2 | 3 | ***************** 4 | Structured arrays 5 | ***************** 6 | 7 | .. automodule:: numpy.doc.structured_arrays 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/source/user/basics.broadcasting.rst: -------------------------------------------------------------------------------- 1 | ************ 2 | Broadcasting 3 | ************ 4 | 5 | .. seealso:: :class:`numpy.broadcast` 6 | 7 | .. automodule:: numpy.doc.broadcasting 8 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/glossary.rst: -------------------------------------------------------------------------------- 1 | ******** 2 | Glossary 3 | ******** 4 | 5 | .. toctree:: 6 | 7 | .. automodule:: numpy.doc.glossary 8 | 9 | Jargon 10 | ------ 11 | 12 | .. automodule:: numpy.doc.jargon 13 | -------------------------------------------------------------------------------- /doc/source/reference/internals.rst: -------------------------------------------------------------------------------- 1 | *************** 2 | NumPy internals 3 | *************** 4 | 5 | .. toctree:: 6 | 7 | internals.code-explanations 8 | 9 | .. automodule:: numpy.doc.internals 10 | -------------------------------------------------------------------------------- /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/reference/routines.oldnumeric.rst: -------------------------------------------------------------------------------- 1 | ************************* 2 | Old Numeric compatibility 3 | ************************* 4 | 5 | .. currentmodule:: numpy 6 | 7 | The oldnumeric module was removed in NumPy 1.9.0. 8 | -------------------------------------------------------------------------------- /doc/source/user/basics.indexing.rst: -------------------------------------------------------------------------------- 1 | .. _basics.indexing: 2 | 3 | ******** 4 | Indexing 5 | ******** 6 | 7 | .. seealso:: :ref:`Indexing routines ` 8 | 9 | .. automodule:: numpy.doc.indexing 10 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/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/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 | -------------------------------------------------------------------------------- /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/random/mtrand/initarray.h: -------------------------------------------------------------------------------- 1 | #include "Python.h" 2 | #define NO_IMPORT_ARRAY 3 | #include "numpy/arrayobject.h" 4 | #include "randomkit.h" 5 | 6 | extern void 7 | init_by_array(rk_state *self, unsigned long init_key[], 8 | npy_intp key_length); 9 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/methods.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_METHODS_H_ 2 | #define _NPY_ARRAY_METHODS_H_ 3 | 4 | extern NPY_NO_EXPORT PyMethodDef array_methods[]; 5 | 6 | NPY_NO_EXPORT const char * 7 | npy_casting_to_string(NPY_CASTING casting); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /tools/win32build/cpuid/SConstruct: -------------------------------------------------------------------------------- 1 | env = Environment(tools = ['mingw']) 2 | 3 | #libcpuid = env.SharedLibrary('cpuid', source = ['cpuid.c']) 4 | #test = env.Program('test', source = ['test.c'], LIBS = libcpuid, RPATH = ['.']) 5 | test = env.Program('test', source = ['test.c', 'cpuid.c']) 6 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/index.rst: -------------------------------------------------------------------------------- 1 | .. _using-git: 2 | 3 | Working with *NumPy* source code 4 | ================================ 5 | 6 | Contents: 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | git_intro 12 | following_latest 13 | git_development 14 | git_resources 15 | -------------------------------------------------------------------------------- /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/dev/index.rst: -------------------------------------------------------------------------------- 1 | ##################### 2 | Contributing to NumPy 3 | ##################### 4 | 5 | .. toctree:: 6 | :maxdepth: 3 7 | 8 | gitwash/index 9 | development_environment 10 | governance/index 11 | 12 | For core developers: see :ref:`development-workflow`. 13 | -------------------------------------------------------------------------------- /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/dev/gitwash/git_development.rst: -------------------------------------------------------------------------------- 1 | .. _git-development: 2 | 3 | ===================== 4 | Git for development 5 | ===================== 6 | 7 | Contents: 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | 12 | development_setup 13 | configure_git 14 | development_workflow 15 | -------------------------------------------------------------------------------- /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 | neps/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/f2py/compile_session.dat: -------------------------------------------------------------------------------- 1 | >>> import f2py2e 2 | >>> fsource = ''' 3 | ... subroutine foo 4 | ... print*, "Hello world!" 5 | ... end 6 | ... ''' 7 | >>> f2py2e.compile(fsource,modulename='hello',verbose=0) 8 | 0 9 | >>> import hello 10 | >>> hello.foo() 11 | Hello world! 12 | -------------------------------------------------------------------------------- /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.subclassing 16 | -------------------------------------------------------------------------------- /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/f2py/simple.f: -------------------------------------------------------------------------------- 1 | cFile: simple.f 2 | subroutine foo(a,m,n) 3 | integer m,n,i,j 4 | real a(m,n) 5 | cf2py intent(in,out) a 6 | cf2py intent(hide) m,n 7 | do i=1,m 8 | do j=1,n 9 | a(i,j) = a(i,j) + 10*i+j 10 | enddo 11 | enddo 12 | end 13 | cEOF 14 | -------------------------------------------------------------------------------- /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/linalg/lapack_lite/wrapped_routines: -------------------------------------------------------------------------------- 1 | dgeev 2 | zgeev 3 | dsyevd 4 | zheevd 5 | dgelsd 6 | zgelsd 7 | dgesv 8 | zgesv 9 | dgetrf 10 | zgetrf 11 | dpotrf 12 | zpotrf 13 | dgesdd 14 | zgesdd 15 | dgeqrf 16 | zgeqrf 17 | # need this b/c it's not properly declared as external in the BLAS source 18 | dcabs1 19 | IGNORE: dlamch 20 | -------------------------------------------------------------------------------- /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 .fftpack import * 7 | from .helper import * 8 | 9 | from numpy.testing.nosetester import _numpy_tester 10 | test = _numpy_tester().test 11 | bench = _numpy_tester().bench 12 | -------------------------------------------------------------------------------- /doc/f2py/pytest.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | #File: pytest.py 4 | import Numeric 5 | def foo(a): 6 | a = Numeric.array(a) 7 | m, n = a.shape 8 | for i in range(m): 9 | for j in range(n): 10 | a[i, j] = a[i, j] + 10*(i+1) + (j+1) 11 | return a 12 | #eof 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | _array_dealloc_buffer_info(PyArrayObject *self); 8 | 9 | NPY_NO_EXPORT PyArray_Descr* 10 | _descriptor_from_pep3118_format(char *s); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /doc/f2py/multiarray/bar.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void bar(int *a,int m,int n) { 5 | int i,j; 6 | printf("C:"); 7 | printf("m=%d, n=%d\n",m,n); 8 | for (i=0;i 5 | 6 | #define CPUID_VENDOR_STRING_LEN 12 7 | 8 | struct _cpu_caps { 9 | int has_cpuid; 10 | int has_mmx; 11 | int has_sse; 12 | int has_sse2; 13 | int has_sse3; 14 | char vendor[CPUID_VENDOR_STRING_LEN+1]; 15 | }; 16 | typedef struct _cpu_caps cpu_caps_t; 17 | 18 | int cpuid_get_caps(cpu_caps_t *cpuinfo); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /doc/f2py/f2python9-final/src/examples/foo.pyf: -------------------------------------------------------------------------------- 1 | !%f90 -*- f90 -*- 2 | python module foo 3 | interface 4 | subroutine exp1(l,u,n) 5 | real*8 dimension(2) :: l 6 | real*8 dimension(2) :: u 7 | integer*4 :: n 8 | end subroutine exp1 9 | end interface 10 | end python module foo 11 | ! This file was auto-generated with f2py 12 | ! (version:2.298). 13 | ! See http://cens.ioc.ee/projects/f2py2e/ 14 | -------------------------------------------------------------------------------- /doc/source/reference/routines.ctypeslib.rst: -------------------------------------------------------------------------------- 1 | *********************************************************** 2 | C-Types Foreign Function Interface (:mod:`numpy.ctypeslib`) 3 | *********************************************************** 4 | 5 | .. currentmodule:: numpy.ctypeslib 6 | 7 | .. autofunction:: as_array 8 | .. autofunction:: as_ctypes 9 | .. autofunction:: ctypes_load_library 10 | .. autofunction:: load_library 11 | .. autofunction:: ndpointer 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/f2py/f2python9-final/mk_pdf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd src 3 | 4 | test -f aerostructure.pdf || convert ../aerostructure.jpg aerostructure.pdf 5 | test -f flow.pdf || convert ../flow.jpg flow.pdf 6 | test -f structure.pdf || convert ../structure.jpg structure.pdf 7 | 8 | cat python9.tex | sed -e "s/eps,/pdf,/g" > python9pdf.tex 9 | pdflatex python9pdf.tex 10 | pdflatex python9pdf.tex 11 | pdflatex python9pdf.tex 12 | 13 | mv python9pdf.pdf ../f2python9.pdf -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/f2py/docutils.conf: -------------------------------------------------------------------------------- 1 | [general] 2 | 3 | # These entries affect all processing: 4 | #source-link: 1 5 | datestamp: %Y-%m-%d %H:%M UTC 6 | generator: 1 7 | 8 | # These entries affect HTML output: 9 | #stylesheet-path: pearu_style.css 10 | output-encoding: latin-1 11 | 12 | # These entries affect reStructuredText-style PEPs: 13 | #pep-template: pep-html-template 14 | #pep-stylesheet-path: stylesheets/pep.css 15 | #python-home: http://www.python.org 16 | #no-random: 1 17 | -------------------------------------------------------------------------------- /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/neps/structured_array_extensions.rst: -------------------------------------------------------------------------------- 1 | =========================== 2 | Structured array extensions 3 | =========================== 4 | 5 | 1. Create with-style context that makes "named-columns" available as names in the namespace. 6 | 7 | with np.columns(array): 8 | price = unit * quantityt 9 | 10 | 11 | 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. 12 | -------------------------------------------------------------------------------- /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/reference/routines.polynomials.package.rst: -------------------------------------------------------------------------------- 1 | Polynomial Package 2 | ================== 3 | 4 | .. versionadded:: 1.4.0 5 | 6 | .. currentmodule:: numpy.polynomial 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | routines.polynomials.classes 12 | routines.polynomials.polynomial 13 | routines.polynomials.chebyshev 14 | routines.polynomials.legendre 15 | routines.polynomials.laguerre 16 | routines.polynomials.hermite 17 | routines.polynomials.hermite_e 18 | -------------------------------------------------------------------------------- /doc/f2py/commands.tex: -------------------------------------------------------------------------------- 1 | \usepackage{xspace} 2 | \usepackage{verbatim} 3 | 4 | %%tth:\newcommand{\xspace}{ } 5 | 6 | \newcommand{\fpy}{\texttt{f2py}\xspace} 7 | 8 | \newcommand{\bs}{\symbol{`\\}} 9 | % need bs here: 10 | %%tth:\newcommand{\bs}{\texttt{}} 11 | 12 | \newcommand{\shell}[1]{\hspace*{1em}\texttt{sh> \begin{minipage}[t]{0.8\textwidth}#1\end{minipage}}} 13 | 14 | 15 | %%% Local Variables: 16 | %%% mode: latex 17 | %%% TeX-master: "f2py2e" 18 | %%% End: 19 | 20 | 21 | -------------------------------------------------------------------------------- /doc/f2py/f2python9-final/mk_html.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd src 3 | 4 | test -f aerostructure.eps || convert ../aerostructure.jpg aerostructure.eps 5 | test -f flow.eps || convert ../flow.jpg flow.eps 6 | test -f structure.eps || convert ../structure.jpg structure.eps 7 | 8 | latex python9.tex 9 | latex python9.tex 10 | latex python9.tex 11 | 12 | test `which tth` && cat python9.tex | sed -e "s/{{}\\\verb@/\\\texttt{/g" | sed -e "s/@{}}/}/g" | tth -Lpython9 -i > ../f2python9.html 13 | cd .. 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 | -------------------------------------------------------------------------------- /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 | >>> -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/f2py/f2python9-final/src/examples/foom.pyf: -------------------------------------------------------------------------------- 1 | !%f90 -*- f90 -*- 2 | python module foo 3 | interface 4 | subroutine exp1(l,u,n) 5 | real*8 dimension(2) :: l 6 | real*8 dimension(2) :: u 7 | intent(out) l,u 8 | integer*4 optional :: n = 1 9 | end subroutine exp1 10 | end interface 11 | end python module foo 12 | ! This file was auto-generated with f2py 13 | ! (version:2.298) and modified by pearu. 14 | ! See http://cens.ioc.ee/projects/f2py2e/ 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/matrixlib/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import division, print_function 3 | 4 | import os 5 | 6 | def configuration(parent_package='', top_path=None): 7 | from numpy.distutils.misc_util import Configuration 8 | config = Configuration('matrixlib', parent_package, top_path) 9 | config.add_data_dir('tests') 10 | return config 11 | 12 | if __name__ == "__main__": 13 | from numpy.distutils.core import setup 14 | config = configuration(top_path='').todict() 15 | setup(**config) 16 | -------------------------------------------------------------------------------- /doc/f2py/ex1/foobar.f90: -------------------------------------------------------------------------------- 1 | !%f90 2 | module foobar ! in 3 | interface ! in :foobar 4 | subroutine foo(a) ! in :foobar:foo.f 5 | integer intent(inout) :: a 6 | end subroutine foo 7 | function bar(a,b) ! in :foobar:bar.f 8 | integer :: a 9 | integer :: b 10 | integer :: bar 11 | end function bar 12 | end interface 13 | end module foobar 14 | 15 | ! This file was auto-generated with f2py (version:0.95). 16 | ! See http://cens.ioc.ee/projects/f2py2e/ 17 | -------------------------------------------------------------------------------- /doc/f2py/ex1/runme: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | f2py2e='python ../../f2py2e.py' 4 | PYINC=`$f2py2e -pyinc` 5 | $f2py2e foobar-smart.pyf --short-latex --overwrite-makefile -makefile foo.f bar.f 6 | gmake -f Makefile-foobar 7 | #gcc -O3 -I$PYINC -I$PYINC/Numeric -shared -o foobarmodule.so foobarmodule.c foo.f bar.f 8 | python -c ' 9 | import foobar 10 | print foobar.__doc__ 11 | print foobar.bar(2,3) 12 | from Numeric import * 13 | a=array(3) 14 | print a,foobar.foo(a),a 15 | print foobar.foo.__doc__ 16 | print foobar.bar.__doc__ 17 | print "ok" 18 | ' 19 | -------------------------------------------------------------------------------- /numpy/testing/__init__.py: -------------------------------------------------------------------------------- 1 | """Common test support for all numpy test scripts. 2 | 3 | This single module should provide all the common functionality for numpy tests 4 | in a single location, so that test scripts can just import it and work right 5 | away. 6 | 7 | """ 8 | from __future__ import division, absolute_import, print_function 9 | 10 | from unittest import TestCase 11 | 12 | from . import decorators as dec 13 | from .nosetester import run_module_suite, NoseTester as Tester 14 | from .utils import * 15 | test = nosetester._numpy_tester().test 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tools/numpy-macosx-installer/README.txt: -------------------------------------------------------------------------------- 1 | This is a set of scripts used to build the new numpy .dmg installer with 2 | documentation. 3 | 4 | The actual content of the dmg is to be put in content: documentation go into 5 | the Documentation subdir, and the .mpkg installer for numpuy itself in the 6 | content directory. The name of the installer should match exactly the one in 7 | the numpy script (otherwise, the background will not appear correctly). 8 | 9 | The artwork is done in inkscape. 10 | 11 | The main script (new-create-dmg) was taken from stackoverflow. 12 | -------------------------------------------------------------------------------- /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/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 | NPY_NO_EXPORT void * 8 | npy_alloc_cache(npy_uintp sz); 9 | 10 | NPY_NO_EXPORT void * 11 | npy_alloc_cache_zero(npy_uintp sz); 12 | 13 | NPY_NO_EXPORT void 14 | npy_free_cache(void * p, npy_uintp sd); 15 | 16 | NPY_NO_EXPORT void * 17 | npy_alloc_cache_dim(npy_uintp sz); 18 | 19 | NPY_NO_EXPORT void 20 | npy_free_cache_dim(void * p, npy_uintp sd); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/random/mtrand/mtrand_py_helper.h: -------------------------------------------------------------------------------- 1 | #ifndef _MTRAND_PY_HELPER_H_ 2 | #define _MTRAND_PY_HELPER_H_ 3 | 4 | #include 5 | 6 | static PyObject *empty_py_bytes(npy_intp length, void **bytes) 7 | { 8 | PyObject *b; 9 | #if PY_MAJOR_VERSION >= 3 10 | b = PyBytes_FromStringAndSize(NULL, length); 11 | if (b) { 12 | *bytes = PyBytes_AS_STRING(b); 13 | } 14 | #else 15 | b = PyString_FromStringAndSize(NULL, length); 16 | if (b) { 17 | *bytes = PyString_AS_STRING(b); 18 | } 19 | #endif 20 | return b; 21 | } 22 | 23 | #endif /* _MTRAND_PY_HELPER_H_ */ 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/source/f2py/run_main_session.dat: -------------------------------------------------------------------------------- 1 | >>> import f2py2e 2 | >>> r=f2py2e.run_main(['-m','scalar','docs/usersguide/scalar.f']) 3 | Reading fortran codes... 4 | Reading file 'docs/usersguide/scalar.f' 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/f2py2e/src/fortranobject.h'], 13 | 'csrc': ['./scalarmodule.c', 14 | '/home/users/pearu/src_cvs/f2py2e/src/fortranobject.c']}} 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 fftpack_lite 11 | config.add_extension('fftpack_lite', 12 | sources=['fftpack_litemodule.c', 'fftpack.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/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/f2py/f2python9-final/src/examples/exp1session.txt: -------------------------------------------------------------------------------- 1 | >>> import foo,Numeric 2 | >>> print foo.exp1.__doc__ 3 | exp1 - Function signature: 4 | l,u = exp1([n]) 5 | Optional arguments: 6 | n := 1 input int 7 | Return objects: 8 | l : rank-1 array('d') with bounds (2) 9 | u : rank-1 array('d') with bounds (2) 10 | 11 | >>> l,u = foo.exp1() 12 | >>> print l,u 13 | [ 1264. 465.] [ 1457. 536.] 14 | >>> print l[0]/l[1], u[0]/u[1]-l[0]/l[1] 15 | 2.71827956989 2.25856657199e-06 16 | >>> l,u = foo.exp1(2) 17 | >>> print l,u 18 | [ 517656. 190435.] [ 566827. 208524.] 19 | >>> print l[0]/l[1], u[0]/u[1]-l[0]/l[1] 20 | 2.71828182845 1.36437527942e-11 21 | -------------------------------------------------------------------------------- /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/f2py/f2python9-final/src/examples/exp1mess.txt: -------------------------------------------------------------------------------- 1 | Reading fortran codes... 2 | Reading file 'exp1.f' 3 | Post-processing... 4 | Block: foo 5 | Block: exp1 6 | Creating 'Makefile-foo'... 7 | Linker: ld ('GNU ld' 2.9.5) 8 | Fortran compiler: f77 ('g77 2.x.x' 2.95.2) 9 | C compiler: cc ('gcc 2.x.x' 2.95.2) 10 | Building modules... 11 | Building module "foo"... 12 | Constructing wrapper function "exp1"... 13 | l,u = exp1([n]) 14 | Wrote C/API module "foo" to file "foomodule.c" 15 | Documentation is saved to file "foomodule.tex" 16 | Run GNU make to build shared modules: 17 | gmake -f Makefile- [test] 18 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/iterators.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAYITERATORS_H_ 2 | #define _NPY_ARRAYITERATORS_H_ 3 | 4 | /* 5 | * Parses an index that has no fancy indexing. Populates 6 | * out_dimensions, out_strides, and out_offset. 7 | */ 8 | NPY_NO_EXPORT int 9 | parse_index(PyArrayObject *self, PyObject *op, 10 | npy_intp *out_dimensions, 11 | npy_intp *out_strides, 12 | npy_intp *out_offset, 13 | int check_index); 14 | 15 | NPY_NO_EXPORT PyObject 16 | *iter_subscript(PyArrayIterObject *, PyObject *); 17 | 18 | NPY_NO_EXPORT int 19 | iter_ass_subscript(PyArrayIterObject *, PyObject *, PyObject *); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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, TestCase, run_module_suite 5 | 6 | class TestDot(TestCase): 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 | 21 | 22 | if __name__ == "__main__": 23 | run_module_suite() 24 | -------------------------------------------------------------------------------- /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/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 | #else 10 | #define __COMP_NPY_UNUSED 11 | #endif 12 | #endif 13 | 14 | /* Use this to tag a variable as not used. It will remove unused variable 15 | * warning on support platforms (see __COM_NPY_UNUSED) and mangle the variable 16 | * to avoid accidental use */ 17 | #define NPY_UNUSED(x) (__NPY_UNUSED_TAGGED ## x) __COMP_NPY_UNUSED 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /doc/source/bugs.rst: -------------------------------------------------------------------------------- 1 | ************** 2 | Reporting bugs 3 | ************** 4 | 5 | File bug reports or feature requests, and make contributions 6 | (e.g. code patches), by opening a "new issue" on GitHub: 7 | 8 | - NumPy Issues: http://github.com/numpy/numpy/issues 9 | 10 | Please give as much information as you can in the ticket. It is extremely 11 | useful if you can supply a small self-contained code snippet that reproduces 12 | the problem. Also specify the component, the version you are referring to and 13 | the milestone. 14 | 15 | Report bugs to the appropriate GitHub project (there is one for NumPy 16 | and a different one for SciPy). 17 | 18 | More information can be found on the http://scipy.org/Developer_Zone 19 | website. 20 | -------------------------------------------------------------------------------- /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/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_data_dir('tests') 10 | return config 11 | 12 | if __name__ == '__main__': 13 | from numpy.distutils.core import setup 14 | setup(maintainer="NumPy Developers", 15 | maintainer_email="numpy-dev@numpy.org", 16 | description="NumPy test module", 17 | url="http://www.numpy.org", 18 | license="NumPy License (BSD Style)", 19 | configuration=configuration, 20 | ) 21 | -------------------------------------------------------------------------------- /doc/source/reference/routines.dual.rst: -------------------------------------------------------------------------------- 1 | Optionally Scipy-accelerated routines (:mod:`numpy.dual`) 2 | ********************************************************* 3 | 4 | .. automodule:: numpy.dual 5 | 6 | Linear algebra 7 | -------------- 8 | 9 | .. currentmodule:: numpy.linalg 10 | 11 | .. autosummary:: 12 | 13 | cholesky 14 | det 15 | eig 16 | eigh 17 | eigvals 18 | eigvalsh 19 | inv 20 | lstsq 21 | norm 22 | pinv 23 | solve 24 | svd 25 | 26 | FFT 27 | --- 28 | 29 | .. currentmodule:: numpy.fft 30 | 31 | .. autosummary:: 32 | 33 | fft 34 | fft2 35 | fftn 36 | ifft 37 | ifft2 38 | ifftn 39 | 40 | Other 41 | ----- 42 | 43 | .. currentmodule:: numpy 44 | 45 | .. autosummary:: 46 | 47 | i0 48 | -------------------------------------------------------------------------------- /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_, run_module_suite 7 | from numpy.testing.utils 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 | 23 | 24 | if __name__ == "__main__": 25 | run_module_suite() 26 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/parameter/constant_integer.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_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 | x(1) = x(1) + x(2) + x(3) * three 11 | return 12 | end subroutine 13 | 14 | subroutine foo_long(x) 15 | implicit none 16 | integer, parameter :: ii = selected_int_kind(18) 17 | integer(ii), intent(inout) :: x 18 | dimension x(3) 19 | integer(ii), parameter :: three = 3_ii 20 | x(1) = x(1) + x(2) + x(3) * three 21 | return 22 | end subroutine 23 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/parameter/constant_real.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_single(x) 5 | implicit none 6 | integer, parameter :: rp = selected_real_kind(6) 7 | real(rp), intent(inout) :: x 8 | dimension x(3) 9 | real(rp), parameter :: three = 3._rp 10 | x(1) = x(1) + x(2) + x(3) * three 11 | return 12 | end subroutine 13 | 14 | subroutine foo_double(x) 15 | implicit none 16 | integer, parameter :: rp = selected_real_kind(15) 17 | real(rp), intent(inout) :: x 18 | dimension x(3) 19 | real(rp), parameter :: three = 3._rp 20 | x(1) = x(1) + x(2) + x(3) * three 21 | return 22 | end subroutine 23 | 24 | -------------------------------------------------------------------------------- /doc/source/reference/routines.other.rst: -------------------------------------------------------------------------------- 1 | Miscellaneous routines 2 | ********************** 3 | 4 | .. toctree:: 5 | 6 | .. currentmodule:: numpy 7 | 8 | Buffer objects 9 | -------------- 10 | .. autosummary:: 11 | :toctree: generated/ 12 | 13 | getbuffer 14 | newbuffer 15 | 16 | Performance tuning 17 | ------------------ 18 | .. autosummary:: 19 | :toctree: generated/ 20 | 21 | alterdot 22 | restoredot 23 | setbufsize 24 | getbufsize 25 | 26 | Memory ranges 27 | ------------- 28 | 29 | .. autosummary:: 30 | :toctree: generated/ 31 | 32 | shares_memory 33 | may_share_memory 34 | 35 | NumPy version comparison 36 | ------------------------ 37 | .. autosummary:: 38 | :toctree: generated/ 39 | 40 | lib.NumpyVersion 41 | -------------------------------------------------------------------------------- /doc/source/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | 3 | {% block rootrellink %} 4 | {% if pagename != 'index' %} 5 |
  • {{ shorttitle|e }}
  • 6 | {% endif %} 7 | {% endblock %} 8 | 9 | {% block sidebarsearch %} 10 | {%- if sourcename %} 11 | 18 | {%- endif %} 19 | {{ super() }} 20 | {% endblock %} 21 | -------------------------------------------------------------------------------- /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_buffer; 9 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_ufunc; 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 | 15 | #endif 16 | -------------------------------------------------------------------------------- /doc/f2py/f2python9-final/src/examples/exp1.f: -------------------------------------------------------------------------------- 1 | subroutine exp1(l,u,n) 2 | C Input: n is number of iterations 3 | C Output: l,u are such that 4 | C l(1)/l(2) < exp(1) < u(1)/u(2) 5 | C 6 | Cf2py integer*4 :: n = 1 7 | Cf2py intent(out) l,u 8 | integer*4 n,i 9 | real*8 l(2),u(2),t,t1,t2,t3,t4 10 | l(2) = 1 11 | l(1) = 0 12 | u(2) = 0 13 | u(1) = 1 14 | do 10 i=0,n 15 | t1 = 4 + 32*(1+i)*i 16 | t2 = 11 + (40+32*i)*i 17 | t3 = 3 + (24+32*i)*i 18 | t4 = 8 + 32*(1+i)*i 19 | t = u(1) 20 | u(1) = l(1)*t1 + t*t2 21 | l(1) = l(1)*t3 + t*t4 22 | t = u(2) 23 | u(2) = l(2)*t1 + t*t2 24 | l(2) = l(2)*t3 + t*t4 25 | 10 continue 26 | end 27 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /tools/win32build/build-cpucaps.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, print_function 2 | 3 | import os 4 | import subprocess 5 | # build cpucaps.dll 6 | # needs to be run in tools/win32build folder under wine 7 | # e.g. wine "C:\Python27\python" build-cpucaps.py 8 | cc = os.environ.get('CC', 'gcc') 9 | fmt = (cc, os.getcwd()) 10 | cmd = '"{0}" -o cpucaps_main.o -c -W -Wall "-I{1}/cpuid" "-I{1}/cpucaps" cpucaps/cpucaps_main.c'.format(*fmt) 11 | subprocess.check_call(cmd, shell=True) 12 | cmd = '"{0}" -o cpuid.o -c -W -Wall "-I{1}/cpuid" cpuid/cpuid.c'.format(*fmt) 13 | subprocess.check_call(cmd, shell=True) 14 | cmd = '"{0}" -shared -Wl,--out-implib,libcpucaps.a -o cpucaps.dll cpuid.o cpucaps_main.o'.format(*fmt) 15 | subprocess.check_call(cmd, shell=True) 16 | os.remove('cpuid.o') 17 | os.remove('cpucaps_main.o') 18 | -------------------------------------------------------------------------------- /doc/source/reference/routines.matlib.rst: -------------------------------------------------------------------------------- 1 | Matrix library (:mod:`numpy.matlib`) 2 | ************************************ 3 | 4 | .. currentmodule:: numpy 5 | 6 | This module contains all functions in the :mod:`numpy` namespace, with 7 | the following replacement functions that return :class:`matrices 8 | ` instead of :class:`ndarrays `. 9 | 10 | .. currentmodule:: numpy 11 | 12 | Functions that are also in the numpy namespace and return matrices 13 | 14 | .. autosummary:: 15 | 16 | mat 17 | matrix 18 | asmatrix 19 | bmat 20 | 21 | 22 | Replacement functions in `matlib` 23 | 24 | .. currentmodule:: numpy.matlib 25 | 26 | .. autosummary:: 27 | :toctree: generated/ 28 | 29 | empty 30 | zeros 31 | ones 32 | eye 33 | identity 34 | repmat 35 | rand 36 | randn 37 | -------------------------------------------------------------------------------- /doc/release/1.6.1-notes.rst: -------------------------------------------------------------------------------- 1 | NumPy 1.6.1 Release Notes 2 | ************************* 3 | 4 | This is a bugfix only release in the 1.6.x series. 5 | 6 | 7 | Issues Fixed 8 | ============ 9 | 10 | * #1834: einsum fails for specific shapes 11 | * #1837: einsum throws nan or freezes python for specific array shapes 12 | * #1838: object <-> structured type arrays regression 13 | * #1851: regression for SWIG based code in 1.6.0 14 | * #1863: Buggy results when operating on array copied with astype() 15 | * #1870: Fix corner case of object array assignment 16 | * #1843: Py3k: fix error with recarray 17 | * #1885: nditer: Error in detecting double reduction loop 18 | * #1874: f2py: fix --include_paths bug 19 | * #1749: Fix ctypes.load_library() 20 | * #1895/1896: iter: writeonly operands weren't always being buffered correctly 21 | -------------------------------------------------------------------------------- /numpy/core/src/umath/ufunc_object.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_UMATH_UFUNC_OBJECT_H_ 2 | #define _NPY_UMATH_UFUNC_OBJECT_H_ 3 | 4 | NPY_NO_EXPORT PyObject * 5 | ufunc_geterr(PyObject *NPY_UNUSED(dummy), PyObject *args); 6 | 7 | NPY_NO_EXPORT PyObject * 8 | ufunc_seterr(PyObject *NPY_UNUSED(dummy), PyObject *args); 9 | 10 | /* interned strings (on umath import) */ 11 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_um_str_out; 12 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_um_str_subok; 13 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_um_str_array_prepare; 14 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_um_str_array_wrap; 15 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_um_str_array_finalize; 16 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_um_str_ufunc; 17 | NPY_VISIBILITY_HIDDEN extern PyObject * npy_um_str_pyvals_name; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /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 | warnings.warn("`build_src` is being run, this may lead to missing " 12 | "files in your sdist! See numpy issue gh-7127 for " 13 | "details", UserWarning, stacklevel=2) 14 | 15 | # We need to ensure that build_src has been executed in order to give 16 | # setuptools' egg_info command real filenames instead of functions which 17 | # generate files. 18 | self.run_command("build_src") 19 | _egg_info.run(self) 20 | -------------------------------------------------------------------------------- /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/tests/test_numpy_version.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import re 4 | 5 | import numpy as np 6 | from numpy.testing import assert_, run_module_suite 7 | 8 | 9 | def test_valid_numpy_version(): 10 | # Verify that the numpy version is a valid one (no .post suffix or other 11 | # nonsense). See gh-6431 for an issue caused by an invalid version. 12 | version_pattern = r"^[0-9]+\.[0-9]+\.[0-9]+(|a[0-9]|b[0-9]|rc[0-9])" 13 | dev_suffix = r"(\.dev0\+([0-9a-f]{7}|Unknown))" 14 | if np.version.release: 15 | res = re.match(version_pattern, np.__version__) 16 | else: 17 | res = re.match(version_pattern + dev_suffix, np.__version__) 18 | 19 | assert_(res is not None, np.__version__) 20 | 21 | 22 | if __name__ == "__main__": 23 | run_module_suite() 24 | -------------------------------------------------------------------------------- /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/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 ( 5 | TestCase, run_module_suite, assert_, assert_equal, assert_array_equal 6 | ) 7 | 8 | class TestView(TestCase): 9 | def test_type(self): 10 | x = np.array([1, 2, 3]) 11 | assert_(isinstance(x.view(np.matrix), np.matrix)) 12 | 13 | def test_keywords(self): 14 | x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)]) 15 | # We must be specific about the endianness here: 16 | y = x.view(dtype='`__: 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 | -------------------------------------------------------------------------------- /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/distutils/fcompiler/none.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | from numpy.distutils.fcompiler import FCompiler 4 | 5 | compilers = ['NoneFCompiler'] 6 | 7 | class NoneFCompiler(FCompiler): 8 | 9 | compiler_type = 'none' 10 | description = 'Fake Fortran compiler' 11 | 12 | executables = {'compiler_f77': None, 13 | 'compiler_f90': None, 14 | 'compiler_fix': None, 15 | 'linker_so': None, 16 | 'linker_exe': None, 17 | 'archiver': None, 18 | 'ranlib': None, 19 | 'version_cmd': None, 20 | } 21 | 22 | def find_executables(self): 23 | pass 24 | 25 | 26 | if __name__ == '__main__': 27 | from distutils import log 28 | log.set_verbosity(2) 29 | compiler = NoneFCompiler() 30 | compiler.customize() 31 | print(compiler.get_version()) 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/f2py/ex1/foobar-smart.f90: -------------------------------------------------------------------------------- 1 | !%f90 2 | module foobar ! in 3 | note(This module contains two examples that are used in & 4 | \texttt{f2py} documentation.) foobar 5 | interface ! in :foobar 6 | subroutine foo(a) ! in :foobar:foo.f 7 | note(Example of a wrapper function of a Fortran subroutine.) foo 8 | integer intent(inout),& 9 | note(5 is added to the variable {{}\verb@a@{}} ``in place''.) :: a 10 | end subroutine foo 11 | function bar(a,b) result (ab) ! in :foobar:bar.f 12 | integer :: a 13 | integer :: b 14 | integer :: ab 15 | note(The first value.) a 16 | note(The second value.) b 17 | note(Add two values.) bar 18 | note(The result.) ab 19 | end function bar 20 | end interface 21 | end module foobar 22 | 23 | ! This file was auto-generated with f2py (version:0.95). 24 | ! See http://cens.ioc.ee/projects/f2py2e/ 25 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/core/tests/test_scalarinherit.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ Test printing of scalar types. 3 | 4 | """ 5 | from __future__ import division, absolute_import, print_function 6 | 7 | import numpy as np 8 | from numpy.testing import TestCase, run_module_suite, assert_ 9 | 10 | 11 | class A(object): 12 | pass 13 | class B(A, np.float64): 14 | pass 15 | 16 | class C(B): 17 | pass 18 | class D(C, B): 19 | pass 20 | 21 | class B0(np.float64, A): 22 | pass 23 | class C0(B0): 24 | pass 25 | 26 | class TestInherit(TestCase): 27 | def test_init(self): 28 | x = B(1.0) 29 | assert_(str(x) == '1.0') 30 | y = C(2.0) 31 | assert_(str(y) == '2.0') 32 | z = D(3.0) 33 | assert_(str(z) == '3.0') 34 | 35 | def test_init2(self): 36 | x = B0(1.0) 37 | assert_(str(x) == '1.0') 38 | y = C0(2.0) 39 | assert_(str(y) == '2.0') 40 | 41 | if __name__ == "__main__": 42 | run_module_suite() 43 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_regression.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | import math 5 | 6 | import numpy as np 7 | from numpy.testing import run_module_suite, dec, assert_raises, assert_equal 8 | 9 | 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 | @dec.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 | 31 | 32 | if __name__ == "__main__": 33 | run_module_suite() 34 | -------------------------------------------------------------------------------- /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/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 | 21 | .. autosummary:: 22 | :toctree: generated/ 23 | 24 | 25 | dtype 26 | format_parser 27 | 28 | Data type information 29 | --------------------- 30 | .. autosummary:: 31 | :toctree: generated/ 32 | 33 | finfo 34 | iinfo 35 | MachAr 36 | 37 | Data type testing 38 | ----------------- 39 | .. autosummary:: 40 | :toctree: generated/ 41 | 42 | issctype 43 | issubdtype 44 | issubsctype 45 | issubclass_ 46 | find_common_type 47 | 48 | Miscellaneous 49 | ------------- 50 | .. autosummary:: 51 | :toctree: generated/ 52 | 53 | typename 54 | sctype2char 55 | mintypecode 56 | -------------------------------------------------------------------------------- /doc/source/neps/index.rst: -------------------------------------------------------------------------------- 1 | =========================== 2 | NumPy Enhancement Proposals 3 | =========================== 4 | 5 | NumPy Enhancement Proposals (NEPs) describe proposed changes to NumPy. 6 | NEPs are modeled on Python Enhancement Proposals (PEPs), and are typically 7 | written up when large changes to NumPy are proposed. 8 | 9 | This page provides an overview of all NEPs, making only a distinction between 10 | the ones that have been implemented and those that have not been implemented. 11 | 12 | Implemented NEPs 13 | ---------------- 14 | 15 | .. toctree:: 16 | :maxdepth: 1 17 | 18 | ufunc-overrides 19 | generalized-ufuncs 20 | new-iterator-ufunc 21 | npy-format 22 | 23 | Other NEPs 24 | ---------- 25 | 26 | .. toctree:: 27 | :maxdepth: 1 28 | 29 | missing-data 30 | math_config_clean 31 | groupby_additions 32 | warnfix 33 | newbugtracker 34 | deferred-ufunc-evaluation 35 | structured_array_extensions 36 | datetime-proposal 37 | datetime-proposal3 38 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_digitize(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 | -------------------------------------------------------------------------------- /tools/win32build/misc/msvcrt90/yop.sh: -------------------------------------------------------------------------------- 1 | PATH=/cygdive/c/Mingw-w64/bin:$PATH 2 | gcc -DRUNTIME=msvcr90 -D__msvcr90__=1 -D__MSVCRT__ -C -E -P -xc-header msvcrt.def.in > msvcr90.def 3 | dlltool --as=as -k --dllname msvcr90.dll --output-lib libmsvcr90.a --def msvcr90.def 4 | for key in printf fprintf sprintf vprintf vfprintf vsprintf; do 5 | src=`nm libmsvcr90.a | sed -n -e '/:$/h;/^[0-7][0-7]* *T */{s///;H;g;s/\n//p' -e '}' | sed -n 's/:_'"$key"'$//p'`; 6 | if test -n "$src"; then 7 | dst=`echo "$src" | sed 's/0/4/'`; repl="$repl $dst"; 8 | tmpfiles="$tmpfiles $src $dst"; 9 | ar x libmsvcr90.a $src; 10 | objcopy --redefine-sym _$key=___msvcrt_$key \ 11 | --redefine-sym __imp__$key=__imp____msvcrt_$key \ 12 | $src $dst; 13 | fi; 14 | done; 15 | test `key=_get_output_format; nm libmsvcr90.a | sed -n -e '/:$/h;/^[0-7][0-7]* *T */{s///;H;g;s/\n//p' -e '}' | sed -n 's/:_'"$key"'$//p'` || repl="$repl ofmt_stub.o"; 16 | test -n "$repl" && ar rcs libmsvcr90.a $repl; 17 | rm -f $tmpfiles 18 | -------------------------------------------------------------------------------- /doc/f2py/Release-1.x.txt: -------------------------------------------------------------------------------- 1 | 2 | I am pleased to announce the first public release of f2py 1.116: 3 | 4 | Writing Python C/API wrappers for Fortran routines can be a very 5 | tedious task, especially if a Fortran routine takes more than 20 6 | arguments but only few of them are relevant for the problems that they 7 | solve. 8 | 9 | The Fortran to Python Interface Generator, or FPIG for short, is a 10 | command line tool (f2py) for generating Python C/API modules for 11 | wrapping Fortran 77 routines, accessing common blocks from Python, and 12 | calling Python functions from Fortran (call-backs). 13 | 14 | The tool can be downloaded from 15 | 16 | http://cens.ioc.ee/projects/f2py2e/ 17 | 18 | where you can find also information about f2py features and its User's 19 | Guide. 20 | 21 | f2py is released under the LGPL license. 22 | 23 | With regards, 24 | Pearu Peterson 25 | 26 |

    f2py 1.116 - The 27 | Fortran to Python Interface Generator (25-Jan-00) 28 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/numpyos.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_NUMPYOS_H_ 2 | #define _NPY_NUMPYOS_H_ 3 | 4 | NPY_NO_EXPORT char* 5 | NumPyOS_ascii_formatd(char *buffer, size_t buf_size, 6 | const char *format, 7 | double val, int decimal); 8 | 9 | NPY_NO_EXPORT char* 10 | NumPyOS_ascii_formatf(char *buffer, size_t buf_size, 11 | const char *format, 12 | float val, int decimal); 13 | 14 | NPY_NO_EXPORT char* 15 | NumPyOS_ascii_formatl(char *buffer, size_t buf_size, 16 | const char *format, 17 | long double val, int decimal); 18 | 19 | NPY_NO_EXPORT double 20 | NumPyOS_ascii_strtod(const char *s, char** endptr); 21 | 22 | NPY_NO_EXPORT long double 23 | NumPyOS_ascii_strtold(const char *s, char** endptr); 24 | 25 | NPY_NO_EXPORT int 26 | NumPyOS_ascii_ftolf(FILE *fp, double *value); 27 | 28 | NPY_NO_EXPORT int 29 | NumPyOS_ascii_ftoLf(FILE *fp, long double *value); 30 | 31 | NPY_NO_EXPORT int 32 | NumPyOS_ascii_isspace(int c); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /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 | * Alex Griffing 16 | 17 | * Charles Harris 18 | 19 | * Nathaniel Smith 20 | 21 | * Julian Taylor 22 | 23 | * Pauli Virtanen 24 | 25 | 26 | Emeritus members 27 | ---------------- 28 | 29 | * Travis Oliphant - Project Founder / Emeritus Leader (served: 2005-2012) 30 | 31 | 32 | NumFOCUS Subcommittee 33 | --------------------- 34 | 35 | * Chuck Harris 36 | 37 | * Ralf Gommers 38 | 39 | * Jaime Fernández del Río 40 | 41 | * Nathaniel Smith 42 | 43 | * External member: Thomas Caswell 44 | 45 | 46 | Institutional Partners 47 | ---------------------- 48 | 49 | * UC Berkeley (Nathaniel Smith) 50 | 51 | 52 | Document history 53 | ---------------- 54 | 55 | https://github.com/numpy/numpy/commits/master/doc/source/dev/governance/governance.rst 56 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/core/tests/test_scalarprint.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ Test printing of scalar types. 3 | 4 | """ 5 | from __future__ import division, absolute_import, print_function 6 | 7 | import numpy as np 8 | from numpy.testing import TestCase, assert_, run_module_suite 9 | 10 | 11 | class TestRealScalars(TestCase): 12 | def test_str(self): 13 | svals = [0.0, -0.0, 1, -1, np.inf, -np.inf, np.nan] 14 | styps = [np.float16, np.float32, np.float64, np.longdouble] 15 | actual = [str(f(c)) for c in svals for f in styps] 16 | wanted = [ 17 | '0.0', '0.0', '0.0', '0.0', 18 | '-0.0', '-0.0', '-0.0', '-0.0', 19 | '1.0', '1.0', '1.0', '1.0', 20 | '-1.0', '-1.0', '-1.0', '-1.0', 21 | 'inf', 'inf', 'inf', 'inf', 22 | '-inf', '-inf', '-inf', '-inf', 23 | 'nan', 'nan', 'nan', 'nan'] 24 | 25 | for res, val in zip(actual, wanted): 26 | assert_(res == val) 27 | 28 | 29 | if __name__ == "__main__": 30 | run_module_suite() 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/f2py/ex1/foobarmodule.tex: -------------------------------------------------------------------------------- 1 | % This file is auto-generated with f2py (version:2.266) 2 | \section{Module \texttt{foobar}} 3 | 4 | This module contains two examples that are used in \texttt{f2py} documentation. 5 | 6 | \subsection{Wrapper function \texttt{foo}} 7 | 8 | 9 | \noindent{{}\verb@foo@{}}\texttt{(a)} 10 | --- Example of a wrapper function of a Fortran subroutine. 11 | 12 | \noindent Required arguments: 13 | \begin{description} 14 | \item[]{{}\verb@a : in/output rank-0 array(int,'i')@{}} 15 | --- 5 is added to the variable {{}\verb@a@{}} ``in place''. 16 | \end{description} 17 | 18 | \subsection{Wrapper function \texttt{bar}} 19 | 20 | 21 | \noindent{{}\verb@bar = bar@{}}\texttt{(a, b)} 22 | --- Add two values. 23 | 24 | \noindent Required arguments: 25 | \begin{description} 26 | \item[]{{}\verb@a : input int@{}} 27 | --- The first value. 28 | \item[]{{}\verb@b : input int@{}} 29 | --- The second value. 30 | \end{description} 31 | \noindent Return objects: 32 | \begin{description} 33 | \item[]{{}\verb@bar : int@{}} 34 | --- See elsewhere. 35 | \end{description} 36 | 37 | -------------------------------------------------------------------------------- /tools/win32build/cpuid/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cpuid.h" 4 | 5 | int main() 6 | { 7 | cpu_caps_t *cpuinfo; 8 | 9 | cpuinfo = malloc(sizeof(*cpuinfo)); 10 | 11 | if (cpuinfo == NULL) { 12 | fprintf(stderr, "Error allocating\n"); 13 | } 14 | 15 | cpuid_get_caps(cpuinfo); 16 | printf("This cpu string is %s\n", cpuinfo->vendor); 17 | 18 | if (cpuinfo->has_mmx) { 19 | printf("This cpu has mmx instruction set\n"); 20 | } else { 21 | printf("This cpu does NOT have mmx instruction set\n"); 22 | } 23 | 24 | if (cpuinfo->has_sse) { 25 | printf("This cpu has sse instruction set\n"); 26 | } else { 27 | printf("This cpu does NOT have sse instruction set\n"); 28 | } 29 | 30 | if (cpuinfo->has_sse2) { 31 | printf("This cpu has sse2 instruction set\n"); 32 | } else { 33 | printf("This cpu does NOT have sse2 instruction set\n"); 34 | } 35 | 36 | if (cpuinfo->has_sse3) { 37 | printf("This cpu has sse3 instruction set\n"); 38 | } else { 39 | printf("This cpu does NOT have sse3 instruction set\n"); 40 | } 41 | 42 | free(cpuinfo); 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /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/private/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/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 | -------------------------------------------------------------------------------- /doc/release/1.7.1-notes.rst: -------------------------------------------------------------------------------- 1 | NumPy 1.7.1 Release Notes 2 | ************************* 3 | 4 | This is a bugfix only release in the 1.7.x series. 5 | It supports Python 2.4 - 2.7 and 3.1 - 3.3 and is the last series that 6 | supports Python 2.4 - 2.5. 7 | 8 | 9 | Issues fixed 10 | ============ 11 | 12 | * gh-2973: Fix `1` is printed during numpy.test() 13 | * gh-2983: BUG: gh-2969: Backport memory leak fix 80b3a34. 14 | * gh-3007: Backport gh-3006 15 | * gh-2984: Backport fix complex polynomial fit 16 | * gh-2982: BUG: Make nansum work with booleans. 17 | * gh-2985: Backport large sort fixes 18 | * gh-3039: Backport object take 19 | * gh-3105: Backport nditer fix op axes initialization 20 | * gh-3108: BUG: npy-pkg-config ini files were missing after Bento build. 21 | * gh-3124: BUG: PyArray_LexSort allocates too much temporary memory. 22 | * gh-3131: BUG: Exported f2py_size symbol prevents linking multiple f2py modules. 23 | * gh-3117: Backport gh-2992 24 | * gh-3135: DOC: Add mention of PyArray_SetBaseObject stealing a reference 25 | * gh-3134: DOC: Fix typo in fft docs (the indexing variable is 'm', not 'n'). 26 | * gh-3136: Backport #3128 27 | -------------------------------------------------------------------------------- /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 | isneginf 23 | isposinf 24 | 25 | Array type testing 26 | ------------------ 27 | .. autosummary:: 28 | :toctree: generated/ 29 | 30 | iscomplex 31 | iscomplexobj 32 | isfortran 33 | isreal 34 | isrealobj 35 | isscalar 36 | 37 | Logical operations 38 | ------------------ 39 | .. autosummary:: 40 | :toctree: generated/ 41 | 42 | logical_and 43 | logical_or 44 | logical_not 45 | logical_xor 46 | 47 | Comparison 48 | ---------- 49 | .. autosummary:: 50 | :toctree: generated/ 51 | 52 | allclose 53 | isclose 54 | array_equal 55 | array_equiv 56 | 57 | .. autosummary:: 58 | :toctree: generated/ 59 | 60 | greater 61 | greater_equal 62 | less 63 | less_equal 64 | equal 65 | not_equal 66 | -------------------------------------------------------------------------------- /numpy/core/tests/test_machar.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | from numpy.core.machar import MachAr 4 | import numpy.core.numerictypes as ntypes 5 | from numpy import errstate, array 6 | from numpy.testing import TestCase, run_module_suite 7 | 8 | class TestMachAr(TestCase): 9 | def _run_machar_highprec(self): 10 | # Instantiate MachAr instance with high enough precision to cause 11 | # underflow 12 | try: 13 | hiprec = ntypes.float96 14 | MachAr(lambda v:array([v], hiprec)) 15 | except AttributeError: 16 | "Skipping test: no ntypes.float96 available on this platform." 17 | 18 | def test_underlow(self): 19 | # Regression test for #759: 20 | # instantiating MachAr for dtype = np.float96 raises spurious warning. 21 | with errstate(all='raise'): 22 | try: 23 | self._run_machar_highprec() 24 | except FloatingPointError as e: 25 | self.fail("Caught %s exception, should not have been raised." % e) 26 | 27 | 28 | if __name__ == "__main__": 29 | run_module_suite() 30 | -------------------------------------------------------------------------------- /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/arraytypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAYTYPES_H_ 2 | #define _NPY_ARRAYTYPES_H_ 3 | 4 | #include "common.h" 5 | 6 | extern NPY_NO_EXPORT PyArray_Descr LONGLONG_Descr; 7 | extern NPY_NO_EXPORT PyArray_Descr LONG_Descr; 8 | extern NPY_NO_EXPORT PyArray_Descr INT_Descr; 9 | 10 | NPY_NO_EXPORT int 11 | set_typeinfo(PyObject *dict); 12 | 13 | /* needed for blasfuncs */ 14 | NPY_NO_EXPORT void 15 | FLOAT_dot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 16 | 17 | NPY_NO_EXPORT void 18 | CFLOAT_dot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 19 | 20 | NPY_NO_EXPORT void 21 | DOUBLE_dot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 22 | 23 | NPY_NO_EXPORT void 24 | CDOUBLE_dot(char *, npy_intp, char *, npy_intp, char *, npy_intp, void *); 25 | 26 | 27 | /* for _pyarray_correlate */ 28 | NPY_NO_EXPORT int 29 | small_correlate(const char * d_, npy_intp dstride, 30 | npy_intp nd, enum NPY_TYPES dtype, 31 | const char * k_, npy_intp kstride, 32 | npy_intp nk, enum NPY_TYPES ktype, 33 | char * out_, npy_intp ostride); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_mixed.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | import textwrap 5 | 6 | from numpy.testing import run_module_suite, assert_, assert_equal, dec 7 | import util 8 | 9 | 10 | def _path(*a): 11 | return os.path.join(*((os.path.dirname(__file__),) + a)) 12 | 13 | 14 | class TestMixed(util.F2PyTest): 15 | sources = [_path('src', 'mixed', 'foo.f'), 16 | _path('src', 'mixed', 'foo_fixed.f90'), 17 | _path('src', 'mixed', 'foo_free.f90')] 18 | 19 | @dec.slow 20 | def test_all(self): 21 | assert_(self.module.bar11() == 11) 22 | assert_(self.module.foo_fixed.bar12() == 12) 23 | assert_(self.module.foo_free.bar13() == 13) 24 | 25 | @dec.slow 26 | def test_docstring(self): 27 | expected = """ 28 | a = bar11() 29 | 30 | Wrapper for ``bar11``. 31 | 32 | Returns 33 | ------- 34 | a : int 35 | """ 36 | assert_equal(self.module.bar11.__doc__, 37 | textwrap.dedent(expected).lstrip()) 38 | 39 | if __name__ == "__main__": 40 | run_module_suite() 41 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_assumed_shape.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | 5 | from numpy.testing import run_module_suite, assert_, dec 6 | import util 7 | 8 | 9 | def _path(*a): 10 | return os.path.join(*((os.path.dirname(__file__),) + a)) 11 | 12 | 13 | class TestAssumedShapeSumExample(util.F2PyTest): 14 | sources = [_path('src', 'assumed_shape', 'foo_free.f90'), 15 | _path('src', 'assumed_shape', 'foo_use.f90'), 16 | _path('src', 'assumed_shape', 'precision.f90'), 17 | _path('src', 'assumed_shape', 'foo_mod.f90'), 18 | ] 19 | 20 | @dec.slow 21 | def test_all(self): 22 | r = self.module.fsum([1, 2]) 23 | assert_(r == 3, repr(r)) 24 | r = self.module.sum([1, 2]) 25 | assert_(r == 3, repr(r)) 26 | r = self.module.sum_with_use([1, 2]) 27 | assert_(r == 3, repr(r)) 28 | 29 | r = self.module.mod.sum([1, 2]) 30 | assert_(r == 3, repr(r)) 31 | r = self.module.mod.fsum([1, 2]) 32 | assert_(r == 3, repr(r)) 33 | 34 | if __name__ == "__main__": 35 | run_module_suite() 36 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

    2 |
    3 |
    4 | ----------------- 5 | | **`Travis CI Status`** | 6 | |-------------------| 7 | |[![Travis](https://img.shields.io/travis/numpy/numpy.svg)](https://travis-ci.org/numpy/numpy)| 8 | 9 | 10 | NumPy is the fundamental package needed for scientific computing with Python. 11 | This package contains: 12 | 13 | * a powerful N-dimensional array object 14 | * sophisticated (broadcasting) functions 15 | * tools for integrating C/C++ and Fortran code 16 | * useful linear algebra, Fourier transform, and random number capabilities. 17 | 18 | It derives from the old Numeric code base and can be used as a replacement for Numeric. It also adds the features introduced by numarray and can be used to replace numarray. 19 | 20 | More information can be found at the website: 21 | 22 | * http://www.numpy.org 23 | 24 | After installation, tests can be run (if ``nose`` is installed) with: 25 | 26 | python -c 'import numpy; numpy.test()' 27 | 28 | The most current development version is always available from our 29 | git repository: 30 | 31 | * http://github.com/numpy/numpy 32 | -------------------------------------------------------------------------------- /numpy/tests/test_reloading.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import sys 4 | 5 | from numpy.testing import assert_raises, assert_, run_module_suite 6 | 7 | if sys.version_info[:2] >= (3, 4): 8 | from importlib import reload 9 | else: 10 | from imp import reload 11 | 12 | def test_numpy_reloading(): 13 | # gh-7844. Also check that relevant globals retain their identity. 14 | import numpy as np 15 | import numpy._globals 16 | 17 | _NoValue = np._NoValue 18 | VisibleDeprecationWarning = np.VisibleDeprecationWarning 19 | ModuleDeprecationWarning = np.ModuleDeprecationWarning 20 | 21 | reload(np) 22 | assert_(_NoValue is np._NoValue) 23 | assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) 24 | assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) 25 | 26 | assert_raises(RuntimeError, reload, numpy._globals) 27 | reload(np) 28 | assert_(_NoValue is np._NoValue) 29 | assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning) 30 | assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning) 31 | 32 | 33 | if __name__ == "__main__": 34 | run_module_suite() 35 | -------------------------------------------------------------------------------- /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/reference/routines.indexing.rst: -------------------------------------------------------------------------------- 1 | .. _routines.indexing: 2 | 3 | Indexing routines 4 | ================= 5 | 6 | .. seealso:: :ref:`Indexing ` 7 | 8 | .. currentmodule:: numpy 9 | 10 | Generating index arrays 11 | ----------------------- 12 | .. autosummary:: 13 | :toctree: generated/ 14 | 15 | c_ 16 | r_ 17 | s_ 18 | nonzero 19 | where 20 | indices 21 | ix_ 22 | ogrid 23 | ravel_multi_index 24 | unravel_index 25 | diag_indices 26 | diag_indices_from 27 | mask_indices 28 | tril_indices 29 | tril_indices_from 30 | triu_indices 31 | triu_indices_from 32 | 33 | Indexing-like operations 34 | ------------------------ 35 | .. autosummary:: 36 | :toctree: generated/ 37 | 38 | take 39 | choose 40 | compress 41 | diag 42 | diagonal 43 | select 44 | 45 | Inserting data into arrays 46 | -------------------------- 47 | .. autosummary:: 48 | :toctree: generated/ 49 | 50 | place 51 | put 52 | putmask 53 | fill_diagonal 54 | 55 | Iterating over arrays 56 | --------------------- 57 | .. autosummary:: 58 | :toctree: generated/ 59 | 60 | nditer 61 | ndenumerate 62 | ndindex 63 | flatiter 64 | lib.Arrayterator 65 | -------------------------------------------------------------------------------- /doc/source/release.rst: -------------------------------------------------------------------------------- 1 | ************* 2 | Release Notes 3 | ************* 4 | 5 | .. include:: ../release/1.13.0-notes.rst 6 | .. include:: ../release/1.12.0-notes.rst 7 | .. include:: ../release/1.11.3-notes.rst 8 | .. include:: ../release/1.11.2-notes.rst 9 | .. include:: ../release/1.11.1-notes.rst 10 | .. include:: ../release/1.11.0-notes.rst 11 | .. include:: ../release/1.10.4-notes.rst 12 | .. include:: ../release/1.10.3-notes.rst 13 | .. include:: ../release/1.10.2-notes.rst 14 | .. include:: ../release/1.10.1-notes.rst 15 | .. include:: ../release/1.10.0-notes.rst 16 | .. include:: ../release/1.9.2-notes.rst 17 | .. include:: ../release/1.9.1-notes.rst 18 | .. include:: ../release/1.9.0-notes.rst 19 | .. include:: ../release/1.8.2-notes.rst 20 | .. include:: ../release/1.8.1-notes.rst 21 | .. include:: ../release/1.8.0-notes.rst 22 | .. include:: ../release/1.7.2-notes.rst 23 | .. include:: ../release/1.7.1-notes.rst 24 | .. include:: ../release/1.7.0-notes.rst 25 | .. include:: ../release/1.6.2-notes.rst 26 | .. include:: ../release/1.6.1-notes.rst 27 | .. include:: ../release/1.6.0-notes.rst 28 | .. include:: ../release/1.5.0-notes.rst 29 | .. include:: ../release/1.4.0-notes.rst 30 | .. include:: ../release/1.3.0-notes.rst 31 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/convert_datatype.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_CONVERT_DATATYPE_H_ 2 | #define _NPY_ARRAY_CONVERT_DATATYPE_H_ 3 | 4 | NPY_NO_EXPORT PyArray_VectorUnaryFunc * 5 | PyArray_GetCastFunc(PyArray_Descr *descr, int type_num); 6 | 7 | NPY_NO_EXPORT int 8 | PyArray_ObjectType(PyObject *op, int minimum_type); 9 | 10 | NPY_NO_EXPORT PyArrayObject ** 11 | PyArray_ConvertToCommonType(PyObject *op, int *retn); 12 | 13 | NPY_NO_EXPORT int 14 | PyArray_ValidType(int type); 15 | 16 | /* Like PyArray_CanCastArrayTo */ 17 | NPY_NO_EXPORT npy_bool 18 | can_cast_scalar_to(PyArray_Descr *scal_type, char *scal_data, 19 | PyArray_Descr *to, NPY_CASTING casting); 20 | 21 | /* 22 | * This function calls Py_DECREF on flex_dtype, and replaces it with 23 | * a new dtype that has been adapted based on the values in data_dtype 24 | * and data_obj. If the flex_dtype is not flexible, it leaves it as is. 25 | * 26 | * The current flexible dtypes include NPY_STRING, NPY_UNICODE, NPY_VOID, 27 | * and NPY_DATETIME with generic units. 28 | */ 29 | NPY_NO_EXPORT void 30 | PyArray_AdaptFlexibleDType(PyObject *data_obj, PyArray_Descr *data_dtype, 31 | PyArray_Descr **flex_dtype); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /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 | ufuncs 23 | routines 24 | distutils 25 | c-api 26 | internals 27 | swig 28 | 29 | 30 | Acknowledgements 31 | ================ 32 | 33 | Large parts of this manual originate from Travis E. Oliphant's book 34 | `Guide to NumPy `__ (which generously entered 35 | Public Domain in August 2008). The reference documentation for many of 36 | the functions are written by numerous contributors and developers of 37 | NumPy, both prior to and during the 38 | `NumPy Documentation Marathon 39 | `__. 40 | 41 | Please help to improve NumPy's documentation! Instructions on how to 42 | join the ongoing documentation marathon can be found 43 | `on the scipy.org website `__ 44 | -------------------------------------------------------------------------------- /doc/source/reference/routines.testing.rst: -------------------------------------------------------------------------------- 1 | Test Support (:mod:`numpy.testing`) 2 | =================================== 3 | 4 | .. currentmodule:: numpy.testing 5 | 6 | Common test support for all numpy test scripts. 7 | 8 | This single module should provide all the common functionality for numpy 9 | tests in a single location, so that test scripts can just import it and 10 | work right away. 11 | 12 | 13 | Asserts 14 | ------- 15 | .. autosummary:: 16 | :toctree: generated/ 17 | 18 | assert_almost_equal 19 | assert_approx_equal 20 | assert_array_almost_equal 21 | assert_allclose 22 | assert_array_almost_equal_nulp 23 | assert_array_max_ulp 24 | assert_array_equal 25 | assert_array_less 26 | assert_equal 27 | assert_raises 28 | assert_raises_regex 29 | assert_warns 30 | assert_string_equal 31 | 32 | Decorators 33 | ---------- 34 | .. autosummary:: 35 | :toctree: generated/ 36 | 37 | decorators.deprecated 38 | decorators.knownfailureif 39 | decorators.setastest 40 | decorators.skipif 41 | decorators.slow 42 | decorate_methods 43 | 44 | 45 | Test Running 46 | ------------ 47 | .. autosummary:: 48 | :toctree: generated/ 49 | 50 | Tester 51 | run_module_suite 52 | rundocs 53 | -------------------------------------------------------------------------------- /tools/swig/test/ArrayZ.h: -------------------------------------------------------------------------------- 1 | #ifndef ARRAYZ_H 2 | #define ARRAYZ_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class ArrayZ 9 | { 10 | public: 11 | 12 | // Default/length/array constructor 13 | ArrayZ(int length = 0, std::complex* data = 0); 14 | 15 | // Copy constructor 16 | ArrayZ(const ArrayZ & source); 17 | 18 | // Destructor 19 | ~ArrayZ(); 20 | 21 | // Assignment operator 22 | ArrayZ & operator=(const ArrayZ & source); 23 | 24 | // Equals operator 25 | bool operator==(const ArrayZ & other) const; 26 | 27 | // Length accessor 28 | int length() const; 29 | 30 | // Resize array 31 | void resize(int length, std::complex* data = 0); 32 | 33 | // Set item accessor 34 | std::complex & operator[](int i); 35 | 36 | // Get item accessor 37 | const std::complex & operator[](int i) const; 38 | 39 | // String output 40 | std::string asString() const; 41 | 42 | // Get view 43 | void view(std::complex** data, int* length) const; 44 | 45 | private: 46 | // Members 47 | bool _ownData; 48 | int _length; 49 | std::complex * _buffer; 50 | 51 | // Methods 52 | void allocateMemory(); 53 | void deallocateMemory(); 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /numpy/core/include/numpy/numpyconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_NUMPYCONFIG_H_ 2 | #define _NPY_NUMPYCONFIG_H_ 3 | 4 | #include "_numpyconfig.h" 5 | 6 | /* 7 | * On Mac OS X, because there is only one configuration stage for all the archs 8 | * in universal builds, any macro which depends on the arch needs to be 9 | * hardcoded 10 | */ 11 | #ifdef __APPLE__ 12 | #undef NPY_SIZEOF_LONG 13 | #undef NPY_SIZEOF_PY_INTPTR_T 14 | 15 | #ifdef __LP64__ 16 | #define NPY_SIZEOF_LONG 8 17 | #define NPY_SIZEOF_PY_INTPTR_T 8 18 | #else 19 | #define NPY_SIZEOF_LONG 4 20 | #define NPY_SIZEOF_PY_INTPTR_T 4 21 | #endif 22 | #endif 23 | 24 | /** 25 | * To help with the NPY_NO_DEPRECATED_API macro, we include API version 26 | * numbers for specific versions of NumPy. To exclude all API that was 27 | * deprecated as of 1.7, add the following before #including any NumPy 28 | * headers: 29 | * #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION 30 | */ 31 | #define NPY_1_7_API_VERSION 0x00000007 32 | #define NPY_1_8_API_VERSION 0x00000008 33 | #define NPY_1_9_API_VERSION 0x00000008 34 | #define NPY_1_10_API_VERSION 0x00000008 35 | #define NPY_1_11_API_VERSION 0x00000008 36 | #define NPY_1_12_API_VERSION 0x00000008 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /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 | NPY_NO_EXPORT void 23 | format_longdouble(char *buf, size_t buflen, npy_longdouble val, unsigned int prec); 24 | 25 | #if PY_VERSION_HEX >= 0x03000000 26 | NPY_NO_EXPORT void 27 | gentype_struct_free(PyObject *ptr); 28 | #else 29 | NPY_NO_EXPORT void 30 | gentype_struct_free(void *ptr, void *arg); 31 | #endif 32 | 33 | NPY_NO_EXPORT int 34 | is_anyscalar_exact(PyObject *obj); 35 | 36 | NPY_NO_EXPORT int 37 | _typenum_fromtypeobj(PyObject *type, int user); 38 | 39 | NPY_NO_EXPORT void * 40 | scalar_value(PyObject *scalar, PyArray_Descr *descr); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /numpy/polynomial/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | A sub-package for efficiently dealing with polynomials. 3 | 4 | Within the documentation for this sub-package, a "finite power series," 5 | i.e., a polynomial (also referred to simply as a "series") is represented 6 | by a 1-D numpy array of the polynomial's coefficients, ordered from lowest 7 | order term to highest. For example, array([1,2,3]) represents 8 | ``P_0 + 2*P_1 + 3*P_2``, where P_n is the n-th order basis polynomial 9 | applicable to the specific module in question, e.g., `polynomial` (which 10 | "wraps" the "standard" basis) or `chebyshev`. For optimal performance, 11 | all operations on polynomials, including evaluation at an argument, are 12 | implemented as operations on the coefficients. Additional (module-specific) 13 | information can be found in the docstring for the module of interest. 14 | 15 | """ 16 | from __future__ import division, absolute_import, print_function 17 | 18 | from .polynomial import Polynomial 19 | from .chebyshev import Chebyshev 20 | from .legendre import Legendre 21 | from .hermite import Hermite 22 | from .hermite_e import HermiteE 23 | from .laguerre import Laguerre 24 | 25 | from numpy.testing.nosetester import _numpy_tester 26 | test = _numpy_tester().test 27 | bench = _numpy_tester().bench 28 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | skip_tags: true 2 | clone_depth: 1 3 | 4 | os: Visual Studio 2015 5 | 6 | environment: 7 | matrix: 8 | - PY_MAJOR_VER: 2 9 | PYTHON_ARCH: "x86" 10 | - PY_MAJOR_VER: 3 11 | PYTHON_ARCH: "x86_64" 12 | - PY_MAJOR_VER: 3 13 | PYTHON_ARCH: "x86" 14 | 15 | build_script: 16 | # If there's a newer build queued for the same PR, cancel this one 17 | - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` 18 | https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` 19 | Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` 20 | throw "There are newer queued builds for this pull request, failing early." } 21 | - ps: Start-FileDownload "https://repo.continuum.io/miniconda/Miniconda$env:PY_MAJOR_VER-latest-Windows-$env:PYTHON_ARCH.exe" C:\Miniconda.exe; echo "Finished downloading miniconda" 22 | - cmd: C:\Miniconda.exe /S /D=C:\Py 23 | - SET PATH=C:\Py;C:\Py\Scripts;C:\Py\Library\bin;%PATH% 24 | - conda config --set always_yes yes 25 | - conda update conda 26 | - conda install cython nose pytz 27 | - pip install . -vvv 28 | 29 | test_script: 30 | - python runtests.py -v -n 31 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/git_intro.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Introduction 3 | ============ 4 | 5 | These pages describe a git_ and github_ workflow for the NumPy_ 6 | project. 7 | 8 | There are several different workflows here, for different ways of 9 | working with *NumPy*. 10 | 11 | This is not a comprehensive git_ reference, it's just a workflow for our 12 | own project. It's tailored to the github_ hosting service. You may well 13 | find better or quicker ways of getting stuff done with git_, but these 14 | should get you started. 15 | 16 | For general resources for learning git_ see :ref:`git-resources`. 17 | 18 | .. _install-git: 19 | 20 | Install git 21 | =========== 22 | 23 | Overview 24 | -------- 25 | 26 | ================ ============= 27 | Debian / Ubuntu ``sudo apt-get install git-core`` 28 | Fedora ``sudo yum install git-core`` 29 | Windows Download and install msysGit_ 30 | OS X Use the git-osx-installer_ 31 | ================ ============= 32 | 33 | In detail 34 | --------- 35 | 36 | See the git_ page for the most recent information. 37 | 38 | Have a look at the github_ install help pages available from `github help`_ 39 | 40 | There are good instructions here: http://book.git-scm.com/2_installing_git.html 41 | 42 | .. include:: git_links.inc 43 | -------------------------------------------------------------------------------- /doc/source/reference/routines.rst: -------------------------------------------------------------------------------- 1 | .. _routines: 2 | 3 | ******** 4 | Routines 5 | ******** 6 | 7 | In this chapter routine docstrings are presented, grouped by functionality. 8 | Many docstrings contain example code, which demonstrates basic usage 9 | of the routine. The examples assume that NumPy is imported with:: 10 | 11 | >>> import numpy as np 12 | 13 | A convenient way to execute examples is the ``%doctest_mode`` mode of 14 | IPython, which allows for pasting of multi-line examples and preserves 15 | indentation. 16 | 17 | .. toctree:: 18 | :maxdepth: 2 19 | 20 | routines.array-creation 21 | routines.array-manipulation 22 | routines.bitwise 23 | routines.char 24 | routines.ctypeslib 25 | routines.datetime 26 | routines.dtype 27 | routines.dual 28 | routines.emath 29 | routines.err 30 | routines.fft 31 | routines.financial 32 | routines.functional 33 | routines.help 34 | routines.indexing 35 | routines.io 36 | routines.linalg 37 | routines.logic 38 | routines.ma 39 | routines.math 40 | routines.matlib 41 | routines.other 42 | routines.padding 43 | routines.polynomials 44 | routines.random 45 | routines.set 46 | routines.sort 47 | routines.statistics 48 | routines.testing 49 | routines.window 50 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_kind.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | 5 | from numpy.testing import run_module_suite, assert_, dec 6 | from numpy.f2py.crackfortran import ( 7 | _selected_int_kind_func as selected_int_kind, 8 | _selected_real_kind_func as selected_real_kind 9 | ) 10 | import util 11 | 12 | 13 | def _path(*a): 14 | return os.path.join(*((os.path.dirname(__file__),) + a)) 15 | 16 | 17 | class TestKind(util.F2PyTest): 18 | sources = [_path('src', 'kind', 'foo.f90')] 19 | 20 | @dec.slow 21 | def test_all(self): 22 | selectedrealkind = self.module.selectedrealkind 23 | selectedintkind = self.module.selectedintkind 24 | 25 | for i in range(40): 26 | assert_(selectedintkind(i) in [selected_int_kind(i), -1], 27 | 'selectedintkind(%s): expected %r but got %r' % 28 | (i, selected_int_kind(i), selectedintkind(i))) 29 | 30 | for i in range(20): 31 | assert_(selectedrealkind(i) in [selected_real_kind(i), -1], 32 | 'selectedrealkind(%s): expected %r but got %r' % 33 | (i, selected_real_kind(i), selectedrealkind(i))) 34 | 35 | if __name__ == "__main__": 36 | run_module_suite() 37 | -------------------------------------------------------------------------------- /numpy/distutils/command/__init__.py: -------------------------------------------------------------------------------- 1 | """distutils.command 2 | 3 | Package containing implementation of all the standard Distutils 4 | commands. 5 | 6 | """ 7 | from __future__ import division, absolute_import, print_function 8 | 9 | def test_na_writable_attributes_deletion(): 10 | a = np.NA(2) 11 | attr = ['payload', 'dtype'] 12 | for s in attr: 13 | assert_raises(AttributeError, delattr, a, s) 14 | 15 | 16 | __revision__ = "$Id: __init__.py,v 1.3 2005/05/16 11:08:49 pearu Exp $" 17 | 18 | distutils_all = [ #'build_py', 19 | 'clean', 20 | 'install_clib', 21 | 'install_scripts', 22 | 'bdist', 23 | 'bdist_dumb', 24 | 'bdist_wininst', 25 | ] 26 | 27 | __import__('distutils.command', globals(), locals(), distutils_all) 28 | 29 | __all__ = ['build', 30 | 'config_compiler', 31 | 'config', 32 | 'build_src', 33 | 'build_py', 34 | 'build_ext', 35 | 'build_clib', 36 | 'build_scripts', 37 | 'install', 38 | 'install_data', 39 | 'install_headers', 40 | 'install_lib', 41 | 'bdist_rpm', 42 | 'sdist', 43 | ] + distutils_all 44 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/following_latest.rst: -------------------------------------------------------------------------------- 1 | .. _following-latest: 2 | 3 | ============================= 4 | Following the latest source 5 | ============================= 6 | 7 | These are the instructions if you just want to follow the latest 8 | *NumPy* source, but you don't need to do any development for now. 9 | If you do want to contribute a patch (excellent!) or do more extensive 10 | NumPy development, see :ref:`development-workflow`. 11 | 12 | The steps are: 13 | 14 | * :ref:`install-git` 15 | * get local copy of the git repository from Github_ 16 | * update local copy from time to time 17 | 18 | Get the local copy of the code 19 | ============================== 20 | 21 | From the command line:: 22 | 23 | git clone git://github.com/numpy/numpy.git 24 | 25 | You now have a copy of the code tree in the new ``numpy`` directory. 26 | If this doesn't work you can try the alternative read-only url:: 27 | 28 | git clone https://github.com/numpy/numpy.git 29 | 30 | Updating the code 31 | ================= 32 | 33 | From time to time you may want to pull down the latest code. Do this with:: 34 | 35 | cd numpy 36 | git fetch 37 | git merge --ff-only 38 | 39 | The tree in ``numpy`` will now have the latest changes from the initial 40 | repository. 41 | 42 | .. _Github: https://github.com/numpy 43 | -------------------------------------------------------------------------------- /doc/f2py/f2python9-final/README.txt: -------------------------------------------------------------------------------- 1 | 2 | This directory contains the source of the paper 3 | 4 | "Fortran to Python Interface Generator with an Application 5 | to Aerospace Engineering" 6 | 7 | by 8 | Pearu Peterson (the corresponding author) 9 | Joaquim R. R. A. Martins 10 | Juan J. Alonso 11 | 12 | for The 9th International Python Conference, March 5-8, 2001, Long Beach, California. 13 | 14 | The paper is provided here is in the HTML format: 15 | 16 | f2python9.html (size=48151 bytes) 17 | 18 | Note that this file includes the following JPG images 19 | 20 | flow.jpg (size=13266) 21 | structure.jpg (size=17860) 22 | aerostructure.jpg (size=72247) 23 | 24 | PS: 25 | The HTML file f2python9.html is generated using TTH (http://hutchinson.belmont.ma.us/tth/) 26 | from the LaTeX source file `python9.tex'. The source can be found in the 27 | src/ 28 | directory. This directory contains also the following EPS files 29 | flow.eps 30 | structure.eps 31 | aerostructure.eps 32 | and the text files 33 | examples/{exp1.f,exp1mess.txt,exp1session.txt,foo.pyf,foom.pyf} 34 | that are used by the LaTeX source python9.tex. 35 | 36 | Regards, 37 | Pearu 38 | January 15, 2001 39 | -------------------------------------------------------------------------------- /numpy/random/mtrand/Python.pxi: -------------------------------------------------------------------------------- 1 | # :Author: Robert Kern 2 | # :Copyright: 2004, Enthought, Inc. 3 | # :License: BSD Style 4 | 5 | 6 | cdef extern from "Python.h": 7 | # Not part of the Python API, but we might as well define it here. 8 | # Note that the exact type doesn't actually matter for Pyrex. 9 | ctypedef int size_t 10 | 11 | # String API 12 | char* PyString_AsString(object string) 13 | char* PyString_AS_STRING(object string) 14 | object PyString_FromString(char* c_string) 15 | object PyString_FromStringAndSize(char* c_string, int length) 16 | 17 | # Float API 18 | double PyFloat_AsDouble(object ob) 19 | long PyInt_AsLong(object ob) 20 | 21 | # Memory API 22 | void* PyMem_Malloc(size_t n) 23 | void* PyMem_Realloc(void* buf, size_t n) 24 | void PyMem_Free(void* buf) 25 | 26 | void Py_DECREF(object obj) 27 | void Py_XDECREF(object obj) 28 | void Py_INCREF(object obj) 29 | void Py_XINCREF(object obj) 30 | 31 | # TypeCheck API 32 | int PyFloat_Check(object obj) 33 | int PyInt_Check(object obj) 34 | 35 | # Error API 36 | int PyErr_Occurred() 37 | void PyErr_Clear() 38 | 39 | cdef extern from "string.h": 40 | void *memcpy(void *s1, void *s2, int n) 41 | 42 | cdef extern from "math.h": 43 | double fabs(double x) 44 | -------------------------------------------------------------------------------- /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 TestCase, run_module_suite, assert_, assert_equal 5 | 6 | rlevel = 1 7 | 8 | class TestRegression(TestCase): 9 | def test_kron_matrix(self, level=rlevel): 10 | # Ticket #71 11 | x = np.matrix('[1 0; 1 0]') 12 | assert_equal(type(np.kron(x, x)), type(x)) 13 | 14 | def test_matrix_properties(self,level=rlevel): 15 | # Ticket #125 16 | a = np.matrix([1.0], dtype=float) 17 | assert_(type(a.real) is np.matrix) 18 | assert_(type(a.imag) is np.matrix) 19 | c, d = np.matrix([0.0]).nonzero() 20 | assert_(type(c) is np.ndarray) 21 | assert_(type(d) is np.ndarray) 22 | 23 | def test_matrix_multiply_by_1d_vector(self, level=rlevel): 24 | # Ticket #473 25 | def mul(): 26 | np.mat(np.eye(2))*np.ones(2) 27 | 28 | self.assertRaises(ValueError, mul) 29 | 30 | def test_matrix_std_argmax(self,level=rlevel): 31 | # Ticket #83 32 | x = np.asmatrix(np.random.uniform(0, 1, (3, 3))) 33 | self.assertEqual(x.std().shape, ()) 34 | self.assertEqual(x.argmax().shape, ()) 35 | 36 | if __name__ == "__main__": 37 | run_module_suite() 38 | -------------------------------------------------------------------------------- /tools/swig/test/Array2.h: -------------------------------------------------------------------------------- 1 | #ifndef ARRAY2_H 2 | #define ARRAY2_H 3 | 4 | #include "Array1.h" 5 | #include 6 | #include 7 | 8 | class Array2 9 | { 10 | public: 11 | 12 | // Default constructor 13 | Array2(); 14 | 15 | // Size/array constructor 16 | Array2(int nrows, int ncols, long* data=0); 17 | 18 | // Copy constructor 19 | Array2(const Array2 & source); 20 | 21 | // Destructor 22 | ~Array2(); 23 | 24 | // Assignment operator 25 | Array2 & operator=(const Array2 & source); 26 | 27 | // Equals operator 28 | bool operator==(const Array2 & other) const; 29 | 30 | // Length accessors 31 | int nrows() const; 32 | int ncols() const; 33 | 34 | // Resize array 35 | void resize(int nrows, int ncols, long* data=0); 36 | 37 | // Set item accessor 38 | Array1 & operator[](int i); 39 | 40 | // Get item accessor 41 | const Array1 & operator[](int i) const; 42 | 43 | // String output 44 | std::string asString() const; 45 | 46 | // Get view 47 | void view(int* nrows, int* ncols, long** data) const; 48 | 49 | private: 50 | // Members 51 | bool _ownData; 52 | int _nrows; 53 | int _ncols; 54 | long * _buffer; 55 | Array1 * _rows; 56 | 57 | // Methods 58 | void allocateMemory(); 59 | void allocateRows(); 60 | void deallocateMemory(); 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /tools/npy_tempita/compat3.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function 2 | 3 | import sys 4 | 5 | __all__ = ['PY3', 'b', 'basestring_', 'bytes', 'next', 'is_unicode', 6 | 'iteritems'] 7 | 8 | PY3 = True if sys.version_info[0] == 3 else False 9 | 10 | if sys.version_info[0] < 3: 11 | 12 | def next(obj): 13 | return obj.next() 14 | 15 | def iteritems(d, **kw): 16 | return d.iteritems(**kw) 17 | 18 | b = bytes = str 19 | basestring_ = basestring 20 | 21 | else: 22 | 23 | def b(s): 24 | if isinstance(s, str): 25 | return s.encode('latin1') 26 | return bytes(s) 27 | 28 | def iteritems(d, **kw): 29 | return iter(d.items(**kw)) 30 | 31 | next = next 32 | basestring_ = (bytes, str) 33 | bytes = bytes 34 | 35 | text = str 36 | 37 | 38 | def is_unicode(obj): 39 | if sys.version_info[0] < 3: 40 | return isinstance(obj, unicode) 41 | else: 42 | return isinstance(obj, str) 43 | 44 | 45 | def coerce_text(v): 46 | if not isinstance(v, basestring_): 47 | if sys.version_info[0] < 3: 48 | attr = '__unicode__' 49 | else: 50 | attr = '__str__' 51 | if hasattr(v, attr): 52 | return unicode(v) 53 | else: 54 | return bytes(v) 55 | return v 56 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_size.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import os 4 | 5 | from numpy.testing import run_module_suite, assert_equal, dec 6 | import util 7 | 8 | 9 | def _path(*a): 10 | return os.path.join(*((os.path.dirname(__file__),) + a)) 11 | 12 | 13 | class TestSizeSumExample(util.F2PyTest): 14 | sources = [_path('src', 'size', 'foo.f90')] 15 | 16 | @dec.slow 17 | def test_all(self): 18 | r = self.module.foo([[1, 2]]) 19 | assert_equal(r, [3], repr(r)) 20 | 21 | r = self.module.foo([[1, 2], [3, 4]]) 22 | assert_equal(r, [3, 7], repr(r)) 23 | 24 | r = self.module.foo([[1, 2], [3, 4], [5, 6]]) 25 | assert_equal(r, [3, 7, 11], repr(r)) 26 | 27 | @dec.slow 28 | def test_transpose(self): 29 | r = self.module.trans([[1, 2]]) 30 | assert_equal(r, [[1], [2]], repr(r)) 31 | 32 | r = self.module.trans([[1, 2, 3], [4, 5, 6]]) 33 | assert_equal(r, [[1, 4], [2, 5], [3, 6]], repr(r)) 34 | 35 | @dec.slow 36 | def test_flatten(self): 37 | r = self.module.flatten([[1, 2]]) 38 | assert_equal(r, [1, 2], repr(r)) 39 | 40 | r = self.module.flatten([[1, 2, 3], [4, 5, 6]]) 41 | assert_equal(r, [1, 2, 3, 4, 5, 6], repr(r)) 42 | 43 | if __name__ == "__main__": 44 | run_module_suite() 45 | -------------------------------------------------------------------------------- /numpy/linalg/info.py: -------------------------------------------------------------------------------- 1 | """\ 2 | Core Linear Algebra Tools 3 | ------------------------- 4 | Linear algebra basics: 5 | 6 | - norm Vector or matrix norm 7 | - inv Inverse of a square matrix 8 | - solve Solve a linear system of equations 9 | - det Determinant of a square matrix 10 | - lstsq Solve linear least-squares problem 11 | - pinv Pseudo-inverse (Moore-Penrose) calculated using a singular 12 | value decomposition 13 | - matrix_power Integer power of a square matrix 14 | 15 | Eigenvalues and decompositions: 16 | 17 | - eig Eigenvalues and vectors of a square matrix 18 | - eigh Eigenvalues and eigenvectors of a Hermitian matrix 19 | - eigvals Eigenvalues of a square matrix 20 | - eigvalsh Eigenvalues of a Hermitian matrix 21 | - qr QR decomposition of a matrix 22 | - svd Singular value decomposition of a matrix 23 | - cholesky Cholesky decomposition of a matrix 24 | 25 | Tensor operations: 26 | 27 | - tensorsolve Solve a linear tensor equation 28 | - tensorinv Calculate an inverse of a tensor 29 | 30 | Exceptions: 31 | 32 | - LinAlgError Indicates a failed linear algebra operation 33 | 34 | """ 35 | from __future__ import division, absolute_import, print_function 36 | 37 | depends = ['core'] 38 | -------------------------------------------------------------------------------- /numpy/distutils/command/build_py.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | from distutils.command.build_py import build_py as old_build_py 4 | from numpy.distutils.misc_util import is_string 5 | 6 | class build_py(old_build_py): 7 | 8 | def run(self): 9 | build_src = self.get_finalized_command('build_src') 10 | if build_src.py_modules_dict and self.packages is None: 11 | self.packages = list(build_src.py_modules_dict.keys ()) 12 | old_build_py.run(self) 13 | 14 | def find_package_modules(self, package, package_dir): 15 | modules = old_build_py.find_package_modules(self, package, package_dir) 16 | 17 | # Find build_src generated *.py files. 18 | build_src = self.get_finalized_command('build_src') 19 | modules += build_src.py_modules_dict.get(package, []) 20 | 21 | return modules 22 | 23 | def find_modules(self): 24 | old_py_modules = self.py_modules[:] 25 | new_py_modules = [_m for _m in self.py_modules if is_string(_m)] 26 | self.py_modules[:] = new_py_modules 27 | modules = old_build_py.find_modules(self) 28 | self.py_modules[:] = old_py_modules 29 | 30 | return modules 31 | 32 | # XXX: Fix find_source_files for item in py_modules such that item is 3-tuple 33 | # and item[2] is source file. 34 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | # 2 | # Use .add_data_files and .add_data_dir methods in a appropriate 3 | # setup.py files to include non-python files such as documentation, 4 | # data, etc files to distribution. Avoid using MANIFEST.in for that. 5 | # 6 | include MANIFEST.in 7 | include *.txt 8 | include site.cfg.example 9 | include numpy/random/mtrand/generate_mtrand_c.py 10 | recursive-include numpy/random/mtrand *.pyx *.pxd 11 | # Add build support that should go in sdist, but not go in bdist/be installed 12 | recursive-include numpy/_build_utils * 13 | recursive-include numpy/linalg/lapack_lite *.c *.h 14 | # Add sdist files whose use depends on local configuration. 15 | include numpy/core/src/multiarray/cblasfuncs.c 16 | include numpy/core/src/multiarray/python_xerbla.c 17 | # Adding scons build related files not found by distutils 18 | recursive-include numpy/core/code_generators *.py *.txt 19 | recursive-include numpy/core *.in *.h 20 | # Add documentation: we don't use add_data_dir since we do not want to include 21 | # this at installation, only for sdist-generated tarballs 22 | include doc/Makefile doc/postprocess.py 23 | recursive-include doc/release * 24 | recursive-include doc/source * 25 | recursive-include doc/sphinxext * 26 | recursive-include tools/swig * 27 | recursive-include doc/scipy-sphinx-theme * 28 | recursive-include doc/f2py * 29 | 30 | global-exclude *.pyc *.pyo *.pyd 31 | -------------------------------------------------------------------------------- /numpy/distutils/fcompiler/pathf95.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | from numpy.distutils.fcompiler import FCompiler 4 | 5 | compilers = ['PathScaleFCompiler'] 6 | 7 | class PathScaleFCompiler(FCompiler): 8 | 9 | compiler_type = 'pathf95' 10 | description = 'PathScale Fortran Compiler' 11 | version_pattern = r'PathScale\(TM\) Compiler Suite: Version (?P[\d.]+)' 12 | 13 | executables = { 14 | 'version_cmd' : ["pathf95", "-version"], 15 | 'compiler_f77' : ["pathf95", "-fixedform"], 16 | 'compiler_fix' : ["pathf95", "-fixedform"], 17 | 'compiler_f90' : ["pathf95"], 18 | 'linker_so' : ["pathf95", "-shared"], 19 | 'archiver' : ["ar", "-cr"], 20 | 'ranlib' : ["ranlib"] 21 | } 22 | pic_flags = ['-fPIC'] 23 | module_dir_switch = '-module ' # Don't remove ending space! 24 | module_include_switch = '-I' 25 | 26 | def get_flags_opt(self): 27 | return ['-O3'] 28 | def get_flags_debug(self): 29 | return ['-g'] 30 | 31 | if __name__ == '__main__': 32 | from distutils import log 33 | log.set_verbosity(2) 34 | #compiler = PathScaleFCompiler() 35 | from numpy.distutils.fcompiler import new_fcompiler 36 | compiler = new_fcompiler(compiler='pathf95') 37 | compiler.customize() 38 | print(compiler.get_version()) 39 | -------------------------------------------------------------------------------- /doc/source/f2py/advanced.rst: -------------------------------------------------------------------------------- 1 | ====================== 2 | Advanced F2PY usages 3 | ====================== 4 | 5 | Adding self-written functions to F2PY generated modules 6 | ======================================================= 7 | 8 | Self-written Python C/API functions can be defined inside 9 | signature files using ``usercode`` and ``pymethoddef`` statements 10 | (they must be used inside the ``python module`` block). For 11 | example, the following signature file ``spam.pyf`` 12 | 13 | .. include:: spam.pyf 14 | :literal: 15 | 16 | wraps the C library function ``system()``:: 17 | 18 | f2py -c spam.pyf 19 | 20 | In Python: 21 | 22 | .. include:: spam_session.dat 23 | :literal: 24 | 25 | Modifying the dictionary of a F2PY generated module 26 | =================================================== 27 | 28 | The following example illustrates how to add an user-defined 29 | variables to a F2PY generated extension module. Given the following 30 | signature file 31 | 32 | .. include:: var.pyf 33 | :literal: 34 | 35 | compile it as ``f2py -c var.pyf``. 36 | 37 | Notice that the second ``usercode`` statement must be defined inside 38 | an ``interface`` block and where the module dictionary is available through 39 | the variable ``d`` (see ``f2py var.pyf``-generated ``varmodule.c`` for 40 | additional details). 41 | 42 | In Python: 43 | 44 | .. include:: var_session.dat 45 | :literal: 46 | -------------------------------------------------------------------------------- /numpy/lib/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import math 4 | 5 | from .info import __doc__ 6 | from numpy.version import version as __version__ 7 | 8 | from .type_check import * 9 | from .index_tricks import * 10 | from .function_base import * 11 | from .nanfunctions import * 12 | from .shape_base import * 13 | from .stride_tricks import * 14 | from .twodim_base import * 15 | from .ufunclike import * 16 | 17 | from . import scimath as emath 18 | from .polynomial import * 19 | #import convertcode 20 | from .utils import * 21 | from .arraysetops import * 22 | from .npyio import * 23 | from .financial import * 24 | from .arrayterator import Arrayterator 25 | from .arraypad import * 26 | from ._version import * 27 | 28 | __all__ = ['emath', 'math'] 29 | __all__ += type_check.__all__ 30 | __all__ += index_tricks.__all__ 31 | __all__ += function_base.__all__ 32 | __all__ += shape_base.__all__ 33 | __all__ += stride_tricks.__all__ 34 | __all__ += twodim_base.__all__ 35 | __all__ += ufunclike.__all__ 36 | __all__ += arraypad.__all__ 37 | __all__ += polynomial.__all__ 38 | __all__ += utils.__all__ 39 | __all__ += arraysetops.__all__ 40 | __all__ += npyio.__all__ 41 | __all__ += financial.__all__ 42 | __all__ += nanfunctions.__all__ 43 | 44 | from numpy.testing.nosetester import _numpy_tester 45 | test = _numpy_tester().test 46 | bench = _numpy_tester().bench 47 | -------------------------------------------------------------------------------- /numpy/distutils/tests/test_fcompiler_intel.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, absolute_import, print_function 2 | 3 | import numpy.distutils.fcompiler 4 | from numpy.testing import TestCase, run_module_suite, assert_ 5 | 6 | 7 | intel_32bit_version_strings = [ 8 | ("Intel(R) Fortran Intel(R) 32-bit Compiler Professional for applications" 9 | "running on Intel(R) 32, Version 11.1", '11.1'), 10 | ] 11 | 12 | intel_64bit_version_strings = [ 13 | ("Intel(R) Fortran IA-64 Compiler Professional for applications" 14 | "running on IA-64, Version 11.0", '11.0'), 15 | ("Intel(R) Fortran Intel(R) 64 Compiler Professional for applications" 16 | "running on Intel(R) 64, Version 11.1", '11.1') 17 | ] 18 | 19 | class TestIntelFCompilerVersions(TestCase): 20 | def test_32bit_version(self): 21 | fc = numpy.distutils.fcompiler.new_fcompiler(compiler='intel') 22 | for vs, version in intel_32bit_version_strings: 23 | v = fc.version_match(vs) 24 | assert_(v == version) 25 | 26 | 27 | class TestIntelEM64TFCompilerVersions(TestCase): 28 | def test_64bit_version(self): 29 | fc = numpy.distutils.fcompiler.new_fcompiler(compiler='intelem') 30 | for vs, version in intel_64bit_version_strings: 31 | v = fc.version_match(vs) 32 | assert_(v == version) 33 | 34 | 35 | if __name__ == '__main__': 36 | run_module_suite() 37 | -------------------------------------------------------------------------------- /tools/swig/test/Flat.h: -------------------------------------------------------------------------------- 1 | #ifndef FLAT_H 2 | #define FLAT_H 3 | 4 | // The following macro defines the prototypes for a family of 5 | // functions that work with arrays with the forms 6 | // 7 | // void SNAMEProcess(TYPE * array, int size); 8 | // 9 | // for any specified type TYPE (for example: short, unsigned int, long 10 | // long, etc.) with given short name SNAME (for example: short, uint, 11 | // longLong, etc.). The macro is then expanded for the given 12 | // TYPE/SNAME pairs. The resulting functions are for testing numpy 13 | // interfaces for: 14 | // 15 | // * in-place arrays (arbitrary number of dimensions) with a fixed number of elements 16 | // 17 | #define TEST_FUNC_PROTOS(TYPE, SNAME) \ 18 | \ 19 | void SNAME ## Process(TYPE * array, int size); \ 20 | 21 | TEST_FUNC_PROTOS(signed char , schar ) 22 | TEST_FUNC_PROTOS(unsigned char , uchar ) 23 | TEST_FUNC_PROTOS(short , short ) 24 | TEST_FUNC_PROTOS(unsigned short , ushort ) 25 | TEST_FUNC_PROTOS(int , int ) 26 | TEST_FUNC_PROTOS(unsigned int , uint ) 27 | TEST_FUNC_PROTOS(long , long ) 28 | TEST_FUNC_PROTOS(unsigned long , ulong ) 29 | TEST_FUNC_PROTOS(long long , longLong ) 30 | TEST_FUNC_PROTOS(unsigned long long, ulongLong) 31 | TEST_FUNC_PROTOS(float , float ) 32 | TEST_FUNC_PROTOS(double , double ) 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tools/swig/test/Flat.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "Flat.h" 5 | 6 | // The following macro defines a family of functions that work with 1D 7 | // arrays with the forms 8 | // 9 | // void SNAMEProcess(TYPE * array, int size); 10 | // 11 | // for any specified type TYPE (for example: short, unsigned int, long 12 | // long, etc.) with given short name SNAME (for example: short, uint, 13 | // longLong, etc.). The macro is then expanded for the given 14 | // TYPE/SNAME pairs. The resulting functions are for testing numpy 15 | // interfaces for: 16 | // 17 | // * in-place arrays (arbitrary number of dimensions) with a fixed number of elements 18 | // 19 | #define TEST_FUNCS(TYPE, SNAME) \ 20 | \ 21 | void SNAME ## Process(TYPE * array, int size) { \ 22 | for (int i=0; i= half_sz) && 38 | a != 0 && b > @MAX@ / a) { 39 | return 1; 40 | } 41 | return 0; 42 | #endif 43 | } 44 | /**end repeat**/ 45 | 46 | #endif 47 | --------------------------------------------------------------------------------