├── numpy ├── build_utils │ └── __init__.py ├── core │ ├── code_generators │ │ ├── __init__.py │ │ ├── cversions.py │ │ └── cversions.txt │ ├── src │ │ ├── multiarray │ │ │ ├── multiarraymodule.h │ │ │ ├── convert.h │ │ │ ├── hashdescr.h │ │ │ ├── getset.h │ │ │ ├── nditer_pywrap.h │ │ │ ├── sequence.h │ │ │ ├── methods.h │ │ │ ├── arraytypes.h │ │ │ ├── ucsnarrow.h │ │ │ ├── buffer.h │ │ │ ├── refcount.h │ │ │ ├── usertypes.h │ │ │ ├── iterators.h │ │ │ ├── datetime_busday.h │ │ │ ├── numpyos.h │ │ │ ├── numpymemoryview.h │ │ │ ├── arrayobject.h │ │ │ └── item_selection.h │ │ ├── umath │ │ │ ├── umathmodule_onefile.c │ │ │ └── ufunc_object.h │ │ ├── npymath │ │ │ ├── npy_math_common.h │ │ │ └── _signbit.c │ │ └── dummymodule.c │ ├── tests │ │ ├── data │ │ │ ├── astype_copy.pkl │ │ │ └── recarray_from_file.fits │ │ ├── test_indexing.py │ │ └── test_machar.py │ ├── SConstruct │ ├── mlib.ini.in │ ├── npymath.ini.in │ ├── include │ │ └── numpy │ │ │ ├── arrayobject.h │ │ │ ├── npy_no_deprecated_api.h │ │ │ ├── utils.h │ │ │ ├── oldnumeric.h │ │ │ ├── npy_os.h │ │ │ └── numpyconfig.h │ └── bento.info ├── distutils │ ├── tests │ │ ├── f2py_ext │ │ │ ├── __init__.py │ │ │ ├── tests │ │ │ │ └── test_fib2.py │ │ │ ├── src │ │ │ │ ├── fib2.pyf │ │ │ │ └── fib1.f │ │ │ └── setup.py │ │ ├── gen_ext │ │ │ ├── __init__.py │ │ │ └── tests │ │ │ │ └── test_fib3.py │ │ ├── pyrex_ext │ │ │ ├── __init__.py │ │ │ ├── tests │ │ │ │ └── test_primes.py │ │ │ ├── primes.pyx │ │ │ └── setup.py │ │ ├── swig_ext │ │ │ ├── __init__.py │ │ │ ├── src │ │ │ │ ├── zoo.h │ │ │ │ ├── zoo.i │ │ │ │ ├── example.c │ │ │ │ ├── example.i │ │ │ │ └── zoo.cc │ │ │ ├── tests │ │ │ │ ├── test_example2.py │ │ │ │ └── test_example.py │ │ │ └── setup.py │ │ ├── f2py_f90_ext │ │ │ ├── __init__.py │ │ │ ├── src │ │ │ │ └── foo_free.f90 │ │ │ ├── include │ │ │ │ └── body.f90 │ │ │ ├── tests │ │ │ │ └── test_foo.py │ │ │ └── setup.py │ │ └── setup.py │ ├── __version__.py │ ├── info.py │ ├── mingw │ │ └── gfortran_vs2003_hack.c │ ├── compat.py │ ├── command │ │ ├── egg_info.py │ │ ├── develop.py │ │ ├── bdist_rpm.py │ │ ├── sdist.py │ │ ├── install_data.py │ │ ├── __init__.py │ │ ├── autodist.py │ │ └── install_headers.py │ ├── setup.py │ ├── setupscons.py │ ├── numpy_distribution.py │ ├── pathccompiler.py │ └── fcompiler │ │ └── none.py ├── f2py │ ├── NEWS.txt │ ├── docs │ │ ├── usersguide │ │ │ ├── var_session.dat │ │ │ ├── spam_session.dat │ │ │ ├── var.pyf │ │ │ ├── calculate_session.dat │ │ │ ├── ftype.f │ │ │ ├── callback.f │ │ │ ├── compile_session.dat │ │ │ ├── fib2.pyf │ │ │ ├── scalar.f │ │ │ ├── calculate.f │ │ │ ├── extcallback.f │ │ │ ├── common.f │ │ │ ├── allocarr.f90 │ │ │ ├── fib1.f │ │ │ ├── fib1.pyf │ │ │ ├── docutils.conf │ │ │ ├── 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 │ │ ├── FAQ.txt │ │ ├── HISTORY.txt │ │ ├── README.txt │ │ ├── THANKS.txt │ │ ├── pyforttest.pyf │ │ ├── hello.f │ │ ├── pytest.py │ │ ├── simple.f │ │ └── docutils.conf │ ├── 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 │ │ │ ├── kind │ │ │ │ └── foo.f90 │ │ │ └── size │ │ │ │ └── foo.f90 │ │ ├── test_mixed.py │ │ └── test_assumed_shape.py │ ├── TODO.txt │ ├── info.py │ ├── doc │ │ ├── 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 │ │ ├── multiarray │ │ │ ├── bar.c │ │ │ └── foo.f │ │ ├── commands.tex │ │ └── Release-1.x.txt │ ├── __version__.py │ ├── src │ │ └── test │ │ │ ├── foo90.f90 │ │ │ ├── bar.f │ │ │ └── foo.f │ └── README.txt ├── __config__.py.in ├── numarray │ ├── ma.py │ ├── SConstruct │ ├── compat.py │ ├── fft.py │ ├── mlab.py │ ├── matrix.py │ ├── SConscript │ ├── linear_algebra.py │ ├── image.py │ ├── nd_image.py │ ├── random_array.py │ ├── convolve.py │ ├── setupscons.py │ ├── setup.py │ └── __init__.py ├── fft │ ├── SConstruct │ ├── bento.info │ ├── __init__.py │ ├── SConscript │ ├── bscript │ ├── setup.py │ ├── setupscons.py │ ├── fftpack.h │ └── tests │ │ └── test_fftpack.py ├── lib │ ├── SConstruct │ ├── bento.info │ ├── bscript │ ├── SConscript │ ├── setupscons.py │ ├── setup.py │ └── tests │ │ └── test_utils.py ├── linalg │ ├── SConstruct │ ├── lapack_lite │ │ └── wrapped_routines │ ├── bento.info │ ├── SConscript │ ├── setupscons.py │ └── bscript ├── random │ ├── SConstruct │ ├── mtrand │ │ ├── initarray.h │ │ └── mtrand_py_helper.h │ ├── bento.info │ └── bscript ├── doc │ ├── io.py │ ├── howtofind.py │ ├── jargon.py │ ├── performance.py │ ├── methods_vs_functions.py │ └── __init__.py ├── version.py.in ├── oldnumeric │ ├── user_array.py │ ├── tests │ │ └── test_regression.py │ ├── setupscons.py │ ├── setup.py │ ├── array_printer.py │ ├── fft.py │ └── __init__.py ├── matrixlib │ ├── __init__.py │ ├── tests │ │ ├── test_numeric.py │ │ ├── test_multiarray.py │ │ └── test_regression.py │ ├── setup.py │ └── setupscons.py ├── ma │ ├── version.py │ ├── setup.py │ └── setupscons.py ├── compat │ ├── setup.py │ ├── setupscons.py │ └── __init__.py ├── polynomial │ └── setup.py ├── testing │ ├── nulltester.py │ ├── __init__.py │ ├── setupscons.py │ └── setup.py ├── bento.info └── setup.py ├── doc ├── newdtype_example │ ├── floatint │ │ └── __init__.py │ ├── setup.py │ └── example.py ├── cython │ ├── MANIFEST │ ├── run_test.py │ ├── README.txt │ └── Makefile ├── pyrex │ ├── MANIFEST │ ├── run_test.py │ ├── notes │ ├── Makefile │ ├── README.txt │ └── c_python.pxd ├── sphinxext │ ├── __init__.py │ ├── MANIFEST.in │ └── setup.py ├── cdoc │ ├── Makefile │ └── README ├── source │ ├── reference │ │ ├── routines.fft.rst │ │ ├── figures │ │ │ ├── dtype-hierarchy.dia │ │ │ ├── dtype-hierarchy.pdf │ │ │ ├── dtype-hierarchy.png │ │ │ ├── threefundamental.pdf │ │ │ └── threefundamental.png │ │ ├── routines.padding.rst │ │ ├── internals.rst │ │ ├── swig.rst │ │ ├── routines.maskna.rst │ │ ├── routines.numarray.rst │ │ ├── routines.oldnumeric.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.other.rst │ │ ├── routines.polynomials.package.rst │ │ ├── maskedarray.rst │ │ ├── routines.err.rst │ │ ├── routines.bitwise.rst │ │ ├── routines.sort.rst │ │ ├── routines.polynomials.poly1d.rst │ │ ├── routines.dual.rst │ │ ├── routines.matlib.rst │ │ ├── routines.statistics.rst │ │ ├── routines.dtype.rst │ │ ├── routines.logic.rst │ │ └── routines.testing.rst │ ├── scipyshiny_small.png │ ├── dev │ │ ├── gitwash │ │ │ ├── branch_list.png │ │ │ ├── pull_button.png │ │ │ ├── forking_button.png │ │ │ ├── branch_list_compare.png │ │ │ ├── git_development.rst │ │ │ ├── index.rst │ │ │ └── dot2_dot3.rst │ │ ├── gitwash_links.txt │ │ └── index.rst │ ├── user │ │ ├── performance.rst │ │ ├── basics.byteswapping.rst │ │ ├── basics.io.rst │ │ ├── introduction.rst │ │ ├── misc.rst │ │ ├── basics.types.rst │ │ ├── basics.broadcasting.rst │ │ ├── basics.subclassing.rst │ │ ├── basics.indexing.rst │ │ ├── howtofind.rst │ │ ├── basics.rec.rst │ │ ├── c-info.rst │ │ ├── basics.creation.rst │ │ ├── basics.rst │ │ └── index.rst │ ├── glossary.rst │ ├── _templates │ │ ├── indexsidebar.html │ │ ├── layout.html │ │ └── autosummary │ │ │ └── class.rst │ ├── contents.rst │ ├── release.rst │ └── bugs.rst ├── numpybook │ ├── mybook.layout │ ├── Figures │ │ ├── fig1.eps │ │ ├── fig1bw.eps │ │ ├── fig2.eps │ │ ├── fig2bw.eps │ │ ├── contiguous.pdf │ │ ├── hierarchy.dia │ │ ├── hierarchy.fig │ │ ├── hierarchy.pdf │ │ ├── hierarchy.png │ │ └── threefundamental.png │ ├── graphics │ │ ├── note.png │ │ ├── tip.png │ │ ├── warning.png │ │ ├── tip.xfig.fig │ │ ├── warning.fig │ │ ├── tip.fig │ │ └── note.fig │ └── comparison │ │ ├── pyrex │ │ ├── timeme │ │ └── setup.py │ │ ├── weave │ │ ├── timeme │ │ └── filter.py │ │ ├── ctypes │ │ ├── timeme │ │ ├── newfile.dat │ │ └── filter.py │ │ └── f2py │ │ ├── timeme │ │ ├── filter.f │ │ ├── filter.pyf │ │ └── add.f ├── neps │ └── structured_array_extensions.txt ├── swig │ ├── test │ │ ├── Fortran.h │ │ ├── Makefile │ │ ├── Fortran.cxx │ │ ├── Fortran.i │ │ └── Array1.h │ └── Makefile └── release │ └── 1.6.1-notes.rst ├── .gitattributes ├── 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 │ ├── doall.py │ └── misc │ │ └── msvcrt90 │ │ └── yop.sh ├── osxbuild │ ├── docs │ │ └── README.txt │ └── README.txt └── commitstats.py ├── setupsconsegg.py ├── TEST_COMMIT ├── .travis-make-py24-virtualenv.sh ├── benchmarks ├── creating.py ├── casting.py └── sorting.py ├── BENTO_BUILD.txt ├── setupegg.py ├── DEV_README.txt ├── README.txt └── MANIFEST.in /numpy/build_utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/core/code_generators/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc/newdtype_example/floatint/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/distutils/tests/f2py_ext/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/distutils/tests/gen_ext/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/distutils/tests/pyrex_ext/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/distutils/tests/swig_ext/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc/cython/MANIFEST: -------------------------------------------------------------------------------- 1 | numpyx.pyx 2 | setup.py 3 | -------------------------------------------------------------------------------- /doc/pyrex/MANIFEST: -------------------------------------------------------------------------------- 1 | numpyx.pyx 2 | setup.py 3 | -------------------------------------------------------------------------------- /numpy/distutils/tests/f2py_f90_ext/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/f2py/NEWS.txt: -------------------------------------------------------------------------------- 1 | 2 | Read docs/HISTORY.txt -------------------------------------------------------------------------------- /numpy/__config__.py.in: -------------------------------------------------------------------------------- 1 | def show(): 2 | pass 3 | -------------------------------------------------------------------------------- /doc/sphinxext/__init__.py: -------------------------------------------------------------------------------- 1 | from numpydoc import setup 2 | -------------------------------------------------------------------------------- /numpy/numarray/ma.py: -------------------------------------------------------------------------------- 1 | 2 | from numpy.oldnumeric.ma import * 3 | -------------------------------------------------------------------------------- /doc/sphinxext/MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include tests *.py 2 | include *.txt 3 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/var_session.dat: -------------------------------------------------------------------------------- 1 | >>> import var 2 | >>> var.BAR 3 | 5 -------------------------------------------------------------------------------- /numpy/f2py/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_rpm] 2 | doc_files = docs/ 3 | tests/ -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | tools/win32build/nsis_scripts/*.nsi.in eol=crlf 3 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/assumed_shape/.f2py_f2cmap: -------------------------------------------------------------------------------- 1 | dict(real=dict(rk="double")) 2 | -------------------------------------------------------------------------------- /doc/cython/run_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from numpyx import test 3 | test() 4 | -------------------------------------------------------------------------------- /doc/pyrex/run_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from numpyx import test 3 | test() 4 | -------------------------------------------------------------------------------- /numpy/f2py/TODO.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/numpy/f2py/TODO.txt -------------------------------------------------------------------------------- /doc/cdoc/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | doxygen 5 | 6 | .PHONY: all build 7 | 8 | -------------------------------------------------------------------------------- /doc/source/reference/routines.fft.rst: -------------------------------------------------------------------------------- 1 | .. _routines.fft: 2 | .. automodule:: numpy.fft 3 | -------------------------------------------------------------------------------- /numpy/f2py/docs/FAQ.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/numpy/f2py/docs/FAQ.txt -------------------------------------------------------------------------------- /doc/numpybook/mybook.layout: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/mybook.layout -------------------------------------------------------------------------------- /numpy/f2py/docs/HISTORY.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/numpy/f2py/docs/HISTORY.txt -------------------------------------------------------------------------------- /numpy/f2py/docs/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/numpy/f2py/docs/README.txt -------------------------------------------------------------------------------- /numpy/f2py/docs/THANKS.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/numpy/f2py/docs/THANKS.txt -------------------------------------------------------------------------------- /doc/numpybook/Figures/fig1.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/Figures/fig1.eps -------------------------------------------------------------------------------- /doc/numpybook/Figures/fig1bw.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/Figures/fig1bw.eps -------------------------------------------------------------------------------- /doc/numpybook/Figures/fig2.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/Figures/fig2.eps -------------------------------------------------------------------------------- /doc/numpybook/Figures/fig2bw.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/Figures/fig2bw.eps -------------------------------------------------------------------------------- /doc/numpybook/graphics/note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/graphics/note.png -------------------------------------------------------------------------------- /doc/numpybook/graphics/tip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/graphics/tip.png -------------------------------------------------------------------------------- /doc/source/scipyshiny_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/source/scipyshiny_small.png -------------------------------------------------------------------------------- /numpy/f2py/info.py: -------------------------------------------------------------------------------- 1 | """Fortran to Python Interface Generator. 2 | 3 | """ 4 | 5 | postpone_import = True 6 | -------------------------------------------------------------------------------- /doc/numpybook/graphics/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/graphics/warning.png -------------------------------------------------------------------------------- /numpy/f2py/doc/ex1/bar.f: -------------------------------------------------------------------------------- 1 | function bar(a,b) 2 | integer a,b,bar 3 | bar = a + b 4 | end 5 | -------------------------------------------------------------------------------- /doc/numpybook/Figures/contiguous.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/Figures/contiguous.pdf -------------------------------------------------------------------------------- /doc/numpybook/Figures/hierarchy.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/Figures/hierarchy.dia -------------------------------------------------------------------------------- /doc/numpybook/Figures/hierarchy.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/Figures/hierarchy.fig -------------------------------------------------------------------------------- /doc/numpybook/Figures/hierarchy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/Figures/hierarchy.pdf -------------------------------------------------------------------------------- /doc/numpybook/Figures/hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/Figures/hierarchy.png -------------------------------------------------------------------------------- /numpy/core/src/multiarray/multiarraymodule.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_MULTIARRAY_H_ 2 | #define _NPY_MULTIARRAY_H_ 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /numpy/core/tests/data/astype_copy.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/numpy/core/tests/data/astype_copy.pkl -------------------------------------------------------------------------------- /numpy/f2py/doc/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/pyrex/notes: -------------------------------------------------------------------------------- 1 | - cimport with a .pxd file vs 'include foo.pxi'? 2 | 3 | - the need to repeat: pyrex does NOT parse C headers. -------------------------------------------------------------------------------- /doc/source/dev/gitwash/branch_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/source/dev/gitwash/branch_list.png -------------------------------------------------------------------------------- /doc/source/dev/gitwash/pull_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/source/dev/gitwash/pull_button.png -------------------------------------------------------------------------------- /doc/source/user/performance.rst: -------------------------------------------------------------------------------- 1 | *********** 2 | Performance 3 | *********** 4 | 5 | .. automodule:: numpy.doc.performance 6 | -------------------------------------------------------------------------------- /numpy/f2py/doc/f2python9-final/flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/numpy/f2py/doc/f2python9-final/flow.jpg -------------------------------------------------------------------------------- /tools/allocation_tracking/sorttable.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/tools/allocation_tracking/sorttable.js -------------------------------------------------------------------------------- /doc/numpybook/Figures/threefundamental.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/numpybook/Figures/threefundamental.png -------------------------------------------------------------------------------- /doc/source/dev/gitwash/forking_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/source/dev/gitwash/forking_button.png -------------------------------------------------------------------------------- /numpy/core/SConstruct: -------------------------------------------------------------------------------- 1 | from numscons import GetInitEnvironment 2 | GetInitEnvironment(ARGUMENTS).DistutilsSConscript('SConscript') 3 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/convert.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAYOBJECT_CONVERT_H_ 2 | #define _NPY_ARRAYOBJECT_CONVERT_H_ 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /numpy/distutils/__version__.py: -------------------------------------------------------------------------------- 1 | major = 0 2 | minor = 4 3 | micro = 0 4 | version = '%(major)d.%(minor)d.%(micro)d' % (locals()) 5 | -------------------------------------------------------------------------------- /numpy/fft/SConstruct: -------------------------------------------------------------------------------- 1 | from numscons import GetInitEnvironment 2 | GetInitEnvironment(ARGUMENTS).DistutilsSConscript('SConscript') 3 | -------------------------------------------------------------------------------- /numpy/lib/SConstruct: -------------------------------------------------------------------------------- 1 | from numscons import GetInitEnvironment 2 | GetInitEnvironment(ARGUMENTS).DistutilsSConscript('SConscript') 3 | -------------------------------------------------------------------------------- /numpy/distutils/info.py: -------------------------------------------------------------------------------- 1 | """ 2 | Enhanced distutils with Fortran compilers support and more. 3 | """ 4 | 5 | postpone_import = True 6 | -------------------------------------------------------------------------------- /numpy/f2py/doc/ex1/foo.f: -------------------------------------------------------------------------------- 1 | subroutine foo(a) 2 | integer a 3 | cf2py intent(in,out) :: a 4 | a = a + 5 5 | end 6 | -------------------------------------------------------------------------------- /numpy/f2py/doc/f2python9-final/structure.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/numpy/f2py/doc/f2python9-final/structure.jpg -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/linalg/SConstruct: -------------------------------------------------------------------------------- 1 | from numscons import GetInitEnvironment 2 | GetInitEnvironment(ARGUMENTS).DistutilsSConscript('SConscript') 3 | -------------------------------------------------------------------------------- /numpy/numarray/SConstruct: -------------------------------------------------------------------------------- 1 | from numscons import GetInitEnvironment 2 | GetInitEnvironment(ARGUMENTS).DistutilsSConscript('SConscript') 3 | -------------------------------------------------------------------------------- /numpy/numarray/compat.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['NewAxis', 'ArrayType'] 3 | 4 | from numpy import newaxis as NewAxis, ndarray as ArrayType 5 | -------------------------------------------------------------------------------- /numpy/random/SConstruct: -------------------------------------------------------------------------------- 1 | from numscons import GetInitEnvironment 2 | GetInitEnvironment(ARGUMENTS).DistutilsSConscript('SConscript') 3 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/branch_list_compare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/source/dev/gitwash/branch_list_compare.png -------------------------------------------------------------------------------- /doc/source/user/basics.byteswapping.rst: -------------------------------------------------------------------------------- 1 | ************* 2 | Byte-swapping 3 | ************* 4 | 5 | .. automodule:: numpy.doc.byteswapping 6 | -------------------------------------------------------------------------------- /numpy/core/tests/data/recarray_from_file.fits: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/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 | -------------------------------------------------------------------------------- /numpy/distutils/tests/f2py_f90_ext/src/foo_free.f90: -------------------------------------------------------------------------------- 1 | module foo_free 2 | contains 3 | 4 | include "body.f90" 5 | 6 | end module foo_free 7 | -------------------------------------------------------------------------------- /numpy/doc/io.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | ========= 4 | Array I/O 5 | ========= 6 | 7 | Placeholder for array I/O documentation. 8 | 9 | """ 10 | -------------------------------------------------------------------------------- /tools/numpy-macosx-installer/dmgbackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/tools/numpy-macosx-installer/dmgbackground.png -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/source/reference/figures/dtype-hierarchy.dia -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/source/reference/figures/dtype-hierarchy.pdf -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/source/reference/figures/dtype-hierarchy.png -------------------------------------------------------------------------------- /doc/source/reference/figures/threefundamental.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/source/reference/figures/threefundamental.pdf -------------------------------------------------------------------------------- /doc/source/reference/figures/threefundamental.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/doc/source/reference/figures/threefundamental.png -------------------------------------------------------------------------------- /numpy/f2py/doc/f2python9-final/aerostructure.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/numpy/f2py/doc/f2python9-final/aerostructure.jpg -------------------------------------------------------------------------------- /doc/numpybook/comparison/pyrex/timeme: -------------------------------------------------------------------------------- 1 | python2.4 -m timeit -s "import numpy as N; a=N.random.rand(100,200); import filter" "b = filter.filter(a)" 2 | 3 | -------------------------------------------------------------------------------- /doc/numpybook/comparison/weave/timeme: -------------------------------------------------------------------------------- 1 | python2.4 -m timeit -s "import numpy as N; a=N.random.rand(100,200); import filter" "b = filter.filter(a)" 2 | 3 | -------------------------------------------------------------------------------- /numpy/lib/bento.info: -------------------------------------------------------------------------------- 1 | HookFile: bscript 2 | 3 | Library: 4 | Extension: _compiled_base 5 | Sources: 6 | src/_compiled_base.c 7 | -------------------------------------------------------------------------------- /numpy/numarray/fft.py: -------------------------------------------------------------------------------- 1 | 2 | from numpy.oldnumeric.fft import * 3 | import numpy.oldnumeric.fft as nof 4 | 5 | __all__ = nof.__all__ 6 | 7 | del nof 8 | -------------------------------------------------------------------------------- /tools/numpy-macosx-installer/art/dmgbackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakevdp/numpy/HEAD/tools/numpy-macosx-installer/art/dmgbackground.png -------------------------------------------------------------------------------- /doc/numpybook/comparison/ctypes/timeme: -------------------------------------------------------------------------------- 1 | python2.4 -m timeit -s "import numpy as N; a=N.random.rand(100,200); import filter" "b = filter.filter(a)" 2 | 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 -------------------------------------------------------------------------------- /numpy/numarray/mlab.py: -------------------------------------------------------------------------------- 1 | 2 | from numpy.oldnumeric.mlab import * 3 | import numpy.oldnumeric.mlab as nom 4 | 5 | __all__ = nom.__all__ 6 | 7 | del nom 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/doc/howtofind.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | ================= 4 | How to Find Stuff 5 | ================= 6 | 7 | How to find things in NumPy. 8 | 9 | """ 10 | -------------------------------------------------------------------------------- /numpy/doc/jargon.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | ====== 4 | Jargon 5 | ====== 6 | 7 | Placeholder for computer science, engineering and other jargon. 8 | 9 | """ 10 | -------------------------------------------------------------------------------- /numpy/fft/bento.info: -------------------------------------------------------------------------------- 1 | HookFile: bscript 2 | 3 | Library: 4 | Extension: fftpack_lite 5 | Sources: 6 | fftpack_litemodule.c, fftpack.c 7 | -------------------------------------------------------------------------------- /numpy/distutils/tests/f2py_f90_ext/include/body.f90: -------------------------------------------------------------------------------- 1 | subroutine bar13(a) 2 | !f2py intent(out) a 3 | integer a 4 | a = 13 5 | end subroutine bar13 6 | -------------------------------------------------------------------------------- /numpy/f2py/docs/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 | -------------------------------------------------------------------------------- /numpy/doc/performance.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | =========== 4 | Performance 5 | =========== 6 | 7 | Placeholder for Improving Performance documentation. 8 | 9 | """ 10 | -------------------------------------------------------------------------------- /doc/numpybook/comparison/f2py/timeme: -------------------------------------------------------------------------------- 1 | python2.4 -m timeit -s "import numpy as N; a=N.random.rand(100,200); import filter" "b=N.zeros_like(a); none = filter.DFILTER2D(a,b)" 2 | -------------------------------------------------------------------------------- /doc/source/user/introduction.rst: -------------------------------------------------------------------------------- 1 | ************ 2 | Introduction 3 | ************ 4 | 5 | 6 | .. toctree:: 7 | 8 | whatisnumpy 9 | install 10 | howtofind 11 | -------------------------------------------------------------------------------- /doc/source/user/misc.rst: -------------------------------------------------------------------------------- 1 | ************* 2 | Miscellaneous 3 | ************* 4 | 5 | .. automodule:: numpy.doc.misc 6 | 7 | .. automodule:: numpy.doc.methods_vs_functions 8 | -------------------------------------------------------------------------------- /numpy/f2py/docs/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/basics.types.rst: -------------------------------------------------------------------------------- 1 | ********** 2 | Data types 3 | ********** 4 | 5 | .. seealso:: :ref:`Data type objects ` 6 | 7 | .. automodule:: numpy.doc.basics 8 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/hashdescr.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_HASHDESCR_H_ 2 | #define _NPY_HASHDESCR_H_ 3 | 4 | NPY_NO_EXPORT long 5 | PyArray_DescrHash(PyObject* odescr); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 -------------------------------------------------------------------------------- /doc/source/dev/gitwash_links.txt: -------------------------------------------------------------------------------- 1 | .. _NumPy: http://numpy.scipy.org 2 | .. _`NumPy github`: http://github.com/numpy/numpy 3 | .. _`NumPy mailing list`: http://scipy.org/Mailing_Lists 4 | -------------------------------------------------------------------------------- /doc/source/user/basics.broadcasting.rst: -------------------------------------------------------------------------------- 1 | ************ 2 | Broadcasting 3 | ************ 4 | 5 | .. seealso:: :class:`numpy.broadcast` 6 | 7 | .. automodule:: numpy.doc.broadcasting 8 | -------------------------------------------------------------------------------- /doc/pyrex/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | python setup.py build_ext --inplace 3 | 4 | test: all 5 | python run_test.py 6 | 7 | .PHONY: clean 8 | clean: 9 | rm -rf *~ *.so *.c *.o build 10 | -------------------------------------------------------------------------------- /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/umath/umathmodule_onefile.c: -------------------------------------------------------------------------------- 1 | #include "loops.c" 2 | 3 | #include "ufunc_object.c" 4 | #include "ufunc_type_resolution.c" 5 | #include "reduction.c" 6 | #include "umathmodule.c" 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /setupsconsegg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | A setup.py script to use setuptools, which gives egg goodness, etc. 4 | """ 5 | 6 | from setuptools import setup 7 | execfile('setupscons.py') 8 | -------------------------------------------------------------------------------- /numpy/distutils/tests/swig_ext/src/zoo.h: -------------------------------------------------------------------------------- 1 | 2 | class Zoo{ 3 | int n; 4 | char animals[10][50]; 5 | public: 6 | Zoo(); 7 | void shut_up(char *animal); 8 | void display(); 9 | }; 10 | -------------------------------------------------------------------------------- /doc/pyrex/README.txt: -------------------------------------------------------------------------------- 1 | WARNING: this code is deprecated and slated for removal soon. See the 2 | doc/cython directory for the replacement, which uses Cython (the actively 3 | maintained version of Pyrex). 4 | -------------------------------------------------------------------------------- /numpy/distutils/compat.py: -------------------------------------------------------------------------------- 1 | """Small modules to cope with python 2 vs 3 incompatibilities inside 2 | numpy.distutils 3 | """ 4 | import sys 5 | 6 | def get_exception(): 7 | return sys.exc_info()[1] 8 | -------------------------------------------------------------------------------- /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/doc/methods_vs_functions.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | ===================== 4 | Methods vs. Functions 5 | ===================== 6 | 7 | Placeholder for Methods vs. Functions documentation. 8 | 9 | """ 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 | -------------------------------------------------------------------------------- /numpy/numarray/matrix.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['Matrix'] 3 | 4 | from numpy import matrix as _matrix 5 | 6 | def Matrix(data, typecode=None, copy=1, savespace=0): 7 | return _matrix(data, typecode, copy=copy) 8 | -------------------------------------------------------------------------------- /numpy/version.py.in: -------------------------------------------------------------------------------- 1 | short_version = $VERSION 2 | version = $VERSION 3 | full_version = $FULL_VERSION 4 | git_revision = $GIT_REVISION 5 | release = $IS_RELEASED 6 | 7 | if not release: 8 | version = full_version 9 | -------------------------------------------------------------------------------- /doc/source/_templates/indexsidebar.html: -------------------------------------------------------------------------------- 1 |

Resources

2 | 6 | -------------------------------------------------------------------------------- /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/getset.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_GETSET_H_ 2 | #define _NPY_ARRAY_GETSET_H_ 3 | 4 | #ifdef NPY_ENABLE_SEPARATE_COMPILATION 5 | extern NPY_NO_EXPORT PyGetSetDef array_getsetlist[]; 6 | #endif 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/distutils/tests/swig_ext/src/zoo.i: -------------------------------------------------------------------------------- 1 | // -*- c++ -*- 2 | // Example copied from http://linuxgazette.net/issue49/pramode.html 3 | 4 | %module example2 5 | 6 | %{ 7 | #include "zoo.h" 8 | %} 9 | 10 | %include "zoo.h" 11 | -------------------------------------------------------------------------------- /numpy/fft/__init__.py: -------------------------------------------------------------------------------- 1 | # To get sub-modules 2 | from info import __doc__ 3 | 4 | from fftpack import * 5 | from helper import * 6 | 7 | from numpy.testing import Tester 8 | test = Tester().test 9 | bench = Tester().bench 10 | -------------------------------------------------------------------------------- /numpy/random/mtrand/initarray.h: -------------------------------------------------------------------------------- 1 | #include "Python.h" 2 | #include "numpy/arrayobject.h" 3 | #include "randomkit.h" 4 | 5 | extern void 6 | init_by_array(rk_state *self, unsigned long init_key[], 7 | npy_intp key_length); 8 | -------------------------------------------------------------------------------- /doc/source/reference/routines.maskna.rst: -------------------------------------------------------------------------------- 1 | NA-Masked Array Routines 2 | ======================== 3 | 4 | .. currentmodule:: numpy 5 | 6 | NA Values 7 | --------- 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | isna 12 | -------------------------------------------------------------------------------- /doc/source/reference/routines.numarray.rst: -------------------------------------------------------------------------------- 1 | ********************************************** 2 | Numarray compatibility (:mod:`numpy.numarray`) 3 | ********************************************** 4 | 5 | .. automodule:: numpy.numarray 6 | 7 | -------------------------------------------------------------------------------- /doc/source/user/howtofind.rst: -------------------------------------------------------------------------------- 1 | ************************* 2 | How to find documentation 3 | ************************* 4 | 5 | .. seealso:: :ref:`Numpy-specific help functions ` 6 | 7 | .. automodule:: numpy.doc.howtofind 8 | -------------------------------------------------------------------------------- /doc/source/dev/index.rst: -------------------------------------------------------------------------------- 1 | ##################### 2 | Contributing to Numpy 3 | ##################### 4 | 5 | .. toctree:: 6 | :maxdepth: 3 7 | 8 | gitwash/index 9 | 10 | For core developers: see :ref:`development-workflow`. 11 | -------------------------------------------------------------------------------- /doc/source/user/basics.rec.rst: -------------------------------------------------------------------------------- 1 | .. _structured_arrays: 2 | 3 | *************************************** 4 | Structured arrays (aka "Record arrays") 5 | *************************************** 6 | 7 | .. automodule:: numpy.doc.structured_arrays 8 | -------------------------------------------------------------------------------- /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/__version__.py: -------------------------------------------------------------------------------- 1 | major = 2 2 | 3 | try: 4 | from __svn_version__ import version 5 | version_info = (major, version) 6 | version = '%s_%s' % version_info 7 | except (ImportError, ValueError): 8 | version = str(major) 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/oldnumeric/user_array.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | from numpy.oldnumeric import * 4 | from numpy.lib.user_array import container as UserArray 5 | 6 | import numpy.oldnumeric as nold 7 | __all__ = nold.__all__[:] 8 | __all__ += ['UserArray'] 9 | del nold 10 | -------------------------------------------------------------------------------- /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/matrixlib/__init__.py: -------------------------------------------------------------------------------- 1 | """Sub-package containing the matrix class and related functions.""" 2 | from defmatrix import * 3 | 4 | __all__ = defmatrix.__all__ 5 | 6 | from numpy.testing import Tester 7 | test = Tester().test 8 | bench = Tester().bench 9 | -------------------------------------------------------------------------------- /numpy/f2py/README.txt: -------------------------------------------------------------------------------- 1 | ====================================================================== 2 | F2PY - Fortran to Python Interface Generator 3 | ====================================================================== 4 | 5 | Read docs/README.txt 6 | -------------------------------------------------------------------------------- /numpy/random/bento.info: -------------------------------------------------------------------------------- 1 | HookFile: bscript 2 | 3 | Library: 4 | Extension: mtrand 5 | Sources: 6 | mtrand/mtrand.c, 7 | mtrand/randomkit.c, 8 | mtrand/initarray.c, 9 | mtrand/distributions.c 10 | -------------------------------------------------------------------------------- /doc/source/contents.rst: -------------------------------------------------------------------------------- 1 | ##################### 2 | Numpy manual contents 3 | ##################### 4 | 5 | .. toctree:: 6 | 7 | user/index 8 | reference/index 9 | dev/index 10 | release 11 | about 12 | bugs 13 | license 14 | glossary 15 | -------------------------------------------------------------------------------- /numpy/f2py/docs/pytest.py: -------------------------------------------------------------------------------- 1 | #File: pytest.py 2 | import Numeric 3 | def foo(a): 4 | a = Numeric.array(a) 5 | m,n = a.shape 6 | for i in range(m): 7 | for j in range(n): 8 | a[i,j] = a[i,j] + 10*(i+1) + (j+1) 9 | return a 10 | #eof 11 | -------------------------------------------------------------------------------- /doc/source/reference/routines.oldnumeric.rst: -------------------------------------------------------------------------------- 1 | *************************************************** 2 | Old Numeric compatibility (:mod:`numpy.oldnumeric`) 3 | *************************************************** 4 | 5 | .. currentmodule:: numpy 6 | 7 | .. automodule:: numpy.oldnumeric 8 | 9 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/lib/bscript: -------------------------------------------------------------------------------- 1 | from bento.commands import hooks 2 | 3 | @hooks.pre_build 4 | def build(context): 5 | context.tweak_extension("_compiled_base", 6 | includes=["../core/include", "../core/include/numpy", "../core", 7 | "../core/src/private"]) 8 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/matrixlib/tests/test_numeric.py: -------------------------------------------------------------------------------- 1 | from numpy.testing import assert_equal, TestCase 2 | from numpy.core import ones 3 | from numpy import matrix 4 | 5 | class TestDot(TestCase): 6 | def test_matscalar(self): 7 | b1 = matrix(ones((3,3),dtype=complex)) 8 | assert_equal(b1*1.0, b1) 9 | -------------------------------------------------------------------------------- /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 | 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /numpy/fft/SConscript: -------------------------------------------------------------------------------- 1 | # Last Change: Thu Jun 12 06:00 PM 2008 J 2 | # vim:syntax=python 3 | from numscons import GetNumpyEnvironment 4 | 5 | env = GetNumpyEnvironment(ARGUMENTS) 6 | 7 | env.NumpyPythonExtension('fftpack_lite', 8 | source = ['fftpack_litemodule.c', 'fftpack.c']) 9 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /numpy/fft/bscript: -------------------------------------------------------------------------------- 1 | from bento.commands import hooks 2 | 3 | @hooks.pre_build 4 | def build(context): 5 | context.tweak_extension("fftpack_lite", 6 | includes=["../core/include", "../core/include/numpy", 7 | "../core", "../core/src/private"]) 8 | -------------------------------------------------------------------------------- /doc/source/user/basics.rst: -------------------------------------------------------------------------------- 1 | ************ 2 | Numpy basics 3 | ************ 4 | 5 | .. toctree:: 6 | :maxdepth: 2 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/core/src/multiarray/sequence.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_SEQUENCE_H_ 2 | #define _NPY_ARRAY_SEQUENCE_H_ 3 | 4 | #ifdef NPY_ENABLE_SEPARATE_COMPILATION 5 | extern NPY_NO_EXPORT PySequenceMethods array_as_sequence; 6 | #else 7 | NPY_NO_EXPORT PySequenceMethods array_as_sequence; 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from numpy.testing import * 3 | from f2py_f90_ext import foo 4 | 5 | class TestFoo(TestCase): 6 | def test_foo_free(self): 7 | assert_equal(foo.foo_free.bar13(),13) 8 | 9 | if __name__ == "__main__": 10 | run_module_suite() 11 | -------------------------------------------------------------------------------- /numpy/distutils/tests/gen_ext/tests/test_fib3.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from numpy.testing import * 3 | from gen_ext import fib3 4 | 5 | class TestFib3(TestCase): 6 | def test_fib(self): 7 | assert_array_equal(fib3.fib(6),[0,1,1,2,3,5]) 8 | 9 | if __name__ == "__main__": 10 | run_module_suite() 11 | -------------------------------------------------------------------------------- /numpy/numarray/SConscript: -------------------------------------------------------------------------------- 1 | # Last Change: Thu Jun 12 06:00 PM 2008 J 2 | # vim:syntax=python 3 | from numscons import GetNumpyEnvironment 4 | 5 | env = GetNumpyEnvironment(ARGUMENTS) 6 | env.Prepend(CPPPATH=['numpy', "#$build_prefix/numpy/core/src/private"]) 7 | env.NumpyPythonExtension('_capi', source = ['_capi.c']) 8 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/methods.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_METHODS_H_ 2 | #define _NPY_ARRAY_METHODS_H_ 3 | 4 | #ifdef NPY_ENABLE_SEPARATE_COMPILATION 5 | extern NPY_NO_EXPORT PyMethodDef array_methods[]; 6 | #endif 7 | 8 | NPY_NO_EXPORT const char * 9 | npy_casting_to_string(NPY_CASTING casting); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /numpy/distutils/tests/f2py_ext/tests/test_fib2.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from numpy.testing import * 3 | from f2py_ext import fib2 4 | 5 | class TestFib2(TestCase): 6 | 7 | def test_fib(self): 8 | assert_array_equal(fib2.fib(6),[0,1,1,2,3,5]) 9 | 10 | if __name__ == "__main__": 11 | run_module_suite() 12 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /numpy/oldnumeric/tests/test_regression.py: -------------------------------------------------------------------------------- 1 | from numpy.testing import * 2 | 3 | rlevel = 1 4 | 5 | class TestRegression(TestCase): 6 | def test_numeric_random(self, level=rlevel): 7 | """Ticket #552""" 8 | from numpy.oldnumeric.random_array import randint 9 | randint(0,50,[2,3]) 10 | 11 | -------------------------------------------------------------------------------- /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 | patching 14 | git_development 15 | git_resources 16 | 17 | 18 | -------------------------------------------------------------------------------- /numpy/distutils/tests/f2py_ext/src/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 | -------------------------------------------------------------------------------- /numpy/f2py/docs/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/lib/SConscript: -------------------------------------------------------------------------------- 1 | # Last Change: Thu Jun 12 06:00 PM 2008 J 2 | # vim:syntax=python 3 | from numscons import GetNumpyEnvironment 4 | 5 | env = GetNumpyEnvironment(ARGUMENTS) 6 | env.Prepend(CPPPATH=["#$build_prefix/numpy/core/src/private"]) 7 | env.NumpyPythonExtension('_compiled_base', source = ['src/_compiled_base.c']) 8 | -------------------------------------------------------------------------------- /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 | #endif 11 | -------------------------------------------------------------------------------- /numpy/distutils/tests/swig_ext/src/example.c: -------------------------------------------------------------------------------- 1 | /* File : example.c */ 2 | 3 | double My_variable = 3.0; 4 | 5 | /* Compute factorial of n */ 6 | int fact(int n) { 7 | if (n <= 1) return 1; 8 | else return n*fact(n-1); 9 | } 10 | 11 | /* Compute n mod m */ 12 | int my_mod(int n, int m) { 13 | return(n % m); 14 | } 15 | -------------------------------------------------------------------------------- /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/linalg/bento.info: -------------------------------------------------------------------------------- 1 | HookFile: bscript 2 | 3 | Library: 4 | Extension: lapack_lite 5 | Sources: 6 | blas_lite.c, 7 | dlamch.c, 8 | dlapack_lite.c, 9 | f2c_lite.c, 10 | lapack_litemodule.c, 11 | python_xerbla.c, 12 | zlapack_lite.c 13 | -------------------------------------------------------------------------------- /numpy/oldnumeric/setupscons.py: -------------------------------------------------------------------------------- 1 | 2 | def configuration(parent_package='',top_path=None): 3 | from numpy.distutils.misc_util import Configuration 4 | return Configuration('oldnumeric',parent_package,top_path) 5 | 6 | if __name__ == '__main__': 7 | from numpy.distutils.core import setup 8 | setup(configuration=configuration) 9 | -------------------------------------------------------------------------------- /doc/source/release.rst: -------------------------------------------------------------------------------- 1 | ************* 2 | Release Notes 3 | ************* 4 | 5 | .. include:: ../release/1.3.0-notes.rst 6 | .. include:: ../release/1.4.0-notes.rst 7 | .. include:: ../release/1.5.0-notes.rst 8 | .. include:: ../release/1.6.0-notes.rst 9 | .. include:: ../release/1.6.1-notes.rst 10 | .. include:: ../release/1.6.2-notes.rst 11 | -------------------------------------------------------------------------------- /doc/numpybook/graphics/tip.xfig.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 1 3 0 1 1 1 50 -1 20 0.000 1 0.0000 3600 2400 660 660 3600 2400 4260 2400 11 | 1 3 0 1 7 7 51 -1 20 0.000 1 0.0000 3600 2400 720 720 3600 2400 4320 2400 12 | 4 0 7 50 -1 2 92 0.0000 4 960 390 3450 2850 i\001 13 | -------------------------------------------------------------------------------- /TEST_COMMIT: -------------------------------------------------------------------------------- 1 | oliphant: yes 2 | stefanv: yes 3 | rkern: yes 4 | pearu: yes 5 | fperez: yes 6 | chanley: yes 7 | cookedm: yes 8 | swalton: yes 9 | eric: yes 10 | charris: no 11 | fonnesbeck: no 12 | afayolle: no 13 | dubois: no 14 | sasha: yes 15 | tim_hochberg: yes 16 | jarrod.millman: yes 17 | ariver: 2010-01-14 20:02:18 18 | rgommers: test build bot v3 19 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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/f2py/doc/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 3 | #include 4 | 5 | Zoo::Zoo() 6 | { 7 | n = 0; 8 | } 9 | 10 | void Zoo::shut_up(char *animal) 11 | { 12 | if (n < 10) { 13 | strcpy(animals[n], animal); 14 | n++; 15 | } 16 | } 17 | 18 | void Zoo::display() 19 | { 20 | int i; 21 | for(i = 0; i < n; i++) 22 | printf("%s\n", animals[i]); 23 | } 24 | -------------------------------------------------------------------------------- /numpy/numarray/linear_algebra.py: -------------------------------------------------------------------------------- 1 | 2 | from numpy.oldnumeric.linear_algebra import * 3 | 4 | import numpy.oldnumeric.linear_algebra as nol 5 | 6 | __all__ = list(nol.__all__) 7 | __all__ += ['qr_decomposition'] 8 | 9 | from numpy.linalg import qr as _qr 10 | 11 | def qr_decomposition(a, mode='full'): 12 | res = _qr(a, mode) 13 | if mode == 'full': 14 | return res 15 | return (None, res) 16 | -------------------------------------------------------------------------------- /doc/source/reference/routines.set.rst: -------------------------------------------------------------------------------- 1 | Set routines 2 | ============ 3 | 4 | .. currentmodule:: numpy 5 | 6 | Making proper sets 7 | ------------------ 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | unique 12 | 13 | Boolean operations 14 | ------------------ 15 | .. autosummary:: 16 | :toctree: generated/ 17 | 18 | in1d 19 | intersect1d 20 | setdiff1d 21 | setxor1d 22 | union1d 23 | -------------------------------------------------------------------------------- /doc/source/reference/routines.help.rst: -------------------------------------------------------------------------------- 1 | .. _routines.help: 2 | 3 | Numpy-specific help functions 4 | ============================= 5 | 6 | .. currentmodule:: numpy 7 | 8 | Finding help 9 | ------------ 10 | 11 | .. autosummary:: 12 | :toctree: generated/ 13 | 14 | lookfor 15 | 16 | 17 | Reading help 18 | ------------ 19 | 20 | .. autosummary:: 21 | :toctree: generated/ 22 | 23 | info 24 | source 25 | -------------------------------------------------------------------------------- /numpy/f2py/doc/f2python9-final/mk_ps.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 | dvips python9.dvi -o ../f2python9.ps 13 | cd .. 14 | gzip -f f2python9.ps 15 | -------------------------------------------------------------------------------- /numpy/distutils/command/egg_info.py: -------------------------------------------------------------------------------- 1 | from setuptools.command.egg_info import egg_info as _egg_info 2 | 3 | class egg_info(_egg_info): 4 | def run(self): 5 | # We need to ensure that build_src has been executed in order to give 6 | # setuptools' egg_info command real filenames instead of functions which 7 | # generate files. 8 | self.run_command("build_src") 9 | _egg_info.run(self) 10 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/allocarr.f90: -------------------------------------------------------------------------------- 1 | module mod 2 | real, allocatable, dimension(:,:) :: b 3 | contains 4 | subroutine foo 5 | integer k 6 | if (allocated(b)) then 7 | print*, "b=[" 8 | do k = 1,size(b,1) 9 | print*, b(k,1:size(b,2)) 10 | enddo 11 | print*, "]" 12 | else 13 | print*, "b is not allocated" 14 | endif 15 | end subroutine foo 16 | end module mod 17 | -------------------------------------------------------------------------------- /doc/newdtype_example/setup.py: -------------------------------------------------------------------------------- 1 | 2 | from numpy.distutils.core import setup 3 | 4 | def configuration(parent_package = '', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | config = Configuration('floatint',parent_package,top_path) 7 | 8 | config.add_extension('floatint', 9 | sources = ['floatint.c']); 10 | return config 11 | 12 | setup(configuration=configuration) 13 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/ucsnarrow.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_UCSNARROW_H_ 2 | #define _NPY_UCSNARROW_H_ 3 | 4 | NPY_NO_EXPORT int 5 | PyUCS2Buffer_FromUCS4(Py_UNICODE *ucs2, npy_ucs4 *ucs4, int ucs4length); 6 | 7 | NPY_NO_EXPORT int 8 | PyUCS2Buffer_AsUCS4(Py_UNICODE *ucs2, npy_ucs4 *ucs4, int ucs2len, int ucs4len); 9 | 10 | NPY_NO_EXPORT PyUnicodeObject * 11 | PyUnicode_FromUCS4(char *src, Py_ssize_t size, int swap, int align); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /tools/win32build/cpuid/cpuid.h: -------------------------------------------------------------------------------- 1 | #ifndef _GABOU_CPUID_H 2 | #define _GABOU_CPUID_H 3 | 4 | #include 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/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/f2py/doc/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 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/fib1.f: -------------------------------------------------------------------------------- 1 | C FILE: FIB1.F 2 | SUBROUTINE FIB(A,N) 3 | C 4 | C CALCULATE FIRST N FIBONACCI NUMBERS 5 | C 6 | INTEGER N 7 | REAL*8 A(N) 8 | DO I=1,N 9 | IF (I.EQ.1) THEN 10 | A(I) = 0.0D0 11 | ELSEIF (I.EQ.2) THEN 12 | A(I) = 1.0D0 13 | ELSE 14 | A(I) = A(I-1) + A(I-2) 15 | ENDIF 16 | ENDDO 17 | END 18 | C END FILE FIB1.F 19 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE_BUFFER_H_ 2 | #define _NPY_PRIVATE_BUFFER_H_ 3 | 4 | #ifdef NPY_ENABLE_SEPARATE_COMPILATION 5 | extern NPY_NO_EXPORT PyBufferProcs array_as_buffer; 6 | #else 7 | NPY_NO_EXPORT PyBufferProcs array_as_buffer; 8 | #endif 9 | 10 | NPY_NO_EXPORT void 11 | _array_dealloc_buffer_info(PyArrayObject *self); 12 | 13 | NPY_NO_EXPORT PyArray_Descr* 14 | _descriptor_from_pep3118_format(char *s); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /numpy/f2py/doc/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 -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/distutils/tests/f2py_ext/src/fib1.f: -------------------------------------------------------------------------------- 1 | C FILE: FIB1.F 2 | SUBROUTINE FIB(A,N) 3 | C 4 | C CALCULATE FIRST N FIBONACCI NUMBERS 5 | C 6 | INTEGER N 7 | REAL*8 A(N) 8 | DO I=1,N 9 | IF (I.EQ.1) THEN 10 | A(I) = 0.0D0 11 | ELSEIF (I.EQ.2) THEN 12 | A(I) = 1.0D0 13 | ELSE 14 | A(I) = A(I-1) + A(I-2) 15 | ENDIF 16 | ENDDO 17 | END 18 | C END FILE FIB1.F 19 | -------------------------------------------------------------------------------- /numpy/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 | -------------------------------------------------------------------------------- /.travis-make-py24-virtualenv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | VIRTENV=$1 4 | 5 | set -x 6 | set -e 7 | 8 | curl -O http://www.python.org/ftp/python/2.4.6/Python-2.4.6.tar.bz2 9 | tar xjf Python-2.4.6.tar.bz2 10 | cd Python-2.4.6 11 | cat >setup.cfg < 1000: 10 | kmax = 1000 11 | k = 0 12 | n = 2 13 | while k < kmax: 14 | i = 0 15 | while i < k and n % p[i] <> 0: 16 | i = i + 1 17 | if i == k: 18 | p[k] = n 19 | k = k + 1 20 | result.append(n) 21 | n = n + 1 22 | return result 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/f2py/docs/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/f2py/docs/usersguide/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/matrixlib/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | config = Configuration('matrixlib', parent_package, top_path) 7 | config.add_data_dir('tests') 8 | return config 9 | 10 | if __name__ == "__main__": 11 | from numpy.distutils.core import setup 12 | config = configuration(top_path='').todict() 13 | setup(**config) 14 | -------------------------------------------------------------------------------- /numpy/numarray/image.py: -------------------------------------------------------------------------------- 1 | try: 2 | from stsci.image import * 3 | except ImportError: 4 | try: 5 | from scipy.stsci.image import * 6 | except ImportError: 7 | msg = \ 8 | """The image package is not installed 9 | 10 | It can be downloaded by checking out the latest source from 11 | http://svn.scipy.org/svn/scipy/trunk/Lib/stsci or by downloading and 12 | installing all of SciPy from http://www.scipy.org. 13 | """ 14 | raise ImportError(msg) 15 | -------------------------------------------------------------------------------- /numpy/numarray/nd_image.py: -------------------------------------------------------------------------------- 1 | try: 2 | from ndimage import * 3 | except ImportError: 4 | try: 5 | from scipy.ndimage import * 6 | except ImportError: 7 | msg = \ 8 | """The nd_image package is not installed 9 | 10 | It can be downloaded by checking out the latest source from 11 | http://svn.scipy.org/svn/scipy/trunk/Lib/ndimage or by downloading and 12 | installing all of SciPy from http://www.scipy.org. 13 | """ 14 | raise ImportError(msg) 15 | -------------------------------------------------------------------------------- /numpy/matrixlib/setupscons.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | 4 | def configuration(parent_package='', top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | config = Configuration('matrixlib', parent_package, top_path) 7 | config.add_data_dir('tests') 8 | return config 9 | 10 | if __name__ == "__main__": 11 | from numpy.distutils.core import setup 12 | config = configuration(top_path='').todict() 13 | setup(**config) 14 | -------------------------------------------------------------------------------- /numpy/numarray/random_array.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['ArgumentError', 'F', 'beta', 'binomial', 'chi_square', 3 | 'exponential', 'gamma', 'get_seed', 'multinomial', 4 | 'multivariate_normal', 'negative_binomial', 'noncentral_F', 5 | 'noncentral_chi_square', 'normal', 'permutation', 'poisson', 6 | 'randint', 'random', 'random_integers', 'standard_normal', 7 | 'uniform', 'seed'] 8 | 9 | from numpy.oldnumeric.random_array import * 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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: f2py_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 | -------------------------------------------------------------------------------- /benchmarks/creating.py: -------------------------------------------------------------------------------- 1 | from benchmark import Benchmark 2 | 3 | modules = ['numpy','Numeric','numarray'] 4 | 5 | N = [10,10] 6 | b = Benchmark(modules, 7 | title='Creating %s zeros.' % N, 8 | runs=3,reps=10000) 9 | 10 | b['numpy'] = ('a=np.zeros(shape,type)', 'shape=%s;type=float' % N) 11 | b['Numeric'] = ('a=np.zeros(shape,type)', 'shape=%s;type=np.Float' % N) 12 | b['numarray'] = ('a=np.zeros(shape,type)', "shape=%s;type=np.Float" % N) 13 | 14 | b.run() 15 | -------------------------------------------------------------------------------- /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/numarray/convolve.py: -------------------------------------------------------------------------------- 1 | try: 2 | from stsci.convolve import * 3 | except ImportError: 4 | try: 5 | from scipy.stsci.convolve import * 6 | except ImportError: 7 | msg = \ 8 | """The convolve package is not installed. 9 | 10 | It can be downloaded by checking out the latest source from 11 | http://svn.scipy.org/svn/scipy/trunk/Lib/stsci or by downloading and 12 | installing all of SciPy from http://www.scipy.org. 13 | """ 14 | raise ImportError(msg) 15 | -------------------------------------------------------------------------------- /numpy/distutils/tests/f2py_ext/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | def configuration(parent_package='',top_path=None): 3 | from numpy.distutils.misc_util import Configuration 4 | config = Configuration('f2py_ext',parent_package,top_path) 5 | config.add_extension('fib2', ['src/fib2.pyf','src/fib1.f']) 6 | config.add_data_dir('tests') 7 | return config 8 | 9 | if __name__ == "__main__": 10 | from numpy.distutils.core import setup 11 | setup(configuration=configuration) 12 | -------------------------------------------------------------------------------- /numpy/f2py/doc/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 | -------------------------------------------------------------------------------- /numpy/f2py/doc/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 | -------------------------------------------------------------------------------- /numpy/distutils/tests/swig_ext/tests/test_example.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from numpy.testing import * 3 | from swig_ext import example 4 | 5 | class TestExample(TestCase): 6 | def test_fact(self): 7 | assert_equal(example.fact(10),3628800) 8 | 9 | def test_cvar(self): 10 | assert_equal(example.cvar.My_variable,3.0) 11 | example.cvar.My_variable = 5 12 | assert_equal(example.cvar.My_variable,5.0) 13 | 14 | 15 | if __name__ == "__main__": 16 | run_module_suite() 17 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /numpy/testing/nulltester.py: -------------------------------------------------------------------------------- 1 | ''' Null tester to signal nose tests disabled 2 | 3 | Merely returns error reporting lack of nose package or version number 4 | below requirements. 5 | 6 | See pkgtester, nosetester modules 7 | 8 | ''' 9 | 10 | class NullTester(object): 11 | def test(self, labels=None, *args, **kwargs): 12 | raise ImportError( 13 | 'Need nose >=0.10 for tests - see %s' % 14 | 'http://somethingaboutorange.com/mrl/projects/nose') 15 | bench = test 16 | -------------------------------------------------------------------------------- /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 unittest import TestCase 9 | 10 | import decorators as dec 11 | from utils import * 12 | from numpytest import * 13 | from nosetester import NoseTester as Tester 14 | from nosetester import run_module_suite 15 | test = Tester().test 16 | -------------------------------------------------------------------------------- /doc/source/reference/routines.err.rst: -------------------------------------------------------------------------------- 1 | Floating point error handling 2 | ***************************** 3 | 4 | .. currentmodule:: numpy 5 | 6 | Setting and getting error handling 7 | ---------------------------------- 8 | 9 | .. autosummary:: 10 | :toctree: generated/ 11 | 12 | seterr 13 | geterr 14 | seterrcall 15 | geterrcall 16 | errstate 17 | 18 | Internal functions 19 | ------------------ 20 | 21 | .. autosummary:: 22 | :toctree: generated/ 23 | 24 | seterrobj 25 | geterrobj 26 | -------------------------------------------------------------------------------- /numpy/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 | import _inspect 12 | import py3k 13 | from _inspect import getargspec, formatargspec 14 | from py3k import * 15 | 16 | __all__ = [] 17 | __all__.extend(_inspect.__all__) 18 | __all__.extend(py3k.__all__) 19 | -------------------------------------------------------------------------------- /numpy/distutils/tests/pyrex_ext/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | def configuration(parent_package='',top_path=None): 3 | from numpy.distutils.misc_util import Configuration 4 | config = Configuration('pyrex_ext',parent_package,top_path) 5 | config.add_extension('primes', 6 | ['primes.pyx']) 7 | config.add_data_dir('tests') 8 | return config 9 | 10 | if __name__ == "__main__": 11 | from numpy.distutils.core import setup 12 | setup(configuration=configuration) 13 | -------------------------------------------------------------------------------- /numpy/numarray/setupscons.py: -------------------------------------------------------------------------------- 1 | from os.path import join 2 | 3 | def configuration(parent_package='',top_path=None): 4 | from numpy.distutils.misc_util import Configuration 5 | config = Configuration('numarray',parent_package,top_path) 6 | 7 | config.add_data_files('include/numpy/') 8 | config.add_sconscript('SConstruct', source_files = ['_capi.c']) 9 | 10 | return config 11 | 12 | if __name__ == '__main__': 13 | from numpy.distutils.core import setup 14 | setup(configuration=configuration) 15 | -------------------------------------------------------------------------------- /numpy/f2py/doc/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 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/extcallback_session.dat: -------------------------------------------------------------------------------- 1 | >>> import pfromf 2 | >>> pfromf.f2() 3 | Traceback (most recent call last): 4 | File "", line 1, in ? 5 | pfromf.error: Callback fpy not defined (as an argument or module pfromf attribute). 6 | 7 | >>> def f(): print "python f" 8 | ... 9 | >>> pfromf.fpy = f 10 | >>> pfromf.f2() 11 | in f2, calling f2py.. 12 | python f 13 | >>> pfromf.f1() 14 | in f1, calling f2 twice.. 15 | in f2, calling f2py.. 16 | python f 17 | in f2, calling f2py.. 18 | python f 19 | >>> -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /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/bento.info: -------------------------------------------------------------------------------- 1 | Recurse: 2 | core, fft, lib, linalg, random 3 | 4 | Library: 5 | Packages: 6 | build_utils, 7 | compat, 8 | core, 9 | core.code_generators, 10 | distutils, 11 | distutils.command, 12 | distutils.fcompiler, 13 | doc, 14 | f2py, 15 | fft, 16 | lib, 17 | linalg, 18 | ma, 19 | matrixlib, 20 | numarray, 21 | oldnumeric, 22 | polynomial, 23 | random, 24 | testing 25 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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/f2py/doc/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 | -------------------------------------------------------------------------------- /numpy/f2py/doc/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/oldnumeric/array_printer.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['array2string'] 3 | 4 | from numpy import array2string as _array2string 5 | 6 | def array2string(a, max_line_width=None, precision=None, 7 | suppress_small=None, separator=' ', 8 | array_output=0): 9 | if array_output: 10 | prefix="array(" 11 | style=repr 12 | else: 13 | prefix = "" 14 | style=str 15 | return _array2string(a, max_line_width, precision, 16 | suppress_small, separator, prefix, style) 17 | -------------------------------------------------------------------------------- /numpy/lib/setupscons.py: -------------------------------------------------------------------------------- 1 | from os.path import join 2 | 3 | def configuration(parent_package='',top_path=None): 4 | from numpy.distutils.misc_util import Configuration 5 | 6 | config = Configuration('lib',parent_package,top_path) 7 | 8 | config.add_sconscript('SConstruct', 9 | source_files = [join('src', '_compiled_base.c')]) 10 | config.add_data_dir('tests') 11 | 12 | return config 13 | 14 | if __name__=='__main__': 15 | from numpy.distutils.core import setup 16 | setup(configuration=configuration) 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /numpy/numarray/setup.py: -------------------------------------------------------------------------------- 1 | from os.path import join 2 | 3 | def configuration(parent_package='',top_path=None): 4 | from numpy.distutils.misc_util import Configuration 5 | config = Configuration('numarray',parent_package,top_path) 6 | 7 | config.add_data_files('include/numpy/*') 8 | 9 | config.add_extension('_capi', 10 | sources=['_capi.c'], 11 | ) 12 | 13 | return config 14 | 15 | if __name__ == '__main__': 16 | from numpy.distutils.core import setup 17 | setup(configuration=configuration) 18 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /BENTO_BUILD.txt: -------------------------------------------------------------------------------- 1 | No-frill version: 2 | 3 | * Clone bento:: 4 | 5 | git clone git://github.com/cournape/Bento.git bento-git 6 | 7 | * Bootstrap bento:: 8 | 9 | cd bento-git && python bootstrap.py 10 | 11 | * Download waf from svn (svn >= r11575 is required) 12 | * Build numpy with bento: 13 | 14 | export WAFDIR=ROOT_OF_WAF_SVN_TRUNK # WAFDIR should be such as $WAFDIR/waflib exists 15 | $BENTO_ROOT/bentomaker build -j 4 # 4 threads in parallel 16 | # or with progress bar 17 | $BENTO_ROOT/bentomaker build -p 18 | # or with verbose output 19 | $BENTO_ROOT/bentomaker build -v 20 | -------------------------------------------------------------------------------- /benchmarks/casting.py: -------------------------------------------------------------------------------- 1 | from benchmark import Benchmark 2 | 3 | modules = ['numpy','Numeric','numarray'] 4 | 5 | b = Benchmark(modules, 6 | title='Casting a (10,10) integer array to float.', 7 | runs=3,reps=10000) 8 | 9 | N = [10,10] 10 | b['numpy'] = ('b = a.astype(int)', 11 | 'a=numpy.zeros(shape=%s,dtype=float)' % N) 12 | b['Numeric'] = ('b = a.astype("l")', 13 | 'a=Numeric.zeros(shape=%s,typecode="d")' % N) 14 | b['numarray'] = ("b = a.astype('l')", 15 | "a=numarray.zeros(shape=%s,typecode='d')" % N) 16 | 17 | b.run() 18 | -------------------------------------------------------------------------------- /numpy/fft/setup.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def configuration(parent_package='',top_path=None): 4 | from numpy.distutils.misc_util import Configuration 5 | config = Configuration('fft',parent_package,top_path) 6 | 7 | config.add_data_dir('tests') 8 | 9 | # Configure fftpack_lite 10 | config.add_extension('fftpack_lite', 11 | sources=['fftpack_litemodule.c', 'fftpack.c'] 12 | ) 13 | 14 | 15 | return config 16 | 17 | if __name__ == '__main__': 18 | from numpy.distutils.core import setup 19 | setup(configuration=configuration) 20 | -------------------------------------------------------------------------------- /doc/newdtype_example/example.py: -------------------------------------------------------------------------------- 1 | import floatint.floatint as ff 2 | import numpy as np 3 | 4 | # Setting using array is hard because 5 | # The parser doesn't stop at tuples always 6 | # So, the setitem code will be called with scalars on the 7 | # wrong shaped array. 8 | # But we can get a view as an ndarray of the given type: 9 | g = np.array([1,2,3,4,5,6,7,8]).view(ff.floatint_type) 10 | 11 | # Now, the elements will be the scalar type associated 12 | # with the ndarray. 13 | print g[0] 14 | print type(g[1]) 15 | 16 | # Now, you need to register ufuncs and more arrfuncs to do useful things... 17 | -------------------------------------------------------------------------------- /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 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 /* 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 /* SIZEOF_INT */ 32 | } 33 | -------------------------------------------------------------------------------- /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/numpybook/comparison/f2py/filter.f: -------------------------------------------------------------------------------- 1 | 2 | SUBROUTINE DFILTER2D(A,B,M,N) 3 | C 4 | DOUBLE PRECISION A(M,N) 5 | DOUBLE PRECISION B(M,N) 6 | INTEGER N, M 7 | CF2PY INTENT(OUT) :: B 8 | CF2PY INTENT(HIDE) :: N 9 | CF2PY INTENT(HIDE) :: M 10 | DO 20 I = 2,M-1 11 | DO 40 J=2,N-1 12 | B(I,J) = A(I,J) + 13 | $ (A(I-1,J)+A(I+1,J) + 14 | $ A(I,J-1)+A(I,J+1) )*0.5D0 + 15 | $ (A(I-1,J-1) + A(I-1,J+1) + 16 | $ A(I+1,J-1) + A(I+1,J+1))*0.25D0 17 | 40 CONTINUE 18 | 20 CONTINUE 19 | END 20 | 21 | -------------------------------------------------------------------------------- /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/distutils/tests/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | def configuration(parent_package='',top_path=None): 3 | from numpy.distutils.misc_util import Configuration 4 | config = Configuration('testnumpydistutils',parent_package,top_path) 5 | config.add_subpackage('pyrex_ext') 6 | config.add_subpackage('f2py_ext') 7 | #config.add_subpackage('f2py_f90_ext') 8 | config.add_subpackage('swig_ext') 9 | config.add_subpackage('gen_ext') 10 | return config 11 | 12 | if __name__ == "__main__": 13 | from numpy.distutils.core import setup 14 | setup(configuration=configuration) 15 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/callback_session.dat: -------------------------------------------------------------------------------- 1 | >>> import callback 2 | >>> print callback.foo.__doc__ 3 | foo - Function signature: 4 | r = foo(fun,[fun_extra_args]) 5 | Required arguments: 6 | fun : call-back function 7 | Optional arguments: 8 | fun_extra_args := () input tuple 9 | Return objects: 10 | r : float 11 | Call-back functions: 12 | def fun(i): return r 13 | Required arguments: 14 | i : input int 15 | Return objects: 16 | r : float 17 | 18 | >>> def f(i): return i*i 19 | ... 20 | >>> print callback.foo(f) 21 | 110.0 22 | >>> print callback.foo(lambda i:1) 23 | 11.0 24 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 Numeric 14 | >>> a=Numeric.array(2) # these are integer rank-0 arrays 15 | >>> b=Numeric.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 -------------------------------------------------------------------------------- /numpy/fft/setupscons.py: -------------------------------------------------------------------------------- 1 | def configuration(parent_package = '', top_path = None): 2 | from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs 3 | config = Configuration('fft', parent_package, top_path) 4 | 5 | config.add_data_dir('tests') 6 | 7 | config.add_sconscript('SConstruct', 8 | source_files = ['fftpack_litemodule.c', 'fftpack.c', 9 | 'fftpack.h']) 10 | 11 | return config 12 | 13 | if __name__ == '__main__': 14 | from numpy.distutils.core import setup 15 | setup(configuration=configuration) 16 | -------------------------------------------------------------------------------- /numpy/matrixlib/tests/test_multiarray.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import * 3 | 4 | class TestView(TestCase): 5 | def test_type(self): 6 | x = np.array([1,2,3]) 7 | assert_(isinstance(x.view(np.matrix),np.matrix)) 8 | 9 | def test_keywords(self): 10 | x = np.array([(1,2)],dtype=[('a',np.int8),('b',np.int8)]) 11 | # We must be specific about the endianness here: 12 | y = x.view(dtype='>> 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/distutils/setupscons.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os.path 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 | if os.path.exists("site.cfg"): 11 | config.add_data_files('site.cfg') 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 | -------------------------------------------------------------------------------- /numpy/testing/setupscons.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | def configuration(parent_package='',top_path=None): 4 | from numpy.distutils.misc_util import Configuration 5 | config = Configuration('testing',parent_package,top_path) 6 | return config 7 | 8 | if __name__ == '__main__': 9 | from numpy.distutils.core import setup 10 | setup(maintainer = "NumPy Developers", 11 | maintainer_email = "numpy-dev@numpy.org", 12 | description = "NumPy test module", 13 | url = "http://www.numpy.org", 14 | license = "NumPy License (BSD Style)", 15 | configuration = configuration, 16 | ) 17 | -------------------------------------------------------------------------------- /numpy/doc/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | ref_dir = os.path.join(os.path.dirname(__file__)) 4 | 5 | __all__ = [f[:-3] for f in os.listdir(ref_dir) if f.endswith('.py') and 6 | not f.startswith('__')] 7 | __all__.sort() 8 | 9 | for f in __all__: 10 | __import__(__name__ + '.' + f) 11 | 12 | del f, ref_dir 13 | 14 | __doc__ = """\ 15 | Topical documentation 16 | ===================== 17 | 18 | The following topics are available: 19 | %s 20 | 21 | You can view them by 22 | 23 | >>> help(np.doc.TOPIC) #doctest: +SKIP 24 | 25 | """ % '\n- '.join([''] + __all__) 26 | 27 | __all__.extend(['__doc__']) 28 | -------------------------------------------------------------------------------- /numpy/f2py/doc/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 -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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/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 | -------------------------------------------------------------------------------- /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 setuptools.command.develop import develop as old_develop 7 | 8 | class develop(old_develop): 9 | __doc__ = old_develop.__doc__ 10 | def install_for_development(self): 11 | # Build sources in-place, too. 12 | self.reinitialize_command('build_src', inplace=1) 13 | # Make sure scripts are built. 14 | self.run_command('build_scripts') 15 | old_develop.install_for_development(self) 16 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/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 | -------------------------------------------------------------------------------- /numpy/f2py/doc/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/ma/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | __author__ = "Pierre GF Gerard-Marchant ($Author: jarrod.millman $)" 3 | __version__ = '1.0' 4 | __revision__ = "$Revision: 3473 $" 5 | __date__ = '$Date: 2007-10-29 17:18:13 +0200 (Mon, 29 Oct 2007) $' 6 | 7 | import os 8 | 9 | def configuration(parent_package='',top_path=None): 10 | from numpy.distutils.misc_util import Configuration 11 | config = Configuration('ma',parent_package,top_path) 12 | config.add_data_dir('tests') 13 | return config 14 | 15 | if __name__ == "__main__": 16 | from numpy.distutils.core import setup 17 | config = configuration(top_path='').todict() 18 | setup(**config) 19 | -------------------------------------------------------------------------------- /numpy/ma/setupscons.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | __author__ = "Pierre GF Gerard-Marchant ($Author: jarrod.millman $)" 3 | __version__ = '1.0' 4 | __revision__ = "$Revision: 3473 $" 5 | __date__ = '$Date: 2007-10-29 17:18:13 +0200 (Mon, 29 Oct 2007) $' 6 | 7 | import os 8 | 9 | def configuration(parent_package='',top_path=None): 10 | from numpy.distutils.misc_util import Configuration 11 | config = Configuration('ma',parent_package,top_path) 12 | config.add_data_dir('tests') 13 | return config 14 | 15 | if __name__ == "__main__": 16 | from numpy.distutils.core import setup 17 | config = configuration(top_path='').todict() 18 | setup(**config) 19 | -------------------------------------------------------------------------------- /doc/source/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | {% block rootrellink %} 3 |
  • {{ shorttitle }}{{ reldelim1 }}
  • 4 | {% endblock %} 5 | 6 | {% block sidebarsearch %} 7 | {%- if sourcename %} 8 | 15 | {%- endif %} 16 | {{ super() }} 17 | {% endblock %} 18 | -------------------------------------------------------------------------------- /setupegg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | A setup.py script to use setuptools, which gives egg goodness, etc. 4 | 5 | This is used to build installers for OS X through bdist_mpkg. 6 | 7 | Notes 8 | ----- 9 | Using ``python setupegg.py install`` directly results in file permissions being 10 | set wrong, with nose refusing to run any tests. To run the tests anyway, use:: 11 | 12 | >>> np.test(extra_argv=['--exe']) 13 | 14 | """ 15 | 16 | import sys 17 | from setuptools import setup 18 | 19 | if sys.version_info[0] >= 3: 20 | import imp 21 | setupfile = imp.load_source('setupfile', 'setup.py') 22 | setupfile.setup_package() 23 | else: 24 | execfile('setup.py') 25 | -------------------------------------------------------------------------------- /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/testing/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | def configuration(parent_package='',top_path=None): 4 | from numpy.distutils.misc_util import Configuration 5 | config = Configuration('testing',parent_package,top_path) 6 | 7 | config.add_data_dir('tests') 8 | return config 9 | 10 | if __name__ == '__main__': 11 | from numpy.distutils.core import setup 12 | setup(maintainer = "NumPy Developers", 13 | maintainer_email = "numpy-dev@numpy.org", 14 | description = "NumPy test module", 15 | url = "http://www.numpy.org", 16 | license = "NumPy License (BSD Style)", 17 | configuration = configuration, 18 | ) 19 | -------------------------------------------------------------------------------- /numpy/lib/setup.py: -------------------------------------------------------------------------------- 1 | from os.path import join 2 | 3 | def configuration(parent_package='',top_path=None): 4 | from numpy.distutils.misc_util import Configuration 5 | 6 | config = Configuration('lib',parent_package,top_path) 7 | 8 | config.add_include_dirs(join('..','core','include')) 9 | 10 | 11 | config.add_extension('_compiled_base', 12 | sources=[join('src','_compiled_base.c')] 13 | ) 14 | 15 | config.add_data_dir('benchmarks') 16 | config.add_data_dir('tests') 17 | 18 | return config 19 | 20 | if __name__=='__main__': 21 | from numpy.distutils.core import setup 22 | setup(configuration=configuration) 23 | -------------------------------------------------------------------------------- /doc/numpybook/comparison/weave/filter.py: -------------------------------------------------------------------------------- 1 | from scipy import weave, zeros_like 2 | 3 | def filter(a): 4 | if a.ndim != 2: 5 | raise ValueError, "a must be 2-d" 6 | code = r""" 7 | int i,j; 8 | for(i=1;i>> 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 Numeric 12 | >>> a=Numeric.array('123') 13 | >>> b=Numeric.array('123') 14 | >>> c=Numeric.array('123') 15 | >>> d=Numeric.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') -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/moddata_session.dat: -------------------------------------------------------------------------------- 1 | >>> import moddata 2 | >>> print moddata.mod.__doc__ 3 | i - 'i'-scalar 4 | x - 'i'-array(4) 5 | a - 'f'-array(2,3) 6 | foo - Function signature: 7 | foo() 8 | 9 | 10 | >>> moddata.mod.i = 5 11 | >>> moddata.mod.x[:2] = [1,2] 12 | >>> moddata.mod.a = [[1,2,3],[4,5,6]] 13 | >>> moddata.mod.foo() 14 | i= 5 15 | x=[ 1 2 0 0 ] 16 | a=[ 17 | [ 1.000000 , 2.000000 , 3.000000 ] 18 | [ 4.000000 , 5.000000 , 6.000000 ] 19 | ] 20 | Setting a(1,2)=a(1,2)+3 21 | >>> moddata.mod.a # a is Fortran-contiguous 22 | array([[ 1., 5., 3.], 23 | [ 4., 5., 6.]],'f') 24 | -------------------------------------------------------------------------------- /numpy/f2py/tests/src/assumed_shape/foo_mod.f90: -------------------------------------------------------------------------------- 1 | 2 | module mod 3 | 4 | contains 5 | 6 | subroutine sum(x, res) 7 | implicit none 8 | real, intent(in) :: x(:) 9 | real, intent(out) :: res 10 | 11 | integer :: i 12 | 13 | !print *, "sum: size(x) = ", size(x) 14 | 15 | res = 0.0 16 | 17 | do i = 1, size(x) 18 | res = res + x(i) 19 | enddo 20 | 21 | end subroutine sum 22 | 23 | function fsum(x) result (res) 24 | implicit none 25 | real, intent(in) :: x(:) 26 | real :: res 27 | 28 | integer :: i 29 | 30 | !print *, "fsum: size(x) = ", size(x) 31 | 32 | res = 0.0 33 | 34 | do i = 1, size(x) 35 | res = res + x(i) 36 | enddo 37 | 38 | end function fsum 39 | 40 | 41 | end module mod 42 | -------------------------------------------------------------------------------- /doc/source/reference/routines.polynomials.poly1d.rst: -------------------------------------------------------------------------------- 1 | Poly1d 2 | ====== 3 | 4 | .. currentmodule:: numpy 5 | 6 | Basics 7 | ------ 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | poly1d 12 | polyval 13 | poly 14 | roots 15 | 16 | Fitting 17 | ------- 18 | .. autosummary:: 19 | :toctree: generated/ 20 | 21 | polyfit 22 | 23 | Calculus 24 | -------- 25 | .. autosummary:: 26 | :toctree: generated/ 27 | 28 | polyder 29 | polyint 30 | 31 | Arithmetic 32 | ---------- 33 | .. autosummary:: 34 | :toctree: generated/ 35 | 36 | polyadd 37 | polydiv 38 | polymul 39 | polysub 40 | 41 | Warnings 42 | -------- 43 | .. autosummary:: 44 | :toctree: generated/ 45 | 46 | RankWarning 47 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/distutils/numpy_distribution.py: -------------------------------------------------------------------------------- 1 | # XXX: Handle setuptools ? 2 | from distutils.core import Distribution 3 | 4 | # This class is used because we add new files (sconscripts, and so on) with the 5 | # scons command 6 | class NumpyDistribution(Distribution): 7 | def __init__(self, attrs = None): 8 | # A list of (sconscripts, pre_hook, post_hook, src, parent_names) 9 | self.scons_data = [] 10 | # A list of installable libraries 11 | self.installed_libraries = [] 12 | # A dict of pkg_config files to generate/install 13 | self.installed_pkg_config = {} 14 | Distribution.__init__(self, attrs) 15 | 16 | def has_scons_scripts(self): 17 | return bool(self.scons_data) 18 | -------------------------------------------------------------------------------- /numpy/distutils/tests/f2py_f90_ext/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | def configuration(parent_package='',top_path=None): 3 | from numpy.distutils.misc_util import Configuration 4 | config = Configuration('f2py_f90_ext',parent_package,top_path) 5 | config.add_extension('foo', 6 | ['src/foo_free.f90'], 7 | include_dirs=['include'], 8 | f2py_options=['--include_paths', 9 | config.paths('include')[0]] 10 | ) 11 | config.add_data_dir('tests') 12 | return config 13 | 14 | if __name__ == "__main__": 15 | from numpy.distutils.core import setup 16 | setup(configuration=configuration) 17 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_mixed.py: -------------------------------------------------------------------------------- 1 | import os 2 | import math 3 | 4 | from numpy.testing import * 5 | from numpy import array 6 | 7 | import util 8 | 9 | def _path(*a): 10 | return os.path.join(*((os.path.dirname(__file__),) + a)) 11 | 12 | class TestMixed(util.F2PyTest): 13 | sources = [_path('src', 'mixed', 'foo.f'), 14 | _path('src', 'mixed', 'foo_fixed.f90'), 15 | _path('src', 'mixed', 'foo_free.f90')] 16 | 17 | @dec.slow 18 | def test_all(self): 19 | assert_( self.module.bar11() == 11) 20 | assert_( self.module.foo_fixed.bar12() == 12) 21 | assert_( self.module.foo_free.bar13() == 13) 22 | 23 | if __name__ == "__main__": 24 | import nose 25 | nose.runmodule() 26 | -------------------------------------------------------------------------------- /doc/pyrex/c_python.pxd: -------------------------------------------------------------------------------- 1 | # -*- Mode: Python -*- Not really, but close enough 2 | 3 | # Expose as much of the Python C API as we need here 4 | 5 | cdef extern from "stdlib.h": 6 | ctypedef int size_t 7 | 8 | cdef extern from "Python.h": 9 | ctypedef int Py_intptr_t 10 | void* PyMem_Malloc(size_t) 11 | void* PyMem_Realloc(void *p, size_t n) 12 | void PyMem_Free(void *p) 13 | char* PyString_AsString(object string) 14 | object PyString_FromString(char *v) 15 | object PyString_InternFromString(char *v) 16 | int PyErr_CheckSignals() 17 | object PyFloat_FromDouble(double v) 18 | void Py_XINCREF(object o) 19 | void Py_XDECREF(object o) 20 | void Py_CLEAR(object o) # use instead of decref 21 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/usertypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE_USERTYPES_H_ 2 | #define _NPY_PRIVATE_USERTYPES_H_ 3 | 4 | #ifdef NPY_ENABLE_SEPARATE_COMPILATION 5 | extern NPY_NO_EXPORT PyArray_Descr **userdescrs; 6 | #else 7 | NPY_NO_EXPORT PyArray_Descr **userdescrs; 8 | #endif 9 | 10 | NPY_NO_EXPORT void 11 | PyArray_InitArrFuncs(PyArray_ArrFuncs *f); 12 | 13 | NPY_NO_EXPORT int 14 | PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, 15 | NPY_SCALARKIND scalar); 16 | 17 | NPY_NO_EXPORT int 18 | PyArray_RegisterDataType(PyArray_Descr *descr); 19 | 20 | NPY_NO_EXPORT int 21 | PyArray_RegisterCastFunc(PyArray_Descr *descr, int totype, 22 | PyArray_VectorUnaryFunc *castfunc); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /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 | 49 | -------------------------------------------------------------------------------- /doc/numpybook/comparison/f2py/filter.pyf: -------------------------------------------------------------------------------- 1 | ! -*- f90 -*- 2 | ! Note: the context of this file is case sensitive. 3 | 4 | python module filter ! in 5 | interface ! in :filter 6 | subroutine dfilter2d(a,b,m,n) ! in :filter:filter.f 7 | double precision dimension(m,n) :: a 8 | double precision dimension(m,n),intent(out),depend(m,n) :: b 9 | integer optional,intent(hide),check(shape(a,0)==m),depend(a) :: m=shape(a,0) 10 | integer optional,intent(hide),check(shape(a,1)==n),depend(a) :: n=shape(a,1) 11 | end subroutine dfilter2d 12 | end interface 13 | end python module filter 14 | 15 | ! This file was auto-generated with f2py (version:2_3032). 16 | ! See http://cens.ioc.ee/projects/f2py2e/ 17 | -------------------------------------------------------------------------------- /DEV_README.txt: -------------------------------------------------------------------------------- 1 | Thank you for your willingness to help make NumPy the best array system 2 | available. 3 | 4 | We have a few simple rules: 5 | 6 | * try hard to keep the Git repository in a buildable state and to not 7 | indiscriminately muck with what others have contributed. 8 | 9 | * Simple changes (including bug fixes) and obvious improvements are 10 | always welcome. Changes that fundamentally change behavior need 11 | discussion on numpy-discussions@scipy.org before anything is 12 | done. 13 | 14 | * Please add meaningful comments when you check changes in. These 15 | comments form the basis of the change-log. 16 | 17 | * Add unit tests to exercise new code, and regression tests 18 | whenever you fix a bug. 19 | 20 | -------------------------------------------------------------------------------- /doc/cython/README.txt: -------------------------------------------------------------------------------- 1 | ================== 2 | NumPy and Cython 3 | ================== 4 | 5 | This directory contains a small example of how to use NumPy and Cython 6 | together. While much work is planned for the Summer of 2008 as part of the 7 | Google Summer of Code project to improve integration between the two, even 8 | today Cython can be used effectively to write optimized code that accesses 9 | NumPy arrays. 10 | 11 | The example provided is just a stub showing how to build an extension and 12 | access the array objects; improvements to this to show more sophisticated tasks 13 | are welcome. 14 | 15 | To run it locally, simply type:: 16 | 17 | make help 18 | 19 | which shows you the currently available targets (these are just handy 20 | shorthands for common commands). -------------------------------------------------------------------------------- /numpy/f2py/doc/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/tests/swig_ext/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | def configuration(parent_package='',top_path=None): 3 | from numpy.distutils.misc_util import Configuration 4 | config = Configuration('swig_ext',parent_package,top_path) 5 | config.add_extension('_example', 6 | ['src/example.i','src/example.c'] 7 | ) 8 | config.add_extension('_example2', 9 | ['src/zoo.i','src/zoo.cc'], 10 | depends=['src/zoo.h'], 11 | include_dirs=['src'] 12 | ) 13 | config.add_data_dir('tests') 14 | return config 15 | 16 | if __name__ == "__main__": 17 | from numpy.distutils.core import setup 18 | setup(configuration=configuration) 19 | -------------------------------------------------------------------------------- /numpy/fft/tests/test_fftpack.py: -------------------------------------------------------------------------------- 1 | from __future__ import division 2 | 3 | import numpy as np 4 | from numpy.testing import TestCase, run_module_suite, assert_array_almost_equal 5 | 6 | def fft1(x): 7 | L = len(x) 8 | phase = -2j*np.pi*(np.arange(L)/float(L)) 9 | phase = np.arange(L).reshape(-1, 1) * phase 10 | return np.sum(x*np.exp(phase), axis=1) 11 | 12 | class TestFFTShift(TestCase): 13 | 14 | def test_fft_n(self): 15 | self.assertRaises(ValueError, np.fft.fft, [1, 2, 3], 0) 16 | 17 | 18 | class TestFFT1D(TestCase): 19 | 20 | def test_basic(self): 21 | rand = np.random.random 22 | x = rand(30) + 1j*rand(30) 23 | assert_array_almost_equal(fft1(x), np.fft.fft(x)) 24 | 25 | 26 | if __name__ == "__main__": 27 | run_module_suite() 28 | -------------------------------------------------------------------------------- /numpy/linalg/SConscript: -------------------------------------------------------------------------------- 1 | # Last Change: Thu Jun 12 06:00 PM 2008 J 2 | # vim:syntax=python 3 | from numscons import GetNumpyEnvironment, scons_get_mathlib 4 | from numscons import CheckF77LAPACK 5 | from numscons import write_info 6 | 7 | env = GetNumpyEnvironment(ARGUMENTS) 8 | 9 | config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK}) 10 | 11 | use_lapack = config.CheckLAPACK() 12 | 13 | mlib = scons_get_mathlib(env) 14 | env.AppendUnique(LIBS = mlib) 15 | 16 | config.Finish() 17 | write_info(env) 18 | 19 | sources = ['lapack_litemodule.c'] 20 | if not use_lapack: 21 | sources.extend(['python_xerbla.c', 'zlapack_lite.c', 'dlapack_lite.c', 22 | 'blas_lite.c', 'dlamch.c', 'f2c_lite.c']) 23 | env.NumpyPythonExtension('lapack_lite', source = sources) 24 | -------------------------------------------------------------------------------- /numpy/linalg/setupscons.py: -------------------------------------------------------------------------------- 1 | 2 | def configuration(parent_package='',top_path=None): 3 | from numpy.distutils.misc_util import Configuration 4 | from numpy.distutils.system_info import get_info 5 | config = Configuration('linalg',parent_package,top_path) 6 | 7 | config.add_data_dir('tests') 8 | 9 | config.add_sconscript('SConstruct', 10 | source_files = ['lapack_litemodule.c', 11 | 'zlapack_lite.c', 'dlapack_lite.c', 12 | 'blas_lite.c', 'dlamch.c', 13 | 'f2c_lite.c','f2c.h']) 14 | 15 | return config 16 | 17 | if __name__ == '__main__': 18 | from numpy.distutils.core import setup 19 | setup(configuration=configuration) 20 | -------------------------------------------------------------------------------- /numpy/core/include/numpy/oldnumeric.h: -------------------------------------------------------------------------------- 1 | #include "arrayobject.h" 2 | 3 | #ifndef REFCOUNT 4 | # define REFCOUNT NPY_REFCOUNT 5 | # define MAX_ELSIZE 16 6 | #endif 7 | 8 | #define PyArray_UNSIGNED_TYPES 9 | #define PyArray_SBYTE NPY_BYTE 10 | #define PyArray_CopyArray PyArray_CopyInto 11 | #define _PyArray_multiply_list PyArray_MultiplyIntList 12 | #define PyArray_ISSPACESAVER(m) NPY_FALSE 13 | #define PyScalarArray_Check PyArray_CheckScalar 14 | 15 | #define CONTIGUOUS NPY_CONTIGUOUS 16 | #define OWN_DIMENSIONS 0 17 | #define OWN_STRIDES 0 18 | #define OWN_DATA NPY_OWNDATA 19 | #define SAVESPACE 0 20 | #define SAVESPACEBIT 0 21 | 22 | #undef import_array 23 | #define import_array() { if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); } } 24 | -------------------------------------------------------------------------------- /doc/numpybook/comparison/ctypes/newfile.dat: -------------------------------------------------------------------------------- 1 | $@>@ -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/core/code_generators/cversions.txt: -------------------------------------------------------------------------------- 1 | # hash below were defined from numpy_api_order.txt and ufunc_api_order.txt 2 | 0x00000001 = 603580d224763e58c5e7147f804dc0f5 3 | 0x00000002 = 8ecb29306758515ae69749c803a75da1 4 | 0x00000003 = bf22c0d05b31625d2a7015988d61ce5a 5 | # Starting from here, the hash is defined from numpy_api.full_api dict 6 | # version 4 added neighborhood iterators and PyArray_Correlate2 7 | 0x00000004 = 3d8940bf7b0d2a4e25be4338c14c3c85 8 | 0x00000005 = 77e2e846db87f25d7cf99f9d812076f0 9 | # Version 6 (NumPy 1.6) added new iterator, half float and casting functions, 10 | # PyArray_CountNonzero, PyArray_NewLikeArray and PyArray_MatrixProduct2. 11 | 0x00000006 = e61d5dc51fa1c6459328266e215d6987 12 | # Version 7 (NumPy 1.7) improved datetime64, misc utilities. 13 | 0x00000007 = e396ba3912dcf052eaee1b0b203a7724 14 | -------------------------------------------------------------------------------- /numpy/distutils/pathccompiler.py: -------------------------------------------------------------------------------- 1 | from distutils.unixccompiler import UnixCCompiler 2 | 3 | class PathScaleCCompiler(UnixCCompiler): 4 | 5 | """ 6 | PathScale compiler compatible with an gcc built Python. 7 | """ 8 | 9 | compiler_type = 'pathcc' 10 | cc_exe = 'pathcc' 11 | cxx_exe = 'pathCC' 12 | 13 | def __init__ (self, verbose=0, dry_run=0, force=0): 14 | UnixCCompiler.__init__ (self, verbose, dry_run, force) 15 | cc_compiler = self.cc_exe 16 | cxx_compiler = self.cxx_exe 17 | self.set_executables(compiler=cc_compiler, 18 | compiler_so=cc_compiler, 19 | compiler_cxx=cxx_compiler, 20 | linker_exe=cc_compiler, 21 | linker_so=cc_compiler + ' -shared') 22 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/source/reference/routines.statistics.rst: -------------------------------------------------------------------------------- 1 | Statistics 2 | ========== 3 | 4 | .. currentmodule:: numpy 5 | 6 | 7 | Order statistics 8 | ---------------- 9 | 10 | .. autosummary:: 11 | :toctree: generated/ 12 | 13 | amin 14 | amax 15 | nanmin 16 | nanmax 17 | ptp 18 | percentile 19 | 20 | Averages and variances 21 | ---------------------- 22 | 23 | .. autosummary:: 24 | :toctree: generated/ 25 | 26 | average 27 | mean 28 | median 29 | std 30 | var 31 | 32 | Correlating 33 | ----------- 34 | 35 | .. autosummary:: 36 | :toctree: generated/ 37 | 38 | corrcoef 39 | correlate 40 | cov 41 | 42 | Histograms 43 | ---------- 44 | 45 | .. autosummary:: 46 | :toctree: generated/ 47 | 48 | histogram 49 | histogram2d 50 | histogramdd 51 | bincount 52 | digitize 53 | -------------------------------------------------------------------------------- /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 | 14 | NPY_NO_EXPORT PyObject 15 | *iter_subscript(PyArrayIterObject *, PyObject *); 16 | 17 | NPY_NO_EXPORT int 18 | iter_ass_subscript(PyArrayIterObject *, PyObject *, PyObject *); 19 | 20 | NPY_NO_EXPORT int 21 | slice_GetIndices(PySliceObject *r, npy_intp length, 22 | npy_intp *start, npy_intp *stop, npy_intp *step, 23 | npy_intp *slicelength); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /numpy/distutils/command/bdist_rpm.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | if 'setuptools' in sys.modules: 4 | from setuptools.command.bdist_rpm import bdist_rpm as old_bdist_rpm 5 | else: 6 | from distutils.command.bdist_rpm import bdist_rpm as old_bdist_rpm 7 | 8 | class bdist_rpm(old_bdist_rpm): 9 | 10 | def _make_spec_file(self): 11 | spec_file = old_bdist_rpm._make_spec_file(self) 12 | 13 | # Replace hardcoded setup.py script name 14 | # with the real setup script name. 15 | setup_py = os.path.basename(sys.argv[0]) 16 | if setup_py == 'setup.py': 17 | return spec_file 18 | new_spec_file = [] 19 | for line in spec_file: 20 | line = line.replace('setup.py',setup_py) 21 | new_spec_file.append(line) 22 | return new_spec_file 23 | -------------------------------------------------------------------------------- /doc/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 | -------------------------------------------------------------------------------- /doc/release/1.6.1-notes.rst: -------------------------------------------------------------------------------- 1 | ========================= 2 | NumPy 1.6.1 Release Notes 3 | ========================= 4 | 5 | This is a bugfix only release in the 1.6.x series. 6 | 7 | 8 | Issues fixed 9 | ------------ 10 | 11 | #1834 einsum fails for specific shapes 12 | #1837 einsum throws nan or freezes python for specific array shapes 13 | #1838 object <-> structured type arrays regression 14 | #1851 regression for SWIG based code in 1.6.0 15 | #1863 Buggy results when operating on array copied with astype() 16 | #1870 Fix corner case of object array assignment 17 | #1843 Py3k: fix error with recarray 18 | #1885 nditer: Error in detecting double reduction loop 19 | #1874 f2py: fix --include_paths bug 20 | #1749 Fix ctypes.load_library() 21 | #1895/1896 iter: writeonly operands weren't always being buffered correctly 22 | 23 | -------------------------------------------------------------------------------- /tools/win32build/doall.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import os 3 | 4 | if __name__ == '__main__': 5 | from optparse import OptionParser 6 | parser = OptionParser() 7 | parser.add_option("-p", "--pyver", dest="pyver", 8 | help = "Python version (2.4, 2.5, etc...)") 9 | 10 | opts, args = parser.parse_args() 11 | pyver = opts.pyver 12 | 13 | if not pyver: 14 | pyver = "2.5" 15 | 16 | # Bootstrap 17 | subprocess.check_call(['python', 'prepare_bootstrap.py', '-p', pyver]) 18 | 19 | # Build binaries 20 | subprocess.check_call(['python', 'build.py', '-p', pyver], 21 | cwd = 'bootstrap-%s' % pyver) 22 | 23 | # Build installer using nsis 24 | subprocess.check_call(['makensis', 'numpy-superinstaller.nsi'], 25 | cwd = 'bootstrap-%s' % pyver) 26 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/datetime_busday.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE__DATETIME_BUSDAY_H_ 2 | #define _NPY_PRIVATE__DATETIME_BUSDAY_H_ 3 | 4 | /* 5 | * This is the 'busday_offset' function exposed for calling 6 | * from Python. 7 | */ 8 | NPY_NO_EXPORT PyObject * 9 | array_busday_offset(PyObject *NPY_UNUSED(self), 10 | PyObject *args, PyObject *kwds); 11 | 12 | /* 13 | * This is the 'busday_count' function exposed for calling 14 | * from Python. 15 | */ 16 | NPY_NO_EXPORT PyObject * 17 | array_busday_count(PyObject *NPY_UNUSED(self), 18 | PyObject *args, PyObject *kwds); 19 | 20 | /* 21 | * This is the 'is_busday' function exposed for calling 22 | * from Python. 23 | */ 24 | NPY_NO_EXPORT PyObject * 25 | array_is_busday(PyObject *NPY_UNUSED(self), 26 | PyObject *args, PyObject *kwds); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /numpy/distutils/command/sdist.py: -------------------------------------------------------------------------------- 1 | import sys 2 | if 'setuptools' in sys.modules: 3 | from setuptools.command.sdist import sdist as old_sdist 4 | else: 5 | from distutils.command.sdist import sdist as old_sdist 6 | 7 | from numpy.distutils.misc_util import get_data_files 8 | 9 | class sdist(old_sdist): 10 | 11 | def add_defaults (self): 12 | old_sdist.add_defaults(self) 13 | 14 | dist = self.distribution 15 | 16 | if dist.has_data_files(): 17 | for data in dist.data_files: 18 | self.filelist.extend(get_data_files(data)) 19 | 20 | if dist.has_headers(): 21 | headers = [] 22 | for h in dist.headers: 23 | if isinstance(h,str): headers.append(h) 24 | else: headers.append(h[1]) 25 | self.filelist.extend(headers) 26 | 27 | return 28 | -------------------------------------------------------------------------------- /tools/osxbuild/docs/README.txt: -------------------------------------------------------------------------------- 1 | NumPy is the fundamental package needed for scientific computing with Python. 2 | This package contains: 3 | 4 | * a powerful N-dimensional array object 5 | * sophisticated (broadcasting) functions 6 | * tools for integrating C/C++ and Fortran code 7 | * useful linear algebra, Fourier transform, and random number capabilities. 8 | 9 | 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. 10 | 11 | More information can be found at the website: 12 | 13 | http://scipy.org/NumPy 14 | 15 | After installation, tests can be run with: 16 | 17 | python -c 'import numpy; numpy.test()' 18 | 19 | The most current development version is always available from our 20 | git repository: 21 | 22 | http://github.com/numpy/numpy 23 | -------------------------------------------------------------------------------- /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 int 23 | NumPyOS_ascii_ftolf(FILE *fp, double *value); 24 | 25 | NPY_NO_EXPORT int 26 | NumPyOS_ascii_isspace(char c); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /doc/sphinxext/setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | 3 | version = "0.4" 4 | 5 | setup( 6 | name="numpydoc", 7 | packages=["numpydoc"], 8 | package_dir={"numpydoc": "."}, 9 | version=version, 10 | description="Sphinx extension to support docstrings in Numpy format", 11 | # classifiers from http://pypi.python.org/pypi?%3Aaction=list_classifiers 12 | classifiers=["Development Status :: 3 - Alpha", 13 | "Environment :: Plugins", 14 | "License :: OSI Approved :: BSD License", 15 | "Topic :: Documentation"], 16 | keywords="sphinx numpy", 17 | author="Pauli Virtanen and others", 18 | author_email="pav@iki.fi", 19 | url="http://github.com/numpy/numpy/tree/master/doc/sphinxext", 20 | license="BSD", 21 | requires=["sphinx (>= 1.0.1)"], 22 | package_data={'numpydoc': ['tests/test_*.py']}, 23 | ) 24 | -------------------------------------------------------------------------------- /numpy/distutils/fcompiler/none.py: -------------------------------------------------------------------------------- 1 | 2 | from numpy.distutils.fcompiler import FCompiler 3 | 4 | compilers = ['NoneFCompiler'] 5 | 6 | class NoneFCompiler(FCompiler): 7 | 8 | compiler_type = 'none' 9 | description = 'Fake Fortran compiler' 10 | 11 | executables = {'compiler_f77' : None, 12 | 'compiler_f90' : None, 13 | 'compiler_fix' : None, 14 | 'linker_so' : None, 15 | 'linker_exe' : None, 16 | 'archiver' : None, 17 | 'ranlib' : None, 18 | 'version_cmd' : None, 19 | } 20 | 21 | def find_executables(self): 22 | pass 23 | 24 | 25 | if __name__ == '__main__': 26 | from distutils import log 27 | log.set_verbosity(2) 28 | compiler = NoneFCompiler() 29 | compiler.customize() 30 | print(compiler.get_version()) 31 | -------------------------------------------------------------------------------- /tools/osxbuild/README.txt: -------------------------------------------------------------------------------- 1 | ================================== 2 | Building an OSX binary for numpy 3 | ================================== 4 | 5 | This directory contains the scripts to build a universal binary for 6 | OSX. The binaries work on OSX 10.4 and 10.5. 7 | 8 | The docstring in build.py may contain more current details. 9 | 10 | Requirements 11 | ============ 12 | 13 | * bdist_mpkg v0.4.3 14 | 15 | Build 16 | ===== 17 | 18 | The build script will build a numpy distribution using bdist_mpkg and 19 | create the mac package (mpkg) bundled in a disk image (dmg). To run 20 | the build script:: 21 | 22 | python build.py 23 | 24 | Install and test 25 | ---------------- 26 | 27 | The *install_and_test.py* script will find the numpy*.mpkg, install it 28 | using the Mac installer and then run the numpy test suite. To run the 29 | install and test:: 30 | 31 | python install_and_test.py 32 | 33 | -------------------------------------------------------------------------------- /numpy/linalg/bscript: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from bento.commands.hooks \ 4 | import \ 5 | pre_build 6 | 7 | @pre_build 8 | def pbuild(context): 9 | bld = context.waf_context 10 | 11 | def build_lapack_lite(extension): 12 | kw = {} 13 | if bld.env.HAS_LAPACK: 14 | for s in ['python_xerbla.c', 'zlapack_lite.c', 'dlapack_lite.c', 15 | 'blas_lite.c', 'dlamch.c', 'f2c_lite.c']: 16 | extension.sources.pop(extension.sources.index(s)) 17 | kw["uselib"] = "LAPACK" 18 | 19 | includes = ["../core/include", "../core/include/numpy", "../core", 20 | "../core/src/private"] 21 | return context.default_builder(extension, 22 | includes=includes, 23 | **kw) 24 | context.register_builder("lapack_lite", build_lapack_lite) 25 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/numpymemoryview.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE_NUMPYMEMORYVIEW_H_ 2 | #define _NPY_PRIVATE_NUMPYMEMORYVIEW_H_ 3 | 4 | /* 5 | * Memoryview is introduced to 2.x series only in 2.7, so for supporting 2.6, 6 | * we need to have a minimal implementation here. 7 | */ 8 | #if (PY_VERSION_HEX >= 0x02060000) && (PY_VERSION_HEX < 0x02070000) 9 | 10 | typedef struct { 11 | PyObject_HEAD 12 | PyObject *base; 13 | Py_buffer view; 14 | } PyMemorySimpleViewObject; 15 | 16 | NPY_NO_EXPORT PyObject * 17 | PyMemorySimpleView_FromObject(PyObject *base); 18 | 19 | #define PyMemorySimpleView_GET_BUFFER(op) (&((PyMemorySimpleViewObject *)(op))->view) 20 | 21 | #define PyMemoryView_FromObject PyMemorySimpleView_FromObject 22 | #define PyMemoryView_GET_BUFFER PyMemorySimpleView_GET_BUFFER 23 | 24 | #endif 25 | 26 | NPY_NO_EXPORT int 27 | _numpymemoryview_init(PyObject **typeobject); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /doc/numpybook/comparison/ctypes/filter.py: -------------------------------------------------------------------------------- 1 | __all__ = ['filter2d'] 2 | 3 | import numpy as N 4 | import os 5 | import ctypes 6 | 7 | _path = os.path.dirname('__file__') 8 | lib = N.ctypeslib.load_library('code', _path) 9 | 10 | lib.dfilter2d.restype = None 11 | lib.dfilter2d.argtypes = [N.ctypeslib.ndpointer(float, ndim=2, 12 | flags='aligned'), 13 | N.ctypeslib.ndpointer(float, ndim=2, 14 | flags='aligned, contiguous,'\ 15 | 'writeable'), 16 | ctypes.POINTER(N.ctypeslib.c_intp), 17 | ctypes.POINTER(N.ctypeslib.c_intp)] 18 | 19 | def filter2d(a): 20 | a = N.require(a, float, ['ALIGNED']) 21 | b = N.zeros_like(a) 22 | lib.dfilter2d(a, b, a.ctypes.strides, a.ctypes.shape) 23 | return b 24 | -------------------------------------------------------------------------------- /numpy/core/tests/test_indexing.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.compat import asbytes 3 | from numpy.testing import * 4 | import sys, warnings 5 | 6 | # The C implementation of fancy indexing is relatively complicated, 7 | # and has many seeming inconsistencies. It also appears to lack any 8 | # kind of test suite, making any changes to the underlying code difficult 9 | # because of its fragility. 10 | 11 | # This file is to remedy the test suite part a little bit, 12 | # but hopefully NumPy indexing can be changed to be more systematic 13 | # at some point in the future. 14 | 15 | def test_boolean_indexing(): 16 | # Indexing a 2-dimensional array with a length-1 array of 'True' 17 | a = np.array([[ 0., 0., 0.]]) 18 | b = np.array([ True], dtype=bool) 19 | assert_equal(a[b], a) 20 | 21 | a[b] = 1. 22 | assert_equal(a, [[1., 1., 1.]]) 23 | 24 | if __name__ == "__main__": 25 | run_module_suite() 26 | -------------------------------------------------------------------------------- /doc/swig/Makefile: -------------------------------------------------------------------------------- 1 | # List all of the subdirectories here for recursive make 2 | SUBDIRS = test doc 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 | -------------------------------------------------------------------------------- /doc/swig/test/Makefile: -------------------------------------------------------------------------------- 1 | # SWIG 2 | INTERFACES = Array.i Farray.i Vector.i Matrix.i Tensor.i Fortran.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 Farray.cxx Farray.h Vector.cxx Vector.h \ 9 | Matrix.cxx Matrix.h Tensor.cxx Tensor.h Fortran.h Fortran.cxx 10 | ./setup.py build_ext -i 11 | 12 | # Test target: run the tests 13 | .PHONY : test 14 | test: all 15 | python testVector.py 16 | python testMatrix.py 17 | python testTensor.py 18 | python testArray.py 19 | python testFarray.py 20 | python testFortran.py 21 | 22 | # Rule: %.i -> %_wrap.cxx 23 | %_wrap.cxx: %.i %.h ../numpy.i 24 | swig -c++ -python $< 25 | %_wrap.cxx: %.i %1.h %2.h ../numpy.i 26 | swig -c++ -python $< 27 | 28 | # Clean target 29 | .PHONY : clean 30 | clean: 31 | $(RM) -r build 32 | $(RM) *.so 33 | $(RM) $(WRAPPERS) 34 | $(RM) $(PROXIES) 35 | -------------------------------------------------------------------------------- /numpy/oldnumeric/fft.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ['fft', 'fft2d', 'fftnd', 'hermite_fft', 'inverse_fft', 3 | 'inverse_fft2d', 'inverse_fftnd', 4 | 'inverse_hermite_fft', 'inverse_real_fft', 5 | 'inverse_real_fft2d', 'inverse_real_fftnd', 6 | 'real_fft', 'real_fft2d', 'real_fftnd'] 7 | 8 | from numpy.fft import fft 9 | from numpy.fft import fft2 as fft2d 10 | from numpy.fft import fftn as fftnd 11 | from numpy.fft import hfft as hermite_fft 12 | from numpy.fft import ifft as inverse_fft 13 | from numpy.fft import ifft2 as inverse_fft2d 14 | from numpy.fft import ifftn as inverse_fftnd 15 | from numpy.fft import ihfft as inverse_hermite_fft 16 | from numpy.fft import irfft as inverse_real_fft 17 | from numpy.fft import irfft2 as inverse_real_fft2d 18 | from numpy.fft import irfftn as inverse_real_fftnd 19 | from numpy.fft import rfft as real_fft 20 | from numpy.fft import rfft2 as real_fft2d 21 | from numpy.fft import rfftn as real_fftnd 22 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tools/commitstats.py: -------------------------------------------------------------------------------- 1 | 2 | # Run svn log -l 3 | 4 | import re 5 | import numpy as np 6 | import os 7 | 8 | names = re.compile(r'r\d+\s[|]\s(.*)\s[|]\s200') 9 | 10 | def get_count(filename, repo): 11 | mystr = open(filename).read() 12 | result = names.findall(mystr) 13 | u = np.unique(result) 14 | count = [(x,result.count(x),repo) for x in u] 15 | return count 16 | 17 | 18 | command = 'svn log -l 2300 > output.txt' 19 | os.chdir('..') 20 | os.system(command) 21 | 22 | count = get_count('output.txt', 'NumPy') 23 | 24 | 25 | os.chdir('../scipy') 26 | os.system(command) 27 | 28 | count.extend(get_count('output.txt', 'SciPy')) 29 | 30 | os.chdir('../scikits') 31 | os.system(command) 32 | count.extend(get_count('output.txt', 'SciKits')) 33 | count.sort() 34 | 35 | 36 | 37 | print "** SciPy and NumPy **" 38 | print "=====================" 39 | for val in count: 40 | print val 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /doc/numpybook/comparison/pyrex/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from distutils.core import setup 4 | from distutils.extension import Extension 5 | 6 | import numpy 7 | 8 | # Define a pyrex-based extension module, using the generated sources if pyrex 9 | from Pyrex.Distutils import build_ext 10 | pyx_sources = ['add.pyx'] 11 | cmdclass = {'build_ext': build_ext} 12 | 13 | 14 | pyx_ext = Extension('add', 15 | pyx_sources, 16 | include_dirs = [numpy.get_include()]) 17 | 18 | pyx_ext2 = Extension('blur', 19 | ['blur.pyx'], 20 | include_dirs = [numpy.get_include()]) 21 | 22 | 23 | # Call the routine which does the real work 24 | setup(name = 'add', 25 | description = 'Small example on using Pyrex to write a Numpy extension', 26 | url = 'http://www.scipy.org/Cookbook/Pyrex_and_NumPy', 27 | ext_modules = [pyx_ext, pyx_ext2], 28 | cmdclass = cmdclass, 29 | ) 30 | -------------------------------------------------------------------------------- /numpy/distutils/command/install_data.py: -------------------------------------------------------------------------------- 1 | import sys 2 | have_setuptools = ('setuptools' in sys.modules) 3 | 4 | from distutils.command.install_data import install_data as old_install_data 5 | 6 | #data installer with improved intelligence over distutils 7 | #data files are copied into the project directory instead 8 | #of willy-nilly 9 | class install_data (old_install_data): 10 | 11 | def run(self): 12 | old_install_data.run(self) 13 | 14 | if have_setuptools: 15 | # Run install_clib again, since setuptools does not run sub-commands 16 | # of install automatically 17 | self.run_command('install_clib') 18 | 19 | def finalize_options (self): 20 | self.set_undefined_options('install', 21 | ('install_lib', 'install_dir'), 22 | ('root', 'root'), 23 | ('force', 'force'), 24 | ) 25 | -------------------------------------------------------------------------------- /doc/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/f2py/docs/usersguide/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/numpybook/comparison/f2py/add.f: -------------------------------------------------------------------------------- 1 | C 2 | SUBROUTINE ZADD(A,B,C,N) 3 | C 4 | DOUBLE COMPLEX A(*) 5 | DOUBLE COMPLEX B(*) 6 | DOUBLE COMPLEX C(*) 7 | INTEGER N 8 | DO 20 J = 1, N 9 | C(J) = A(J) + B(J) 10 | 20 CONTINUE 11 | END 12 | 13 | SUBROUTINE CADD(A,B,C,N) 14 | C 15 | COMPLEX A(*) 16 | COMPLEX B(*) 17 | COMPLEX C(*) 18 | INTEGER N 19 | DO 20 J = 1, N 20 | C(J) = A(J) + B(J) 21 | 20 CONTINUE 22 | END 23 | 24 | SUBROUTINE DADD(A,B,C,N) 25 | C 26 | DOUBLE PRECISION A(*) 27 | DOUBLE PRECISION B(*) 28 | DOUBLE PRECISION C(*) 29 | INTEGER N 30 | DO 20 J = 1, N 31 | C(J) = A(J) + B(J) 32 | 20 CONTINUE 33 | END 34 | 35 | SUBROUTINE SADD(A,B,C,N) 36 | C 37 | REAL A(*) 38 | REAL B(*) 39 | REAL C(*) 40 | INTEGER N 41 | DO 20 J = 1, N 42 | C(J) = A(J) + B(J) 43 | 20 CONTINUE 44 | END 45 | 46 | -------------------------------------------------------------------------------- /numpy/f2py/doc/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 | -------------------------------------------------------------------------------- /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 submitting a "ticket" on the Trac pages: 7 | 8 | - Numpy Trac: http://scipy.org/scipy/numpy 9 | 10 | Because of spam abuse, you must create an account on our Trac in order 11 | to submit a ticket, then click on the "New Ticket" tab that only 12 | appears when you have logged in. Please give as much information as 13 | you can in the ticket. It is extremely useful if you can supply a 14 | small self-contained code snippet that reproduces the problem. Also 15 | specify the component, the version you are referring to and the 16 | milestone. 17 | 18 | Report bugs to the appropriate Trac instance (there is one for NumPy 19 | and a different one for SciPy). There are also read-only mailing lists 20 | for tracking the status of your bug ticket. 21 | 22 | More information can be found on the http://scipy.org/Developer_Zone 23 | website. 24 | -------------------------------------------------------------------------------- /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/_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/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 | * harcoded 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 | 33 | #endif 34 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | NumPy is the fundamental package needed for scientific computing with Python. 2 | This package contains: 3 | 4 | * a powerful N-dimensional array object 5 | * sophisticated (broadcasting) functions 6 | * tools for integrating C/C++ and Fortran code 7 | * useful linear algebra, Fourier transform, and random number capabilities. 8 | 9 | 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. 10 | 11 | More information can be found at the website: 12 | 13 | http://scipy.org/NumPy 14 | 15 | After installation, tests can be run with: 16 | 17 | python -c 'import numpy; numpy.test()' 18 | 19 | Starting in NumPy 1.7, deprecation warnings have been set to 'raise' by 20 | default, so the -Wd command-line option is no longer necessary. 21 | 22 | The most current development version is always available from our 23 | git repository: 24 | 25 | http://github.com/numpy/numpy 26 | 27 | 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/core/bento.info: -------------------------------------------------------------------------------- 1 | HookFile: bscript 2 | 3 | Library: 4 | CompiledLibrary: npymath 5 | Sources: 6 | src/npymath/_signbit.c, 7 | src/npymath/ieee754.c.src, 8 | src/npymath/npy_math.c.src, 9 | src/npymath/npy_math_complex.c.src, 10 | src/npymath/halffloat.c 11 | CompiledLibrary: npysort 12 | Sources: 13 | src/npysort/quicksort.c.src, 14 | src/npysort/mergesort.c.src, 15 | src/npysort/heapsort.c.src 16 | Extension: multiarray 17 | Sources: 18 | src/multiarray/multiarraymodule_onefile.c 19 | Extension: multiarray_tests 20 | Sources: 21 | src/multiarray/multiarray_tests.c.src 22 | Extension: umath 23 | Sources: 24 | src/umath/umathmodule_onefile.c 25 | Extension: umath_tests 26 | Sources: 27 | src/umath/umath_tests.c.src 28 | Extension: scalarmath 29 | Sources: 30 | src/scalarmathmodule.c.src 31 | -------------------------------------------------------------------------------- /numpy/distutils/command/__init__.py: -------------------------------------------------------------------------------- 1 | """distutils.command 2 | 3 | Package containing implementation of all the standard Distutils 4 | commands.""" 5 | 6 | __revision__ = "$Id: __init__.py,v 1.3 2005/05/16 11:08:49 pearu Exp $" 7 | 8 | distutils_all = [ #'build_py', 9 | 'clean', 10 | 'install_clib', 11 | 'install_scripts', 12 | 'bdist', 13 | 'bdist_dumb', 14 | 'bdist_wininst', 15 | ] 16 | 17 | __import__('distutils.command',globals(),locals(),distutils_all) 18 | 19 | __all__ = ['build', 20 | 'config_compiler', 21 | 'config', 22 | 'build_src', 23 | 'build_py', 24 | 'build_ext', 25 | 'build_clib', 26 | 'build_scripts', 27 | 'install', 28 | 'install_data', 29 | 'install_headers', 30 | 'install_lib', 31 | 'bdist_rpm', 32 | 'sdist', 33 | ] + distutils_all 34 | -------------------------------------------------------------------------------- /numpy/f2py/doc/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/distutils/command/autodist.py: -------------------------------------------------------------------------------- 1 | """This module implements additional tests ala autoconf which can be useful.""" 2 | 3 | # We put them here since they could be easily reused outside numpy.distutils 4 | 5 | def check_inline(cmd): 6 | """Return the inline identifier (may be empty).""" 7 | cmd._check_compiler() 8 | body = """ 9 | #ifndef __cplusplus 10 | static %(inline)s int static_func (void) 11 | { 12 | return 0; 13 | } 14 | %(inline)s int nostatic_func (void) 15 | { 16 | return 0; 17 | } 18 | #endif""" 19 | 20 | for kw in ['inline', '__inline__', '__inline']: 21 | st = cmd.try_compile(body % {'inline': kw}, None, None) 22 | if st: 23 | return kw 24 | 25 | return '' 26 | 27 | def check_compiler_gcc4(cmd): 28 | """Return True if the C compiler is GCC 4.x.""" 29 | cmd._check_compiler() 30 | body = """ 31 | int 32 | main() 33 | { 34 | #ifndef __GNUC__ && (__GNUC__ >= 4) 35 | die in an horrible death 36 | #endif 37 | } 38 | """ 39 | return cmd.try_compile(body, None, None) 40 | -------------------------------------------------------------------------------- /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 COMPATIBILITY 8 | include *.txt 9 | include setupscons.py 10 | include setupsconsegg.py 11 | include setupegg.py 12 | include site.cfg.example 13 | include tools/py3tool.py 14 | # Adding scons build related files not found by distutils 15 | recursive-include numpy/core/code_generators *.py *.txt 16 | recursive-include numpy/core *.in *.h 17 | recursive-include numpy SConstruct SConscript 18 | # Add documentation: we don't use add_data_dir since we do not want to include 19 | # this at installation, only for sdist-generated tarballs 20 | include doc/Makefile doc/postprocess.py 21 | recursive-include doc/release * 22 | recursive-include doc/source * 23 | recursive-include doc/sphinxext * 24 | recursive-include doc/cython * 25 | recursive-include doc/pyrex * 26 | recursive-include doc/swig * 27 | -------------------------------------------------------------------------------- /numpy/oldnumeric/__init__.py: -------------------------------------------------------------------------------- 1 | # Don't add these to the __all__ variable though 2 | from numpy import * 3 | 4 | def _move_axis_to_0(a, axis): 5 | if axis == 0: 6 | return a 7 | n = len(a.shape) 8 | if axis < 0: 9 | axis += n 10 | axes = range(1, axis+1) + [0,] + range(axis+1, n) 11 | return transpose(a, axes) 12 | 13 | # Add these 14 | from compat import * 15 | from functions import * 16 | from precision import * 17 | from ufuncs import * 18 | from misc import * 19 | 20 | import compat 21 | import precision 22 | import functions 23 | import misc 24 | import ufuncs 25 | 26 | import numpy 27 | __version__ = numpy.__version__ 28 | del numpy 29 | 30 | __all__ = ['__version__'] 31 | __all__ += compat.__all__ 32 | __all__ += precision.__all__ 33 | __all__ += functions.__all__ 34 | __all__ += ufuncs.__all__ 35 | __all__ += misc.__all__ 36 | 37 | del compat 38 | del functions 39 | del precision 40 | del ufuncs 41 | del misc 42 | 43 | from numpy.testing import Tester 44 | test = Tester().test 45 | bench = Tester().bench 46 | -------------------------------------------------------------------------------- /numpy/distutils/command/install_headers.py: -------------------------------------------------------------------------------- 1 | import os 2 | from distutils.command.install_headers import install_headers as old_install_headers 3 | 4 | class install_headers (old_install_headers): 5 | 6 | def run (self): 7 | headers = self.distribution.headers 8 | if not headers: 9 | return 10 | 11 | prefix = os.path.dirname(self.install_dir) 12 | for header in headers: 13 | if isinstance(header,tuple): 14 | # Kind of a hack, but I don't know where else to change this... 15 | if header[0] == 'numpy.core': 16 | header = ('numpy', header[1]) 17 | if os.path.splitext(header[1])[1] == '.inc': 18 | continue 19 | d = os.path.join(*([prefix]+header[0].split('.'))) 20 | header = header[1] 21 | else: 22 | d = self.install_dir 23 | self.mkpath(d) 24 | (out, _) = self.copy_file(header, d) 25 | self.outfiles.append(out) 26 | -------------------------------------------------------------------------------- /numpy/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | def configuration(parent_package='',top_path=None): 4 | from numpy.distutils.misc_util import Configuration 5 | config = Configuration('numpy',parent_package,top_path) 6 | config.add_subpackage('distutils') 7 | config.add_subpackage('testing') 8 | config.add_subpackage('f2py') 9 | config.add_subpackage('core') 10 | config.add_subpackage('lib') 11 | config.add_subpackage('oldnumeric') 12 | config.add_subpackage('numarray') 13 | config.add_subpackage('fft') 14 | config.add_subpackage('linalg') 15 | config.add_subpackage('random') 16 | config.add_subpackage('ma') 17 | config.add_subpackage('matrixlib') 18 | config.add_subpackage('compat') 19 | config.add_subpackage('polynomial') 20 | config.add_subpackage('doc') 21 | config.add_data_dir('doc') 22 | config.add_data_dir('tests') 23 | config.make_config_py() # installs __config__.py 24 | return config 25 | 26 | if __name__ == '__main__': 27 | print('This is the wrong setup.py file to run') 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/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/dummymodule.c: -------------------------------------------------------------------------------- 1 | 2 | /* -*- c -*- */ 3 | 4 | /* 5 | * This is a dummy module whose purpose is to get distutils to generate the 6 | * configuration files before the libraries are made. 7 | */ 8 | 9 | #define NPY_NO_DEPRECATED_API NPY_API_VERSION 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 | PyObject *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/multiarray/item_selection.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE__ITEM_SELECTION_H_ 2 | #define _NPY_PRIVATE__ITEM_SELECTION_H_ 3 | 4 | /* 5 | * Counts the number of True values in a raw boolean array. This 6 | * is a low-overhead function which does no heap allocations. 7 | * 8 | * Returns -1 on error. 9 | */ 10 | NPY_NO_EXPORT npy_intp 11 | count_boolean_trues(int ndim, char *data, npy_intp *ashape, npy_intp *astrides); 12 | 13 | /* 14 | * Gets a single item from the array, based on a single multi-index 15 | * array of values, which must be of length PyArray_NDIM(self). 16 | */ 17 | NPY_NO_EXPORT PyObject * 18 | PyArray_MultiIndexGetItem(PyArrayObject *self, npy_intp *multi_index); 19 | 20 | /* 21 | * Sets a single item in the array, based on a single multi-index 22 | * array of values, which must be of length PyArray_NDIM(self). 23 | * 24 | * Returns 0 on success, -1 on failure. 25 | */ 26 | NPY_NO_EXPORT int 27 | PyArray_MultiIndexSetItem(PyArrayObject *self, npy_intp *multi_index, 28 | PyObject *obj); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /numpy/f2py/tests/test_assumed_shape.py: -------------------------------------------------------------------------------- 1 | import os 2 | import math 3 | 4 | from numpy.testing import * 5 | from numpy import array 6 | 7 | import util 8 | 9 | def _path(*a): 10 | return os.path.join(*((os.path.dirname(__file__),) + a)) 11 | 12 | class TestAssumedShapeSumExample(util.F2PyTest): 13 | sources = [_path('src', 'assumed_shape', 'foo_free.f90'), 14 | _path('src', 'assumed_shape', 'foo_use.f90'), 15 | _path('src', 'assumed_shape', 'precision.f90'), 16 | _path('src', 'assumed_shape', 'foo_mod.f90'), 17 | ] 18 | 19 | @dec.slow 20 | def test_all(self): 21 | r = self.module.fsum([1,2]) 22 | assert_(r==3,`r`) 23 | r = self.module.sum([1,2]) 24 | assert_(r==3,`r`) 25 | r = self.module.sum_with_use([1,2]) 26 | assert_(r==3,`r`) 27 | 28 | r = self.module.mod.sum([1,2]) 29 | assert_(r==3,`r`) 30 | r = self.module.mod.fsum([1,2]) 31 | assert_(r==3,`r`) 32 | 33 | if __name__ == "__main__": 34 | import nose 35 | nose.runmodule() 36 | -------------------------------------------------------------------------------- /numpy/f2py/doc/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/lib/tests/test_utils.py: -------------------------------------------------------------------------------- 1 | from numpy.testing import * 2 | import numpy.lib.utils as utils 3 | from numpy.lib import deprecate 4 | 5 | from StringIO import StringIO 6 | 7 | def test_lookfor(): 8 | out = StringIO() 9 | utils.lookfor('eigenvalue', module='numpy', output=out, 10 | import_modules=False) 11 | out = out.getvalue() 12 | assert_('numpy.linalg.eig' in out) 13 | 14 | 15 | @deprecate 16 | def old_func(self, x): 17 | return x 18 | 19 | @deprecate(message="Rather use new_func2") 20 | def old_func2(self, x): 21 | return x 22 | 23 | def old_func3(self, x): 24 | return x 25 | new_func3 = deprecate(old_func3, old_name="old_func3", new_name="new_func3") 26 | 27 | def test_deprecate_decorator(): 28 | assert_('deprecated' in old_func.__doc__) 29 | 30 | def test_deprecate_decorator_message(): 31 | assert_('Rather use new_func2' in old_func2.__doc__) 32 | 33 | def test_deprecate_fn(): 34 | assert_('old_func3' in new_func3.__doc__) 35 | assert_('new_func3' in new_func3.__doc__) 36 | 37 | if __name__ == "__main__": 38 | run_module_suite() 39 | -------------------------------------------------------------------------------- /doc/cython/Makefile: -------------------------------------------------------------------------------- 1 | # Simple makefile to quickly access handy build commands for Cython extension 2 | # code generation. Note that the actual code to produce the extension lives in 3 | # the setup.py file, this Makefile is just meant as a command 4 | # convenience/reminder while doing development. 5 | 6 | help: 7 | @echo "Numpy/Cython tasks. Available tasks:" 8 | @echo "ext -> build the Cython extension module." 9 | @echo "html -> create annotated HTML from the .pyx sources" 10 | @echo "test -> run a simple test demo." 11 | @echo "all -> Call ext, html and finally test." 12 | 13 | all: ext html test 14 | 15 | ext: numpyx.so 16 | 17 | test: ext 18 | python run_test.py 19 | 20 | html: numpyx.pyx.html 21 | 22 | numpyx.so: numpyx.pyx numpyx.c 23 | python setup.py build_ext --inplace 24 | 25 | numpyx.pyx.html: numpyx.pyx 26 | cython -a numpyx.pyx 27 | @echo "Annotated HTML of the C code generated in numpyx.html" 28 | 29 | # Phony targets for cleanup and similar uses 30 | 31 | .PHONY: clean 32 | clean: 33 | rm -rf *~ *.so *.c *.o *.html build 34 | 35 | # Suffix rules 36 | %.c : %.pyx 37 | cython $< 38 | -------------------------------------------------------------------------------- /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 | .. warning:: 13 | 14 | This "User Guide" is still a work in progress; some of the material 15 | is not organized, and several aspects of NumPy are not yet covered 16 | sufficient detail. We are an open source community continually 17 | working to improve the documentation and eagerly encourage interested 18 | parties to contribute. For information on how to do so, please visit 19 | the NumPy `doc wiki `_. 20 | 21 | More documentation for NumPy can be found on the `numpy.org 22 | `__ website. 23 | 24 | Thanks! 25 | 26 | .. toctree:: 27 | :maxdepth: 2 28 | 29 | introduction 30 | basics 31 | performance 32 | misc 33 | c-info 34 | -------------------------------------------------------------------------------- /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 | array_equal 54 | array_equiv 55 | 56 | .. autosummary:: 57 | :toctree: generated/ 58 | 59 | greater 60 | greater_equal 61 | less 62 | less_equal 63 | equal 64 | not_equal 65 | -------------------------------------------------------------------------------- /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_array_equal 22 | assert_array_less 23 | assert_equal 24 | assert_raises 25 | assert_warns 26 | assert_string_equal 27 | 28 | Decorators 29 | ---------- 30 | .. autosummary:: 31 | :toctree: generated/ 32 | 33 | decorators.deprecated 34 | decorators.knownfailureif 35 | decorators.setastest 36 | decorators.skipif 37 | decorators.slow 38 | decorate_methods 39 | 40 | 41 | Test Running 42 | ------------ 43 | .. autosummary:: 44 | :toctree: generated/ 45 | 46 | Tester 47 | run_module_suite 48 | rundocs 49 | -------------------------------------------------------------------------------- /benchmarks/sorting.py: -------------------------------------------------------------------------------- 1 | from benchmark import Benchmark 2 | 3 | modules = ['numpy','Numeric','numarray'] 4 | b = Benchmark(modules,runs=3,reps=100) 5 | 6 | N = 10000 7 | b.title = 'Sorting %d elements' % N 8 | b['numarray'] = ('a=np.array(None,shape=%d,typecode="i");a.sort()'%N,'') 9 | b['numpy'] = ('a=np.empty(shape=%d, dtype="i");a.sort()'%N,'') 10 | b['Numeric'] = ('a=np.empty(shape=%d, typecode="i");np.sort(a)'%N,'') 11 | b.run() 12 | 13 | N1,N2 = 100,100 14 | b.title = 'Sorting (%d,%d) elements, last axis' % (N1,N2) 15 | b['numarray'] = ('a=np.array(None,shape=(%d,%d),typecode="i");a.sort()'%(N1,N2),'') 16 | b['numpy'] = ('a=np.empty(shape=(%d,%d), dtype="i");a.sort()'%(N1,N2),'') 17 | b['Numeric'] = ('a=np.empty(shape=(%d,%d),typecode="i");np.sort(a)'%(N1,N2),'') 18 | b.run() 19 | 20 | N1,N2 = 100,100 21 | b.title = 'Sorting (%d,%d) elements, first axis' % (N1,N2) 22 | b['numarray'] = ('a=np.array(None,shape=(%d,%d), typecode="i");a.sort(0)'%(N1,N2),'') 23 | b['numpy'] = ('a=np.empty(shape=(%d,%d),dtype="i");np.sort(a,0)'%(N1,N2),'') 24 | b['Numeric'] = ('a=np.empty(shape=(%d,%d),typecode="i");np.sort(a,0)'%(N1,N2),'') 25 | b.run() 26 | -------------------------------------------------------------------------------- /doc/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/tests/test_machar.py: -------------------------------------------------------------------------------- 1 | from numpy.testing import * 2 | 3 | from numpy.core.machar import MachAr 4 | import numpy.core.numerictypes as ntypes 5 | from numpy import seterr, array 6 | 7 | class TestMachAr(TestCase): 8 | def _run_machar_highprec(self): 9 | # Instanciate MachAr instance with high enough precision to cause 10 | # underflow 11 | try: 12 | hiprec = ntypes.float96 13 | machar = MachAr(lambda v:array([v], hiprec)) 14 | except AttributeError: 15 | "Skipping test: no nyptes.float96 available on this platform." 16 | 17 | def test_underlow(self): 18 | """Regression testing for #759: instanciating MachAr for dtype = 19 | np.float96 raises spurious warning.""" 20 | serrstate = seterr(all='raise') 21 | try: 22 | try: 23 | self._run_machar_highprec() 24 | except FloatingPointError, e: 25 | self.fail("Caught %s exception, should not have been raised." % e) 26 | finally: 27 | seterr(**serrstate) 28 | 29 | 30 | if __name__ == "__main__": 31 | run_module_suite() 32 | -------------------------------------------------------------------------------- /numpy/random/bscript: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | from bento.commands import hooks 5 | import waflib 6 | 7 | @hooks.post_configure 8 | def configure(context): 9 | conf = context.waf_context 10 | 11 | conf.env.USE_WINCRYPT = False 12 | if conf.check_declaration("_WIN32", mandatory=False): 13 | conf.env.USE_WINCRYPT = True 14 | 15 | conf.env.NEEDS_MINGW32_WORKAROUND = False 16 | if sys.platform == "win32" and conf.check_declaration("__GNUC__", mandatory=False): 17 | conf.env.NEEDS_MINGW32_WORKAROUND = True 18 | 19 | @hooks.pre_build 20 | def build(context): 21 | bld = context.waf_context 22 | 23 | if bld.env.NEEDS_MINGW32_WORKAROUND: 24 | raise NotImplementedError("Check for mingw time workaround stuff") 25 | 26 | def builder(extension): 27 | includes = ["../core/include", "../core/include/numpy", "../core", 28 | "../core/src/private"] 29 | kw = {} 30 | if bld.env.USE_WINCRYPT: 31 | kw["lib"] = "ADVAPI32" 32 | return context.default_builder(extension, includes=includes, **kw) 33 | context.register_builder("mtrand", builder) 34 | -------------------------------------------------------------------------------- /numpy/matrixlib/tests/test_regression.py: -------------------------------------------------------------------------------- 1 | from numpy.testing import * 2 | import numpy as np 3 | 4 | rlevel = 1 5 | 6 | class TestRegression(TestCase): 7 | def test_kron_matrix(self,level=rlevel): 8 | """Ticket #71""" 9 | x = np.matrix('[1 0; 1 0]') 10 | assert_equal(type(np.kron(x,x)),type(x)) 11 | 12 | def test_matrix_properties(self,level=rlevel): 13 | """Ticket #125""" 14 | a = np.matrix([1.0],dtype=float) 15 | assert_(type(a.real) is np.matrix) 16 | assert_(type(a.imag) is np.matrix) 17 | c,d = np.matrix([0.0]).nonzero() 18 | assert_(type(c) is np.matrix) 19 | assert_(type(d) is np.matrix) 20 | 21 | def test_matrix_multiply_by_1d_vector(self, level=rlevel) : 22 | """Ticket #473""" 23 | def mul() : 24 | np.mat(np.eye(2))*np.ones(2) 25 | 26 | self.assertRaises(ValueError,mul) 27 | 28 | def test_matrix_std_argmax(self,level=rlevel): 29 | """Ticket #83""" 30 | x = np.asmatrix(np.random.uniform(0,1,(3,3))) 31 | self.assertEqual(x.std().shape, ()) 32 | self.assertEqual(x.argmax().shape, ()) 33 | 34 | --------------------------------------------------------------------------------