├── numpy ├── core │ ├── code_generators │ │ ├── __init__.py │ │ ├── genapi2.py │ │ ├── cversions.py │ │ └── cversions.txt │ ├── src │ │ ├── multiarray │ │ │ ├── shape.h │ │ │ ├── multiarraymodule.h │ │ │ ├── getset.h │ │ │ ├── methods.h │ │ │ ├── hashdescr.h │ │ │ ├── sequence.h │ │ │ ├── arraytypes.h │ │ │ ├── buffer.h │ │ │ ├── ucsnarrow.h │ │ │ ├── usertypes.h │ │ │ ├── refcount.h │ │ │ ├── _datetime.h │ │ │ ├── convert_datatype.h │ │ │ ├── descriptor.h │ │ │ ├── common.h │ │ │ ├── numpymemoryview.h │ │ │ ├── scalartypes.h │ │ │ ├── number.h │ │ │ └── iterators.h │ │ ├── umath │ │ │ └── ufunc_object.h │ │ └── private │ │ │ └── numpy_config.h │ ├── _mx_datetime_parser.py │ ├── SConstruct │ ├── tests │ │ ├── data │ │ │ ├── astype_copy.pkl │ │ │ └── recarray_from_file.fits │ │ ├── test_methods.py │ │ ├── test_arrayprint.py │ │ ├── test_scalartypes.py │ │ ├── test_iterators.py │ │ ├── test_blasdot.py │ │ ├── test_machar.py │ │ └── test_function_base.py │ ├── mlib.ini.in │ ├── umath_clr.py │ ├── multiarray_clr.py │ └── include │ │ └── numpy │ │ ├── _numpyconfig.h.in │ │ ├── numpyconfig.h │ │ ├── arrayobject.h │ │ └── oldnumeric.h ├── 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 │ ├── fcompiler │ │ └── none.py │ └── intelccompiler.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 │ │ ├── README.txt │ │ ├── THANKS.txt │ │ ├── HISTORY.txt │ │ ├── pyforttest.pyf │ │ ├── hello.f │ │ ├── pytest.py │ │ ├── simple.f │ │ └── docutils.conf │ ├── setup.cfg │ ├── 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 │ ├── tests │ │ ├── src │ │ │ └── mixed │ │ │ │ ├── foo.f │ │ │ │ ├── foo_free.f90 │ │ │ │ └── foo_fixed.f90 │ │ └── test_mixed.py │ ├── __version__.py │ ├── src │ │ └── test │ │ │ ├── foo90.f90 │ │ │ ├── bar.f │ │ │ └── foo.f │ └── README.txt ├── numarray │ ├── ma.py │ ├── SConstruct │ ├── compat.py │ ├── fft.py │ ├── mlab.py │ ├── matrix.py │ ├── linear_algebra.py │ ├── image.py │ ├── nd_image.py │ ├── random_array.py │ ├── SConscript │ ├── convolve.py │ ├── setupscons.py │ ├── setup.py │ └── __init__.py ├── fft │ ├── SConstruct │ ├── fftpack_lite_clr.py │ ├── __init__.py │ ├── npy_ironpython.h │ ├── SConscript │ ├── setupscons.py │ ├── setup.py │ ├── tests │ │ └── test_fftpack.py │ └── fftpack.h ├── lib │ ├── SConstruct │ ├── SConscript │ ├── setupscons.py │ ├── setup.py │ ├── tests │ │ └── test_utils.py │ └── __init__.py ├── linalg │ ├── SConstruct │ ├── lapack_lite_clr.py │ ├── npy_ironpython.h │ ├── lapack_lite │ │ └── wrapped_routines │ ├── SConscript │ └── setupscons.py ├── random │ ├── SConstruct │ └── mtrand │ │ ├── initarray.h │ │ └── generate_mtrand_c.py ├── doc │ ├── io.py │ ├── howtofind.py │ ├── jargon.py │ ├── performance.py │ ├── methods_vs_functions.py │ └── __init__.py ├── NumpyDotNet │ ├── NpyAccessLib │ │ ├── generate_code.bat │ │ └── NpyAccessLib.vcxproj.user │ └── UMathModule.cs ├── 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 │ ├── setup.py │ └── setupscons.py ├── ma │ ├── version.py │ ├── setup.py │ └── setupscons.py ├── compat │ ├── setup.py │ ├── setupscons.py │ └── __init__.py ├── polynomial │ ├── setup.py │ └── __init__.py ├── testing │ ├── nulltester.py │ ├── __init__.py │ ├── setupscons.py │ └── setup.py └── 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 │ │ ├── internals.rst │ │ ├── swig.rst │ │ ├── routines.numarray.rst │ │ ├── routines.oldnumeric.rst │ │ ├── routines.functional.rst │ │ ├── routines.window.rst │ │ ├── routines.financial.rst │ │ ├── routines.matlib.rst │ │ ├── routines.emath.rst │ │ ├── routines.set.rst │ │ ├── routines.help.rst │ │ ├── routines.ctypeslib.rst │ │ ├── routines.other.rst │ │ ├── maskedarray.rst │ │ ├── routines.err.rst │ │ ├── routines.sort.rst │ │ ├── routines.bitwise.rst │ │ ├── routines.poly.rst │ │ ├── routines.dual.rst │ │ ├── routines.statistics.rst │ │ ├── routines.dtype.rst │ │ ├── routines.logic.rst │ │ ├── routines.testing.rst │ │ └── routines.indexing.rst │ ├── scipyshiny_small.png │ ├── release.rst │ ├── user │ │ ├── performance.rst │ │ ├── basics.byteswapping.rst │ │ ├── basics.io.rst │ │ ├── introduction.rst │ │ ├── misc.rst │ │ ├── basics.types.rst │ │ ├── basics.broadcasting.rst │ │ ├── basics.subclassing.rst │ │ ├── c-info.rst │ │ ├── basics.indexing.rst │ │ ├── howtofind.rst │ │ ├── basics.rec.rst │ │ ├── basics.creation.rst │ │ ├── basics.rst │ │ └── index.rst │ ├── dev │ │ ├── gitwash │ │ │ ├── branch_list.png │ │ │ ├── pull_button.png │ │ │ ├── forking_button.png │ │ │ ├── branch_list_compare.png │ │ │ ├── git_development.rst │ │ │ ├── index.rst │ │ │ ├── dot2_dot3.rst │ │ │ └── following_latest.rst │ │ ├── gitwash_links.txt │ │ └── index.rst │ ├── _templates │ │ ├── indexsidebar.html │ │ ├── autosummary │ │ │ └── class.rst │ │ └── layout.html │ ├── glossary.rst │ ├── contents.rst │ └── bugs.rst ├── numpybook │ ├── mybook.layout │ ├── Figures │ │ ├── fig1.eps │ │ ├── fig2.eps │ │ ├── fig1bw.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 ├── release │ └── 2.0.0-notes.rst ├── neps │ └── structured_array_extensions.txt └── swig │ ├── test │ ├── Fortran.h │ ├── Makefile │ ├── Fortran.cxx │ ├── Fortran.i │ └── Array1.h │ └── Makefile ├── libndarray ├── autogen.sh ├── windows │ ├── msvc2010.suo │ ├── msvc2008.vcxproj.user │ ├── test │ │ ├── main.c │ │ └── do.sh │ ├── build.py │ └── msvc2010.sln ├── redo ├── README.txt ├── tools │ └── long_double.c └── src │ └── npy_utils.h ├── .gitattributes ├── tools ├── numpy-macosx-installer │ ├── dmgbackground.png │ ├── art │ │ └── dmgbackground.png │ └── README.txt ├── c_coverage │ └── c_coverage_collect.sh ├── nptool ├── 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 ├── release.sh ├── benchmarks ├── creating.py ├── casting.py └── sorting.py ├── iron_setup.py ├── setupegg.py ├── DEV_README.txt ├── MANIFEST.in └── README.txt /numpy/core/code_generators/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /numpy/core/code_generators/genapi2.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 -------------------------------------------------------------------------------- /doc/sphinxext/__init__.py: -------------------------------------------------------------------------------- 1 | from numpydoc import setup 2 | -------------------------------------------------------------------------------- /numpy/numarray/ma.py: -------------------------------------------------------------------------------- 1 | 2 | from numpy.oldnumeric.ma import * 3 | -------------------------------------------------------------------------------- /libndarray/autogen.sh: -------------------------------------------------------------------------------- 1 | autoreconf --force --verbose --install 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/TODO.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/numpy/f2py/TODO.txt -------------------------------------------------------------------------------- /numpy/f2py/docs/FAQ.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/numpy/f2py/docs/FAQ.txt -------------------------------------------------------------------------------- /numpy/f2py/docs/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/numpy/f2py/docs/README.txt -------------------------------------------------------------------------------- /numpy/f2py/docs/THANKS.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/numpy/f2py/docs/THANKS.txt -------------------------------------------------------------------------------- /doc/numpybook/mybook.layout: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/mybook.layout -------------------------------------------------------------------------------- /numpy/core/src/multiarray/shape.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_SHAPE_H_ 2 | #define _NPY_ARRAY_SHAPE_H_ 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /numpy/f2py/docs/HISTORY.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/numpy/f2py/docs/HISTORY.txt -------------------------------------------------------------------------------- /numpy/f2py/info.py: -------------------------------------------------------------------------------- 1 | """Fortran to Python Interface Generator. 2 | 3 | """ 4 | 5 | postpone_import = True 6 | -------------------------------------------------------------------------------- /doc/numpybook/Figures/fig1.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/Figures/fig1.eps -------------------------------------------------------------------------------- /doc/numpybook/Figures/fig2.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/Figures/fig2.eps -------------------------------------------------------------------------------- /doc/numpybook/graphics/note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/graphics/note.png -------------------------------------------------------------------------------- /doc/numpybook/graphics/tip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/graphics/tip.png -------------------------------------------------------------------------------- /doc/source/scipyshiny_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/source/scipyshiny_small.png -------------------------------------------------------------------------------- /libndarray/windows/msvc2010.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/libndarray/windows/msvc2010.suo -------------------------------------------------------------------------------- /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/fig1bw.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/Figures/fig1bw.eps -------------------------------------------------------------------------------- /doc/numpybook/Figures/fig2bw.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/Figures/fig2bw.eps -------------------------------------------------------------------------------- /numpy/core/_mx_datetime_parser.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/numpy/core/_mx_datetime_parser.py -------------------------------------------------------------------------------- /numpy/core/src/multiarray/multiarraymodule.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_MULTIARRAY_H_ 2 | #define _NPY_MULTIARRAY_H_ 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /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/numpybook/Figures/contiguous.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/Figures/contiguous.pdf -------------------------------------------------------------------------------- /doc/numpybook/Figures/hierarchy.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/Figures/hierarchy.dia -------------------------------------------------------------------------------- /doc/numpybook/Figures/hierarchy.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/Figures/hierarchy.fig -------------------------------------------------------------------------------- /doc/numpybook/Figures/hierarchy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/Figures/hierarchy.pdf -------------------------------------------------------------------------------- /doc/numpybook/Figures/hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/Figures/hierarchy.png -------------------------------------------------------------------------------- /doc/numpybook/graphics/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/graphics/warning.png -------------------------------------------------------------------------------- /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/release.rst: -------------------------------------------------------------------------------- 1 | ************* 2 | Release Notes 3 | ************* 4 | 5 | .. include:: ../release/1.3.0-notes.rst 6 | -------------------------------------------------------------------------------- /doc/source/user/performance.rst: -------------------------------------------------------------------------------- 1 | *********** 2 | Performance 3 | *********** 4 | 5 | .. automodule:: numpy.doc.performance 6 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/branch_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/source/dev/gitwash/branch_list.png -------------------------------------------------------------------------------- /doc/source/dev/gitwash/pull_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/source/dev/gitwash/pull_button.png -------------------------------------------------------------------------------- /numpy/core/SConstruct: -------------------------------------------------------------------------------- 1 | from numscons import GetInitEnvironment 2 | GetInitEnvironment(ARGUMENTS).DistutilsSConscript('SConscript') 3 | -------------------------------------------------------------------------------- /numpy/core/tests/data/astype_copy.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/numpy/core/tests/data/astype_copy.pkl -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/forking_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/source/dev/gitwash/forking_button.png -------------------------------------------------------------------------------- /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/flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/numpy/f2py/doc/f2python9-final/flow.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/numpybook/Figures/threefundamental.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/numpybook/Figures/threefundamental.png -------------------------------------------------------------------------------- /doc/source/user/basics.byteswapping.rst: -------------------------------------------------------------------------------- 1 | ************* 2 | Byte-swapping 3 | ************* 4 | 5 | .. automodule:: numpy.doc.byteswapping 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/branch_list_compare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/source/dev/gitwash/branch_list_compare.png -------------------------------------------------------------------------------- /numpy/core/tests/data/recarray_from_file.fits: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/numpy/core/tests/data/recarray_from_file.fits -------------------------------------------------------------------------------- /numpy/f2py/doc/f2python9-final/structure.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/numpy/f2py/doc/f2python9-final/structure.jpg -------------------------------------------------------------------------------- /tools/numpy-macosx-installer/dmgbackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/tools/numpy-macosx-installer/dmgbackground.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/source/reference/figures/dtype-hierarchy.dia -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/source/reference/figures/dtype-hierarchy.pdf -------------------------------------------------------------------------------- /doc/source/reference/figures/dtype-hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/source/reference/figures/dtype-hierarchy.png -------------------------------------------------------------------------------- /numpy/f2py/doc/f2python9-final/aerostructure.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/numpy/f2py/doc/f2python9-final/aerostructure.jpg -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/reference/figures/threefundamental.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/source/reference/figures/threefundamental.pdf -------------------------------------------------------------------------------- /doc/source/reference/figures/threefundamental.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/doc/source/reference/figures/threefundamental.png -------------------------------------------------------------------------------- /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/NumpyDotNet/NpyAccessLib/generate_code.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | "%IRONPYTHON_HOME%/ipy.exe" ..\..\core\code_generators\generate_umath.py 4 | 5 | 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tools/numpy-macosx-installer/art/dmgbackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numpy/numpy-refactor/HEAD/tools/numpy-macosx-installer/art/dmgbackground.png -------------------------------------------------------------------------------- /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/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/core/src/multiarray/getset.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_GETSET_H_ 2 | #define _NPY_ARRAY_GETSET_H_ 3 | 4 | extern NPY_NO_EXPORT PyGetSetDef array_getsetlist[]; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/methods.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_METHODS_H_ 2 | #define _NPY_ARRAY_METHODS_H_ 3 | 4 | extern NPY_NO_EXPORT PyMethodDef array_methods[]; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /libndarray/windows/msvc2008.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/hashdescr.h: -------------------------------------------------------------------------------- 1 | #ifndef _NUMPY_HASHDESCR_H_ 2 | #define _NUMPY_HASHDESCR_H_ 3 | 4 | NPY_NO_EXPORT long 5 | PyArray_DescrHash(PyObject* odescr); 6 | 7 | #endif 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/user/basics.subclassing.rst: -------------------------------------------------------------------------------- 1 | .. _basics.subclassing: 2 | 3 | ******************* 4 | Subclassing ndarray 5 | ******************* 6 | 7 | .. automodule:: numpy.doc.subclassing 8 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/sequence.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_SEQUENCE_H_ 2 | #define _NPY_ARRAY_SEQUENCE_H_ 3 | 4 | extern NPY_NO_EXPORT PySequenceMethods array_as_sequence; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /numpy/fft/fftpack_lite_clr.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.platform == 'cli': 4 | import clr 5 | clr.AddReference("fftpack_lite") 6 | 7 | from numpy__fft__fftpack_cython import * 8 | -------------------------------------------------------------------------------- /numpy/linalg/lapack_lite_clr.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.platform == 'cli': 4 | import clr 5 | clr.AddReference("lapack_lite") 6 | 7 | from numpy__linalg__lapack_lite import * 8 | -------------------------------------------------------------------------------- /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/NumpyDotNet/NpyAccessLib/NpyAccessLib.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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.beyond-basics 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/source/glossary.rst: -------------------------------------------------------------------------------- 1 | ******** 2 | Glossary 3 | ******** 4 | 5 | .. toctree:: 6 | 7 | .. glossary:: 8 | 9 | .. automodule:: numpy.doc.glossary 10 | 11 | Jargon 12 | ------ 13 | 14 | .. automodule:: numpy.doc.jargon 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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(__file__).test 9 | bench = Tester(__file__).bench 10 | -------------------------------------------------------------------------------- /tools/nptool: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # This tool helps with various tasks that arise in numpy development and 4 | # testing. 5 | 6 | import nptool 7 | import sys 8 | 9 | tool = nptool.nptool() 10 | 11 | tool.cmd( sys.argv[1:] ) 12 | -------------------------------------------------------------------------------- /doc/release/2.0.0-notes.rst: -------------------------------------------------------------------------------- 1 | ========================= 2 | NumPy 2.0.0 Release Notes 3 | ========================= 4 | 5 | 6 | Highlights 7 | ========== 8 | 9 | 10 | New features 11 | ============ 12 | 13 | 14 | Changes 15 | ======= 16 | 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libndarray/windows/test/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "npy_math.h" 3 | 4 | 5 | main (void) 6 | { 7 | double x, y; 8 | 9 | x = 2.0; 10 | y = npy_sqrt(x); 11 | printf("sqrt(2) = %f\n", y); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /numpy/f2py/README.txt: -------------------------------------------------------------------------------- 1 | ====================================================================== 2 | F2PY - Fortran to Python Interface Generator 3 | ====================================================================== 4 | 5 | Read docs/README.txt 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/fft/npy_ironpython.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_IRONPYTHON_H_ 2 | #define _NPY_IRONPYTHON_H_ 3 | 4 | #include "npy_object.h" 5 | 6 | #define Npy_INTERFACE_OBJECT(a) (System::Runtime::InteropServices::GCHandle::FromIntPtr((System::IntPtr)Npy_INTERFACE(a)).Target) 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /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(__file__).test 8 | bench = Tester(__file__).bench 9 | -------------------------------------------------------------------------------- /numpy/linalg/npy_ironpython.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_IRONPYTHON_H_ 2 | #define _NPY_IRONPYTHON_H_ 3 | 4 | #include "npy_object.h" 5 | 6 | #define Npy_INTERFACE_OBJECT(a) (System::Runtime::InteropServices::GCHandle::FromIntPtr((System::IntPtr)Npy_INTERFACE(a)).Target) 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/random/mtrand/initarray.h: -------------------------------------------------------------------------------- 1 | #include "randomkit.h" 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | extern void 8 | init_by_array(rk_state *self, unsigned long init_key[], 9 | unsigned long key_length); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libndarray/windows/test/do.sh: -------------------------------------------------------------------------------- 1 | rm -f main.exe main.obj 2 | 3 | cl /c "/IC:\\Documents and Settings\\builder\\usr\\include" main.c 4 | 5 | link /nologo /OUT:main.exe \ 6 | "/LIBPATH:C:\\Documents and Settings\\builder\\usr\\lib" \ 7 | main.obj ndarray.lib 8 | 9 | ./main.exe 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libndarray/redo: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | make clean 4 | 5 | rm -rf src/npy_config.h 6 | rm -rf src/.deps src/.dirstamp stamp-h1 autom4te.cache aclocal.m4 7 | rm -rf tools/.deps tools/.dirstamp Makefile Makefile.in 8 | 9 | autoreconf -fvi 10 | 11 | bash configure --disable-static 12 | 13 | make 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/core/src/umath/ufunc_object.h: -------------------------------------------------------------------------------- 1 | #ifndef _UMATH_OBJECT_H_ 2 | #define _UMATH_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/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 | -------------------------------------------------------------------------------- /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/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/core/umath_clr.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | 4 | 5 | if sys.platform == 'cli': 6 | import clr 7 | import math 8 | clr.AddReference("NumpyDotNet") 9 | import NumpyDotNet 10 | NumpyDotNet.umath.__init__() 11 | pi = math.pi 12 | e = math.e 13 | from NumpyDotNet.umath import * 14 | 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /TEST_COMMIT: -------------------------------------------------------------------------------- 1 | oliphant: yes 2 | 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 | ilanschnell: 5 19 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/arraytypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAYTYPES_H_ 2 | #define _NPY_ARRAYTYPES_H_ 3 | 4 | NDARRAY_API extern NpyArray_Descr npy_LONGLONG_Descr; 5 | NDARRAY_API extern NpyArray_Descr npy_LONG_Descr; 6 | NDARRAY_API extern NpyArray_Descr npy_INT_Descr; 7 | 8 | NPY_NO_EXPORT int 9 | set_typeinfo(PyObject *dict); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef _PRIVATE_BUFFER_H_ 2 | #define _PRIVATE_BUFFER_H_ 3 | 4 | 5 | extern NPY_NO_EXPORT PyBufferProcs array_as_buffer; 6 | 7 | 8 | NPY_NO_EXPORT void 9 | _array_dealloc_buffer_info(PyArrayObject *self); 10 | 11 | NPY_NO_EXPORT NpyArray_Descr* 12 | _descriptor_from_pep3118_format(char *s); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libndarray/README.txt: -------------------------------------------------------------------------------- 1 | The ndarray library 2 | =================== 3 | 4 | This directory contains the core ndarray library, 5 | which is written in pure C and is independent of 6 | the Python C-API. 7 | 8 | 9 | Building: 10 | --------- 11 | 12 | On Unix systems, this library follows the configure, 13 | make, make install pattern. 14 | 15 | On Windows, the 'windows' directory s used to build 16 | Python for Win32 and x64 platforms. 17 | -------------------------------------------------------------------------------- /numpy/core/tests/test_methods.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from numpy.testing import * 3 | import numpy as np 4 | 5 | class TestMethods(TestCase): 6 | 7 | def test_itemset( self ): 8 | 9 | # array method itemset is implemented via array_setscalar 10 | 11 | x = np.arange(3) 12 | x.itemset( 1, 99 ) 13 | 14 | assert_array_equal( x, [0, 99, 2] ) 15 | 16 | if __name__ == "__main__": 17 | run_module_suite() 18 | -------------------------------------------------------------------------------- /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/core/tests/test_arrayprint.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import numpy as np 3 | from numpy.testing import * 4 | 5 | class TestArrayRepr(object): 6 | def test_nan_inf(self): 7 | x = np.array([np.nan, np.inf]) 8 | if sys.platform == 'cli': 9 | assert_equal(repr(x), 'array([nan, inf])') 10 | else: 11 | assert_equal(repr(x), 'array([ nan, inf])') 12 | 13 | if __name__ == "__main__": 14 | run_module_suite() 15 | -------------------------------------------------------------------------------- /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/lib/SConscript: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from numscons import GetNumpyEnvironment 4 | 5 | 6 | env = GetNumpyEnvironment(ARGUMENTS) 7 | env.Prepend(CPPPATH=["#$build_prefix/numpy/core/src/private", 8 | os.environ['NDARRAY_INC_DIR']]) 9 | 10 | env.NumpyPythonExtension( 11 | '_compiled_base', 12 | LIBS=['ndarray'], 13 | LIBPATH=[os.environ['NDARRAY_LIB_DIR']], 14 | source = ['src/_compiled_base.c']) 15 | -------------------------------------------------------------------------------- /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/distutils/tests/pyrex_ext/primes.pyx: -------------------------------------------------------------------------------- 1 | # 2 | # Calculate prime numbers 3 | # 4 | 5 | def primes(int kmax): 6 | cdef int n, k, i 7 | cdef int p[1000] 8 | result = [] 9 | if kmax > 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/random/mtrand/generate_mtrand_c.py: -------------------------------------------------------------------------------- 1 | import re 2 | import subprocess 3 | 4 | 5 | def remove_long_path(): 6 | path = 'mtrand.c' 7 | pat = re.compile(r'"[^"]*mtrand\.pyx"') 8 | code = open(path).read() 9 | code = pat.sub(r'"mtrand.pyx"', code) 10 | open(path, 'w').write(code) 11 | 12 | 13 | def main(): 14 | subprocess.check_call(['cython', 'mtrand.pyx']) 15 | remove_long_path() 16 | 17 | 18 | if __name__ == '__main__': 19 | main() 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/SConscript: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | from numscons import GetNumpyEnvironment 5 | 6 | 7 | 8 | env = GetNumpyEnvironment(ARGUMENTS) 9 | env.Prepend(CPPPATH=['numpy', "#$build_prefix/numpy/core/src/private", 10 | os.environ['NDARRAY_INC_DIR']]) 11 | if sys.platform == 'win32': 12 | env.Prepend(LIBPATH=[os.environ['NDARRAY_LIB_DIR']]) 13 | env.Prepend(LIBS=['ndarray']) 14 | env.NumpyPythonExtension('_capi', source = ['_capi.c']) 15 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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(__file__).test 16 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /doc/source/reference/routines.sort.rst: -------------------------------------------------------------------------------- 1 | Sorting and searching 2 | ===================== 3 | 4 | .. currentmodule:: numpy 5 | 6 | Sorting 7 | ------- 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | sort 12 | lexsort 13 | argsort 14 | ndarray.sort 15 | msort 16 | sort_complex 17 | 18 | Searching 19 | --------- 20 | .. autosummary:: 21 | :toctree: generated/ 22 | 23 | argmax 24 | nanargmax 25 | argmin 26 | nanargmin 27 | argwhere 28 | nonzero 29 | flatnonzero 30 | where 31 | searchsorted 32 | extract 33 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /doc/source/_templates/autosummary/class.rst: -------------------------------------------------------------------------------- 1 | {% extends "!autosummary/class.rst" %} 2 | 3 | {% block methods %} 4 | {% if methods %} 5 | .. HACK 6 | .. autosummary:: 7 | :toctree: 8 | {% for item in methods %} 9 | {{ name }}.{{ item }} 10 | {%- endfor %} 11 | {% endif %} 12 | {% endblock %} 13 | 14 | {% block attributes %} 15 | {% if attributes %} 16 | .. HACK 17 | .. autosummary:: 18 | :toctree: 19 | {% for item in attributes %} 20 | {{ name }}.{{ item }} 21 | {%- endfor %} 22 | {% endif %} 23 | {% endblock %} 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/core/include/numpy/_numpyconfig.h.in: -------------------------------------------------------------------------------- 1 | #ifndef _NUMPYCONFIG_H_ 2 | #error this header should not be included directly, always include numpyconfig.h instead 3 | #endif 4 | 5 | @DEFINE_NPY_NO_SIGNAL@ 6 | #define NPY_NO_SMP @NPY_NO_SMP@ 7 | 8 | #define NPY_VISIBILITY_HIDDEN @VISIBILITY_HIDDEN@ 9 | 10 | @DEFINE_NPY_USE_C99_FORMATS@ 11 | 12 | @DEFINE_NPY_HAVE_ENDIAN_H@ 13 | 14 | /* Ugly, but we can't test this in a proper manner without requiring a C++ 15 | * compiler at the configuration stage of numpy ? */ 16 | #ifndef __STDC_FORMAT_MACROS 17 | #define __STDC_FORMAT_MACROS 1 18 | #endif 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libndarray/tools/long_double.c: -------------------------------------------------------------------------------- 1 | /* 2 | "before" is 16 bytes to ensure there's no padding between it and "x". 3 | We're not expecting any "long double" bigger than 16 bytes or with 4 | alignment requirements stricter than 16 bytes. 5 | */ 6 | typedef long double test_type; 7 | 8 | struct { 9 | char before[16]; 10 | test_type x; 11 | char after[8]; 12 | } 13 | 14 | foo = { 15 | { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', 16 | 'a', 'R', '8', 'q', 'y', 'b', '1', 'W' }, 17 | -123456789.0, 18 | { 'z', '7', 'p', 'L', 'C', '3', 'S', 'i' } 19 | }; 20 | -------------------------------------------------------------------------------- /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/core/include/numpy/numpyconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef _NUMPYCONFIG_H_ 2 | #define _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 | #endif 25 | -------------------------------------------------------------------------------- /numpy/distutils/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('distutils',parent_package,top_path) 6 | config.add_subpackage('command') 7 | config.add_subpackage('fcompiler') 8 | config.add_data_dir('tests') 9 | config.add_data_files('site.cfg') 10 | config.add_data_files('mingw/gfortran_vs2003_hack.c') 11 | config.make_config_py() 12 | return config 13 | 14 | if __name__ == '__main__': 15 | from numpy.distutils.core import setup 16 | setup(configuration=configuration) 17 | -------------------------------------------------------------------------------- /numpy/f2py/docs/usersguide/run_main_session.dat: -------------------------------------------------------------------------------- 1 | >>> import f2py2e 2 | >>> r=f2py2e.run_main(['-m','scalar','docs/usersguide/scalar.f']) 3 | Reading fortran codes... 4 | Reading file 'docs/usersguide/scalar.f' 5 | Post-processing... 6 | Block: scalar 7 | Block: FOO 8 | Building modules... 9 | Building module "scalar"... 10 | Wrote C/API module "scalar" to file "./scalarmodule.c" 11 | >>> print r 12 | {'scalar': {'h': ['/home/users/pearu/src_cvs/f2py2e/src/fortranobject.h'], 13 | 'csrc': ['./scalarmodule.c', 14 | '/home/users/pearu/src_cvs/f2py2e/src/fortranobject.c']}} 15 | -------------------------------------------------------------------------------- /numpy/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/core/src/multiarray/ucsnarrow.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_UCSNARROW_H_ 2 | #define _NPY_UCSNARROW_H_ 3 | 4 | #ifdef Py_UNICODE_WIDE 5 | #error this should not be included if Py_UNICODE_WIDE is defined 6 | int int int; 7 | #endif 8 | 9 | #include 10 | 11 | NPY_NO_EXPORT int 12 | PyUCS2Buffer_FromUCS4(Py_UNICODE *ucs2, PyArray_UCS4 *ucs4, int ucs4length); 13 | 14 | NPY_NO_EXPORT int 15 | PyUCS2Buffer_AsUCS4(Py_UNICODE *ucs2, PyArray_UCS4 *ucs4, int ucs2len, int ucs4len); 16 | 17 | NPY_NO_EXPORT PyObject * 18 | MyPyUnicode_New(int length); 19 | 20 | NPY_NO_EXPORT int 21 | MyPyUnicode_Resize(PyUnicodeObject *uni, int length); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/usertypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_PRIVATE_USERTYPES_H_ 2 | #define _NPY_PRIVATE_USERTYPES_H_ 3 | 4 | NPY_NO_EXPORT void 5 | PyArray_InitArrFuncs(PyArray_ArrFuncs *f); 6 | 7 | NPY_NO_EXPORT int 8 | PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, 9 | NPY_SCALARKIND scalar); 10 | 11 | NPY_NO_EXPORT int 12 | PyArray_RegisterDataType(PyArray_Descr *descr); 13 | 14 | NPY_NO_EXPORT int 15 | PyArray_RegisterCastFunc(PyArray_Descr *descr, int totype, 16 | PyArray_VectorUnaryFunc *castfunc); 17 | 18 | NPY_NO_EXPORT int 19 | PyArray_TypeNumFromTypeObj(PyTypeObject* typeobj); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /numpy/numarray/setup.py: -------------------------------------------------------------------------------- 1 | from os.path import join 2 | 3 | from numpy.distutils.system_info import get_info 4 | 5 | 6 | def configuration(parent_package='',top_path=None): 7 | from numpy.distutils.misc_util import Configuration 8 | config = Configuration('numarray', parent_package,top_path) 9 | 10 | config.add_data_files('include/numpy/*') 11 | 12 | config.add_extension('_capi', 13 | sources=['_capi.c'], 14 | **get_info('ndarray')) 15 | 16 | return config 17 | 18 | 19 | if __name__ == '__main__': 20 | from numpy.distutils.core import setup 21 | setup(configuration=configuration) 22 | -------------------------------------------------------------------------------- /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/fft/setup.py: -------------------------------------------------------------------------------- 1 | from numpy.distutils.system_info import get_info 2 | 3 | 4 | def configuration(parent_package='',top_path=None): 5 | from numpy.distutils.misc_util import Configuration 6 | config = Configuration('fft',parent_package,top_path) 7 | 8 | config.add_data_dir('tests') 9 | 10 | # Configure fftpack_lite 11 | config.add_extension('fftpack_lite', 12 | sources=['fftpack_litemodule.c', 'fftpack.c'], 13 | **get_info('ndarray')) 14 | 15 | return config 16 | 17 | 18 | if __name__ == '__main__': 19 | from numpy.distutils.core import setup 20 | setup(configuration=configuration) 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | NPY_NO_EXPORT void * 20 | NpyInterface_Incref(void *obj, void **); 21 | 22 | NPY_NO_EXPORT void 23 | NpyInterface_Decref(void *obj, void **); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /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='>> 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/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/core/include/numpy/arrayobject.h: -------------------------------------------------------------------------------- 1 | #ifndef _ARRAYOBJECT_H_ 2 | #define _ARRAYOBJECT_H_ 3 | 4 | /* This expects the following variables to be defined (besides 5 | the usual ones from pyconfig.h 6 | 7 | NPY_SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no 8 | long double is present on platform. 9 | CHAR_BIT -- number of bits in a char (usually 8) 10 | (should be in limits.h) 11 | */ 12 | 13 | #include "ndarraytypes.h" 14 | #include "ndarrayobject.h" 15 | #ifdef NPY_NO_PREFIX 16 | #include "noprefix.h" 17 | #endif 18 | 19 | #include "numpy/interrupt.h" 20 | 21 | #endif /* _ARRAYOBJECT_H_ */ 22 | -------------------------------------------------------------------------------- /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/numarray/__init__.py: -------------------------------------------------------------------------------- 1 | from util import * 2 | from numerictypes import * 3 | from functions import * 4 | from ufuncs import * 5 | from compat import * 6 | from session import * 7 | 8 | import util 9 | import numerictypes 10 | import functions 11 | import ufuncs 12 | import compat 13 | import session 14 | 15 | __all__ = ['session', 'numerictypes'] 16 | __all__ += util.__all__ 17 | __all__ += numerictypes.__all__ 18 | __all__ += functions.__all__ 19 | __all__ += ufuncs.__all__ 20 | __all__ += compat.__all__ 21 | __all__ += session.__all__ 22 | 23 | del util 24 | del functions 25 | del ufuncs 26 | del compat 27 | 28 | from numpy.testing import Tester 29 | test = Tester(__file__).test 30 | bench = Tester(__file__).bench 31 | -------------------------------------------------------------------------------- /doc/source/reference/routines.poly.rst: -------------------------------------------------------------------------------- 1 | Polynomials 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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/lib/setup.py: -------------------------------------------------------------------------------- 1 | from os.path import join 2 | 3 | from numpy.distutils.system_info import get_info 4 | 5 | 6 | def configuration(parent_package='',top_path=None): 7 | from numpy.distutils.misc_util import Configuration 8 | 9 | config = Configuration('lib', parent_package, top_path) 10 | 11 | config.add_include_dirs(join('..','core','include')) 12 | 13 | config.add_extension('_compiled_base', 14 | sources=[join('src', '_compiled_base.c')], 15 | **get_info('ndarray')) 16 | 17 | config.add_data_dir('benchmarks') 18 | config.add_data_dir('tests') 19 | 20 | return config 21 | 22 | if __name__=='__main__': 23 | from numpy.distutils.core import setup 24 | setup(configuration=configuration) 25 | -------------------------------------------------------------------------------- /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/core/src/private/numpy_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _NUMPY_CONFIG_H_ 2 | #define _NUMPY_CONFIG_H_ 3 | 4 | #include "config.h" 5 | 6 | /* Disable broken Sun Workshop Pro math functions */ 7 | #ifdef __SUNPRO_C 8 | #undef HAVE_ATAN2 9 | #endif 10 | 11 | /* 12 | * On Mac OS X, because there is only one configuration stage for all the archs 13 | * in universal builds, any macro which depends on the arch needs to be 14 | * harcoded 15 | */ 16 | #ifdef __APPLE__ 17 | #undef SIZEOF_LONG 18 | #undef SIZEOF_PY_INTPTR_T 19 | 20 | #ifdef __LP64__ 21 | #define SIZEOF_LONG 8 22 | #define SIZEOF_PY_INTPTR_T 8 23 | #else 24 | #define SIZEOF_LONG 4 25 | #define SIZEOF_PY_INTPTR_T 4 26 | #endif 27 | #endif 28 | 29 | #endif /* _NUMPY_CONFIG_H_ */ 30 | -------------------------------------------------------------------------------- /numpy/linalg/SConscript: -------------------------------------------------------------------------------- 1 | import os 2 | from numscons import GetNumpyEnvironment, scons_get_mathlib 3 | from numscons import CheckF77LAPACK 4 | from numscons import write_info 5 | 6 | env = GetNumpyEnvironment(ARGUMENTS) 7 | env.Prepend(CPPPATH=[os.environ['NDARRAY_INC_DIR']]) 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 | -------------------------------------------------------------------------------- /doc/source/reference/routines.statistics.rst: -------------------------------------------------------------------------------- 1 | Statistics 2 | ========== 3 | 4 | .. currentmodule:: numpy 5 | 6 | 7 | Extremal values 8 | --------------- 9 | 10 | .. autosummary:: 11 | :toctree: generated/ 12 | 13 | amin 14 | amax 15 | nanmax 16 | nanmin 17 | ptp 18 | 19 | Averages and variances 20 | ---------------------- 21 | 22 | .. autosummary:: 23 | :toctree: generated/ 24 | 25 | average 26 | mean 27 | median 28 | std 29 | var 30 | 31 | Correlating 32 | ----------- 33 | 34 | .. autosummary:: 35 | :toctree: generated/ 36 | 37 | corrcoef 38 | correlate 39 | cov 40 | 41 | Histograms 42 | ---------- 43 | 44 | .. autosummary:: 45 | :toctree: generated/ 46 | 47 | histogram 48 | histogram2d 49 | histogramdd 50 | bincount 51 | digitize 52 | -------------------------------------------------------------------------------- /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 PyArray_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/dev/gitwash/dot2_dot3.rst: -------------------------------------------------------------------------------- 1 | .. _dot2-dot3: 2 | 3 | ======================================== 4 | Two and three dots in difference specs 5 | ======================================== 6 | 7 | Thanks to Yarik Halchenko for this explanation. 8 | 9 | Imagine a series of commits A, B, C, D... Imagine that there are two 10 | branches, *topic* and *master*. You branched *topic* off *master* when 11 | *master* was at commit 'E'. The graph of the commits looks like this:: 12 | 13 | 14 | A---B---C topic 15 | / 16 | D---E---F---G master 17 | 18 | Then:: 19 | 20 | git diff master..topic 21 | 22 | will output the difference from G to C (i.e. with effects of F and G), 23 | while:: 24 | 25 | git diff master...topic 26 | 27 | would output just differences in the topic branch (i.e. only A, B, and 28 | C). 29 | -------------------------------------------------------------------------------- /numpy/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 | -------------------------------------------------------------------------------- /numpy/fft/fftpack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of tela the Tensor Language. 3 | * Copyright (c) 1994-1995 Pekka Janhunen 4 | */ 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define FFTPACK_DOUBLE_PRECISION 11 | 12 | #ifdef FFTPACK_DOUBLE_PRECISION 13 | #define Treal double 14 | #else 15 | #define Treal float 16 | #endif 17 | 18 | #ifdef __cplusplus 19 | #define GLOBALFUNC(x) ::x 20 | #else 21 | #define GLOBALFUNC(x) x 22 | #endif 23 | 24 | extern void cfftf(int N, Treal data[], const Treal wrk[]); 25 | extern void cfftb(int N, Treal data[], const Treal wrk[]); 26 | extern void cffti(int N, Treal wrk[]); 27 | 28 | extern void rfftf(int N, Treal data[], const Treal wrk[]); 29 | extern void rfftb(int N, Treal data[], const Treal wrk[]); 30 | extern void rffti(int N, Treal wrk[]); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/convert_datatype.h: -------------------------------------------------------------------------------- 1 | #ifndef _NUMPY_CONVERT_DATATYPE_H_ 2 | #define _NUMPY_CONVERT_DATATYPE_H_ 3 | 4 | NPY_NO_EXPORT PyObject * 5 | PyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran); 6 | 7 | NPY_NO_EXPORT int 8 | PyArray_CastTo(PyArrayObject *out, PyArrayObject *mp); 9 | 10 | NPY_NO_EXPORT PyArray_VectorUnaryFunc * 11 | PyArray_GetCastFunc(PyArray_Descr *descr, int type_num); 12 | 13 | NPY_NO_EXPORT int 14 | PyArray_CanCastSafely(int fromtype, int totype); 15 | 16 | NPY_NO_EXPORT Bool 17 | PyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to); 18 | 19 | NPY_NO_EXPORT int 20 | PyArray_ObjectType(PyObject *op, int minimum_type); 21 | 22 | NPY_NO_EXPORT PyArrayObject ** 23 | PyArray_ConvertToCommonType(PyObject *op, int *retn); 24 | 25 | NPY_NO_EXPORT int 26 | PyArray_ValidType(int type); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/descriptor.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAYDESCR_H_ 2 | #define _NPY_ARRAYDESCR_H_ 3 | 4 | #include "npy_dict.h" 5 | #include "npy_api.h" 6 | 7 | 8 | NPY_NO_EXPORT PyObject *npy_arraydescr_protocol_typestr_get(NpyArray_Descr *); 9 | NPY_NO_EXPORT PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *); 10 | NPY_NO_EXPORT PyObject *npy_arraydescr_protocol_descr_get(NpyArray_Descr *self); 11 | NPY_NO_EXPORT PyObject *arraydescr_protocol_descr_get(PyArray_Descr *self); 12 | 13 | NPY_NO_EXPORT PyObject * 14 | array_set_typeDict(PyObject *NPY_UNUSED(ignored), PyObject *args); 15 | 16 | NPY_NO_EXPORT PyArray_Descr * 17 | _arraydescr_fromobj(PyObject *obj); 18 | 19 | NPY_NO_EXPORT char ** 20 | arraydescr_seq_to_nameslist(PyObject *seq); 21 | 22 | NPY_NO_EXPORT NpyDict * 23 | arraydescr_fields_from_pydict(PyObject *dict); 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /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/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _NUMPY_PRIVATE_COMMON_H_ 2 | #define _NUMPY_PRIVATE_COMMON_H_ 3 | 4 | #include 5 | 6 | #define error_converting(x) (((x) == -1) && PyErr_Occurred()) 7 | 8 | 9 | NPY_NO_EXPORT NpyArray_Descr * 10 | _array_find_type(PyObject *op, NpyArray_Descr *minitype, int max); 11 | 12 | NPY_NO_EXPORT NpyArray_Descr * 13 | _array_find_python_scalar_type(PyObject *op); 14 | 15 | NPY_NO_EXPORT NpyArray_Descr * 16 | _array_typedescr_fromstr(char *str); 17 | 18 | NPY_NO_EXPORT char * 19 | index2ptr(PyArrayObject *mp, intp i); 20 | 21 | NPY_NO_EXPORT int 22 | _zerofill(PyArrayObject *ret); 23 | 24 | NPY_NO_EXPORT int 25 | _IsAligned(PyArrayObject *ap); 26 | 27 | NPY_NO_EXPORT npy_bool 28 | _IsWriteable(PyArrayObject *ap); 29 | 30 | #ifndef Py_UNICODE_WIDE 31 | #include "ucsnarrow.h" 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /libndarray/windows/build.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import shutil 4 | from glob import glob 5 | from os.path import expanduser, join 6 | 7 | 8 | sys.path.insert(0, r'..\tools') 9 | 10 | from conv_template import process_file 11 | from mk_config import check_long_double_repr 12 | 13 | src_dir = r'..\src' 14 | 15 | 16 | def write_config(): 17 | os.system(r"cl ..\\tools\\long_double.c") 18 | data = open('npy_config.h').read() 19 | data += ''' 20 | /* long double representation */ 21 | #define NPY_LDOUBLE_%s 1 22 | ''' % check_long_double_repr('long_double.obj') 23 | fo = open(join(src_dir, 'npy_config.h'), 'w') 24 | fo.write(data) 25 | fo.close() 26 | 27 | 28 | 29 | def main(): 30 | write_config() 31 | os.system("msbuild.exe /v:diag msvc2008.vcxproj") 32 | # shutil.copy(r'Release\ndarray.dll', sys.prefix) 33 | 34 | 35 | if __name__ == '__main__': 36 | main() 37 | -------------------------------------------------------------------------------- /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_scalartypes.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from numpy.testing import * 3 | import numpy as np 4 | 5 | class TestIndex(TestCase): 6 | 7 | def test_index( self ): 8 | a = np.arange(5) 9 | 10 | itypes = [ np.byte, np.ubyte, 11 | np.short, np.ushort, 12 | np.int32, np.uint32, 13 | np.int, np.uint, 14 | # np.long, np.ulong, ??? no "ulong" in numpy? 15 | np.longlong, np.ulonglong ] 16 | 17 | for k,t in enumerate( itypes ): 18 | x = t( 1 ) 19 | y = t( 2 ) 20 | assert_equal( a[x:y], [1] ) 21 | 22 | def test_index_bool( self ): 23 | a = np.arange(5) 24 | 25 | x = np.bool_(False) 26 | y = np.bool_(True) 27 | 28 | z = a[x:y] 29 | 30 | assert_equal( z, [0] ) 31 | 32 | if __name__ == "__main__": 33 | run_module_suite() 34 | -------------------------------------------------------------------------------- /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 | common_type 13 | obj2sctype 14 | 15 | Creating data types 16 | ------------------- 17 | 18 | .. autosummary:: 19 | :toctree: generated/ 20 | 21 | 22 | dtype 23 | format_parser 24 | 25 | Data type information 26 | --------------------- 27 | .. autosummary:: 28 | :toctree: generated/ 29 | 30 | finfo 31 | iinfo 32 | MachAr 33 | 34 | Data type testing 35 | ----------------- 36 | .. autosummary:: 37 | :toctree: generated/ 38 | 39 | issctype 40 | issubdtype 41 | issubsctype 42 | issubclass_ 43 | find_common_type 44 | 45 | Miscellaneous 46 | ------------- 47 | .. autosummary:: 48 | :toctree: generated/ 49 | 50 | typename 51 | sctype2char 52 | mintypecode 53 | -------------------------------------------------------------------------------- /numpy/core/src/multiarray/scalartypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_SCALARTYPES_H_ 2 | #define _NPY_SCALARTYPES_H_ 3 | 4 | #include 5 | 6 | NPY_NO_EXPORT void 7 | initialize_numeric_types(void); 8 | 9 | NPY_NO_EXPORT void 10 | format_longdouble(char *buf, size_t buflen, longdouble val, unsigned int prec); 11 | 12 | #if PY_VERSION_HEX >= 0x03000000 13 | NPY_NO_EXPORT void 14 | gentype_struct_free(PyObject *ptr); 15 | #else 16 | NPY_NO_EXPORT void 17 | gentype_struct_free(void *ptr, void *arg); 18 | #endif 19 | 20 | NPY_NO_EXPORT int 21 | _typenum_fromtypeobj(PyObject *type, int user); 22 | 23 | NPY_NO_EXPORT void * 24 | scalar_value(PyObject *scalar, NpyArray_Descr *descr); 25 | 26 | NPY_NO_EXPORT int 27 | NpyInterface_DescrNewFromType(int type, NpyArray_Descr *descr, void **interfaceRet); 28 | 29 | NPY_NO_EXPORT int 30 | NpyInterface_DescrNewFromWrapper(void *baseTmp, NpyArray_Descr *descr, void **interfaceRet); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/core/tests/test_iterators.py: -------------------------------------------------------------------------------- 1 | 2 | import numpy as np 3 | from numpy.testing import * 4 | 5 | 6 | class TestBroadcast(TestCase): 7 | """ Tests np.broadcast. """ 8 | 9 | def _broadcast_add(self, args, dtype): 10 | """ Uses a multiter to do the equiv of a ufunc add. """ 11 | b = np.broadcast(*args) 12 | result = np.empty(b.size, dtype=dtype) 13 | flat_arrays = [ a.ravel() for a in args ] 14 | for i, index in enumerate(b): 15 | val = 0 16 | for j, array in zip(index, flat_arrays): 17 | val += array[j] 18 | result[i] = val 19 | 20 | return result.reshape(b.shape) 21 | 22 | def test_broadcast_add(self): 23 | a = np.arange(10) 24 | b = np.arange(100).reshape(10,10) 25 | 26 | assert_array_equal(a+b, self._broadcast_add((a,b), a.dtype)) 27 | 28 | 29 | if __name__ == "__main__": 30 | run_module_suite() 31 | 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libndarray/windows/msvc2010.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ndarray", "msvc2008.vcxproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2756CDEA26}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Release|Win32 = Release|Win32 9 | Release|x64 = Release|x64 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {CF7AC3D1-E2DF-41D2-BEA6-1E2756CDEA26}.Release|Win32.ActiveCfg = Release|Win32 13 | {CF7AC3D1-E2DF-41D2-BEA6-1E2756CDEA26}.Release|Win32.Build.0 = Release|Win32 14 | {CF7AC3D1-E2DF-41D2-BEA6-1E2756CDEA26}.Release|x64.ActiveCfg = Release|x64 15 | {CF7AC3D1-E2DF-41D2-BEA6-1E2756CDEA26}.Release|x64.Build.0 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/NumpyDotNet/UMathModule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Runtime.InteropServices; 6 | using IronPython.Runtime; 7 | using IronPython.Modules; 8 | using Microsoft.Scripting; 9 | using NumpyDotNet; 10 | 11 | 12 | 13 | namespace NumpyDotNet 14 | { 15 | /// 16 | /// Provides access to the core for ufunc and numeric functions. 17 | /// 18 | internal static class UMathModule 19 | { 20 | 21 | 22 | // 23 | // Core-provided loops. 24 | // 25 | [DllImport("ndarray", CallingConvention = CallingConvention.Cdecl, 26 | EntryPoint = "npy_BYTE_add")] 27 | internal static extern void npy_BYTE_add(IntPtr array, IntPtr newDescr); 28 | 29 | static UMathModule() { 30 | IntPtr x = Marshal.GetFunctionPointerForDelegate(npy_BYTE_add); 31 | npy_BYTE_add(x, IntPtr.Zero); 32 | } 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /doc/source/dev/gitwash/following_latest.rst: -------------------------------------------------------------------------------- 1 | .. _following-latest: 2 | 3 | ============================= 4 | Following the latest source 5 | ============================= 6 | 7 | These are the instructions if you just want to follow the latest 8 | *NumPy* source, but you don't need to do any development for now. 9 | 10 | The steps are: 11 | 12 | * :ref:`install-git` 13 | * get local copy of the git repository from github_ 14 | * update local copy from time to time 15 | 16 | Get the local copy of the code 17 | ============================== 18 | 19 | From the command line:: 20 | 21 | git clone git://github.com/numpy/numpy.git 22 | 23 | You now have a copy of the code tree in the new ``numpy`` directory. 24 | 25 | Updating the code 26 | ================= 27 | 28 | From time to time you may want to pull down the latest code. Do this with:: 29 | 30 | cd numpy 31 | git fetch 32 | git merge --ff-only 33 | 34 | The tree in ``numpy`` will now have the latest changes from the initial 35 | repository. 36 | 37 | .. include:: git_links.inc 38 | -------------------------------------------------------------------------------- /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/core/tests/test_blasdot.py: -------------------------------------------------------------------------------- 1 | from numpy.core import zeros, float64 2 | from numpy.testing import dec, TestCase, assert_almost_equal, assert_ 3 | from numpy.core.multiarray import inner as inner_ 4 | 5 | DECPREC = 14 6 | 7 | class TestInner(TestCase): 8 | def test_vecself(self): 9 | """Ticket 844.""" 10 | # Inner product of a vector with itself segfaults or give meaningless 11 | # result 12 | a = zeros(shape = (1, 80), dtype = float64) 13 | p = inner_(a, a) 14 | assert_almost_equal(p, 0, decimal = DECPREC) 15 | 16 | try: 17 | import numpy.core._dotblas as _dotblas 18 | except ImportError: 19 | _dotblas = None 20 | 21 | @dec.skipif(_dotblas is None, "Numpy is not compiled with _dotblas") 22 | def test_blasdot_used(): 23 | from numpy.core import dot, vdot, inner, alterdot, restoredot 24 | assert_(dot is _dotblas.dot) 25 | assert_(vdot is _dotblas.vdot) 26 | assert_(inner is _dotblas.inner) 27 | assert_(alterdot is _dotblas.alterdot) 28 | assert_(restoredot is _dotblas.restoredot) 29 | -------------------------------------------------------------------------------- /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(__file__).test 45 | bench = Tester(__file__).bench 46 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/polynomial/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | A sub-package for efficiently dealing with polynomials. 3 | 4 | Within the documentation for this sub-package, a "finite power series," 5 | i.e., a polynomial (also referred to simply as a "series") is represented 6 | by a 1-D numpy array of the polynomial's coefficients, ordered from lowest 7 | order term to highest. For example, array([1,2,3]) represents 8 | ``P_0 + 2*P_1 + 3*P_2``, where P_n is the n-th order basis polynomial 9 | applicable to the specific module in question, e.g., `polynomial` (which 10 | "wraps" the "standard" basis) or `chebyshev`. For optimal performance, 11 | all operations on polynomials, including evaluation at an argument, are 12 | implemented as operations on the coefficients. Additional (module-specific) 13 | information can be found in the docstring for the module of interest. 14 | 15 | """ 16 | from polynomial import * 17 | from chebyshev import * 18 | from legendre import * 19 | from polyutils import * 20 | 21 | from numpy.testing import Tester 22 | test = Tester(__file__).test 23 | bench = Tester(__file__).bench 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | When installing a new version of numpy for the first time or before upgrading 20 | to a newer version, it is recommended to turn on deprecation warnings when 21 | running the tests: 22 | 23 | python -Wd -c 'import numpy; numpy.test()' 24 | 25 | The most current development version is always available from our 26 | git repository: 27 | 28 | http://github.com/numpy/numpy 29 | 30 | 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/lib/__init__.py: -------------------------------------------------------------------------------- 1 | from info import __doc__ 2 | from numpy.version import version as __version__ 3 | 4 | from type_check import * 5 | from index_tricks import * 6 | from function_base import * 7 | from shape_base import * 8 | from stride_tricks import * 9 | from twodim_base import * 10 | from ufunclike import * 11 | 12 | import scimath as emath 13 | from polynomial import * 14 | #import convertcode 15 | from utils import * 16 | from arraysetops import * 17 | from npyio import * 18 | from financial import * 19 | import math 20 | from arrayterator import * 21 | 22 | __all__ = ['emath','math'] 23 | __all__ += type_check.__all__ 24 | __all__ += index_tricks.__all__ 25 | __all__ += function_base.__all__ 26 | __all__ += shape_base.__all__ 27 | __all__ += stride_tricks.__all__ 28 | __all__ += twodim_base.__all__ 29 | __all__ += ufunclike.__all__ 30 | __all__ += polynomial.__all__ 31 | __all__ += utils.__all__ 32 | __all__ += arraysetops.__all__ 33 | __all__ += npyio.__all__ 34 | __all__ += financial.__all__ 35 | 36 | from numpy.testing import Tester 37 | test = Tester(__file__).test 38 | bench = Tester(__file__).bench 39 | -------------------------------------------------------------------------------- /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/sphinxext/setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | import setuptools 3 | import sys, os 4 | 5 | version = "0.4" 6 | 7 | setup( 8 | name="numpydoc", 9 | packages=["numpydoc"], 10 | package_dir={"numpydoc": ""}, 11 | version=version, 12 | description="Sphinx extension to support docstrings in Numpy format", 13 | # classifiers from http://pypi.python.org/pypi?%3Aaction=list_classifiers 14 | classifiers=["Development Status :: 3 - Alpha", 15 | "Environment :: Plugins", 16 | "License :: OSI Approved :: BSD License", 17 | "Topic :: Documentation"], 18 | keywords="sphinx numpy", 19 | author="Pauli Virtanen and others", 20 | author_email="pav@iki.fi", 21 | url="http://github.com/numpy/numpy/tree/master/doc/sphinxext", 22 | license="BSD", 23 | zip_safe=False, 24 | install_requires=["Sphinx >= 1.0.1"], 25 | package_data={'numpydoc': 'tests', '': ''}, 26 | entry_points={ 27 | "console_scripts": [ 28 | "autosummary_generate = numpydoc.autosummary_generate:main", 29 | ], 30 | }, 31 | ) 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /numpy/distutils/intelccompiler.py: -------------------------------------------------------------------------------- 1 | 2 | from distutils.unixccompiler import UnixCCompiler 3 | from numpy.distutils.exec_command import find_executable 4 | 5 | class IntelCCompiler(UnixCCompiler): 6 | 7 | """ A modified Intel compiler compatible with an gcc built Python. 8 | """ 9 | 10 | compiler_type = 'intel' 11 | cc_exe = 'icc' 12 | 13 | def __init__ (self, verbose=0, dry_run=0, force=0): 14 | UnixCCompiler.__init__ (self, verbose,dry_run, force) 15 | compiler = self.cc_exe 16 | self.set_executables(compiler=compiler, 17 | compiler_so=compiler, 18 | compiler_cxx=compiler, 19 | linker_exe=compiler, 20 | linker_so=compiler + ' -shared') 21 | 22 | class IntelItaniumCCompiler(IntelCCompiler): 23 | compiler_type = 'intele' 24 | 25 | # On Itanium, the Intel Compiler used to be called ecc, let's search for 26 | # it (now it's also icc, so ecc is last in the search). 27 | for cc_exe in map(find_executable,['icc','ecc']): 28 | if cc_exe: 29 | break 30 | -------------------------------------------------------------------------------- /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/src/multiarray/number.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAY_NUMBER_H_ 2 | #define _NPY_ARRAY_NUMBER_H_ 3 | 4 | #include 5 | #include "numpy/ufuncobject.h" 6 | 7 | 8 | extern NPY_NO_EXPORT PyNumberMethods array_as_number; 9 | 10 | 11 | NPY_NO_EXPORT PyObject * 12 | array_int(PyArrayObject *v); 13 | 14 | NPY_NO_EXPORT PyObject * 15 | PyArray_GetNumericOp(enum NpyArray_Ops op); 16 | 17 | NPY_NO_EXPORT int 18 | PyArray_SetNumericOps(PyObject *dict); 19 | 20 | NPY_NO_EXPORT PyObject * 21 | PyArray_GetNumericOps(void); 22 | 23 | NPY_NO_EXPORT PyObject * 24 | PyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op); 25 | 26 | NPY_NO_EXPORT PyObject * 27 | PyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op); 28 | 29 | NPY_NO_EXPORT PyObject * 30 | PyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis, 31 | int rtype, PyArrayObject *out); 32 | 33 | NPY_NO_EXPORT PyObject * 34 | PyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis, 35 | int rtype, PyArrayObject *out); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /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/core/src/multiarray/iterators.h: -------------------------------------------------------------------------------- 1 | #ifndef _NPY_ARRAYITERATORS_H_ 2 | #define _NPY_ARRAYITERATORS_H_ 3 | 4 | NPY_NO_EXPORT intp 5 | parse_subindex(PyObject *op, intp *step_size, intp *n_steps, intp max); 6 | 7 | NPY_NO_EXPORT PyObject 8 | *iter_subscript(PyArrayIterObject *, PyObject *); 9 | 10 | NPY_NO_EXPORT PyObject* 11 | npy_iter_subscript(NpyArrayIterObject* self, PyObject* ind); 12 | 13 | NPY_NO_EXPORT int 14 | iter_ass_subscript(PyArrayIterObject *, PyObject *, PyObject *); 15 | 16 | NPY_NO_EXPORT int 17 | npy_iter_ass_subscript(NpyArrayIterObject* self, PyObject* ind, PyObject* val); 18 | 19 | NPY_NO_EXPORT int 20 | slice_GetIndices(PySliceObject *r, intp length, 21 | intp *start, intp *stop, intp *step, 22 | intp *slicelength); 23 | 24 | NPY_NO_EXPORT int 25 | NpyInterface_IterNewWrapper(NpyArrayIterObject *iter, void **interfaceRet); 26 | 27 | NPY_NO_EXPORT int 28 | NpyInterface_MultiIterNewWrapper(NpyArrayMultiIterObject *iter, void **interfaceRet); 29 | 30 | NPY_NO_EXPORT int 31 | NpyInterface_NeighborhoodIterNewWrapper(NpyArrayNeighborhoodIterObject *iter, void **interfaceRet); 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /doc/source/reference/routines.indexing.rst: -------------------------------------------------------------------------------- 1 | .. _routines.indexing: 2 | 3 | Indexing routines 4 | ================= 5 | 6 | .. seealso:: :ref:`Indexing ` 7 | 8 | .. currentmodule:: numpy 9 | 10 | Generating index arrays 11 | ----------------------- 12 | .. autosummary:: 13 | :toctree: generated/ 14 | 15 | c_ 16 | r_ 17 | s_ 18 | nonzero 19 | where 20 | indices 21 | ix_ 22 | ogrid 23 | unravel_index 24 | diag_indices 25 | diag_indices_from 26 | mask_indices 27 | tril_indices 28 | tril_indices_from 29 | triu_indices 30 | triu_indices_from 31 | 32 | Indexing-like operations 33 | ------------------------ 34 | .. autosummary:: 35 | :toctree: generated/ 36 | 37 | take 38 | choose 39 | compress 40 | diag 41 | diagonal 42 | select 43 | 44 | Inserting data into arrays 45 | -------------------------- 46 | .. autosummary:: 47 | :toctree: generated/ 48 | 49 | place 50 | put 51 | putmask 52 | fill_diagonal 53 | 54 | Iterating over arrays 55 | --------------------- 56 | .. autosummary:: 57 | :toctree: generated/ 58 | 59 | ndenumerate 60 | ndindex 61 | flatiter 62 | -------------------------------------------------------------------------------- /numpy/core/tests/test_function_base.py: -------------------------------------------------------------------------------- 1 | 2 | from numpy.testing import * 3 | from numpy import logspace, linspace 4 | 5 | class TestLogspace(TestCase): 6 | def test_basic(self): 7 | y = logspace(0,6) 8 | assert(len(y)==50) 9 | y = logspace(0,6,num=100) 10 | assert(y[-1] == 10**6) 11 | y = logspace(0,6,endpoint=0) 12 | assert(y[-1] < 10**6) 13 | y = logspace(0,6,num=7) 14 | assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6]) 15 | 16 | class TestLinspace(TestCase): 17 | def test_basic(self): 18 | y = linspace(0,10) 19 | assert(len(y)==50) 20 | y = linspace(2,10,num=100) 21 | assert(y[-1] == 10) 22 | y = linspace(2,10,endpoint=0) 23 | assert(y[-1] < 10) 24 | 25 | def test_corner(self): 26 | y = list(linspace(0,1,1)) 27 | assert y == [0.0], y 28 | y = list(linspace(0,1,2.5)) 29 | assert y == [0.0, 1.0] 30 | 31 | def test_type(self): 32 | t1 = linspace(0,1,0).dtype 33 | t2 = linspace(0,1,1).dtype 34 | t3 = linspace(0,1,2).dtype 35 | assert_equal(t1, t2) 36 | assert_equal(t2, t3) 37 | 38 | --------------------------------------------------------------------------------