summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2008-08-05 09:20:07 +0000
committerStefan van der Walt <stefan@sun.ac.za>2008-08-05 09:20:07 +0000
commit6647bf7eaeb915e2d09db8b5c7584ee286962d3b (patch)
tree803c7d548fb8dc8f571aad76c6473f20ba71c01d
parentf8f44a0595da3ae8be9458ead1366bcc72cd3390 (diff)
downloadpython-numpy-6647bf7eaeb915e2d09db8b5c7584ee286962d3b.tar.gz
python-numpy-6647bf7eaeb915e2d09db8b5c7584ee286962d3b.tar.bz2
python-numpy-6647bf7eaeb915e2d09db8b5c7584ee286962d3b.zip
Merge from documentation editor.
-rw-r--r--numpy/__init__.py57
-rw-r--r--numpy/add_newdocs.py2515
-rw-r--r--numpy/core/arrayprint.py164
-rw-r--r--numpy/core/code_generators/docstrings.py1944
-rw-r--r--numpy/core/defmatrix.py131
-rw-r--r--numpy/core/fromnumeric.py1381
-rw-r--r--numpy/core/memmap.py133
-rw-r--r--numpy/core/numeric.py1093
-rw-r--r--numpy/core/records.py140
-rw-r--r--numpy/ctypeslib.py100
-rw-r--r--numpy/doc/reference/basics.py132
-rw-r--r--numpy/doc/reference/broadcasting.py171
-rw-r--r--numpy/doc/reference/creation.py127
-rw-r--r--numpy/doc/reference/glossary.py362
-rw-r--r--numpy/doc/reference/indexing.py379
-rw-r--r--numpy/doc/reference/internals.py157
-rw-r--r--numpy/doc/reference/structured_arrays.py175
-rw-r--r--numpy/doc/reference/ufuncs.py130
-rw-r--r--numpy/doc/reference/zen.py9
-rw-r--r--numpy/dual.py12
-rw-r--r--numpy/fft/__init__.py34
-rw-r--r--numpy/fft/fftpack.py335
-rw-r--r--numpy/lib/_datasource.py5
-rw-r--r--numpy/lib/arraysetops.py115
-rw-r--r--numpy/lib/financial.py189
-rw-r--r--numpy/lib/format.py103
-rw-r--r--numpy/lib/function_base.py1679
-rw-r--r--numpy/lib/getlimits.py92
-rw-r--r--numpy/lib/index_tricks.py53
-rw-r--r--numpy/lib/io.py225
-rw-r--r--numpy/lib/machar.py82
-rw-r--r--numpy/lib/polynomial.py540
-rw-r--r--numpy/lib/shape_base.py1000
-rw-r--r--numpy/lib/stride_tricks.py6
-rw-r--r--numpy/lib/twodim_base.py447
-rw-r--r--numpy/lib/type_check.py160
-rw-r--r--numpy/lib/ufunclike.py77
-rw-r--r--numpy/lib/utils.py128
-rw-r--r--numpy/linalg/__init__.py43
-rw-r--r--numpy/linalg/linalg.py424
-rw-r--r--numpy/ma/__init__.py40
-rw-r--r--numpy/ma/extras.py113
-rw-r--r--numpy/random/__init__.py84
-rw-r--r--numpy/random/mtrand/mtrand.c6193
-rw-r--r--numpy/random/mtrand/mtrand.pyx1355
-rw-r--r--numpy/testing/utils.py36
46 files changed, 16388 insertions, 6482 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py
index eac45af4a..6c9493fc0 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -7,7 +7,34 @@ Provides
2. Fast mathematical operations over arrays
3. Linear Algebra, Fourier Transforms, Random Number Generation
-Documentation is available in the docstrings and at http://www.scipy.org
+How to use the documentation
+----------------------------
+Documentation is available in two forms: docstrings provided
+with the code, and a loose standing reference guide, available from
+`the NumPy homepage <http://www.scipy.org>`_.
+
+We recommend exploring the docstrings using
+`IPython <http://ipython.scipy.org>`_, an advanced Python shell with
+TAB-completion and introspection capabilities. See below for further
+instructions.
+
+The docstring examples assume that `numpy` has been imported as `np`::
+
+ >>> import numpy as np
+
+Code snippets are indicated by three greater-than signs::
+
+ >>> x = x + 1
+
+Use the built-in ``help`` function to view a function's docstring::
+
+ >>> help(np.sort)
+
+For some objects, ``np.info(obj)`` may provide additional help.
+
+To search for objects of which the documentation contains keywords, do::
+
+ >>> np.lookfor('keyword')
Available subpackages
---------------------
@@ -34,19 +61,13 @@ distutils
Enhancements to distutils with support for
Fortran compilers support and more.
-
Global symbols from subpackages
-------------------------------
-======== =================================
-core all (use numpy.* not numpy.core.*)
-lib all (use numpy.* not numpy.lib.*)
-testing NumpyTest
-======== =================================
-
+Do not import directly from `core` and `lib`: those functions
+have been imported into the `numpy` namespace.
Utility tools
-------------
-
test
Run numpy unittests
pkgload
@@ -60,6 +81,24 @@ matlib
__version__
Numpy version string
+Viewing documentation using IPython
+-----------------------------------
+Start IPython with the NumPy profile (``ipython -p numpy``), which will
+import `numpy` under the alias `np`. Then, use the ``cpaste`` command to
+paste examples into the shell. To see which functions are available in
+`numpy`, type ``np.<TAB>`` (where ``<TAB>`` refers to the TAB key), or use
+``np.*cos*?<ENTER>`` (where ``<ENTER>`` refers to the ENTER key) to narrow
+down the list. To view the docstring for a function, use
+``np.cos?<ENTER>`` (to view the docstring) and ``np.cos??<ENTER>`` (to view
+the source code).
+
+Copies vs. in-place operation
+-----------------------------
+Most of the methods in `numpy` return a copy of the array argument (e.g.,
+`sort`). In-place versions of these methods are often available as
+array methods, i.e. ``x = np.array([1,2,3]); x.sort()``. Exceptions to
+this rule are documented.
+
"""
# We first need to detect if we're being called as part of the numpy setup
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
index eb1083df7..5826f6c70 100644
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -63,41 +63,70 @@ dtype([('surname', '|S25'), ('age', '|u1')])
""")
-add_newdoc('numpy.core','dtype',
- [('fields', "Fields of the data-type or None if no fields"),
- ('names', "Names of fields or None if no fields"),
- ('alignment', "Needed alignment for this data-type"),
- ('byteorder',
- "Little-endian (<), big-endian (>), native (=), or "\
- "not-applicable (|)"),
- ('char', "Letter typecode for this data-type"),
- ('type', "Type object associated with this data-type"),
- ('kind', "Character giving type-family of this data-type"),
- ('itemsize', "Size of each item"),
- ('hasobject', "Non-zero if Python objects are in "\
- "this data-type"),
- ('num', "Internally-used number for builtin base"),
- ('newbyteorder',
-"""self.newbyteorder(endian)
-
-Returns a copy of the dtype object with altered byteorders.
-If `endian` is not given all byteorders are swapped.
-Otherwise endian can be '>', '<', or '=' to force a particular
-byteorder. Data-types in all fields are also updated in the
-new dtype object.
-"""),
- ("__reduce__", "self.__reduce__() for pickling"),
- ("__setstate__", "self.__setstate__() for pickling"),
- ("subdtype", "A tuple of (descr, shape) or None"),
- ("descr", "The array_interface data-type descriptor."),
- ("str", "The array interface typestring."),
- ("name", "The name of the true data-type"),
- ("base", "The base data-type or self if no subdtype"),
- ("shape", "The shape of the subdtype or (1,)"),
- ("isbuiltin", "Is this a built-in data-type?"),
- ("isnative", "Is the byte-order of this data-type native?")
- ]
- )
+add_newdoc('numpy.core', 'dtype',
+ """
+ Create a data type.
+
+ A numpy array is homogeneous, and contains elements described by a
+ dtype. A dtype can be constructed from different combinations of
+ fundamental numeric types, as illustrated below.
+
+ Examples
+ --------
+ Using array-scalar type:
+
+ >>> np.dtype(np.int16)
+ dtype('int16')
+
+ Record, one field name 'f1', containing int16:
+
+ >>> np.dtype([('f1', np.int16)])
+ dtype([('f1', '<i2')])
+
+ Record, one field named 'f1', in itself containing a record with one field:
+
+ >>> np.dtype([('f1', [('f1', np.int16)])])
+ dtype([('f1', [('f1', '<i2')])])
+
+ Record, two fields: the first field contains an unsigned int, the
+ second an int32:
+
+ >>> np.dtype([('f1', np.uint), ('f2', np.int32)])
+ dtype([('f1', '<u4'), ('f2', '<i4')])
+
+ Using array-protocol type strings:
+
+ >>> np.dtype([('a','f8'),('b','S10')])
+ dtype([('a', '<f8'), ('b', '|S10')])
+
+ Using comma-separated field formats. The shape is (2,3):
+
+ >>> np.dtype("i4, (2,3)f8")
+ dtype([('f0', '<i4'), ('f1', '<f8', (2, 3))])
+
+ Using tuples. ``int`` is a fixed type, 3 the field's shape. ``void``
+ is a flexible type, here of size 10:
+
+ >>> np.dtype([('hello',(np.int,3)),('world',np.void,10)])
+ dtype([('hello', '<i4', 3), ('world', '|V10')])
+
+ Subdivide ``int16`` into 2 ``int8``'s, called x and y. 0 and 1 are
+ the offsets in bytes:
+
+ >>> np.dtype((np.int16, {'x':(np.int8,0), 'y':(np.int8,1)}))
+ dtype(('<i2', [('x', '|i1'), ('y', '|i1')]))
+
+ Using dictionaries. Two fields named 'gender' and 'age':
+
+ >>> np.dtype({'names':['gender','age'], 'formats':['S1',np.uint8]})
+ dtype([('gender', '|S1'), ('age', '|u1')])
+
+ Offsets in bytes, here 0 and 25:
+
+ >>> np.dtype({'surname':('S25',0),'age':(np.uint8,25)})
+ dtype([('surname', '|S25'), ('age', '|u1')])
+
+ """)
###############################################################################
#
@@ -191,59 +220,125 @@ add_newdoc('numpy.core', 'broadcast', ('size',
#
###############################################################################
-add_newdoc('numpy.core.multiarray','array',
- """array(object, dtype=None, copy=1,order=None, subok=0,ndmin=0)
+add_newdoc('numpy.core.multiarray', 'array',
+ """
+ array(object, dtype=None, copy=True, order=None, subok=True, ndmin=True)
- Return an array from object with the specified data-type.
+ Create an array.
Parameters
----------
object : array-like
- an array, any object exposing the array interface, any
+ An array, any object exposing the array interface, an
object whose __array__ method returns an array, or any
(nested) sequence.
- dtype : data-type
+ dtype : data-type, optional
The desired data-type for the array. If not given, then
the type will be determined as the minimum type required
to hold the objects in the sequence. This argument can only
be used to 'upcast' the array. For downcasting, use the
.astype(t) method.
- copy : bool
- If true, then force a copy. Otherwise a copy will only occur
- if __array__ returns a copy, obj is a nested sequence, or
- a copy is needed to satisfy any of the other requirements
- order : {'C', 'F', 'A' (None)}
- Specify the order of the array. If order is 'C', then the
+ copy : bool, optional
+ If true (default), then the object is copied. Otherwise, a copy
+ will only be made if __array__ returns a copy, if obj is a
+ nested sequence, or if a copy is needed to satisfy any of the other
+ requirements (`dtype`, `order`, etc.).
+ order : {'C', 'F', 'A'}, optional
+ Specify the order of the array. If order is 'C' (default), then the
array will be in C-contiguous order (last-index varies the
- fastest). If order is 'FORTRAN', then the returned array
+ fastest). If order is 'F', then the returned array
will be in Fortran-contiguous order (first-index varies the
- fastest). If order is None, then the returned array may
- be in either C-, or Fortran-contiguous order or even
- discontiguous.
- subok : bool
+ fastest). If order is 'A', then the returned array may
+ be in any order (either C-, Fortran-contiguous, or even
+ discontiguous).
+ subok : bool, optional
If True, then sub-classes will be passed-through, otherwise
- the returned array will be forced to be a base-class array
- ndmin : int
+ the returned array will be forced to be a base-class array.
+ ndmin : int, optional
Specifies the minimum number of dimensions that the resulting
- array should have. 1's will be pre-pended to the shape as
+ array should have. Ones will be pre-pended to the shape as
needed to meet this requirement.
+ Examples
+ --------
+ >>> np.array([1, 2, 3])
+ array([1, 2, 3])
+
+ Upcasting:
+
+ >>> np.array([1, 2, 3.0])
+ array([ 1., 2., 3.])
+
+ More than one dimension:
+
+ >>> np.array([[1, 2], [3, 4]])
+ array([[1, 2],
+ [3, 4]])
+
+ Minimum dimensions 2:
+
+ >>> np.array([1, 2, 3], ndmin=2)
+ array([[1, 2, 3]])
+
+ Type provided:
+
+ >>> np.array([1, 2, 3], dtype=complex)
+ array([ 1.+0.j, 2.+0.j, 3.+0.j])
+
+ Data-type consisting of more than one element:
+
+ >>> x = np.array([(1,2),(3,4)],dtype=[('a','<i4'),('b','<i4')])
+ >>> x['a']
+ array([1, 3])
+
+ Creating an array from sub-classes:
+
+ >>> np.array(np.mat('1 2; 3 4'))
+ array([[1, 2],
+ [3, 4]])
+
+ >>> np.array(np.mat('1 2; 3 4'), subok=True)
+ matrix([[1, 2],
+ [3, 4]])
+
""")
-add_newdoc('numpy.core.multiarray','empty',
- """empty(shape, dtype=float, order='C')
+add_newdoc('numpy.core.multiarray', 'empty',
+ """
+ empty(shape, dtype=float, order='C')
- Return a new array of given shape and type with all entries uninitialized.
- This can be faster than zeros.
+ Return a new array of given shape and type, without initialising entries.
Parameters
----------
- shape : tuple of integers
- Shape of the new array
- dtype : data-type
- The desired data-type for the array.
- order : {'C', 'F'}
- Whether to store multidimensional data in C or Fortran order.
+ shape : {tuple of int, int}
+ Shape of the empty array
+ dtype : data-type, optional
+ Desired output data-type.
+ order : {'C', 'F'}, optional
+ Whether to store multi-dimensional data in C (row-major) or
+ Fortran (column-major) order in memory.
+
+ See Also
+ --------
+ empty_like, zeros
+
+ Notes
+ -----
+ `empty`, unlike `zeros`, does not set the array values to zero,
+ and may therefore be marginally faster. On the other hand, it requires
+ the user to manually set all the values in the array, and should be
+ used with caution.
+
+ Examples
+ --------
+ >>> np.empty([2, 2])
+ array([[ -9.74499359e+001, 6.69583040e-309], #random data
+ [ 2.13182611e-314, 3.06959433e-309]])
+
+ >>> np.empty([2, 2], dtype=int)
+ array([[-1073741821, -1067949133], #random data
+ [ 496041986, 19249760]])
""")
@@ -260,19 +355,56 @@ add_newdoc('numpy.core.multiarray','scalar',
""")
-add_newdoc('numpy.core.multiarray','zeros',
- """zeros(shape, dtype=float, order='C')
+add_newdoc('numpy.core.multiarray', 'zeros',
+ """
+ zeros(shape, dtype=float, order='C')
- Return a new array of given shape and type, filled zeros.
+ Return a new array of given shape and type, filled with zeros.
Parameters
----------
- shape : tuple of integers
- Shape of the new array
- dtype : data-type
- The desired data-type for the array.
- order : {'C', 'F'}
- Whether to store multidimensional data in C or Fortran order.
+ shape : {tuple of ints, int}
+ Shape of the new array, e.g., ``(2, 3)`` or ``2``.
+ dtype : data-type, optional
+ The desired data-type for the array, e.g., `numpy.int8`. Default is
+ `numpy.float64`.
+ order : {'C', 'F'}, optional
+ Whether to store multidimensional data in C- or Fortran-contiguous
+ (row- or column-wise) order in memory.
+
+ Returns
+ -------
+ out : ndarray
+ Array of zeros with the given shape, dtype, and order.
+
+ See Also
+ --------
+ numpy.zeros_like : Return an array of zeros with shape and type of input.
+ numpy.ones_like : Return an array of ones with shape and type of input.
+ numpy.empty_like : Return an empty array with shape and type of input.
+ numpy.ones : Return a new array setting values to one.
+ numpy.empty : Return a new uninitialized array.
+
+ Examples
+ --------
+ >>> np.zeros(5)
+ array([ 0., 0., 0., 0., 0.])
+
+ >>> np.zeros((5,), dtype=numpy.int)
+ array([0, 0, 0, 0, 0])
+
+ >>> np.zeros((2, 1))
+ array([[ 0.],
+ [ 0.]])
+
+ >>> s = (2,2)
+ >>> np.zeros(s)
+ array([[ 0., 0.],
+ [ 0., 0.]])
+
+ >>> np.zeros((2,), dtype=[('x', 'i4'), ('y', 'i4')])
+ array([(0, 0), (0, 0)],
+ dtype=[('x', '<i4'), ('y', '<i4')])
""")
@@ -284,119 +416,325 @@ add_newdoc('numpy.core.multiarray','set_typeDict',
""")
-add_newdoc('numpy.core.multiarray','fromstring',
- """fromstring(string, dtype=float, count=-1, sep='')
+add_newdoc('numpy.core.multiarray', 'fromstring',
+ """
+ fromstring(string, dtype=float, count=-1, sep='')
- Return a new 1d array initialized from the raw binary data in string.
+ Return a new 1d array initialized from raw binary or text data in
+ string.
- If count is positive, the new array will have count elements, otherwise its
- size is determined by the size of string. If sep is not empty then the
- string is interpreted in ASCII mode and converted to the desired number type
- using sep as the separator between elements (extra whitespace is ignored).
- ASCII integer conversions are base-10; octal and hex are not supported.
+ Parameters
+ ----------
+ string : str
+ A string containing the data.
+ dtype : dtype, optional
+ The data type of the array. For binary input data, the data must be
+ in exactly this format.
+ count : int, optional
+ Read this number of `dtype` elements from the data. If this is
+ negative, then the size will be determined from the length of the
+ data.
+ sep : str, optional
+ If provided and not empty, then the data will be interpreted as
+ ASCII text with decimal numbers. This argument is interpreted as the
+ string separating numbers in the data. Extra whitespace between
+ elements is also ignored.
+
+ Returns
+ -------
+ arr : array
+ The constructed array.
+
+ Raises
+ ------
+ ValueError
+ If the string is not the correct size to satisfy the requested
+ `dtype` and `count`.
+
+ Examples
+ --------
+ >>> np.fromstring('\\x01\\x02', dtype=np.uint8)
+ array([1, 2], dtype=uint8)
+ >>> np.fromstring('1 2', dtype=int, sep=' ')
+ array([1, 2])
+ >>> np.fromstring('1, 2', dtype=int, sep=',')
+ array([1, 2])
+ >>> np.fromstring('\\x01\\x02\\x03\\x04\\x05', dtype=np.uint8, count=3)
+ array([1, 2, 3], dtype=uint8)
+
+ Invalid inputs:
+
+ >>> np.fromstring('\\x01\\x02\\x03\\x04\\x05', dtype=np.int32)
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ ValueError: string size must be a multiple of element size
+ >>> np.fromstring('\\x01\\x02', dtype=np.uint8, count=3)
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ ValueError: string is smaller than requested size
""")
-add_newdoc('numpy.core.multiarray','fromiter',
- """fromiter(iterable, dtype, count=-1)
+add_newdoc('numpy.core.multiarray', 'fromiter',
+ """
+ fromiter(iterable, dtype, count=-1)
- Return a new 1d array initialized from iterable.
+ Create a new 1-dimensional array from an iterable object.
Parameters
----------
- iterable
- Iterable object from which to obtain data
+ iterable : iterable object
+ An iterable object providing data for the array.
dtype : data-type
- Data type of the returned array.
- count : int
- Number of items to read. -1 means all data in the iterable.
+ The data type of the returned array.
+ count : int, optional
+ The number of items to read from iterable. The default is -1,
+ which means all data is read.
Returns
-------
- new_array : ndarray
+ out : ndarray
+ The output array.
+
+ Notes
+ -----
+ Specify ``count`` to improve performance. It allows
+ ``fromiter`` to pre-allocate the output array, instead of
+ resizing it on demand.
+
+ Examples
+ --------
+ >>> iterable = (x*x for x in range(5))
+ >>> np.fromiter(iterable, np.float)
+ array([ 0., 1., 4., 9., 16.])
""")
-add_newdoc('numpy.core.multiarray','fromfile',
- """fromfile(file=, dtype=float, count=-1, sep='')
+add_newdoc('numpy.core.multiarray', 'fromfile',
+ """
+ fromfile(file, dtype=float, count=-1, sep='')
- Return an array of the given data type from a text or binary file.
+ Construct an array from data in a text or binary file.
- Data written using the tofile() method can be conveniently recovered using
- this function.
+ A highly efficient way of reading binary data with a known data-type,
+ as well as parsing simply formatted text files. Data written using the
+ `tofile` method can be read using this function.
Parameters
----------
file : file or string
- Open file object or string containing a file name.
+ Open file object or filename.
dtype : data-type
Data type of the returned array.
- For binary files, it is also used to determine the size and order of
- the items in the file.
+ For binary files, it is used to determine the size and byte-order
+ of the items in the file.
count : int
- Number of items to read. -1 means all data in the whole file.
+ Number of items to read. ``-1`` means all items (i.e., the complete
+ file).
sep : string
Separator between items if file is a text file.
Empty ("") separator means the file should be treated as binary.
+ Spaces (" ") in the separator match zero or more whitespace characters.
+ A separator consisting only of spaces must match at least one
+ whitespace.
See also
--------
- loadtxt : load data from text files
+ load, save
+ ndarray.tofile
+ loadtxt : More flexible way of loading data from a text file.
Notes
-----
- WARNING: This function should be used sparingly as the binary files are not
- platform independent. In particular, they contain no endianess or datatype
- information. Nevertheless it can be useful for reading in simply formatted
- or binary data quickly.
+ Do not rely on the combination of `tofile` and `fromfile` for
+ data storage, as the binary files generated are are not platform
+ independent. In particular, no byte-order or data-type information is
+ saved. Data can be stored in the platform independent ``.npy`` format
+ using `save` and `load` instead.
+
+ Examples
+ --------
+ Construct an ndarray:
+
+ >>> dt = np.dtype([('time', [('min', int), ('sec', int)]),
+ ... ('temp', float)])
+ >>> x = np.zeros((1,), dtype=dt)
+ >>> x['time']['min'] = 10; x['temp'] = 98.25
+ >>> x
+ array([((10, 0), 98.25)],
+ dtype=[('time', [('min', '<i4'), ('sec', '<i4')]), ('temp', '<f8')])
+
+ Save the raw data to disk:
+
+ >>> import os
+ >>> fname = os.tmpnam()
+ >>> x.tofile(fname)
+
+ Read the raw data from disk:
+
+ >>> np.fromfile(fname, dtype=dt)
+ array([((10, 0), 98.25)],
+ dtype=[('time', [('min', '<i4'), ('sec', '<i4')]), ('temp', '<f8')])
+
+ The recommended way to store and load data:
+
+ >>> np.save(fname, x)
+ >>> np.load(fname + '.npy')
+ array([((10, 0), 98.25)],
+ dtype=[('time', [('min', '<i4'), ('sec', '<i4')]), ('temp', '<f8')])
""")
-add_newdoc('numpy.core.multiarray','frombuffer',
- """frombuffer(buffer=, dtype=float, count=-1, offset=0)
+add_newdoc('numpy.core.multiarray', 'frombuffer',
+ """
+ frombuffer(buffer, dtype=float, count=-1, offset=0)
- Returns a 1-d array of data type dtype from buffer.
+ Interpret a buffer as a 1-dimensional array.
Parameters
----------
buffer
- An object that exposes the buffer interface
- dtype : data-type
+ An object that exposes the buffer interface.
+ dtype : data-type, optional
Data type of the returned array.
- count : int
- Number of items to read. -1 means all data in the buffer.
- offset : int
- Number of bytes to jump from the start of the buffer before reading
+ count : int, optional
+ Number of items to read. ``-1`` means all data in the buffer.
+ offset : int, optional
+ Start reading the buffer from this offset.
Notes
-----
- If the buffer has data that is not in machine byte-order, then
- use a proper data type descriptor. The data will not be
- byteswapped, but the array will manage it in future operations.
+ If the buffer has data that is not in machine byte-order, this
+ should be specified as part of the data-type, e.g.::
+
+ >>> dt = np.dtype(int)
+ >>> dt = dt.newbyteorder('>')
+ >>> np.frombuffer(buf, dtype=dt)
+
+ The data of the resulting array will not be byteswapped,
+ but will be interpreted correctly.
+
+ Examples
+ --------
+ >>> s = 'hello world'
+ >>> np.frombuffer(s, dtype='S1', count=5, offset=6)
+ array(['w', 'o', 'r', 'l', 'd'],
+ dtype='|S1')
""")
-add_newdoc('numpy.core.multiarray','concatenate',
- """concatenate((a1, a2, ...), axis=0)
+add_newdoc('numpy.core.multiarray', 'concatenate',
+ """
+ concatenate((a1, a2, ...), axis=0)
+
+ Join a sequence of arrays together.
+
+ Parameters
+ ----------
+ a1, a2, ... : sequence of ndarrays
+ The arrays must have the same shape, except in the dimension
+ corresponding to `axis` (the first, by default).
+ axis : int, optional
+ The axis along which the arrays will be joined. Default is 0.
- Join arrays together.
+ Returns
+ -------
+ res : ndarray
+ The concatenated array.
- The tuple of sequences (a1, a2, ...) are joined along the given axis
- (default is the first one) into a single numpy array.
+ See Also
+ --------
+ array_split : Split an array into multiple sub-arrays of equal or
+ near-equal size.
+ split : Split array into a list of multiple sub-arrays of equal size.
+ hsplit : Split array into multiple sub-arrays horizontally (column wise)
+ vsplit : Split array into multiple sub-arrays vertically (row wise)
+ dsplit : Split array into multiple sub-arrays along the 3rd axis (depth).
+ hstack : Stack arrays in sequence horizontally (column wise)
+ vstack : Stack arrays in sequence vertically (row wise)
+ dstack : Stack arrays in sequence depth wise (along third dimension)
Examples
--------
- >>> np.concatenate( ([0,1,2], [5,6,7]) )
- array([0, 1, 2, 5, 6, 7])
+ >>> a = np.array([[1, 2], [3, 4]])
+ >>> b = np.array([[5, 6]])
+ >>> np.concatenate((a, b), axis=0)
+ array([[1, 2],
+ [3, 4],
+ [5, 6]])
""")
-add_newdoc('numpy.core.multiarray','inner',
- """inner(a,b)
+add_newdoc('numpy.core.multiarray', 'inner',
+ """
+ inner(a, b)
+
+ Inner product of two arrays.
+
+ Ordinary inner product of vectors for 1-D arrays (without complex
+ conjugation), in higher dimensions a sum product over the last axes.
+
+ Parameters
+ ----------
+ a, b : array_like
+ If `a` and `b` are nonscalar, their last dimensions of must match.
+
+ Returns
+ -------
+ out : ndarray
+ `out.shape = a.shape[:-1] + b.shape[:-1]`
+
+ Raises
+ ------
+ ValueError
+ If the last dimension of `a` and `b` has different size.
+
+ See Also
+ --------
+ tensordot : Sum products over arbitrary axes.
+ dot : Generalised matrix product, using second last dimension of `b`.
+
+ Notes
+ -----
+ For vectors (1-D arrays) it computes the ordinary inner-product::
+
+ np.inner(a, b) = sum(a[:]*b[:])
+
+ More generally, if `ndim(a) = r > 0` and `ndim(b) = s > 0`::
+
+ np.inner(a, b) = np.tensordot(a, b, axes=(-1,-1))
+
+ or explicitly::
+
+ np.inner(a, b)[i0,...,ir-1,j0,...,js-1]
+ = sum(a[i0,...,ir-1,:]*b[j0,...,js-1,:])
- Returns the dot product of two arrays, which has shape a.shape[:-1] +
- b.shape[:-1] with elements computed by the product of the elements
- from the last dimensions of a and b.
+ In addition `a` or `b` may be scalars, in which case::
+
+ np.inner(a,b) = a*b
+
+ Examples
+ --------
+ Ordinary inner product for vectors:
+
+ >>> a = np.array([1,2,3])
+ >>> b = np.array([0,1,0])
+ >>> np.inner(a, b)
+ 2
+
+ A multidimensional example:
+
+ >>> a = np.arange(24).reshape((2,3,4))
+ >>> b = np.arange(4)
+ >>> np.inner(a, b)
+ array([[ 14, 38, 62],
+ [ 86, 110, 134]])
+
+ An example where `b` is a scalar:
+
+ >>> np.inner(np.eye(2), 7)
+ array([[ 7., 0.],
+ [ 0., 7.]])
""")
@@ -406,17 +744,59 @@ add_newdoc('numpy.core','fastCopyAndTranspose',
add_newdoc('numpy.core.multiarray','correlate',
"""cross_correlate(a,v, mode=0)""")
-add_newdoc('numpy.core.multiarray','arange',
- """arange([start,] stop[, step,], dtype=None)
+add_newdoc('numpy.core.multiarray', 'arange',
+ """
+ arange([start,] stop[, step,], dtype=None)
- For integer arguments, just like range() except it returns an array
- whose type can be specified by the keyword argument dtype. If dtype
- is not specified, the type of the result is deduced from the type of
- the arguments.
+ Return evenly spaced values within a given interval.
- For floating point arguments, the length of the result is ceil((stop -
- start)/step). This rule may result in the last element of the result
- being greater than stop.
+ Values are generated within the half-open interval ``[start, stop)``
+ (in other words, the interval including `start` but excluding `stop`).
+ For integer arguments, the function is equivalent to ``range``
+ (but returns an array).
+
+ Parameters
+ ----------
+ start : number, optional
+ Start of interval. The interval includes this value. The default
+ start value is 0.
+ end : number
+ End of interval. The interval does not include this value.
+ step : number, optional
+ Spacing between values. For any output `out`, this is the distance
+ between two adjacent values, ``out[i+1] - out[i]``. The default
+ step size is 1. If `step` is specified, `start` must also be given.
+ dtype : dtype
+ The type of the output array. If `dtype` is not given, infer the data
+ type from the other input arguments.
+
+ Returns
+ -------
+ out : ndarray
+ Array of evenly spaced values.
+
+ For floating point arguments, the length of the result is
+ ``ceil((stop - start)/step)``. Because of floating point overflow,
+ this rule may result in the last element of `out` being greater
+ than `stop`.
+
+ See Also
+ --------
+ range : The Python equivalent for integers
+ linspace : Evenly spaced numbers with careful handling of endpoints.
+ ogrid: Arrays of evenly spaced numbers in N-dimensions
+ mgrid: Grid-shaped arrays of evenly spaced numbers in N-dimensions
+
+ Examples
+ --------
+ >>> np.arange(3)
+ array([0, 1, 2])
+ >>> np.arange(3.0)
+ array([ 0., 1., 2.])
+ >>> np.arange(3,7)
+ array([3, 4, 5, 6])
+ >>> np.arange(3,7,2)
+ array([3, 5])
""")
@@ -435,76 +815,157 @@ add_newdoc('numpy.core.multiarray','_reconstruct',
""")
-add_newdoc('numpy.core.multiarray','set_string_function',
- """set_string_function(f, repr=1)
+add_newdoc('numpy.core.multiarray', 'set_string_function',
+ """
+ set_string_function(f, repr=1)
+
+ Set a Python function to be used when pretty printing arrays.
- Set the python function f to be the function used to obtain a pretty
- printable string version of an array whenever an array is printed.
- f(M) should expect an array argument M, and should return a string
- consisting of the desired representation of M for printing.
+ Parameters
+ ----------
+ f : Python function
+ Function to be used to pretty print arrays. The function should expect
+ a single array argument and return a string of the representation of
+ the array.
+ repr : int
+ Unknown.
+
+ Examples
+ --------
+ >>> def pprint(arr):
+ ... return 'HA! - What are you going to do now?'
+ ...
+ >>> np.set_string_function(pprint)
+ >>> a = np.arange(10)
+ >>> a
+ HA! - What are you going to do now?
+ >>> print a
+ [0 1 2 3 4 5 6 7 8 9]
""")
-add_newdoc('numpy.core.multiarray','set_numeric_ops',
- """set_numeric_ops(op=func, ...)
+add_newdoc('numpy.core.multiarray', 'set_numeric_ops',
+ """
+ set_numeric_ops(op1=func1, op2=func2, ...)
+
+ Set numerical operators for array objects.
- Set some or all of the number methods for all array objects. Do not
- forget **dict can be used as the argument list. Return the functions
- that were replaced, which can be stored and set later.
+ Parameters
+ ----------
+ op1, op2, ... : callable
+ Each ``op = func`` pair describes an operator to be replaced.
+ For example, ``add = lambda x, y: np.add(x, y) % 5`` would replace
+ addition by modulus 5 addition.
+
+ Returns
+ -------
+ saved_ops : list of callables
+ A list of all operators, stored before making replacements.
+
+ Notes
+ -----
+ .. WARNING::
+ Use with care! Incorrect usage may lead to memory errors.
+
+ A function replacing an operator cannot make use of that operator.
+ For example, when replacing add, you may not use ``+``. Instead,
+ directly call ufuncs:
+
+ >>> def add_mod5(x, y):
+ ... return np.add(x, y) % 5
+ ...
+ >>> old_funcs = np.set_numeric_ops(add=add_mod5)
+
+ >>> x = np.arange(12).reshape((3, 4))
+ >>> x + x
+ array([[0, 2, 4, 1],
+ [3, 0, 2, 4],
+ [1, 3, 0, 2]])
+
+ >>> ignore = np.set_numeric_ops(**old_funcs) # restore operators
""")
-add_newdoc('numpy.core.multiarray','where',
- """where(condition, x, y) or where(condition)
+add_newdoc('numpy.core.multiarray', 'where',
+ """
+ where(condition, [x, y])
+
+ Return elements, either from `x` or `y`, depending on `condition`.
- Return elements from `x` or `y`, depending on `condition`.
+ If only `condition` is given, return ``condition.nonzero()``.
Parameters
----------
- condition : array of bool
- When True, yield x, otherwise yield y.
- x,y : 1-dimensional arrays
+ condition : array_like, bool
+ When True, yield `x`, otherwise yield `y`.
+ x, y : array_like, optional
Values from which to choose.
+ Returns
+ -------
+ out : ndarray or tuple of ndarrays
+ If both `x` and `y` are specified, the output array, shaped like
+ `condition`, contains elements of `x` where `condition` is True,
+ and elements from `y` elsewhere.
+
+ If only `condition` is given, return the tuple
+ ``condition.nonzero()``, the indices where `condition` is True.
+
+ See Also
+ --------
+ nonzero
+
Notes
-----
- This is equivalent to
+ If `x` and `y` are given and input arrays are 1-D, `where` is
+ equivalent to::
[xv if c else yv for (c,xv,yv) in zip(condition,x,y)]
- The result is shaped like `condition` and has elements of `x`
- or `y` where `condition` is respectively True or False.
-
- In the special case, where only `condition` is given, the
- tuple condition.nonzero() is returned, instead.
-
Examples
--------
- >>> np.where([True,False,True],[1,2,3],[4,5,6])
- array([1, 5, 3])
+ >>> x = np.arange(9.).reshape(3, 3)
+ >>> np.where( x > 5 )
+ (array([2, 2, 2]), array([0, 1, 2]))
+ >>> x[np.where( x > 3.0 )] # Note: result is 1D.
+ array([ 4., 5., 6., 7., 8.])
+ >>> np.where(x < 5, x, -1) # Note: broadcasting.
+ array([[ 0., 1., 2.],
+ [ 3., 4., -1.],
+ [-1., -1., -1.]])
+
+ >>> np.where([[True, False], [True, True]],
+ ... [[1, 2], [3, 4]],
+ ... [[9, 8], [7, 6]])
+ array([[1, 8],
+ [3, 4]])
+
+ >>> np.where([[0, 1], [1, 0]])
+ (array([0, 1]), array([1, 0]))
""")
-add_newdoc('numpy.core.multiarray','lexsort',
- """lexsort(keys=, axis=-1) -> array of indices. Argsort with list of keys.
+add_newdoc('numpy.core.multiarray', 'lexsort',
+ """
+ lexsort(keys, axis=-1)
+
+ Perform an indirect sort using a list of keys.
- Perform an indirect sort using a list of keys. The first key is sorted,
- then the second, and so on through the list of keys. At each step the
- previous order is preserved when equal keys are encountered. The result is
- a sort on multiple keys. If the keys represented columns of a spreadsheet,
- for example, this would sort using multiple columns (the last key being
- used for the primary sort order, the second-to-last key for the secondary
- sort order, and so on).
+ Imagine three input keys, ``a``, ``b`` and ``c``. These can be seen as
+ columns in a spreadsheet. The first row of the spreadsheet would
+ therefore be ``a[0], b[0], c[0]``. Lexical sorting orders the different
+ rows by first sorting on the on first column (key), then the second,
+ and so forth. At each step, the previous ordering is preserved
+ when equal keys are encountered.
Parameters
----------
- keys : (k,N) array or tuple of (N,) sequences
- Array containing values that the returned indices should sort, or
- a sequence of things that can be converted to arrays of the same shape.
-
- axis : integer
- Axis to be indirectly sorted. Default is -1 (i.e. last axis).
+ keys : (k,N) array or tuple containing k (N,)-shaped sequences
+ The `k` different "columns" to be sorted. The last column is the
+ primary sort column.
+ axis : integer, optional
+ Axis to be indirectly sorted. By default, sort over the last axis.
Returns
-------
@@ -513,28 +974,68 @@ add_newdoc('numpy.core.multiarray','lexsort',
See Also
--------
- argsort : indirect sort
- sort : inplace sort
+ argsort : Indirect sort.
+ sort : In-place sort.
Examples
--------
- >>> a = [1,5,1,4,3,6,7]
- >>> b = [9,4,0,4,0,4,3]
- >>> ind = np.lexsort((b,a))
+ Sort names: first by surname, then by name.
+
+ >>> surnames = ('Hertz', 'Galilei', 'Hertz')
+ >>> first_names = ('Heinrich', 'Galileo', 'Gustav')
+ >>> ind = np.lexsort((first_names, surnames))
+ >>> ind
+ array([1, 2, 0])
+
+ >>> [surnames[i] + ", " + first_names[i] for i in ind]
+ ['Galilei, Galileo', 'Hertz, Gustav', 'Hertz, Heinrich']
+
+ Sort two columns of numbers:
+
+ >>> a = [1,5,1,4,3,4,4] # First column
+ >>> b = [9,4,0,4,0,2,1] # Second column
+ >>> ind = np.lexsort((b,a)) # Sort by second, then first column
>>> print ind
- [2 0 4 3 1 5 6]
- >>> print np.take(a,ind)
- [1 1 3 4 5 6 7]
- >>> print np.take(b,ind)
- [0 9 0 4 4 4 3]
+ [2 0 4 6 5 3 1]
+
+ >>> [(a[i],b[i]) for i in ind]
+ [(1, 0), (1, 9), (3, 0), (4, 1), (4, 2), (4, 4), (5, 4)]
+
+ Note that the first elements are sorted. For each first element,
+ the second elements are also sorted.
+
+ A normal ``argsort`` would have yielded:
+
+ >>> [(a[i],b[i]) for i in np.argsort(a)]
+ [(1, 9), (1, 0), (3, 0), (4, 4), (4, 2), (4, 1), (5, 4)]
+
+ Structured arrays are sorted lexically:
+
+ >>> x = np.array([(1,9), (5,4), (1,0), (4,4), (3,0), (4,2), (4,1)],
+ ... dtype=np.dtype([('x', int), ('y', int)]))
+
+ >>> np.argsort(x) # or np.argsort(x, order=('x', 'y'))
+ array([2, 0, 4, 6, 5, 3, 1])
""")
-add_newdoc('numpy.core.multiarray','can_cast',
- """can_cast(from=d1, to=d2)
+add_newdoc('numpy.core.multiarray', 'can_cast',
+ """
+ can_cast(from=d1, to=d2)
+
+ Returns True if cast between data types can occur without losing precision.
+
+ Parameters
+ ----------
+ from: data type code
+ Data type code to cast from.
+ to: data type code
+ Data type code to cast to.
- Returns True if data type d1 can be cast to data type d2 without
- losing precision.
+ Returns
+ -------
+ out : bool
+ True if cast can occur without losing precision.
""")
@@ -570,32 +1071,115 @@ add_newdoc('numpy.core.multiarray','getbuffer',
add_newdoc('numpy.core.multiarray', 'ndarray',
"""
+ ndarray(shape, dtype=float, buffer=None, offset=0,
+ strides=None, order=None)
+
An array object represents a multidimensional, homogeneous array
- of fixed-size items. An associated data-type-descriptor object
- details the data-type in an array (including byteorder and any
- fields). An array can be constructed using the `numpy.array`
- command. Arrays are sequence, mapping and numeric objects.
- More information is available in the numpy module and by looking
- at the methods and attributes of an array.
+ of fixed-size items. An associated data-type object
+ describes the format of each element in the array (its byte-order,
+ how many bytes it occupies in memory, whether it is an integer or
+ a floating point number, etc.).
- ::
+ Arrays should be constructed using `array`, `zeros` or `empty` (refer to
+ the ``See Also`` section below). The parameters given here describe
+ a low-level method for instantiating an array (`ndarray(...)`).
+
+ For more information, refer to the `numpy` module and examine the
+ the methods and attributes of an array.
+
+ Attributes
+ ----------
+ T : ndarray
+ Transponent of the array.
+ data : buffer
+ Array data in memory.
+ dtype : data type
+ Data type, describing the format of the elements in the array.
+ flags : dict
+ Dictionary containing information related to memory use, e.g.,
+ 'C_CONTIGUOUS', 'OWNDATA', 'WRITEABLE', and others.
+ flat : ndarray
+ Return flattened version of the array as an iterator. The iterator
+ allows assignments, e.g., ``x.flat = 3``.
+ imag : ndarray
+ Imaginary part of the array.
+ real : ndarray
+ Real part of the array.
+ size : int
+ Number of elements in the array.
+ itemsize : int
+ The size of each element in memory (in bytes).
+ nbytes : int
+ The total number of bytes required to store the array data,
+ i.e., ``itemsize * size``.
+ shape : tuple of ints
+ Shape of the array.
+ strides : tuple of ints
+ The step-size required to move from one element to the next in memory.
+ For example, a contiguous ``(3, 4)`` array of type ``int16`` in C-order
+ has strides ``(8, 2)``. This implies that to move from element to
+ element in memory requires jumps of 2 bytes. To move from row-to-row,
+ one needs to jump 6 bytes at a time (``2 * 4``).
+ ctypes : ctypes object
+ Class containing properties of the array needed for interaction
+ with ctypes.
+ base : ndarray
+ If the array is a view on another array, that array is
+ its `base` (unless that array is also a view). The `base` array
+ is where the array data is ultimately stored.
+
+ Parameters
+ ----------
+ shape : tuple of ints
+ Shape of created array.
+ dtype : data type, optional
+ Any object that can be interpreted a numpy data type.
+ buffer : object exposing buffer interface, optional
+ Used to fill the array with data.
+ offset : int, optional
+ Offset of array data in buffer.
+ strides : tuple of ints, optional
+ Strides of data in memory.
+ order : {'C', 'F'}, optional
+ Row-major or column-major order.
- ndarray.__new__(subtype, shape=, dtype=float, buffer=None,
- offset=0, strides=None, order=None)
+ See Also
+ --------
+ array : Construct an array.
+ zeros : Create an array and fill its allocated memory with zeros.
+ empty : Create an array, but leave its allocated memory unchanged.
+ dtype : Create a data type.
+ Notes
+ -----
There are two modes of creating an array using __new__:
- 1. If buffer is None, then only shape, dtype, and order
- are used
- 2. If buffer is an object exporting the buffer interface, then
+ 1. If `buffer` is None, then only `shape`, `dtype`, and `order`
+ are used.
+ 2. If `buffer` is an object exporting the buffer interface, then
all keywords are interpreted.
- The dtype parameter can be any object that can be interpreted as
- a numpy.dtype object.
-
No __init__ method is needed because the array is fully initialized
after the __new__ method.
+ Examples
+ --------
+ These examples illustrate the low-level `ndarray` constructor. Refer
+ to the `See Also` section for easier ways of constructing an ndarray.
+
+ First mode, `buffer` is None:
+
+ >>> np.ndarray(shape=(2,2), dtype=float, order='F')
+ array([[ -1.13698227e+002, 4.25087011e-303],
+ [ 2.88528414e-306, 3.27025015e-309]])
+
+ Second mode:
+
+ >>> np.ndarray((2,), buffer=np.array([1,2,3]),
+ ... offset=np.int_().itemsize,
+ ... dtype=int) # offset = 1*itemsize, i.e. skip first element
+ array([2, 3])
+
""")
@@ -630,7 +1214,23 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('_as_parameter_',
add_newdoc('numpy.core.multiarray', 'ndarray', ('base',
- """Base object if memory is from some other object.
+ """
+ Base object if memory is from some other object.
+
+ Examples
+ --------
+
+ Base of an array owning its memory is None:
+
+ >>> x = np.array([1,2,3,4])
+ >>> x.base is None
+ True
+
+ Slicing creates a view, and the memory is shared with x:
+
+ >>> y = x[2:]
+ >>> y.base is x
+ True
"""))
@@ -654,13 +1254,32 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('dtype',
add_newdoc('numpy.core.multiarray', 'ndarray', ('imag',
- """Imaginary part of the array.
+ """
+ Imaginary part of the array.
+
+ Examples
+ --------
+ >>> x = np.sqrt([1+0j, 0+1j])
+ >>> x.imag
+ array([ 0. , 0.70710678])
+ >>> x.imag.dtype
+ dtype('float64')
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('itemsize',
- """Length of one element in bytes.
+ """
+ Length of one element in bytes.
+
+ Examples
+ --------
+ >>> x = np.array([1,2,3], dtype=np.float64)
+ >>> x.itemsize
+ 8
+ >>> x = np.array([1,2,3], dtype=np.complex128)
+ >>> x.itemsize
+ 16
"""))
@@ -672,49 +1291,134 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('flags',
add_newdoc('numpy.core.multiarray', 'ndarray', ('flat',
- """A 1-d flat iterator.
+ """
+ A 1-d flat iterator.
+
+ Examples
+ --------
+ >>> x = np.arange(3*4*5)
+ >>> x.shape = (3,4,5)
+ >>> x.flat[19]
+ 19
+ >>> x.T.flat[19]
+ 31
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('nbytes',
- """Number of bytes in the array.
+ """
+ Number of bytes in the array.
+
+ Examples
+ --------
+ >>> x = np.zeros((3,5,2), dtype=np.complex128)
+ >>> x.nbytes
+ 480
+ >>> np.prod(x.shape) * x.itemsize
+ 480
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('ndim',
- """Number of array dimensions.
+ """
+ Number of array dimensions.
+
+ Examples
+ --------
+
+ >>> x = np.array([1,2,3])
+ >>> x.ndim
+ 1
+ >>> y = np.zeros((2,3,4))
+ >>> y.ndim
+ 3
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('real',
- """Real part of the array.
+ """
+ Real part of the array.
+
+ Examples
+ --------
+ >>> x = np.sqrt([1+0j, 0+1j])
+ >>> x.real
+ array([ 1. , 0.70710678])
+ >>> x.real.dtype
+ dtype('float64')
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('shape',
- """Tuple of array dimensions.
+ """
+ Tuple of array dimensions.
+
+ Examples
+ --------
+ >>> x = np.array([1,2,3,4])
+ >>> x.shape
+ (4,)
+ >>> y = np.zeros((4,5,6))
+ >>> y.shape
+ (4, 5, 6)
+ >>> y.shape = (2, 5, 2, 3, 2)
+ >>> y.shape
+ (2, 5, 2, 3, 2)
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('size',
- """Number of elements in the array.
+ """
+ Number of elements in the array.
+
+ Examples
+ --------
+ >>> x = np.zeros((3,5,2), dtype=np.complex128)
+ >>> x.size
+ 30
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('strides',
- """Tuple of bytes to step in each dimension.
+ """
+ Tuple of bytes to step in each dimension.
+
+ The byte offset of element ``(i[0], i[1], ..., i[n])`` in an array `a`
+ is::
+
+ offset = sum(np.array(i) * a.strides)
+
+ Examples
+ --------
+ >>> x = np.reshape(np.arange(5*6*7*8), (5,6,7,8)).transpose(2,3,1,0)
+ >>> x.strides
+ (32, 4, 224, 1344)
+ >>> i = np.array([3,5,2,2])
+ >>> offset = sum(i * x.strides)
+ >>> x[3,5,2,2]
+ 813
+ >>> offset / x.itemsize
+ 813
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('T',
- """Same as self.transpose() except self is returned for self.ndim < 2.
+ """
+ Same as self.transpose() except self is returned for self.ndim < 2.
+
+ Examples
+ --------
+ >>> x = np.array([[1.,2.],[3.,4.]])
+ >>> x.T
+ array([[ 1., 3.],
+ [ 2., 4.]])
"""))
@@ -793,68 +1497,54 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('__setstate__',
add_newdoc('numpy.core.multiarray', 'ndarray', ('all',
- """a.all(axis=None, out=None)
+ """
+ a.all(axis=None, out=None)
Check if all of the elements of `a` are true.
- Performs a logical_and over the given axis and returns the result
-
- Parameters
- ----------
- axis : {None, integer}
- Axis to perform the operation over.
- If None, perform over flattened array.
- out : {None, array}, optional
- Array into which the result can be placed. Its type is preserved
- and it must be of the right shape to hold the output.
+ Refer to `numpy.all` for full documentation.
See Also
--------
- all : equivalent function
+ numpy.all : equivalent function
- """))
+ """))
add_newdoc('numpy.core.multiarray', 'ndarray', ('any',
- """a.any(axis=None, out=None)
+ """
+ a.any(axis=None, out=None)
Check if any of the elements of `a` are true.
- Performs a logical_or over the given axis and returns the result
-
- Parameters
- ----------
- axis : {None, integer}
- Axis to perform the operation over.
- If None, perform over flattened array and return a scalar.
- out : {None, array}, optional
- Array into which the result can be placed. Its type is preserved
- and it must be of the right shape to hold the output.
+ Refer to `numpy.any` for full documentation.
See Also
--------
- any : equivalent function
+ numpy.any : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('argmax',
- """a.argmax(axis=None, out=None)
+ """
+ a.argmax(axis=None, out=None)
- Returns array of indices of the maximum values along the given axis.
+ Return indices of the maximum values along the given axis of `a`.
Parameters
----------
- axis : {None, integer}
- If None, the index is into the flattened array, otherwise along
- the specified axis
- out : {None, array}, optional
- Array into which the result can be placed. Its type is preserved
- and it must be of the right shape to hold the output.
+ axis : int, optional
+ Axis along which to operate. By default flattened input is used.
+ out : ndarray, optional
+ Alternative output array in which to place the result. Must
+ be of the same shape and buffer length as the expected output.
Returns
-------
- index_array : {integer_array}
+ index_array : {ndarray, int}
+ An array of indices or single index value, or a reference to `out`
+ if it was specified.
Examples
--------
@@ -870,94 +1560,50 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('argmax',
add_newdoc('numpy.core.multiarray', 'ndarray', ('argmin',
- """a.argmin(axis=None, out=None)
-
- Return array of indices to the minimum values along the given axis.
-
- Parameters
- ----------
- axis : {None, integer}
- If None, the index is into the flattened array, otherwise along
- the specified axis
- out : {None, array}, optional
- Array into which the result can be placed. Its type is preserved
- and it must be of the right shape to hold the output.
+ """
+ a.argmin(axis=None, out=None)
- Returns
- -------
- index_array : {integer_array}
+ Return indices of the minimum values along the given axis of `a`.
- Examples
- --------
- >>> a = np.arange(6).reshape(2,3)
- >>> a.argmin()
- 0
- >>> a.argmin(0)
- array([0, 0, 0])
- >>> a.argmin(1)
- array([0, 0])
+ Refer to `numpy.ndarray.argmax` for detailed documentation.
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('argsort',
- """a.argsort(axis=-1, kind='quicksort', order=None) -> indices
-
- Perform an indirect sort along the given axis using the algorithm specified
- by the kind keyword. It returns an array of indices of the same shape as
- 'a' that index data along the given axis in sorted order.
+ """
+ a.argsort(axis=-1, kind='quicksort', order=None)
- Parameters
- ----------
- axis : integer
- Axis to be indirectly sorted. None indicates that the flattened
- array should be used. Default is -1.
- kind : string
- Sorting algorithm to use. Possible values are 'quicksort',
- 'mergesort', or 'heapsort'. Default is 'quicksort'.
- order : list type or None
- When a is an array with fields defined, this argument specifies
- which fields to compare first, second, etc. Not all fields need be
- specified.
+ Returns the indices that would sort this array.
- Returns
- -------
- indices : integer array
- Array of indices that sort 'a' along the specified axis.
+ Refer to `numpy.argsort` for full documentation.
See Also
--------
- lexsort : indirect stable sort with multiple keys
- sort : inplace sort
+ numpy.argsort : equivalent function
- Notes
- -----
- The various sorts are characterized by average speed, worst case
- performance, need for work space, and whether they are stable. A stable
- sort keeps items with the same key in the same relative order. The three
- available algorithms have the following properties:
+ """))
- ============ ======= ============= ============ ========
- kind speed worst case work space stable
- ============ ======= ============= ============ ========
- 'quicksort' 1 O(n^2) 0 no
- 'mergesort' 2 O(n*log(n)) ~n/2 yes
- 'heapsort' 3 O(n*log(n)) 0 no
- ============ ======= ============= ============ ========
- All the sort algorithms make temporary copies of the data when the
- sort is not along the last axis. Consequently, sorts along the
- last axis are faster and use less space than sorts along other
- axis.
+add_newdoc('numpy.core.multiarray', 'ndarray', ('astype',
+ """
+ a.astype(t)
- """))
+ Copy of the array, cast to a specified type.
+ Parameters
+ ----------
+ t : string or dtype
+ Typecode or data-type to which the array is cast.
-add_newdoc('numpy.core.multiarray', 'ndarray', ('astype',
- """a.astype(t) -> Copy of array cast to type t.
+ Examples
+ --------
+ >>> x = np.array([1, 2, 2.5])
+ >>> x
+ array([ 1. , 2. , 2.5])
- Cast array m to type t. t can be either a string representing a typecode,
- or a python type object of type int, float, or complex.
+ >>> x.astype(int)
+ array([1, 2, 2])
"""))
@@ -977,106 +1623,41 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('choose',
Use an index array to construct a new array from a set of choices.
- Given an array of integers and a set of n choice arrays, this method
- will create a new array that merges each of the choice arrays. Where a
- value in `a` is i, the new array will have the value that choices[i]
- contains in the same place.
-
- Parameters
- ----------
- choices : sequence of arrays
- Choice arrays. The index array and all of the choices should be
- broadcastable to the same shape.
- out : array, optional
- If provided, the result will be inserted into this array. It should
- be of the appropriate shape and dtype
- mode : {'raise', 'wrap', 'clip'}, optional
- Specifies how out-of-bounds indices will behave.
- 'raise' : raise an error
- 'wrap' : wrap around
- 'clip' : clip to the range
-
- Returns
- -------
- merged_array : array
+ Refer to `numpy.choose` for full documentation.
See Also
--------
- choose : equivalent function
-
- Examples
- --------
- >>> choices = [[0, 1, 2, 3], [10, 11, 12, 13],
- ... [20, 21, 22, 23], [30, 31, 32, 33]]
- >>> a = np.array([2, 3, 1, 0], dtype=int)
- >>> a.choose(choices)
- array([20, 31, 12, 3])
- >>> a = np.array([2, 4, 1, 0], dtype=int)
- >>> a.choose(choices, mode='clip')
- array([20, 31, 12, 3])
- >>> a.choose(choices, mode='wrap')
- array([20, 1, 12, 3])
+ numpy.choose : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('clip',
- """a.clip(a_min, a_max, out=None)
+ """
+ a.clip(a_min, a_max, out=None)
- Return an array whose values are limited to [a_min, a_max].
+ Return an array whose values are limited to ``[a_min, a_max]``.
- Parameters
- ----------
- a_min
- Minimum value
- a_max
- Maximum value
- out : {None, array}, optional
- Array into which the clipped values can be placed. Its type
- is preserved and it must be of the right shape to hold the
- output.
+ Refer to `numpy.clip` for full documentation.
- Returns
- -------
- clipped_array : array
- A new array whose elements are same as for a, but values
- < a_min are replaced with a_min, and > a_max with a_max.
+ See Also
+ --------
+ numpy.clip : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('compress',
- """a.compress(condition, axis=None, out=None)
-
- Return selected slices of an array along given axis.
+ """
+ a.compress(condition, axis=None, out=None)
- Parameters
- ----------
- condition : {array}
- Boolean 1-d array selecting which entries to return. If len(condition)
- is less than the size of a along the axis, then output is truncated
- to length of condition array.
- axis : {None, integer}
- Axis along which to take slices. If None, work on the flattened array.
- out : array, optional
- Output array. Its type is preserved and it must be of the right
- shape to hold the output.
+ Return selected slices of this array along given axis.
- Returns
- -------
- compressed_array : array
- A copy of a, without the slices along axis for which condition is false.
+ Refer to `numpy.compress` for full documentation.
- Examples
+ See Also
--------
- >>> a = np.array([[1, 2], [3, 4]])
- >>> a.compress([0, 1], axis=0)
- array([[3, 4]])
- >>> a.compress([1], axis=1)
- array([[1],
- [3]])
- >>> a.compress([0,1,1])
- array([2, 3])
+ numpy.compress : equivalent function
"""))
@@ -1098,17 +1679,37 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('conjugate',
add_newdoc('numpy.core.multiarray', 'ndarray', ('copy',
- """a.copy([order])
+ """
+ a.copy([order])
Return a copy of the array.
Parameters
----------
order : {'C', 'F', 'A'}, optional
- If order is 'C' (False) then the result is contiguous (default).
- If order is 'Fortran' (True) then the result has fortran order.
- If order is 'Any' (None) then the result has fortran order
- only if the array already is in fortran order.
+ By default, the result is stored in C-contiguous (row-major) order in
+ memory. If `order` is `F`, the result has 'Fortran' (column-major)
+ order. If order is 'A' ('Any'), then the result has the same order
+ as the input.
+
+ Examples
+ --------
+ >>> x = np.array([[1,2,3],[4,5,6]], order='F')
+
+ >>> y = x.copy()
+
+ >>> x.fill(0)
+
+ >>> x
+ array([[0, 0, 0],
+ [0, 0, 0]])
+
+ >>> y
+ array([[1, 2, 3],
+ [4, 5, 6]])
+
+ >>> y.flags['C_CONTIGUOUS']
+ True
"""))
@@ -1119,132 +1720,41 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('cumprod',
Return the cumulative product of the elements along the given axis.
- The cumulative product is taken over the flattened array by
- default, otherwise over the specified axis.
-
- Parameters
- ----------
- axis : {None, -1, int}, optional
- Axis along which the product is computed. The default
- (`axis` = None) is to compute over the flattened array.
- dtype : {None, dtype}, optional
- Determines the type of the returned array and of the accumulator
- where the elements are multiplied. If dtype has the value None and
- the type of a is an integer type of precision less than the default
- platform integer, then the default platform integer precision is
- used. Otherwise, the dtype is the same as that of a.
- out : ndarray, optional
- Alternative output array in which to place the result. It must
- have the same shape and buffer length as the expected output
- but the type will be cast if necessary.
-
- Returns
- -------
- cumprod : ndarray.
- A new array holding the result is returned unless out is
- specified, in which case a reference to out is returned.
+ Refer to `numpy.cumprod` for full documentation.
- Notes
- -----
- Arithmetic is modular when using integer types, and no error is
- raised on overflow.
+ See Also
+ --------
+ numpy.cumprod : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('cumsum',
- """a.cumsum(axis=None, dtype=None, out=None)
+ """
+ a.cumsum(axis=None, dtype=None, out=None)
Return the cumulative sum of the elements along the given axis.
- The cumulative sum is calculated over the flattened array by
- default, otherwise over the specified axis.
+ Refer to `numpy.cumsum` for full documentation.
- Parameters
- ----------
- axis : {None, -1, int}, optional
- Axis along which the sum is computed. The default
- (`axis` = None) is to compute over the flattened array.
- dtype : {None, dtype}, optional
- Determines the type of the returned array and of the accumulator
- where the elements are summed. If dtype has the value None and
- the type of a is an integer type of precision less than the default
- platform integer, then the default platform integer precision is
- used. Otherwise, the dtype is the same as that of a.
- out : ndarray, optional
- Alternative output array in which to place the result. It must
- have the same shape and buffer length as the expected output
- but the type will be cast if necessary.
-
- Returns
- -------
- cumsum : ndarray.
- A new array holding the result is returned unless ``out`` is
- specified, in which case a reference to ``out`` is returned.
-
- Notes
- -----
- Arithmetic is modular when using integer types, and no error is
- raised on overflow.
+ See Also
+ --------
+ numpy.cumsum : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('diagonal',
- """a.diagonal(offset=0, axis1=0, axis2=1)
-
- If a is 2-d, return the diagonal of self with the given offset, i.e., the
- collection of elements of the form a[i,i+offset]. If a is n-d with n > 2,
- then the axes specified by axis1 and axis2 are used to determine the 2-d
- subarray whose diagonal is returned. The shape of the resulting array can
- be determined by removing axis1 and axis2 and appending an index to the
- right equal to the size of the resulting diagonals.
+ """
+ a.diagonal(offset=0, axis1=0, axis2=1)
- Parameters
- ----------
- offset : integer
- Offset of the diagonal from the main diagonal. Can be both positive
- and negative. Defaults to main diagonal.
- axis1 : integer
- Axis to be used as the first axis of the 2-d subarrays from which
- the diagonals should be taken. Defaults to first index.
- axis2 : integer
- Axis to be used as the second axis of the 2-d subarrays from which
- the diagonals should be taken. Defaults to second index.
+ Return specified diagonals.
- Returns
- -------
- array_of_diagonals : same type as original array
- If a is 2-d, then a 1-d array containing the diagonal is returned.
- If a is n-d, n > 2, then an array of diagonals is returned.
+ Refer to `numpy.diagonal` for full documentation.
See Also
--------
- diag : matlab workalike for 1-d and 2-d arrays.
- diagflat : creates diagonal arrays
- trace : sum along diagonals
-
- Examples
- --------
- >>> a = np.arange(4).reshape(2,2)
- >>> a
- array([[0, 1],
- [2, 3]])
- >>> a.diagonal()
- array([0, 3])
- >>> a.diagonal(1)
- array([1])
-
- >>> a = np.arange(8).reshape(2,2,2)
- >>> a
- array([[[0, 1],
- [2, 3]],
- <BLANKLINE>
- [[4, 5],
- [6, 7]]])
- >>> a.diagonal(0,-2,-1)
- array([[0, 3],
- [4, 7]])
+ numpy.diagonal : equivalent function
"""))
@@ -1273,26 +1783,60 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('dumps',
add_newdoc('numpy.core.multiarray', 'ndarray', ('fill',
- """a.fill(value)
+ """
+ a.fill(value)
Fill the array with a scalar value.
+ Parameters
+ ----------
+ a : ndarray
+ Input array
+ value : scalar
+ All elements of `a` will be assigned this value.
+
+ Returns
+ -------
+ None
+
+ Examples
+ --------
+ >>> a = np.array([1, 2])
+ >>> a.fill(0)
+ >>> a
+ array([0, 0])
+ >>> a = np.empty(2)
+ >>> a.fill(1)
+ >>> a
+ array([ 1., 1.])
+
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('flatten',
- """a.flatten([order])
+ """
+ a.flatten(order='C')
- Return a 1-d array (always copy)
+ Collapse an array into one dimension.
Parameters
----------
- order : {'C', 'F'}
- Whether to flatten in C or Fortran order.
+ order : {'C', 'F'}, optional
+ Whether to flatten in C (row-major) or Fortran (column-major) order.
+ The default is 'C'.
- Notes
- -----
- a.flatten('F') == a.T.flatten('C')
+ Returns
+ -------
+ y : ndarray
+ A copy of the input array, flattened to one dimension.
+
+ Examples
+ --------
+ >>> a = np.array([[1,2], [3,4]])
+ >>> a.flatten()
+ array([1, 2, 3, 4])
+ >>> a.flatten('F')
+ array([1, 3, 2, 4])
"""))
@@ -1317,86 +1861,46 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('item',
add_newdoc('numpy.core.multiarray', 'ndarray', ('max',
- """a.max(axis=None, out=None)
+ """
+ a.max(axis=None, out=None)
Return the maximum along a given axis.
- Parameters
- ----------
- axis : {None, int}, optional
- Axis along which to operate. By default, ``axis`` is None and the
- flattened input is used.
- out : array_like, optional
- Alternative output array in which to place the result. Must
- be of the same shape and buffer length as the expected output.
+ Refer to `numpy.amax` for full documentation.
- Returns
- -------
- amax : array_like
- New array holding the result.
- If ``out`` was specified, ``out`` is returned.
+ See Also
+ --------
+ numpy.amax : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('mean',
- """a.mean(axis=None, dtype=None, out=None) -> mean
-
- Returns the average of the array elements. The average is taken over the
- flattened array by default, otherwise over the specified axis.
+ """
+ a.mean(axis=None, dtype=None, out=None)
- Parameters
- ----------
- axis : integer
- Axis along which the means are computed. The default is
- to compute the mean of the flattened array.
- dtype : type
- Type to use in computing the means. For arrays of
- integer type the default is float32, for arrays of float types it
- is the same as the array type.
- out : ndarray
- Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
+ Returns the average of the array elements along given axis.
- Returns
- -------
- mean : The return type varies, see above.
- A new array holding the result is returned unless out is specified,
- in which case a reference to out is returned.
+ Refer to `numpy.mean` for full documentation.
See Also
--------
- var : variance
- std : standard deviation
-
- Notes
- -----
- The mean is the sum of the elements along the axis divided by the
- number of elements.
+ numpy.mean : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('min',
- """a.min(axis=None, out=None)
+ """
+ a.min(axis=None, out=None)
Return the minimum along a given axis.
- Parameters
- ----------
- axis : {None, int}, optional
- Axis along which to operate. By default, ``axis`` is None and the
- flattened input is used.
- out : array_like, optional
- Alternative output array in which to place the result. Must
- be of the same shape and buffer length as the expected output.
+ Refer to `numpy.amin` for full documentation.
- Returns
- -------
- amin : array_like
- New array holding the result.
- If ``out`` was specified, ``out`` is returned.
+ See Also
+ --------
+ numpy.amin : equivalent function
"""))
@@ -1410,365 +1914,234 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('newbyteorder',
add_newdoc('numpy.core.multiarray', 'ndarray', ('nonzero',
- """a.nonzero()
-
- Returns a tuple of arrays, one for each dimension of a, containing
- the indices of the non-zero elements in that dimension. The
- corresponding non-zero values can be obtained with::
-
- a[a.nonzero()]
+ """
+ a.nonzero()
- To group the indices by element, rather than dimension, use::
+ Return the indices of the elements of a which are not zero.
- transpose(a.nonzero())
+ Refer to `numpy.nonzero` for full documentation.
- instead. The result of this is always a 2d array, with a row for
- each non-zero element.
+ See Also
+ --------
+ numpy.nonzero : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('prod',
- """a.prod(axis=None, dtype=None, out=None)
+ """
+ a.prod(axis=None, dtype=None, out=None)
Return the product of the array elements over the given axis
- Parameters
- ----------
- axis : {None, integer}
- Axis over which the product is taken. If None is used, then the
- product is over all the array elements.
- dtype : {None, dtype}, optional
- Determines the type of the returned array and of the accumulator
- where the elements are multiplied. If dtype has the value None and
- the type of a is an integer type of precision less than the default
- platform integer, then the default platform integer precision is
- used. Otherwise, the dtype is the same as that of a.
- out : {None, array}, optional
- Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
-
- Returns
- -------
- product_along_axis : {array, scalar}, see dtype parameter above.
- Returns an array whose shape is the same as a with the specified
- axis removed. Returns a 0d array when a is 1d or axis=None.
- Returns a reference to the specified output array if specified.
+ Refer to `numpy.prod` for full documentation.
See Also
--------
- prod : equivalent function
-
- Examples
- --------
- >>> np.prod([1.,2.])
- 2.0
- >>> np.prod([1.,2.], dtype=np.int32)
- 2
- >>> np.prod([[1.,2.],[3.,4.]])
- 24.0
- >>> np.prod([[1.,2.],[3.,4.]], axis=1)
- array([ 2., 12.])
-
- Notes
- -----
- Arithmetic is modular when using integer types, and no error is
- raised on overflow.
+ numpy.prod : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('ptp',
- """a.ptp(axis=None, out=None)
+ """
+ a.ptp(axis=None, out=None)
- Return (maximum - minimum) along the the given dimension
- (i.e. peak-to-peak value).
+ Peak to peak (maximum - minimum) value along a given axis.
- Parameters
- ----------
- axis : {None, int}, optional
- Axis along which to find the peaks. If None (default) the
- flattened array is used.
- out : array_like
- Alternative output array in which to place the result. It must
- have the same shape and buffer length as the expected output
- but the type will be cast if necessary.
+ Refer to `numpy.ptp` for full documentation.
- Returns
- -------
- ptp : ndarray.
- A new array holding the result, unless ``out`` was
- specified, in which case a reference to ``out`` is returned.
-
- Examples
+ See Also
--------
- >>> x = np.arange(4).reshape((2,2))
- >>> x
- array([[0, 1],
- [2, 3]])
- >>> x.ptp(0)
- array([2, 2])
- >>> x.ptp(1)
- array([1, 1])
+ numpy.ptp : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('put',
- """a.put(indices, values, mode='raise')
+ """
+ a.put(indices, values, mode='raise')
Set a.flat[n] = values[n] for all n in indices.
- If values is shorter than indices, it will repeat.
-
- Parameters
- ----------
- indices : array_like
- Target indices, interpreted as integers.
- values : array_like
- Values to place in `a` at target indices.
- mode : {'raise', 'wrap', 'clip'}
- Specifies how out-of-bounds indices will behave.
- 'raise' -- raise an error
- 'wrap' -- wrap around
- 'clip' -- clip to the range
-
- Notes
- -----
- If v is shorter than mask it will be repeated as necessary. In particular v
- can be a scalar or length 1 array. The routine put is the equivalent of the
- following (although the loop is in C for speed):
- ind = array(indices, copy=False)
- v = array(values, copy=False).astype(a.dtype)
- for i in ind: a.flat[i] = v[i]
+ Refer to `numpy.put` for full documentation.
- Examples
+ See Also
--------
- >>> x = np.arange(5)
- >>> x.put([0,2,4],[-1,-2,-3])
- >>> print x
- [-1 1 -2 3 -3]
+ numpy.put : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'putmask',
- """putmask(a, mask, values)
+ """
+ putmask(a, mask, values)
Sets a.flat[n] = values[n] for each n where mask.flat[n] is true.
- If values is not the same size as `a` and `mask` then it will repeat.
+ If `values` is not the same size as `a` and `mask` then it will repeat.
This gives behavior different from a[mask] = values.
Parameters
----------
- a : {array_like}
+ a : array_like
Array to put data into
- mask : {array_like}
+ mask : array_like
Boolean mask array
- values : {array_like}
+ values : array_like
Values to put
- """)
+ See Also
+ --------
+ put, take
+ Examples
+ --------
+ >>> a = np.array([10,20,30,40])
+ >>> mask = np.array([True,False,True,True])
+ >>> a.putmask([60,70,80,90], mask)
+ >>> a
+ array([60, 20, 80, 90])
+ >>> a = np.array([10,20,30,40])
+ >>> a[mask]
+ array([60, 80, 90])
+ >>> a[mask] = np.array([60,70,80,90])
+ >>> a
+ array([60, 20, 70, 80])
+ >>> a.putmask([10,90], mask)
+ >>> a
+ array([10, 20, 10, 90])
+ >>> np.putmask(a, mask, [60,70,80,90])
-add_newdoc('numpy.core.multiarray', 'ndarray', ('ravel',
- """a.ravel([order])
+ """)
- Return a 1d array containing the elements of a (copy only if needed).
- The elements in the new array are taken in the order specified by
- the order keyword. The new array is a view of a if possible,
- otherwise it is a copy.
+add_newdoc('numpy.core.multiarray', 'ndarray', ('ravel',
+ """
+ a.ravel([order])
- Parameters
- ----------
- order : {'C','F'}, optional
- If order is 'C' the elements are taken in row major order. If order
- is 'F' they are taken in column major order.
+ Return a flattened array.
- Returns
- -------
- 1d_array : {array}
+ Refer to `numpy.ravel` for full documentation.
See Also
--------
- ndarray.flat : 1d iterator over the array.
- ndarray.flatten : 1d array copy of the elements of a in C order.
-
- Examples
- --------
- >>> x = np.array([[1,2,3],[4,5,6]])
- >>> x
- array([[1, 2, 3],
- [4, 5, 6]])
- >>> x.ravel()
- array([1, 2, 3, 4, 5, 6])
+ numpy.ravel : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('repeat',
- """a.repeat(repeats, axis=None)
+ """
+ a.repeat(repeats, axis=None)
Repeat elements of an array.
- Parameters
- ----------
- a : {array_like}
- Input array.
- repeats : {integer, integer_array}
- The number of repetitions for each element. If a plain integer, then
- it is applied to all elements. If an array, it needs to be of the
- same length as the chosen axis.
- axis : {None, integer}, optional
- The axis along which to repeat values. If None, then this method
- will operated on the flattened array `a` and return a similarly flat
- result.
-
- Returns
- -------
- repeated_array : array
+ Refer to `numpy.repeat` for full documentation.
- See also
- --------
- tile : tile an array
-
- Examples
+ See Also
--------
- >>> x = np.array([[1,2],[3,4]])
- >>> x.repeat(2)
- array([1, 1, 2, 2, 3, 3, 4, 4])
- >>> x.repeat(3, axis=1)
- array([[1, 1, 1, 2, 2, 2],
- [3, 3, 3, 4, 4, 4]])
- >>> x.repeat([1, 2], axis=0)
- array([[1, 2],
- [3, 4],
- [3, 4]])
+ numpy.repeat : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('reshape',
- """a.reshape(shape, order='C')
+ """
+ a.reshape(shape, order='C')
Returns an array containing the data of a, but with a new shape.
- The result is a view to the original array; if this is not possible,
- a ValueError is raised.
+ Refer to `numpy.reshape` for full documentation.
+
+ See Also
+ --------
+ numpy.reshape : equivalent function
+
+ """))
+
+
+add_newdoc('numpy.core.multiarray', 'ndarray', ('resize',
+ """
+ a.resize(new_shape, refcheck=True, order=False)
+
+ Change shape and size of array in-place.
Parameters
----------
- shape : shape tuple or int
- The new shape should be compatible with the original shape. If an
- integer, then the result will be a 1D array of that length.
- order : {'C', 'F'}, optional
- Determines whether the array data should be viewed as in C
- (row-major) order or FORTRAN (column-major) order.
+ a : ndarray
+ Input array.
+ new_shape : {tuple, int}
+ Shape of resized array.
+ refcheck : bool, optional
+ If False, memory referencing will not be checked. Default is True.
+ order : bool, optional
+ <needs an explanation>. Default if False.
Returns
-------
- reshaped_array : array
- A new view to the array.
+ None
- """))
+ Raises
+ ------
+ ValueError
+ If `a` does not own its own data, or references or views to it exist.
+
+ Examples
+ --------
+ Shrinking an array: array is flattened in C-order, resized, and reshaped:
+
+ >>> a = np.array([[0,1],[2,3]])
+ >>> a.resize((2,1))
+ >>> a
+ array([[0],
+ [1]])
+ Enlarging an array: as above, but missing entries are filled with zeros:
-add_newdoc('numpy.core.multiarray', 'ndarray', ('resize',
- """a.resize(new_shape, refcheck=True, order=False)
+ >>> b = np.array([[0,1],[2,3]])
+ >>> b.resize((2,3))
+ >>> b
+ array([[0, 1, 2],
+ [3, 0, 0]])
+
+ Referencing an array prevents resizing:
- Change size and shape of self inplace. Array must own its own memory and
- not be referenced by other arrays. Returns None.
+ >>> c = a
+ >>> a.resize((1,1))
+ Traceback (most recent call last):
+ ...
+ ValueError: cannot resize an array that has been referenced ...
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('round',
- """a.round(decimals=0, out=None)
+ """
+ a.round(decimals=0, out=None)
Return an array rounded a to the given number of decimals.
- The real and imaginary parts of complex numbers are rounded separately. The
- result of rounding a float is a float so the type must be cast if integers
- are desired. Nothing is done if the input is an integer array and the
- decimals parameter has a value >= 0.
-
- Parameters
- ----------
- decimals : {0, integer}, optional
- Number of decimal places to round to. When decimals is negative it
- specifies the number of positions to the left of the decimal point.
- out : {None, array}, optional
- Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
-
- Returns
- -------
- rounded_array : {array}
- If out=None, returns a new array of the same type as a containing
- the rounded values, otherwise a reference to the output array is
- returned.
+ Refer to `numpy.around` for full documentation.
See Also
--------
- around : equivalent function
-
- Notes
- -----
- Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round
- to 0.0, etc. Results may also be surprising due to the inexact
- representation of decimal fractions in IEEE floating point and the
- errors introduced when scaling by powers of ten.
-
- Examples
- --------
- >>> x = np.array([.5, 1.5, 2.5, 3.5, 4.5])
- >>> x.round()
- array([ 0., 2., 2., 4., 4.])
- >>> x = np.array([1,2,3,11])
- >>> x.round(decimals=1)
- array([ 1, 2, 3, 11])
- >>> x.round(decimals=-1)
- array([ 0, 0, 0, 10])
+ numpy.around : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('searchsorted',
- """a.searchsorted(v, side='left')
-
- Find the indices into a sorted array such that if the corresponding keys in
- v were inserted before the indices the order of a would be preserved. If
- side='left', then the first such index is returned. If side='right', then
- the last such index is returned. If there is no such index because the key
- is out of bounds, then the length of a is returned, i.e., the key would
- need to be appended. The returned index array has the same shape as v.
+ """
+ a.searchsorted(v, side='left')
- Parameters
- ----------
- v : array or list type
- Array of keys to be searched for in a.
- side : string
- Possible values are : 'left', 'right'. Default is 'left'. Return
- the first or last index where the key could be inserted.
+ Find indices where elements of v should be inserted in a to maintain order.
- Returns
- -------
- indices : integer array
- The returned array has the same shape as v.
+ For full documentation, see `numpy.searchsorted`
- See also
+ See Also
--------
- sort
- histogram
-
- Notes
- -----
- The array a must be 1-d and is assumed to be sorted in ascending order.
- Searchsorted uses binary search to find the required insertion points.
+ numpy.searchsorted : equivalent function
"""))
@@ -1787,10 +2160,10 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('setflags',
add_newdoc('numpy.core.multiarray', 'ndarray', ('sort',
- """a.sort(axis=-1, kind='quicksort', order=None) -> None.
+ """
+ a.sort(axis=-1, kind='quicksort', order=None)
- Perform an inplace sort along the given axis using the algorithm specified
- by the kind keyword.
+ Sort an array, in-place.
Parameters
----------
@@ -1813,7 +2186,6 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('sort',
Notes
-----
-
The various sorts are characterized by average speed, worst case
performance, need for work space, and whether they are stable. A stable
sort keeps items with the same key in the same relative order. The three
@@ -1830,193 +2202,81 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('sort',
All the sort algorithms make temporary copies of the data when the sort is
not along the last axis. Consequently, sorts along the last axis are faster
and use less space than sorts along other axis.
+
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('squeeze',
- """m.squeeze()
+ """
+ a.squeeze()
- Remove single-dimensional entries from the shape of a.
+ Remove single-dimensional entries from the shape of `a`.
- Examples
+ Refer to `numpy.squeeze` for full documentation.
+
+ See Also
--------
- >>> x = np.array([[[1,1,1],[2,2,2],[3,3,3]]])
- >>> x.shape
- (1, 3, 3)
- >>> x.squeeze().shape
- (3, 3)
+ numpy.squeeze : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('std',
- """a.std(axis=None, dtype=None, out=None, ddof=0)
-
- Returns the standard deviation of the array elements, a measure of the
- spread of a distribution. The standard deviation is computed for the
- flattened array by default, otherwise over the specified axis.
+ """
+ a.std(axis=None, dtype=None, out=None, ddof=0)
- Parameters
- ----------
- axis : integer
- Axis along which the standard deviation is computed. The default is
- to compute the standard deviation of the flattened array.
- dtype : type
- Type to use in computing the standard deviation. For arrays of
- integer type the default is float32, for arrays of float types it
- is the same as the array type.
- out : ndarray
- Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
- ddof : {0, integer}
- Means Delta Degrees of Freedom. The divisor used in calculations
- is N-ddof.
+ Returns the standard deviation of the array elements along given axis.
- Returns
- -------
- standard deviation : The return type varies, see above.
- A new array holding the result is returned unless out is specified,
- in which case a reference to out is returned.
+ Refer to `numpy.std` for full documentation.
See Also
--------
- var : variance
- mean : average
-
- Notes
- -----
- The standard deviation is the square root of the average of the squared
- deviations from the mean, i.e. var = sqrt(mean(abs(x - x.mean())**2)). The
- computed standard deviation is computed by dividing by the number of
- elements, N-ddof. The option ddof defaults to zero, that is, a biased
- estimate. Note that for complex numbers std takes the absolute value before
- squaring, so that the result is always real and nonnegative.
+ numpy.std : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('sum',
- """a.sum(axis=None, dtype=None, out=None)
+ """
+ a.sum(axis=None, dtype=None, out=None)
- Return the sum of the array elements over the given axis
+ Return the sum of the array elements over the given axis.
- Parameters
- ----------
- axis : {None, integer}
- Axis over which the sum is taken. If None is used, then the sum is
- over all the array elements.
- dtype : {None, dtype}, optional
- Determines the type of the returned array and of the accumulator where
- the elements are summed. If dtype has the value None and the type of a
- is an integer type of precision less than the default platform integer,
- then the default platform integer precision is used. Otherwise, the
- dtype is the same as that of a.
- out : {None, array}, optional
- Array into which the sum can be placed. Its type is preserved and it
- must be of the right shape to hold the output.
-
- Returns
- -------
- sum_along_axis : {array, scalar}, see dtype parameter above.
- Returns an array whose shape is the same as a with the specified axis
- removed. Returns a 0d array when a is 1d or axis=None. Returns a
- reference to the specified output array if specified.
+ Refer to `numpy.sum` for full documentation.
See Also
--------
- sum : equivalent function
-
- Examples
- --------
- >>> np.array([0.5, 1.5]).sum()
- 2.0
- >>> np.array([0.5, 1.5]).sum(dtype=np.int32)
- 1
- >>> np.array([[0, 1], [0, 5]]).sum(axis=0)
- array([0, 6])
- >>> np.array([[0, 1], [0, 5]]).sum(axis=1)
- array([1, 5])
- >>> np.ones(128, dtype=np.int8).sum(dtype=np.int8) # overflow!
- -128
-
- Notes
- -----
- Arithmetic is modular when using integer types, and no error is
- raised on overflow.
+ numpy.sum : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('swapaxes',
- """a.swapaxes(axis1, axis2)
+ """
+ a.swapaxes(axis1, axis2)
- Return a view of the array with axis1 and axis2 interchanged.
+ Return a view of the array with `axis1` and `axis2` interchanged.
- Parameters
- ----------
- axis1 : int
- First axis.
- axis2 : int
- Second axis.
+ Refer to `numpy.swapaxes` for full documentation.
- Examples
+ See Also
--------
- >>> x = np.array([[1,2,3]])
- >>> x.swapaxes(0,1)
- array([[1],
- [2],
- [3]])
-
- >>> x = np.array([[[0,1],[2,3]],[[4,5],[6,7]]])
- >>> x
- array([[[0, 1],
- [2, 3]],
- <BLANKLINE>
- [[4, 5],
- [6, 7]]])
- >>> x.swapaxes(0,2)
- array([[[0, 4],
- [2, 6]],
- <BLANKLINE>
- [[1, 5],
- [3, 7]]])
+ numpy.swapaxes : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('take',
- """a.take(indices, axis=None, out=None, mode='raise')
+ """
+ a.take(indices, axis=None, out=None, mode='raise')
Return an array formed from the elements of a at the given indices.
- This method does the same thing as "fancy" indexing; however, it can
- be easier to use if you need to specify a given axis.
-
- Parameters
- ----------
- indices : int array
- The indices of the values to extract.
- axis : {None, int}, optional
- The axis over which to select values. None signifies that the
- operation should be performed over the flattened array.
- out : {None, array}, optional
- If provided, the result will be inserted into this array. It should
- be of the appropriate shape and dtype.
- mode : {'raise', 'wrap', 'clip'}, optional
- Specifies how out-of-bounds indices will behave.
- 'raise' -- raise an error
- 'wrap' -- wrap around
- 'clip' -- clip to the range
-
- Returns
- -------
- subarray : array
- The returned array has the same type as a.
+ Refer to `numpy.take` for full documentation.
See Also
--------
- take : equivalent function
+ numpy.take : equivalent function
"""))
@@ -2053,12 +2313,31 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('tofile',
add_newdoc('numpy.core.multiarray', 'ndarray', ('tolist',
- """a.tolist()
+ """
+ a.tolist()
- Return the array as nested lists.
+ Return the array as a list or nested lists.
- Copy the data portion of the array to a hierarchical Python list and return
- that list. Data items are converted to the nearest compatible Python type.
+ Parameters
+ ----------
+ a : ndarray
+ Input array.
+
+ Returns
+ -------
+ y : list
+ Copy the data portion of the array to a hierarchical Python list and
+ return that list. Data items are converted to the nearest compatible
+ Python type.
+
+ Examples
+ --------
+ >>> a = np.array([1, 2])
+ >>> a.tolist()
+ [1, 2]
+ >>> a = np.array([[1, 2], [3, 4]])
+ >>> a.tolist()
+ [[1, 2], [3, 4]]
"""))
@@ -2078,53 +2357,16 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('tostring',
add_newdoc('numpy.core.multiarray', 'ndarray', ('trace',
- """a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)
+ """
+ a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)
Return the sum along diagonals of the array.
- If a is 2-d, returns the sum along the diagonal of self with the given
- offset, i.e., the collection of elements of the form a[i,i+offset]. If a
- has more than two dimensions, then the axes specified by axis1 and axis2
- are used to determine the 2-d subarray whose trace is returned. The shape
- of the resulting array can be determined by removing axis1 and axis2 and
- appending an index to the right equal to the size of the resulting
- diagonals.
-
- Parameters
- ----------
- offset : {0, integer}, optional
- Offset of the diagonal from the main diagonal. Can be both positive
- and negative. Defaults to main diagonal.
- axis1 : {0, integer}, optional
- Axis to be used as the first axis of the 2-d subarrays from which
- the diagonals should be taken. Defaults to first axis.
- axis2 : {1, integer}, optional
- Axis to be used as the second axis of the 2-d subarrays from which
- the diagonals should be taken. Defaults to second axis.
- dtype : {None, dtype}, optional
- Determines the type of the returned array and of the accumulator
- where the elements are summed. If dtype has the value None and a is
- of integer type of precision less than the default integer
- precision, then the default integer precision is used. Otherwise,
- the precision is the same as that of a.
- out : {None, array}, optional
- Array into which the sum can be placed. Its type is preserved and
- it must be of the right shape to hold the output.
-
- Returns
- -------
- sum_along_diagonals : array
- If a is 2-d, a 0-d array containing the diagonal is
- returned. If a has larger dimensions, then an array of
- diagonals is returned.
+ Refer to `numpy.trace` for full documentation.
- Examples
+ See Also
--------
- >>> np.eye(3).trace()
- 3.0
- >>> a = np.arange(8).reshape((2,2,2))
- >>> a.trace()
- array([6, 8])
+ numpy.trace : equivalent function
"""))
@@ -2157,54 +2399,23 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('transpose',
add_newdoc('numpy.core.multiarray', 'ndarray', ('var',
- """a.var(axis=None, dtype=None, out=None, ddof=0) -> variance
+ """
+ a.var(axis=None, dtype=None, out=None, ddof=0)
- Returns the variance of the array elements, a measure of the spread of a
- distribution. The variance is computed for the flattened array by default,
- otherwise over the specified axis.
+ Returns the variance of the array elements, along given axis.
- Parameters
- ----------
- axis : integer
- Axis along which the variance is computed. The default is to
- compute the variance of the flattened array.
- dtype : data-type
- Type to use in computing the variance. For arrays of integer type
- the default is float32, for arrays of float types it is the same as
- the array type.
- out : ndarray
- Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
- ddof : {0, integer},
- Means Delta Degrees of Freedom. The divisor used in calculation is
- N - ddof.
-
- Returns
- -------
- variance : The return type varies, see above.
- A new array holding the result is returned unless out is specified,
- in which case a reference to out is returned.
+ Refer to `numpy.var` for full documentation.
See Also
--------
- std : standard deviation
- mean: average
-
- Notes
- -----
- The variance is the average of the squared deviations from the mean,
- i.e. var = mean(abs(x - x.mean())**2). The mean is computed by
- dividing by N-ddof, where N is the number of elements. The argument
- ddof defaults to zero; for an unbiased estimate supply ddof=1. Note
- that for complex numbers the absolute value is taken before squaring,
- so that the result is always real and nonnegative.
+ numpy.var : equivalent function
"""))
add_newdoc('numpy.core.multiarray', 'ndarray', ('view',
- """a.view(dtype=None, type=None)
+ """
+ a.view(dtype=None, type=None)
New view of array with the same data.
@@ -2217,15 +2428,29 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('view',
Examples
--------
- >>> x = np.array([(1,2)],dtype=[('a',np.int8),('b',np.int8)])
- >>> y = x.view(dtype=np.int16, type=np.matrix)
+ >>> x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])
+ Viewing array data using a different type and dtype:
+
+ >>> y = x.view(dtype=np.int16, type=np.matrix)
>>> print y.dtype
int16
>>> print type(y)
<class 'numpy.core.defmatrix.matrix'>
+ Using a view to convert an array to a record array:
+
+ >>> z = x.view(np.recarray)
+ >>> z.a
+ array([1], dtype=int8)
+
+ Views share data:
+
+ >>> x[0] = (9, 10)
+ >>> z[0]
+ (9, 10)
+
"""))
add_newdoc('numpy.core.umath','geterrobj',
@@ -2304,147 +2529,148 @@ add_newdoc("numpy.core","ufunc",
""")
-add_newdoc("numpy.core","ufunc",("reduce",
- """reduce(array,axis=0,dtype=None,out=None)
+add_newdoc('numpy.core', 'ufunc', ('reduce',
+ """
+ reduce(array, axis=0, dtype=None, out=None)
- Reduce applies the operator to all elements of the array producing
- a single result.
+ Reduce applies the operator to all elements of the array.
For a one-dimensional array, reduce produces results equivalent to:
- r = op.identity
- for i in xrange(len(A)):
- r = op(r,A[i])
- return r
+ ::
- For example, add.reduce() is equivalent to sum().
+ r = op.identity
+ for i in xrange(len(A)):
+ r = op(r,A[i])
+ return r
- Parameters:
- -----------
+ For example, add.reduce() is equivalent to sum().
+ Parameters
+ ----------
array : array-like
The array to act on.
axis : integer
The axis along which to apply the reduction.
- dtype : data type or None
+ dtype : {data-type-code, None}
The type used to represent the intermediate results. Defaults
to the data type of the output array if this is provided, or
the data type of the input array if no output array is provided.
- out : array-like or None
+ out : {array-like, None}
A location into which the result is stored. If not provided a
freshly-allocated array is returned.
- Returns:
- --------
-
- r : array
+ Returns
+ -------
+ r : {array, scalar}
The reduced values. If out was supplied, r is equal to out.
- Example:
+ Examples
--------
>>> np.multiply.reduce([2,3,5])
30
"""))
-add_newdoc("numpy.core","ufunc",("accumulate",
- """accumulate(array,axis=None,dtype=None,out=None)
+add_newdoc('numpy.core', 'ufunc', ('accumulate',
+ """
+ accumulate(array, axis=None, dtype=None, out=None)
- Accumulate applies the operator to all elements of the array producing
- cumulative results.
+ Accumulate the result of applying the operator to all elements.
For a one-dimensional array, accumulate produces results equivalent to:
- r = np.empty(len(A))
- t = op.identity
- for i in xrange(len(A)):
+ ::
+
+ r = np.empty(len(A))
+ t = op.identity
+ for i in xrange(len(A)):
t = op(t,A[i])
r[i] = t
- return r
+ return r
For example, add.accumulate() is equivalent to cumsum().
- Parameters:
- -----------
-
- array : array-like
+ Parameters
+ ----------
+ array : array_like
The array to act on.
- axis : integer
+ axis : int, optional
The axis along which to apply the accumulation.
- dtype : data type or None
+ dtype : data-type-code, optional
The type used to represent the intermediate results. Defaults
to the data type of the output array if this is provided, or
the data type of the input array if no output array is provided.
- out : array-like or None
+ out : ndarray, optional
A location into which the result is stored. If not provided a
freshly-allocated array is returned.
- Returns:
- --------
-
- r : array
- The accumulated values. If out was supplied, r is equal to out.
+ Returns
+ -------
+ r : ndarray
+ The accumulated values. If `out` was supplied, `r` is equal to
+ `out`.
- Example:
+ Examples
--------
>>> np.multiply.accumulate([2,3,5])
array([2,6,30])
"""))
-add_newdoc("numpy.core","ufunc",("reduceat",
- """reduceat(self,array,indices,axis=None,dtype=None,out=None)
+add_newdoc('numpy.core', 'ufunc', ('reduceat',
+ """
+ reduceat(self, array, indices, axis=None, dtype=None, out=None)
- Reduceat performs a reduce over an axis using the indices as a guide
+ Reduceat performs a reduce with specified slices over an axis.
- op.reduceat(array,indices) computes
- op.reduce(array[indices[i]:indices[i+1]])
- for i=0..end with an implicit indices[i+1]=len(array)
- assumed when i=end-1
+ Computes op.reduce(`array[indices[i]:indices[i+1]]`)
+ for i=0..end with an implicit `indices[i+1]` = len(`array`)
+ assumed when i = end - 1.
- if indices[i+1] <= indices[i]+1
- then the result is array[indices[i]] for that value
+ If `indices[i]` >= `indices[i + 1]`
+ then the result is `array[indices[i]]` for that value.
- op.accumulate(array) is the same as
- op.reduceat(array,indices)[::2]
- where indices is range(len(array)-1) with a zero placed
+ The function op.accumulate(`array`) is the same as
+ op.reduceat(`array`, `indices`)[::2]
+ where `indices` is range(len(`array`)-1) with a zero placed
in every other sample:
- indices = zeros(len(array)*2-1)
- indices[1::2] = range(1,len(array))
-
- output shape is based on the size of indices
+ `indices` = zeros(len(`array`)*2 - 1)
+ `indices[1::2]` = range(1, len(`array`))
- Parameters:
- -----------
+ The output shape is based on the size of `indices`.
- array : array-like
+ Parameters
+ ----------
+ array : array_like
The array to act on.
- indices : array-like
- Indices specifying ranges to reduce.
- axis : integer
+ indices : array_like
+ Paired indices specifying slices to reduce.
+ axis : int, optional
The axis along which to apply the reduceat.
- dtype : data type or None
+ dtype : data-type-code, optional
The type used to represent the intermediate results. Defaults
to the data type of the output array if this is provided, or
the data type of the input array if no output array is provided.
- out : array-like or None
+ out : ndarray, optional
A location into which the result is stored. If not provided a
freshly-allocated array is returned.
- Returns:
- --------
-
+ Returns
+ -------
r : array
- The reduced values. If out was supplied, r is equal to out.
+ The reduced values. If `out` was supplied, `r` is equal to `out`.
- Example:
+ Examples
--------
To take the running sum of four successive values:
- >>> np.multiply.reduceat(np.arange(8),[0,4, 1,5, 2,6, 3,7])[::2]
+
+ >>> np.add.reduceat(np.arange(8),[0,4, 1,5, 2,6, 3,7])[::2]
array([ 6, 10, 14, 18])
"""))
-add_newdoc("numpy.core","ufunc",("outer",
- """outer(A,B)
+add_newdoc('numpy.core', 'ufunc', ('outer',
+ """
+ outer(A,B)
Compute the result of applying op to all pairs (a,b)
@@ -2453,23 +2679,28 @@ add_newdoc("numpy.core","ufunc",("outer",
where A has B.ndim new axes appended and B has A.ndim new axes prepended.
For A and B one-dimensional, this is equivalent to
- r = empty(len(A),len(B))
- for i in xrange(len(A)):
- for j in xrange(len(B)):
- r[i,j] = A[i]*B[j]
- If A and B are higher-dimensional, the result has dimension A.ndim+B.ndim
+ ::
+
+ r = empty(len(A),len(B))
+ for i in xrange(len(A)):
+ for j in xrange(len(B)):
+ r[i,j] = A[i]*B[j]
- Parameters:
- -----------
+ If A and B are higher-dimensional, the result has dimension A.ndim+B.ndim
+ Parameters
+ ----------
A : array-like
+ First term
B : array-like
+ Second term
- Returns:
- --------
-
+ Returns
+ -------
r : array
- Example:
+ Output array
+
+ Examples
--------
>>> np.multiply.outer([1,2,3],[4,5,6])
array([[ 4, 5, 6],
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index 377457e23..8400802f7 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -34,27 +34,60 @@ _inf_str = 'Inf'
def set_printoptions(precision=None, threshold=None, edgeitems=None,
linewidth=None, suppress=None,
nanstr=None, infstr=None):
- """Set options associated with printing.
-
- :Parameters:
- precision : int
- Number of digits of precision for floating point output (default 8).
- threshold : int
- Total number of array elements which trigger summarization
- rather than full repr (default 1000).
- edgeitems : int
- Number of array items in summary at beginning and end of
- each dimension (default 3).
- linewidth : int
- The number of characters per line for the purpose of inserting
- line breaks (default 75).
- suppress : bool
- Whether or not suppress printing of small floating point values
- using scientific notation (default False).
- nanstr : string
- String representation of floating point not-a-number (default nan).
- infstr : string
- String representation of floating point infinity (default inf).
+ """
+ Set printing options.
+
+ These options determine the way floating point numbers, arrays and
+ other NumPy objects are displayed.
+
+ Parameters
+ ----------
+ precision : int
+ Number of digits of precision for floating point output (default 8).
+ threshold : int
+ Total number of array elements which trigger summarization
+ rather than full repr (default 1000).
+ edgeitems : int
+ Number of array items in summary at beginning and end of
+ each dimension (default 3).
+ linewidth : int
+ The number of characters per line for the purpose of inserting
+ line breaks (default 75).
+ suppress : bool
+ Whether or not suppress printing of small floating point values
+ using scientific notation (default False).
+ nanstr : string
+ String representation of floating point not-a-number (default nan).
+ infstr : string
+ String representation of floating point infinity (default inf).
+
+ Examples
+ --------
+ Floating point precision can be set:
+
+ >>> np.set_printoptions(precision=4)
+ >>> print np.array([1.123456789])
+ [ 1.1235]
+
+ Long arrays can be summarised:
+
+ >>> np.set_printoptions(threshold=5)
+ >>> print np.arange(10)
+ [0 1 2 ..., 7 8 9]
+
+ Small results can be suppressed:
+
+ >>> eps = np.finfo(float).eps
+ >>> x = np.arange(4.)
+
+ >>> x**2 - (x + eps)**2
+ array([ -4.9304e-32, -4.4409e-16, 0.0000e+00, 0.0000e+00])
+
+ >>> np.set_printoptions(suppress=True)
+
+ >>> x**2 - (x + eps)**2
+ array([-0., -0., 0., 0.])
+
"""
global _summaryThreshold, _summaryEdgeItems, _float_output_precision, \
@@ -75,20 +108,26 @@ def set_printoptions(precision=None, threshold=None, edgeitems=None,
_inf_str = infstr
def get_printoptions():
- """Return the current print options.
-
- :Returns:
- dictionary of current print options with keys
- - precision : int
- - threshold : int
- - edgeitems : int
- - linewidth : int
- - suppress : bool
- - nanstr : string
- - infstr : string
-
- :SeeAlso:
- - set_printoptions : parameter descriptions
+ """
+ Return the current print options.
+
+ Returns
+ -------
+ print_opts : dict
+ Dictionary of current print options with keys
+
+ - precision : int
+ - threshold : int
+ - edgeitems : int
+ - linewidth : int
+ - suppress : bool
+ - nanstr : string
+ - infstr : string
+
+ See Also
+ --------
+ set_printoptions : parameter descriptions
+
"""
d = dict(precision=_float_output_precision,
threshold=_summaryThreshold,
@@ -192,34 +231,41 @@ def _convert_arrays(obj):
def array2string(a, max_line_width = None, precision = None,
suppress_small = None, separator=' ', prefix="",
style=repr):
- """Return a string representation of an array.
-
- :Parameters:
- a : ndarray
- Input array.
- max_line_width : int
- The maximum number of columns the string should span. Newline
- characters splits the string appropriately after array elements.
- precision : int
- Floating point precision.
- suppress_small : bool
- Represent very small numbers as zero.
- separator : string
- Inserted between elements.
- prefix : string
- An array is typically printed as
-
- 'prefix(' + array2string(a) + ')'
-
- The length of the prefix string is used to align the
- output correctly.
- style : function
+ """
+ Return a string representation of an array.
+
+ Parameters
+ ----------
+ a : ndarray
+ Input array.
+ max_line_width : int, optional
+ The maximum number of columns the string should span. Newline
+ characters splits the string appropriately after array elements.
+ precision : int, optional
+ Floating point precision.
+ suppress_small : bool, optional
+ Represent very small numbers as zero.
+ separator : string, optional
+ Inserted between elements.
+ prefix : string, optional
+ An array is typically printed as::
+
+ 'prefix(' + array2string(a) + ')'
+
+ The length of the prefix string is used to align the
+ output correctly.
+ style : function, optional
+ Callable.
+
+ See Also
+ --------
+ array_str, array_repr
Examples
--------
-
>>> x = np.array([1e-16,1,2,3])
- >>> print np.core.array2string(x,precision=2,separator=',',suppress_small=True)
+ >>> print np.array2string(x, precision=2, separator=',',
+ ... suppress_small=True)
[ 0., 1., 2., 3.]
"""
diff --git a/numpy/core/code_generators/docstrings.py b/numpy/core/code_generators/docstrings.py
index 3a85221da..e6e6ab0f2 100644
--- a/numpy/core/code_generators/docstrings.py
+++ b/numpy/core/code_generators/docstrings.py
@@ -11,25 +11,181 @@ def add_newdoc(place, name, doc):
add_newdoc('numpy.core.umath', 'absolute',
"""
- Takes |x| elementwise.
+ Calculate the absolute value elementwise.
+
+ Parameters
+ ----------
+ x : array_like
+ An array-like sequence of values or a scalar.
+
+ Returns
+ -------
+ res : {ndarray, scalar}
+ An ndarray containing the absolute value of
+ each element in `x`. For complex input, ``a + ib``, the
+ absolute value is :math:`\\sqrt{ a^2 + b^2 }`.
+
+ Returns a scalar for scalar input.
+
+ Examples
+ --------
+ >>> x = np.array([-1.2, 1.2])
+ >>> np.absolute(x)
+ array([ 1.2, 1.2])
+ >>> np.absolute(1.2 + 1j)
+ 1.5620499351813308
+
+ Plot the function over ``[-10, 10]``:
+
+ >>> import matplotlib.pyplot as plt
+
+ >>> x = np.linspace(-10, 10, 101)
+ >>> plt.plot(x, np.absolute(x))
+ >>> plt.show()
+
+ Plot the function over the complex plane:
+
+ >>> xx = x + 1j * x[:, np.newaxis]
+ >>> plt.imshow(np.abs(xx), extent=[-10, 10, -10, 10])
+ >>> plt.show()
""")
add_newdoc('numpy.core.umath', 'add',
"""
- Adds the arguments elementwise.
+ Add arguments element-wise.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ The arrays to be added.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The sum of `x1` and `x2`, element-wise. Returns scalar if
+ both `x1` and `x2` are scalars.
+
+ Notes
+ -----
+ Equivalent to `x1` + `x2` in terms of array broadcasting.
+
+ Examples
+ --------
+ >>> np.add(1.0, 4.0)
+ 5.0
+ >>> x1 = np.arange(9.0).reshape((3, 3))
+ >>> x2 = np.arange(3.0)
+ >>> np.add(x1, x2)
+ array([[ 0., 2., 4.],
+ [ 3., 5., 7.],
+ [ 6., 8., 10.]])
""")
add_newdoc('numpy.core.umath', 'arccos',
"""
- Inverse cosine elementwise.
+ Trigonometric inverse cosine, element-wise.
+
+ The inverse of `cos` so that, if ``y = cos(x)``, then ``x = arccos(y)``.
+
+ Parameters
+ ----------
+ x : array_like
+ `x`-coordinate on the unit circle.
+ For real arguments, the domain is [-1, 1].
+
+ Returns
+ -------
+ angle : {ndarray, scalar}
+ The angle of the ray intersecting the unit circle at the given
+ `x`-coordinate in radians [0, pi]. If `x` is a scalar then a
+ scalar is returned, otherwise an array of the same shape as `x`
+ is returned.
+
+ See Also
+ --------
+ cos, arctan, arcsin
+
+ Notes
+ -----
+ `arccos` is a multivalued function: for each `x` there are infinitely
+ many numbers `z` such that `cos(z) = x`. The convention is to return the
+ angle `z` whose real part lies in `[0, pi]`.
+
+ For real-valued input data types, `arccos` always returns real output.
+ For each value that cannot be expressed as a real number or infinity, it
+ yields ``nan`` and sets the `invalid` floating point error flag.
+
+ For complex-valued input, `arccos` is a complex analytical function that
+ has branch cuts `[-inf, -1]` and `[1, inf]` and is continuous from above
+ on the former and from below on the latter.
+
+ The inverse `cos` is also known as `acos` or cos^-1.
+
+ References
+ ----------
+ .. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
+ 10th printing, 1964, pp. 79. http://www.math.sfu.ca/~cbm/aands/
+ .. [2] Wikipedia, "Inverse trigonometric function",
+ http://en.wikipedia.org/wiki/Arccos
+
+ Examples
+ --------
+ We expect the arccos of 1 to be 0, and of -1 to be pi:
+
+ >>> np.arccos([1, -1])
+ array([ 0. , 3.14159265])
+
+ Plot arccos:
+
+ >>> import matplotlib.pyplot as plt
+ >>> x = np.linspace(-1, 1, num=100)
+ >>> plt.plot(x, np.arccos(x))
+ >>> plt.axis('tight')
+ >>> plt.show()
""")
add_newdoc('numpy.core.umath', 'arccosh',
"""
- Inverse hyperbolic cosine elementwise.
+ Inverse hyperbolic cosine, elementwise.
+
+ Parameters
+ ----------
+ x : array_like
+ Input array.
+
+ Returns
+ -------
+ out : {ndarray, scalar}
+ Array of the same shape and dtype as `x`.
+
+ Notes
+ -----
+ `arccosh` is a multivalued function: for each `x` there are infinitely
+ many numbers `z` such that `cosh(z) = x`. The convention is to return the
+ `z` whose imaginary part lies in `[-pi, pi]` and the real part in
+ ``[0, inf]``.
+
+ For real-valued input data types, `arccosh` always returns real output.
+ For each value that cannot be expressed as a real number or infinity, it
+ yields ``nan`` and sets the `invalid` floating point error flag.
+
+ For complex-valued input, `arccosh` is a complex analytical function that
+ has a branch cut `[-inf, 1]` and is continuous from above on it.
+
+ References
+ ----------
+ .. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
+ 10th printing, 1964, pp. 86. http://www.math.sfu.ca/~cbm/aands/
+ .. [2] Wikipedia, "Inverse hyperbolic function",
+ http://en.wikipedia.org/wiki/Arccosh
+
+ Examples
+ --------
+ >>> np.arccosh([np.e, 10.0])
+ array([ 1.65745445, 2.99322285])
""")
@@ -37,23 +193,234 @@ add_newdoc('numpy.core.umath', 'arcsin',
"""
Inverse sine elementwise.
+ Parameters
+ ----------
+ x : array_like
+ `y`-coordinate on the unit circle.
+
+ Returns
+ -------
+ angle : {ndarray, scalar}
+ The angle of the ray intersecting the unit circle at the given
+ `y`-coordinate in radians ``[-pi, pi]``. If `x` is a scalar then
+ a scalar is returned, otherwise an array is returned.
+
+ See Also
+ --------
+ sin, arctan, arctan2
+
+ Notes
+ -----
+ `arcsin` is a multivalued function: for each `x` there are infinitely
+ many numbers `z` such that `sin(z) = x`. The convention is to return the
+ angle `z` whose real part lies in `[-pi/2, pi/2]`.
+
+ For real-valued input data types, `arcsin` always returns real output.
+ For each value that cannot be expressed as a real number or infinity, it
+ yields ``nan`` and sets the `invalid` floating point error flag.
+
+ For complex-valued input, `arcsin` is a complex analytical function that
+ has branch cuts `[-inf, -1]` and `[1, inf]` and is continuous from above
+ on the former and from below on the latter.
+
+ The inverse sine is also known as `asin` or ``sin^-1``.
+
+ References
+ ----------
+ .. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
+ 10th printing, 1964, pp. 79. http://www.math.sfu.ca/~cbm/aands/
+ .. [2] Wikipedia, "Inverse trigonometric function",
+ http://en.wikipedia.org/wiki/Arcsin
+
+ Examples
+ --------
+ >>> np.arcsin(1) # pi/2
+ 1.5707963267948966
+ >>> np.arcsin(-1) # -pi/2
+ -1.5707963267948966
+ >>> np.arcsin(0)
+ 0.0
+
""")
add_newdoc('numpy.core.umath', 'arcsinh',
"""
Inverse hyperbolic sine elementwise.
+ Parameters
+ ----------
+ x : array_like
+ Input array.
+
+ Returns
+ -------
+ out : ndarray
+ Array of of the same shape as `x`.
+
+ Notes
+ -----
+ `arcsinh` is a multivalued function: for each `x` there are infinitely
+ many numbers `z` such that `sinh(z) = x`. The convention is to return the
+ `z` whose imaginary part lies in `[-pi/2, pi/2]`.
+
+ For real-valued input data types, `arcsinh` always returns real output.
+ For each value that cannot be expressed as a real number or infinity, it
+ yields ``nan`` and sets the `invalid` floating point error flag.
+
+ For complex-valued input, `arccos` is a complex analytical function that
+ has branch cuts `[1j, infj]` and `[-1j, -infj]` and is continuous from
+ the right on the former and from the left on the latter.
+
+ The inverse hyperbolic sine is also known as `asinh` or ``sinh^-1``.
+
+ References
+ ----------
+ .. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
+ 10th printing, 1964, pp. 86. http://www.math.sfu.ca/~cbm/aands/
+ .. [2] Wikipedia, "Inverse hyperbolic function",
+ http://en.wikipedia.org/wiki/Arcsinh
+
+ Examples
+ --------
+ >>> np.arcsinh(np.array([np.e, 10.0]))
+ array([ 1.72538256, 2.99822295])
+
""")
add_newdoc('numpy.core.umath', 'arctan',
"""
- Inverse tangent elementwise.
+ Trigonometric inverse tangent, element-wise.
+
+ The inverse of tan, so that if ``y = tan(x)`` then
+ ``x = arctan(y)``.
+
+ Parameters
+ ----------
+ x : {array_like, scalar}
+ Input values. `arctan` is applied to each element of `x`.
+
+ Returns
+ -------
+ out : {ndarray, scalar}
+ Out has the same shape as `x`. Its real part is
+ in ``[-pi/2, pi/2]``. It is a scalar if `x` is a scalar.
+
+ See Also
+ --------
+ arctan2 : Calculate the arctan of y/x.
+
+ Notes
+ -----
+ `arctan` is a multivalued function: for each `x` there are infinitely
+ many numbers `z` such that `tan(z) = x`. The convention is to return the
+ angle `z` whose real part lies in `[-pi/2, pi/2]`.
+
+ For real-valued input data types, `arctan` always returns real output.
+ For each value that cannot be expressed as a real number or infinity, it
+ yields ``nan`` and sets the `invalid` floating point error flag.
+
+ For complex-valued input, `arctan` is a complex analytical function that
+ has branch cuts `[1j, infj]` and `[-1j, -infj]` and is continuous from the
+ left on the former and from the right on the latter.
+
+ The inverse tangent is also known as `atan` or ``tan^-1``.
+
+ References
+ ----------
+ .. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
+ 10th printing, 1964, pp. 79. http://www.math.sfu.ca/~cbm/aands/
+ .. [2] Wikipedia, "Inverse trigonometric function",
+ http://en.wikipedia.org/wiki/Arctan
+
+ Examples
+ --------
+ We expect the arctan of 0 to be 0, and of 1 to be :math:`\\pi/4`:
+
+ >>> np.arctan([0, 1])
+ array([ 0. , 0.78539816])
+
+ >>> np.pi/4
+ 0.78539816339744828
+
+ Plot arctan:
+
+ >>> import matplotlib.pyplot as plt
+ >>> x = np.linspace(-10, 10)
+ >>> plt.plot(x, np.arctan(x))
+ >>> plt.axis('tight')
+ >>> plt.show()
""")
add_newdoc('numpy.core.umath', 'arctan2',
"""
- A safe and correct arctan(x1/x2)
+ Elementwise arc tangent of ``x1/x2`` choosing the quadrant correctly.
+
+ The quadrant (ie. branch) is chosen so that ``arctan2(x1, x2)``
+ is the signed angle in radians between the line segments
+ ``(0,0) - (1,0)`` and ``(0,0) - (x2,x1)``. This function is defined
+ also for `x2` = 0.
+
+ `arctan2` is not defined for complex-valued arguments.
+
+ Parameters
+ ----------
+ x1 : array-like, real-valued
+ y-coordinates.
+ x2 : array-like, real-valued
+ x-coordinates. `x2` must be broadcastable to match the shape of `x1`,
+ or vice versa.
+
+ Returns
+ -------
+ angle : array-like
+ Array of angles in radians, in the range ``[-pi, pi]``.
+
+ See Also
+ --------
+ arctan, tan
+
+ Notes
+ -----
+ `arctan2` is identical to the `atan2` function of the underlying
+ C library. The following special values are defined in the C standard [2]:
+
+ ====== ====== ================
+ `x1` `x2` `arctan2(x1,x2)`
+ ====== ====== ================
+ +/- 0 +0 +/- 0
+ +/- 0 -0 +/- pi
+ > 0 +/-inf +0 / +pi
+ < 0 +/-inf -0 / -pi
+ +/-inf +inf +/- (pi/4)
+ +/-inf -inf +/- (3*pi/4)
+ ====== ====== ================
+
+ Note that +0 and -0 are distinct floating point numbers.
+
+ References
+ ----------
+ .. [1] Wikipedia, "atan2",
+ http://en.wikipedia.org/wiki/Atan2
+ .. [2] ISO/IEC standard 9899:1999, "Programming language C", 1999.
+
+ Examples
+ --------
+ Consider four points in different quadrants:
+
+ >>> x = np.array([-1, +1, +1, -1])
+ >>> y = np.array([-1, -1, +1, +1])
+ >>> np.arctan2(y, x) * 180 / np.pi
+ array([-135., -45., 45., 135.])
+
+ Note the order of the parameters. `arctan2` is defined also when `x2` = 0
+ and at several other special points, obtaining values in
+ the range ``[-pi, pi]``:
+
+ >>> np.arctan2([1., -1.], [0., 0.])
+ array([ 1.57079633, -1.57079633])
+ >>> np.arctan2([0., 0., np.inf], [+0., -0., np.inf])
+ array([ 0. , 3.14159265, 0.78539816])
""")
@@ -61,35 +428,284 @@ add_newdoc('numpy.core.umath', 'arctanh',
"""
Inverse hyperbolic tangent elementwise.
+ Parameters
+ ----------
+ x : array_like
+ Input array.
+
+ Returns
+ -------
+ out : ndarray
+ Array of the same shape as `x`.
+
+ Notes
+ -----
+ `arctanh` is a multivalued function: for each `x` there are infinitely
+ many numbers `z` such that `tanh(z) = x`. The convention is to return the
+ `z` whose imaginary part lies in `[-pi/2, pi/2]`.
+
+ For real-valued input data types, `arctanh` always returns real output.
+ For each value that cannot be expressed as a real number or infinity, it
+ yields ``nan`` and sets the `invalid` floating point error flag.
+
+ For complex-valued input, `arctanh` is a complex analytical function that
+ has branch cuts `[-1, -inf]` and `[1, inf]` and is continuous from
+ above on the former and from below on the latter.
+
+ The inverse hyperbolic tangent is also known as `atanh` or ``tanh^-1``.
+
+ References
+ ----------
+ .. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
+ 10th printing, 1964, pp. 86. http://www.math.sfu.ca/~cbm/aands/
+ .. [2] Wikipedia, "Inverse hyperbolic function",
+ http://en.wikipedia.org/wiki/Arctanh
+
+ Examples
+ --------
+ >>> np.arctanh([0, -0.5])
+ array([ 0. , -0.54930614])
+
""")
add_newdoc('numpy.core.umath', 'bitwise_and',
"""
- Computes x1 & x2 elementwise.
+ Compute bit-wise AND of two arrays, element-wise.
+
+ When calculating the bit-wise AND between two elements, ``x`` and ``y``,
+ each element is first converted to its binary representation (which works
+ just like the decimal system, only now we're using 2 instead of 10):
+
+ .. math:: x = \\sum_{i=0}^{W-1} a_i \\cdot 2^i\\\\\n y = \\sum_{i=0}^{W-1} b_i \\cdot 2^i,
+
+ where ``W`` is the bit-width of the type (i.e., 8 for a byte or uint8),
+ and each :math:`a_i` and :math:`b_j` is either 0 or 1. For example, 13
+ is represented as ``00001101``, which translates to
+ :math:`2^4 + 2^3 + 2`.
+
+ The bit-wise operator is the result of
+
+ .. math:: z = \\sum_{i=0}^{i=W-1} (a_i \\wedge b_i) \\cdot 2^i,
+
+ where :math:`\\wedge` is the AND operator, which yields one whenever
+ both :math:`a_i` and :math:`b_i` are 1.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ Only integer types are handled (including booleans).
+
+ Returns
+ -------
+ out : array_like
+ Result.
+
+ See Also
+ --------
+ bitwise_or, bitwise_xor
+ logical_and
+ binary_repr :
+ Return the binary representation of the input number as a string.
+
+ Examples
+ --------
+ We've seen that 13 is represented by ``00001101``. Similary, 17 is
+ represented by ``00010001``. The bit-wise AND of 13 and 17 is
+ therefore ``000000001``, or 1:
+
+ >>> np.bitwise_and(13, 17)
+ 1
+
+ >>> np.bitwise_and(14, 13)
+ 12
+ >>> np.binary_repr(12)
+ '1100'
+ >>> np.bitwise_and([14,3], 13)
+ array([12, 1])
+
+ >>> np.bitwise_and([11,7], [4,25])
+ array([0, 1])
+ >>> np.bitwise_and(np.array([2,5,255]), np.array([3,14,16]))
+ array([ 2, 4, 16])
+ >>> np.bitwise_and([True, True], [False, True])
+ array([False, True], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'bitwise_or',
"""
- Computes x1 | x2 elementwise.
+ Compute bit-wise OR of two arrays, element-wise.
+
+ When calculating the bit-wise OR between two elements, ``x`` and ``y``,
+ each element is first converted to its binary representation (which works
+ just like the decimal system, only now we're using 2 instead of 10):
+
+ .. math:: x = \\sum_{i=0}^{W-1} a_i \\cdot 2^i\\\\\n y = \\sum_{i=0}^{W-1} b_i \\cdot 2^i,
+
+ where ``W`` is the bit-width of the type (i.e., 8 for a byte or uint8),
+ and each :math:`a_i` and :math:`b_j` is either 0 or 1. For example, 13
+ is represented as ``00001101``, which translates to
+ :math:`2^4 + 2^3 + 2`.
+
+ The bit-wise operator is the result of
+
+ .. math:: z = \\sum_{i=0}^{i=W-1} (a_i \\vee b_i) \\cdot 2^i,
+
+ where :math:`\\vee` is the OR operator, which yields one whenever
+ either :math:`a_i` or :math:`b_i` is 1.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ Only integer types are handled (including booleans).
+
+ Returns
+ -------
+ out : array_like
+ Result.
+
+ See Also
+ --------
+ bitwise_and, bitwise_xor
+ logical_or
+ binary_repr :
+ Return the binary representation of the input number as a string.
+
+ Examples
+ --------
+ We've seen that 13 is represented by ``00001101``. Similary, 16 is
+ represented by ``00010000``. The bit-wise OR of 13 and 16 is
+ therefore ``000111011``, or 29:
+
+ >>> np.bitwise_or(13, 16)
+ 29
+ >>> np.binary_repr(29)
+ '11101'
+
+ >>> np.bitwise_or(32, 2)
+ 34
+ >>> np.bitwise_or([33, 4], 1)
+ array([33, 5])
+ >>> np.bitwise_or([33, 4], [1, 2])
+ array([33, 6])
+
+ >>> np.bitwise_or(np.array([2, 5, 255]), np.array([4, 4, 4]))
+ array([ 6, 5, 255])
+ >>> np.bitwise_or(np.array([2, 5, 255, 2147483647L], dtype=np.int32), \\\n... np.array([4, 4, 4, 2147483647L], dtype=np.int32))
+ array([ 6, 5, 255, 2147483647])
+ >>> np.bitwise_or([True, True], [False, True])
+ array([ True, True], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'bitwise_xor',
"""
- Computes x1 ^ x2 elementwise.
+ Compute bit-wise XOR of two arrays, element-wise.
+
+ When calculating the bit-wise XOR between two elements, ``x`` and ``y``,
+ each element is first converted to its binary representation (which works
+ just like the decimal system, only now we're using 2 instead of 10):
+
+ .. math:: x = \\sum_{i=0}^{W-1} a_i \\cdot 2^i\\\\\n y = \\sum_{i=0}^{W-1} b_i \\cdot 2^i,
+
+ where ``W`` is the bit-width of the type (i.e., 8 for a byte or uint8),
+ and each :math:`a_i` and :math:`b_j` is either 0 or 1. For example, 13
+ is represented as ``00001101``, which translates to
+ :math:`2^4 + 2^3 + 2`.
+
+ The bit-wise operator is the result of
+
+ .. math:: z = \\sum_{i=0}^{i=W-1} (a_i \\oplus b_i) \\cdot 2^i,
+
+ where :math:`\\oplus` is the XOR operator, which yields one whenever
+ either :math:`a_i` or :math:`b_i` is 1, but not both.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ Only integer types are handled (including booleans).
+
+ Returns
+ -------
+ out : ndarray
+ Result.
+
+ See Also
+ --------
+ bitwise_and, bitwise_or
+ logical_xor
+ binary_repr :
+ Return the binary representation of the input number as a string.
+
+ Examples
+ --------
+ We've seen that 13 is represented by ``00001101``. Similary, 17 is
+ represented by ``00010001``. The bit-wise XOR of 13 and 17 is
+ therefore ``00011100``, or 28:
+
+ >>> np.bitwise_xor(13, 17)
+ 28
+ >>> np.binary_repr(28)
+ '11100'
+
+ >>> np.bitwise_xor(31, 5)
+ 26
+ >>> np.bitwise_xor([31,3], 5)
+ array([26, 6])
+
+ >>> np.bitwise_xor([31,3], [5,6])
+ array([26, 5])
+ >>> np.bitwise_xor([True, True], [False, True])
+ array([ True, False], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'ceil',
"""
- Elementwise smallest integer >= x.
+ Return the ceiling of the input, element-wise.
+
+ The ceil of the scalar `x` is the smallest integer `i`, such that
+ `i >= x`. It is often denoted as :math:`\\lceil x \\rceil`.
+
+ Parameters
+ ----------
+ x : array_like
+ Input data.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The ceiling of each element in `x`.
+
+ Examples
+ --------
+ >>> a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
+ >>> np.ceil(a)
+ array([-1., -1., -0., 1., 2., 2., 2.])
""")
add_newdoc('numpy.core.umath', 'conjugate',
"""
- Takes the conjugate of x elementwise.
+ Return the complex conjugate, element-wise.
+
+ The complex conjugate of a complex number is obtained by changing the
+ sign of its imaginary part.
+
+ Parameters
+ ----------
+ x : array_like
+ Input value.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The complex conjugate of `x`, with same dtype as `y`.
+
+ Examples
+ --------
+ >>> np.conjugate(1+2j)
+ (1-2j)
""")
@@ -97,35 +713,225 @@ add_newdoc('numpy.core.umath', 'cos',
"""
Cosine elementwise.
+ Parameters
+ ----------
+ x : array_like
+ Input array in radians.
+
+ Returns
+ -------
+ out : ndarray
+ Output array of same shape as `x`.
+
+ Examples
+ --------
+ >>> np.cos(np.array([0, np.pi/2, np.pi]))
+ array([ 1.00000000e+00, 6.12303177e-17, -1.00000000e+00])
+
""")
add_newdoc('numpy.core.umath', 'cosh',
"""
- Hyperbolic cosine elementwise.
+ Hyperbolic cosine, element-wise.
+
+ Equivalent to ``1/2 * (np.exp(x) + np.exp(-x))`` and ``np.cos(1j*x)``.
+
+ Parameters
+ ----------
+ x : array_like
+ Input array.
+
+ Returns
+ -------
+ out : ndarray
+ Output array of same shape as `x`.
+
+ Examples
+ --------
+ >>> np.cosh(0)
+ 1.0
+
+ The hyperbolic cosine describes the shape of a hanging cable:
+
+ >>> import matplotlib.pyplot as plt
+ >>> x = np.linspace(-4, 4, 1000)
+ >>> plt.plot(x, np.cosh(x))
+ >>> plt.show()
""")
add_newdoc('numpy.core.umath', 'degrees',
"""
- Converts angle from radians to degrees
+ Convert angles from radians to degrees.
+
+ Parameters
+ ----------
+ x : array-like
+ Angle in radians.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The corresponding angle in degrees.
+
+
+ See Also
+ --------
+ radians : Convert angles from degrees to radians.
+ unwrap : Remove large jumps in angle by wrapping.
+
+ Notes
+ -----
+ degrees(x) is ``180 * x / pi``.
+
+ Examples
+ --------
+ >>> np.degrees(np.pi/2)
+ 90.0
""")
add_newdoc('numpy.core.umath', 'divide',
"""
- Divides the arguments elementwise.
+ Divide arguments element-wise.
+
+ Parameters
+ ----------
+ x1 : array_like
+ Dividend array.
+ x2 : array_like
+ Divisor array.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The quotient `x1/x2`, element-wise. Returns a scalar if
+ both `x1` and `x2` are scalars.
+
+ See Also
+ --------
+ seterr : Set whether to raise or warn on overflow, underflow and division
+ by zero.
+
+ Notes
+ -----
+ Equivalent to `x1` / `x2` in terms of array-broadcasting.
+
+ Behavior on division by zero can be changed using `seterr`.
+
+ When both `x1` and `x2` are of an integer type, `divide` will return
+ integers and throw away the fractional part. Moreover, division by zero
+ always yields zero in integer arithmetic.
+
+ Examples
+ --------
+ >>> np.divide(2.0, 4.0)
+ 0.5
+ >>> x1 = np.arange(9.0).reshape((3, 3))
+ >>> x2 = np.arange(3.0)
+ >>> np.divide(x1, x2)
+ array([[ NaN, 1. , 1. ],
+ [ Inf, 4. , 2.5],
+ [ Inf, 7. , 4. ]])
+
+ Note the behavior with integer types:
+
+ >>> np.divide(2, 4)
+ 0
+ >>> np.divide(2, 4.)
+ 0.5
+
+ Division by zero always yields zero in integer arithmetic, and does not
+ raise an exception or a warning:
+
+ >>> np.divide(np.array([0, 1], dtype=int), np.array([0, 0], dtype=int))
+ array([0, 0])
+
+ Division by zero can, however, be caught using `seterr`:
+
+ >>> old_err_state = np.seterr(divide='raise')
+ >>> np.divide(1, 0)
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ FloatingPointError: divide by zero encountered in divide
+
+ >>> ignored_states = np.seterr(**old_err_state)
+ >>> np.divide(1, 0)
+ 0
""")
add_newdoc('numpy.core.umath', 'equal',
"""
- Returns elementwise x1 == x2 in a bool array
+ Returns elementwise x1 == x2 in a bool array.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ Input arrays of the same shape.
+
+ Returns
+ -------
+ out : boolean
+ The elementwise test `x1` == `x2`.
""")
add_newdoc('numpy.core.umath', 'exp',
"""
- e**x elementwise.
+ Calculate the exponential of the elements in the input array.
+
+ Parameters
+ ----------
+ x : array_like
+ Input values.
+
+ Returns
+ -------
+ out : ndarray
+ Element-wise exponential of `x`.
+
+ Notes
+ -----
+ The irrational number ``e`` is also known as Euler's number. It is
+ approximately 2.718281, and is the base of the natural logarithm,
+ ``ln`` (this means that, if :math:`x = \\ln y = \\log_e y`,
+ then :math:`e^x = y`. For real input, ``exp(x)`` is always positive.
+
+ For complex arguments, ``x = a + ib``, we can write
+ :math:`e^x = e^a e^{ib}`. The first term, :math:`e^a`, is already
+ known (it is the real argument, described above). The second term,
+ :math:`e^{ib}`, is :math:`\\cos b + i \\sin b`, a function with magnitude
+ 1 and a periodic phase.
+
+ References
+ ----------
+ .. [1] Wikipedia, "Exponential function",
+ http://en.wikipedia.org/wiki/Exponential_function
+ .. [2] M. Abramovitz and I. A. Stegun, "Handbook of Mathematical Functions
+ with Formulas, Graphs, and Mathematical Tables," Dover, 1964, p. 69,
+ http://www.math.sfu.ca/~cbm/aands/page_69.htm
+
+ Examples
+ --------
+ Plot the magnitude and phase of ``exp(x)`` in the complex plane:
+
+ >>> import matplotlib.pyplot as plt
+
+ >>> x = np.linspace(-2*np.pi, 2*np.pi, 100)
+ >>> xx = x + 1j * x[:, np.newaxis] # a + ib over complex plane
+ >>> out = np.exp(xx)
+
+ >>> plt.subplot(121)
+ >>> plt.imshow(np.abs(out),
+ ... extent=[-2*np.pi, 2*np.pi, -2*np.pi, 2*np.pi])
+ >>> plt.title('Magnitude of exp(x)')
+
+ >>> plt.subplot(122)
+ >>> plt.imshow(np.angle(out),
+ ... extent=[-2*np.pi, 2*np.pi, -2*np.pi, 2*np.pi])
+ >>> plt.title('Phase (angle) of exp(x)')
+ >>> plt.show()
""")
@@ -137,67 +943,368 @@ add_newdoc('numpy.core.umath', 'expm1',
add_newdoc('numpy.core.umath', 'fabs',
"""
- Absolute values.
+ Compute the absolute values elementwise.
+
+ This function returns the absolute values (positive magnitude) of the data
+ in `x`. Complex values are not handled, use `absolute` to find the
+ absolute values of complex data.
+
+ Parameters
+ ----------
+ x : array_like
+ The array of numbers for which the absolute values are required. If
+ `x` is a scalar, the result `y` will also be a scalar.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The absolute values of `x`, the returned values are always floats.
+
+ See Also
+ --------
+ absolute : Absolute values including `complex` types.
+
+ Examples
+ --------
+ >>> np.fabs(-1)
+ 1.0
+ >>> np.fabs([-1.2, 1.2])
+ array([ 1.2, 1.2])
""")
add_newdoc('numpy.core.umath', 'floor',
"""
- Elementwise largest integer <= x
+ Return the floor of the input, element-wise.
+
+ The floor of the scalar `x` is the largest integer `i`, such that
+ `i <= x`. It is often denoted as :math:`\\lfloor x \\rfloor`.
+
+ Parameters
+ ----------
+ x : array_like
+ Input data.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The floor of each element in `x`.
+
+ Notes
+ -----
+ Some spreadsheet programs calculate the "floor-towards-zero", in other
+ words ``floor(-2.5) == -2``. NumPy, however, uses the a definition of
+ `floor` such that `floor(-2.5) == -3``.
+
+ Examples
+ --------
+ >>> a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
+ >>> np.floor(a)
+ array([-2., -2., -1., 0., 1., 1., 2.])
""")
add_newdoc('numpy.core.umath', 'floor_divide',
"""
- Floor divides the arguments elementwise.
+ Return the largest integer smaller or equal to the division of the inputs.
+
+ Parameters
+ ----------
+ x1 : array_like
+ Numerator.
+ x2 : array_like
+ Denominator.
+
+ Returns
+ -------
+ y : ndarray
+ y = floor(`x1`/`x2`)
+
+
+ See Also
+ --------
+ divide : Standard division.
+ floor : Round a number to the nearest integer toward minus infinity.
+ ceil : Round a number to the nearest integer toward infinity.
+
+ Examples
+ --------
+ >>> np.floor_divide(7,3)
+ 2
+ >>> np.floor_divide([1., 2., 3., 4.], 2.5)
+ array([ 0., 0., 1., 1.])
""")
add_newdoc('numpy.core.umath', 'fmod',
"""
- Computes (C-like) x1 % x2 elementwise.
+ Return the remainder of division.
+
+ This is the NumPy implementation of the C modulo operator `%`.
+
+ Parameters
+ ----------
+ x1 : array_like
+ Dividend.
+ x2 : array_like
+ Divisor.
+
+ Returns
+ -------
+ y : array_like
+ The remainder of the division of `x1` by `x2`.
+
+ See Also
+ --------
+ mod : Modulo operation where the quotient is `floor(x1,x2)`.
+
+ Notes
+ -----
+ The result of the modulo operation for negative dividend and divisors is
+ bound by conventions. In `fmod`, the sign of the remainder is the sign of
+ the dividend, and the sign of the divisor has no influence on the results.
+
+ Examples
+ --------
+ >>> np.fmod([-3, -2, -1, 1, 2, 3], 2)
+ array([-1, 0, -1, 1, 0, 1])
+
+ >>> np.mod([-3, -2, -1, 1, 2, 3], 2)
+ array([1, 0, 1, 1, 0, 1])
""")
add_newdoc('numpy.core.umath', 'greater',
"""
- Returns elementwise x1 > x2 in a bool array.
+ Return (x1 > x2) element-wise.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ Input arrays.
+
+ Returns
+ -------
+ Out : {ndarray, bool}
+ Output array of bools, or a single bool if `x1` and `x2` are scalars.
+
+ See Also
+ --------
+ greater_equal
+
+ Examples
+ --------
+ >>> np.greater([4,2],[2,2])
+ array([ True, False], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'greater_equal',
"""
- Returns elementwise x1 >= x2 in a bool array.
+ Returns (x1 >= x2) element-wise.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ Input arrays.
+
+ Returns
+ -------
+ Out : {ndarray, bool}
+ Output array of bools, or a single bool if `x1` and `x2` are scalars.
+
+ See Also
+ --------
+ greater
+
+ Examples
+ --------
+ >>> np.greater_equal([4,2],[2,2])
+ array([ True, True], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'hypot',
"""
- sqrt(x1**2 + x2**2) elementwise
+ Given two sides of a right triangle, return its hypotenuse.
+
+ Parameters
+ ----------
+ x : array-like
+ Base of the triangle.
+ y : array-like
+ Height of the triangle.
+
+ Returns
+ -------
+ z : {ndarray, scalar}
+ Hypotenuse of the triangle: sqrt(x**2 + y**2)
+
+
+ Examples
+ --------
+ >>> np.hypot(3,4)
+ 5.0
""")
add_newdoc('numpy.core.umath', 'invert',
"""
- Computes ~x (bit inversion) elementwise.
+ Compute bit-wise inversion, or bit-wise NOT, element-wise.
+
+ When calculating the bit-wise NOT of an element ``x``, each element is
+ first converted to its binary representation (which works
+ just like the decimal system, only now we're using 2 instead of 10):
+
+ .. math:: x = \\sum_{i=0}^{W-1} a_i \\cdot 2^i
+
+ where ``W`` is the bit-width of the type (i.e., 8 for a byte or uint8),
+ and each :math:`a_i` is either 0 or 1. For example, 13 is represented
+ as ``00001101``, which translates to :math:`2^4 + 2^3 + 2`.
+
+ The bit-wise operator is the result of
+
+ .. math:: z = \\sum_{i=0}^{i=W-1} (\\lnot a_i) \\cdot 2^i,
+
+ where :math:`\\lnot` is the NOT operator, which yields 1 whenever
+ :math:`a_i` is 0 and yields 0 whenever :math:`a_i` is 1.
+
+ For signed integer inputs, the two's complement is returned.
+ In a two's-complement system negative numbers are represented by the two's
+ complement of the absolute value. This is the most common method of
+ representing signed integers on computers [1]_. A N-bit two's-complement
+ system can represent every integer in the range
+ :math:`-2^{N-1}` to :math:`+2^{N-1}-1`.
+
+ Parameters
+ ----------
+ x1 : ndarray
+ Only integer types are handled (including booleans).
+
+ Returns
+ -------
+ out : ndarray
+ Result.
+
+ See Also
+ --------
+ bitwise_and, bitwise_or, bitwise_xor
+ logical_not
+ binary_repr :
+ Return the binary representation of the input number as a string.
+
+ Notes
+ -----
+ `bitwise_not` is an alias for `invert`:
+
+ >>> np.bitwise_not is np.invert
+ True
+
+ References
+ ----------
+ .. [1] Wikipedia, "Two's complement",
+ http://en.wikipedia.org/wiki/Two's_complement
+
+ Examples
+ --------
+ We've seen that 13 is represented by ``00001101``.
+ The invert or bit-wise NOT of 13 is then:
+
+ >>> np.invert(np.array([13], dtype=uint8))
+ array([242], dtype=uint8)
+ >>> np.binary_repr(x, width=8)
+ '00001101'
+ >>> np.binary_repr(242, width=8)
+ '11110010'
+
+ The result depends on the bit-width:
+
+ >>> np.invert(np.array([13], dtype=uint16))
+ array([65522], dtype=uint16)
+ >>> np.binary_repr(x, width=16)
+ '0000000000001101'
+ >>> np.binary_repr(65522, width=16)
+ '1111111111110010'
+
+ When using signed integer types the result is the two's complement of
+ the result for the unsigned type:
+
+ >>> np.invert(np.array([13], dtype=int8))
+ array([-14], dtype=int8)
+ >>> np.binary_repr(-14, width=8)
+ '11110010'
+
+ Booleans are accepted as well:
+
+ >>> np.invert(array([True, False]))
+ array([False, True], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'isfinite',
"""
- Returns True where x is finite
+ Returns True where x is finite, False otherwise.
+
+ Parameters
+ ----------
+ x : array_like
+ input values
+
+ Returns
+ -------
+ y : {ndarray, bool}
+ array of bools
+
+ Notes
+ -----
+ `Nan` is considered as non-finite.
+
+ Examples
+ --------
+ >>> np.isfinite([np.log(-1.),1.,np.log(0)])
+ array([False, True, False], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'isinf',
"""
- Returns True where x is +inf or -inf
+ Returns True where x is +inf or -inf, False otherwise.
+
+ Parameters
+ ----------
+ x : array_like
+ input values
+
+ Returns
+ -------
+ y : {ndarray, bool}
+ array of bools
+
+ Examples
+ --------
+ >>> np.isinf([np.inf, -np.inf, 1.0, np.nan])
+ array([ True, True, False, False], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'isnan',
"""
- Returns True where x is Not-A-Number
+ Returns True where elements are Not-A-Number, False otherwise.
+
+ Parameters
+ ----------
+ x : array_like
+ input values.
+
+ Returns
+ -------
+ y : {ndarray, bool}
+ array of bools
+
+ Examples
+ --------
+ >>> np.isnan([np.log(-1.),1.,np.log(0)])
+ array([ True, False, False], dtype=bool)
""")
@@ -209,55 +1316,325 @@ add_newdoc('numpy.core.umath', 'left_shift',
add_newdoc('numpy.core.umath', 'less',
"""
- Returns elementwise x1 < x2 in a bool array.
+ Returns (x1 < x2) element-wise.
+
+ Parameters
+ ----------
+ x1, x2 : array-like
+ Input arrays.
+
+ Returns
+ -------
+ Out : {ndarray, bool}
+ Output array of bools, or a single bool if `x1` and `x2` are scalars.
+
+ See Also
+ --------
+ less_equal
+
+ Examples
+ --------
+ >>> np.less([1,2],[2,2])
+ array([ True, False], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'less_equal',
"""
- Returns elementwise x1 <= x2 in a bool array
+ Returns (x1 <= x2) element-wise.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ Input arrays.
+
+ Returns
+ -------
+ Out : {ndarray, bool}
+ Output array of bools, or a single bool if `x1` and `x2` are scalars.
+
+ See Also
+ --------
+ less
+
+ Examples
+ --------
+ >>> np.less_equal([1,2,3],[2,2,2])
+ array([ True, True, False], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'log',
"""
- Logarithm base e elementwise.
+ Natural logarithm, element-wise.
+
+ The natural logarithm `log` is the inverse of the exponential function,
+ so that `log(exp(x)) = x`. The natural logarithm is logarithm in base `e`.
+
+ Parameters
+ ----------
+ x : array_like
+ Input value.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The natural logarithm of `x`, element-wise.
+
+ See Also
+ --------
+ log10, log2, log1p
+
+ Notes
+ -----
+ Logarithm is a multivalued function: for each `x` there is an infinite
+ number of `z` such that `exp(z) = x`. The convention is to return the `z`
+ whose imaginary part lies in `[-pi, pi]`.
+
+ For real-valued input data types, `log` always returns real output. For
+ each value that cannot be expressed as a real number or infinity, it
+ yields ``nan`` and sets the `invalid` floating point error flag.
+
+ For complex-valued input, `log` is a complex analytical function that
+ has a branch cut `[-inf, 0]` and is continuous from above on it. `log`
+ handles the floating-point negative zero as an infinitesimal negative
+ number, conforming to the C99 standard.
+
+ References
+ ----------
+ .. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
+ 10th printing, 1964, pp. 67. http://www.math.sfu.ca/~cbm/aands/
+ .. [2] Wikipedia, "Logarithm". http://en.wikipedia.org/wiki/Logarithm
+
+ Examples
+ --------
+ >>> np.log([1, np.e, np.e**2, 0])
+ array([ 0., 1., 2., -Inf])
""")
add_newdoc('numpy.core.umath', 'log10',
"""
- Logarithm base 10 elementwise.
+ Compute the logarithm in base 10 elementwise.
+
+ Parameters
+ ----------
+ x : array_like
+ input values.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ base-10 logarithm of `x`.
+
+
+ Notes
+ -----
+ Logarithm is a multivalued function: for each `x` there is an infinite
+ number of `z` such that `10**z = x`. The convention is to return the `z`
+ whose imaginary part lies in `[-pi, pi]`.
+
+ For real-valued input data types, `log10` always returns real output. For
+ each value that cannot be expressed as a real number or infinity, it
+ yields ``nan`` and sets the `invalid` floating point error flag.
+
+ For complex-valued input, `log10` is a complex analytical function that
+ has a branch cut `[-inf, 0]` and is continuous from above on it. `log10`
+ handles the floating-point negative zero as an infinitesimal negative
+ number, conforming to the C99 standard.
+
+ References
+ ----------
+ .. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
+ 10th printing, 1964, pp. 67. http://www.math.sfu.ca/~cbm/aands/
+ .. [2] Wikipedia, "Logarithm". http://en.wikipedia.org/wiki/Logarithm
+
+ Examples
+ --------
+ >>> np.log10([1.e-15,-3.])
+ array([-15., NaN])
""")
add_newdoc('numpy.core.umath', 'log1p',
"""
- log(1+x) to base e elementwise.
+ `log(1 + x)` in base `e`, elementwise.
+
+ Parameters
+ ----------
+ x : array_like
+ Input values.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ Natural logarithm of `1 + x`, elementwise.
+
+ Notes
+ -----
+ For real-valued input, `log1p` is accurate also for `x` so small
+ that `1 + x == 1` in floating-point accuracy.
+
+ Logarithm is a multivalued function: for each `x` there is an infinite
+ number of `z` such that `exp(z) = 1 + x`. The convention is to return
+ the `z` whose imaginary part lies in `[-pi, pi]`.
+
+ For real-valued input data types, `log1p` always returns real output. For
+ each value that cannot be expressed as a real number or infinity, it
+ yields ``nan`` and sets the `invalid` floating point error flag.
+
+ For complex-valued input, `log1p` is a complex analytical function that
+ has a branch cut `[-inf, -1]` and is continuous from above on it. `log1p`
+ handles the floating-point negative zero as an infinitesimal negative
+ number, conforming to the C99 standard.
+
+ References
+ ----------
+ .. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
+ 10th printing, 1964, pp. 67. http://www.math.sfu.ca/~cbm/aands/
+ .. [2] Wikipedia, "Logarithm". http://en.wikipedia.org/wiki/Logarithm
+
+ Examples
+ --------
+ >>> np.log1p(1e-99)
+ 1e-99
+ >>> np.log(1 + 1e-99)
+ 0.0
""")
add_newdoc('numpy.core.umath', 'logical_and',
"""
- Returns x1 and x2 elementwise.
+ Compute the truth value of x1 AND x2 elementwise.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ Logical AND is applied to the elements of `x1` and `x2`.
+ They have to be of the same shape.
+
+
+ Returns
+ -------
+ y : {ndarray, bool}
+ Boolean result with the same shape as `x1` and `x2` of the logical
+ AND operation on elements of `x1` and `x2`.
+
+ See Also
+ --------
+ logical_or, logical_not, logical_xor
+ bitwise_and
+
+ Examples
+ --------
+ >>> np.logical_and(True, False)
+ False
+ >>> np.logical_and([True, False], [False, False])
+ array([False, False], dtype=bool)
+
+ >>> x = np.arange(5)
+ >>> np.logical_and(x>1, x<4)
+ array([False, False, True, True, False], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'logical_not',
"""
- Returns not x elementwise.
+ Compute the truth value of NOT x elementwise.
+
+ Parameters
+ ----------
+ x : array_like
+ Logical NOT is applied to the elements of `x`.
+
+ Returns
+ -------
+ y : {ndarray, bool}
+ Boolean result with the same shape as `x` of the NOT operation
+ on elements of `x`.
+
+ See Also
+ --------
+ logical_and, logical_or, logical_xor
+
+ Examples
+ --------
+ >>> np.logical_not(3)
+ False
+ >>> np.logical_not([True, False, 0, 1])
+ array([False, True, True, False], dtype=bool)
+
+ >>> x = np.arange(5)
+ >>> np.logical_not(x<3)
+ array([False, False, False, True, True], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'logical_or',
"""
- Returns x1 or x2 elementwise.
+ Compute the truth value of x1 OR x2 elementwise.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ Logical OR is applied to the elements of `x1` and `x2`.
+ They have to be of the same shape.
+
+ Returns
+ -------
+ y : {ndarray, bool}
+ Boolean result with the same shape as `x1` and `x2` of the logical
+ OR operation on elements of `x1` and `x2`.
+
+ See Also
+ --------
+ logical_and, logical_not, logical_xor
+ bitwise_or
+
+ Examples
+ --------
+ >>> np.logical_or(True, False)
+ True
+ >>> np.logical_or([True, False], [False, False])
+ array([ True, False], dtype=bool)
+
+ >>> x = np.arange(5)
+ >>> np.logical_or(x < 1, x > 3)
+ array([ True, False, False, False, True], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'logical_xor',
"""
- Returns x1 xor x2 elementwise.
+ Compute the truth value of x1 XOR x2 elementwise.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ Logical XOR is applied to the elements of `x1` and `x2`.
+ They have to be of the same shape.
+
+ Returns
+ -------
+ y : {ndarray, bool}
+ Boolean result with the same shape as `x1` and `x2` of the logical
+ XOR operation on elements of `x1` and `x2`.
+
+ See Also
+ --------
+ logical_and, logical_or, logical_not
+ bitwise_xor
+
+ Examples
+ --------
+ >>> np.logical_xor(True, False)
+ True
+ >>> np.logical_xor([True, True, False, False], [True, False, True, False])
+ array([False, True, True, False], dtype=bool)
+
+ >>> x = np.arange(5)
+ >>> np.logical_xor(x < 1, x > 3)
+ array([ True, False, False, False, True], dtype=bool)
""")
@@ -275,51 +1652,233 @@ add_newdoc('numpy.core.umath', 'minimum',
add_newdoc('numpy.core.umath', 'modf',
"""
- Breaks x into fractional (y1) and integral (y2) parts.
+ Return the fractional and integral part of a number.
+
+ The fractional and integral parts are negative if the given number is
+ negative.
- Each output has the same sign as the input.
+ Parameters
+ ----------
+ x : array_like
+ Input number.
+
+ Returns
+ -------
+ y1 : ndarray
+ Fractional part of `x`.
+ y2 : ndarray
+ Integral part of `x`.
+
+ Examples
+ --------
+ >>> np.modf(2.5)
+ (0.5, 2.0)
+ >>> np.modf(-.4)
+ (-0.40000000000000002, -0.0)
""")
add_newdoc('numpy.core.umath', 'multiply',
"""
- Multiplies the arguments elementwise.
+ Multiply arguments elementwise.
+
+ Parameters
+ ----------
+ x1, x2 : array-like
+ The arrays to be multiplied.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The product of `x1` and `x2`, elementwise. Returns a scalar if
+ both `x1` and `x2` are scalars.
+
+ Notes
+ -----
+ Equivalent to `x1` * `x2` in terms of array-broadcasting.
+
+ Examples
+ --------
+ >>> np.multiply(2.0, 4.0)
+ 8.0
+
+ >>> x1 = np.arange(9.0).reshape((3, 3))
+ >>> x2 = np.arange(3.0)
+ >>> np.multiply(x1, x2)
+ array([[ 0., 1., 4.],
+ [ 0., 4., 10.],
+ [ 0., 7., 16.]])
""")
add_newdoc('numpy.core.umath', 'negative',
"""
- Determines -x elementwise
+ Returns an array with the negative of each element of the original array.
+
+ Parameters
+ ----------
+ x : {array_like, scalar}
+ Input array.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ Returned array or scalar `y=-x`.
+
+ Examples
+ --------
+ >>> np.negative([1.,-1.])
+ array([-1., 1.])
""")
add_newdoc('numpy.core.umath', 'not_equal',
"""
- Returns elementwise x1 |= x2
+ Return (x1 != x2) element-wise.
+
+ Parameters
+ ----------
+ x1, x2 : array_like
+ Input arrays.
+ out : ndarray, optional
+ A placeholder the same shape as `x1` to store the result.
+
+ Returns
+ -------
+ not_equal : ndarray bool, scalar bool
+ For each element in `x1, x2`, return True if `x1` is not equal
+ to `x2` and False otherwise.
+
+
+ See Also
+ --------
+ equal, greater, greater_equal, less, less_equal
+
+ Examples
+ --------
+ >>> np.not_equal([1.,2.], [1., 3.])
+ array([False, True], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'ones_like',
"""
- Returns an array of ones of the shape and typecode of x.
+ Returns an array of zeros with the same shape and type as a given array.
+
+ Equivalent to ``a.copy().fill(1)``.
+
+ Please refer to the documentation for `zeros_like`.
+
+ See Also
+ --------
+ zeros_like
+
+ Examples
+ --------
+ >>> a = np.array([[1, 2, 3], [4, 5, 6]])
+ >>> np.ones_like(a)
+ array([[1, 1, 1],
+ [1, 1, 1]])
""")
add_newdoc('numpy.core.umath', 'power',
"""
- Computes x1**x2 elementwise.
+ Computes `x1` ** `x2` elementwise.
+
+ Raise each base in `x1` to the power of the exponents in `x2`. This
+ requires that `x1` and `x2` must be broadcastable to the same shape.
+
+ Parameters
+ ----------
+ x1 : array_like
+ The bases.
+ x2 : array_like
+ The exponents.
+
+ Returns
+ -------
+ y : ndarray
+ The bases in `x1` raised to the exponents in `x2`.
+
+ Examples
+ --------
+ Cube each element in a list.
+
+ >>> x1 = range(6)
+ >>> x1
+ [0, 1, 2, 3, 4, 5]
+ >>> np.power(x1, 3)
+ array([ 0, 1, 8, 27, 64, 125])
+
+ Raise the bases to different exponents.
+
+ >>> x2 = [1.0, 2.0, 3.0, 3.0, 2.0, 1.0]
+ >>> np.power(x1, x2)
+ array([ 0., 1., 8., 27., 16., 5.])
+
+ The effect of broadcasting.
+
+ >>> x2 = np.array([[1, 2, 3, 3, 2, 1], [1, 2, 3, 3, 2, 1]])
+ >>> x2
+ array([[1, 2, 3, 3, 2, 1],
+ [1, 2, 3, 3, 2, 1]])
+ >>> np.power(x1, x2)
+ array([[ 0, 1, 8, 27, 16, 5],
+ [ 0, 1, 8, 27, 16, 5]])
""")
add_newdoc('numpy.core.umath', 'radians',
"""
- Converts angle from degrees to radians
+ Convert angles from degrees to radians.
+
+ Parameters
+ ----------
+ x : array_like
+ Angles in degrees.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The corresponding angle in radians.
+
+ See Also
+ --------
+ degrees : Convert angles from radians to degrees.
+ unwrap : Remove large jumps in angle by wrapping.
+
+ Notes
+ -----
+ ``radians(x)`` is ``x * pi / 180``.
+
+ Examples
+ --------
+ >>> np.radians(180)
+ 3.1415926535897931
""")
add_newdoc('numpy.core.umath', 'reciprocal',
"""
- Compute 1/x
+ Compute 1/x.
+
+ Parameters
+ ----------
+ x : array_like
+ Input value.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ Return value.
+
+ Examples
+ --------
+ >>> reciprocal(2.)
+ 0.5
+ >>> reciprocal([1, 2., 3.33])
+ array([ 1. , 0.5 , 0.3003003])
""")
@@ -327,6 +1886,33 @@ add_newdoc('numpy.core.umath', 'remainder',
"""
Computes x1-n*x2 where n is floor(x1 / x2)
+ Parameters
+ ----------
+ x1 : array_like
+ Dividend array.
+ x2 : array_like
+ Divisor array.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The quotient `x1/x2`, element-wise. Returns a scalar if
+ both `x1` and `x2` are scalars.
+
+ See Also
+ --------
+ divide
+ floor
+
+ Notes
+ -----
+ Returns 0 when `x2` is 0.
+
+ Examples
+ --------
+ >>> np.remainder([4,7],[2,3])
+ array([0, 1])
+
""")
add_newdoc('numpy.core.umath', 'right_shift',
@@ -337,55 +1923,266 @@ add_newdoc('numpy.core.umath', 'right_shift',
add_newdoc('numpy.core.umath', 'rint',
"""
- Round x elementwise to the nearest integer, round halfway cases away from zero
+ Round elements of the array to the nearest integer.
+
+ Parameters
+ ----------
+ x : array_like
+ Input array.
+
+ Returns
+ -------
+ out : ndarray
+ Output array is same shape and type as `x`.
+
+ Examples
+ --------
+ >>> a = [-4.1, -3.6, -2.5, 0.1, 2.5, 3.1, 3.9]
+ >>> np.rint(a)
+ array([-4., -4., -2., 0., 2., 3., 4.])
""")
add_newdoc('numpy.core.umath', 'sign',
"""
- Returns -1 if x < 0 and 0 if x==0 and 1 if x > 0
+ Return the sign of a number.
+
+ -1 if x < 0, 0 if x==0, 1 if x > 0.
+
+ Parameters
+ ----------
+ x : array_like
+ Input values.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The sign of `x`.
+
+ Examples
+ --------
+ >>> np.sign([-5., 4.5])
+ array([-1., 1.])
+ >>> np.sign(0)
+ 0
""")
add_newdoc('numpy.core.umath', 'signbit',
"""
- Returns True where signbit of x is set (x<0).
+ Returns True where `signbit` of `x` is set (`x<0`).
+
+ Parameters
+ ----------
+ x: array-like or scalar
+ the input value(s).
+ output : array-like or scalar
+ the returned boolean(s)
+
+ Examples
+ --------
+ >>> np.signbit(-1.2)
+ True
+ >>> np.signbit(np.array([1,-2.3,2.1]))
+ array([False, True, False], dtype=bool)
""")
add_newdoc('numpy.core.umath', 'sin',
"""
- Sine elementwise.
+ Trigonometric sine, element-wise.
+
+ Parameters
+ ----------
+ x : array_like
+ Angle, in radians (:math:`2 \\pi` rad equals 360 degrees).
+
+ Returns
+ -------
+ y : array_like
+ The sine of each element of x.
+
+ See Also
+ --------
+ arcsin, sinh, cos
+
+ Notes
+ -----
+ The sine is one of the fundamental functions of trigonometry
+ (the mathematical study of triangles). Consider a circle of radius
+ 1 centered on the origin. A ray comes in from the :math:`+x` axis,
+ makes an angle at the origin (measured counter-clockwise from that
+ axis), and departs from the origin. The :math:`y` coordinate of
+ the outgoing ray's intersection with the unit circle is the sine
+ of that angle. It ranges from -1 for :math:`x=3\\pi / 2` to
+ +1 for :math:`\\pi / 2.` The function has zeroes where the angle is
+ a multiple of :math:`\\pi`. Sines of angles between :math:`\\pi` and
+ :math:`2\\pi` are negative. The numerous properties of the sine and
+ related functions are included in any standard trigonometry text.
+
+ Examples
+ --------
+ Print sine of one angle:
+
+ >>> np.sin(np.pi/2.)
+ 1.0
+
+ Print sines of an array of angles given in degrees:
+
+ >>> np.sin(np.array((0., 30., 45., 60., 90.)) * np.pi / 180. )
+ array([ 0. , 0.5 , 0.70710678, 0.8660254 , 1. ])
+
+ Plot the sine function:
+
+ >>> import matplotlib.pylab as plt
+ >>> x = np.linspace(-np.pi, np.pi, 201)
+ >>> plt.plot(x, np.sin(x))
+ >>> plt.xlabel('Angle [rad]')
+ >>> plt.ylabel('sin(x)')
+ >>> plt.axis('tight')
+ >>> plt.show()
""")
add_newdoc('numpy.core.umath', 'sinh',
"""
- Hyperbolic sine elementwise.
+ Hyperbolic sine, element-wise.
+
+ Equivalent to ``1/2 * (np.exp(x) - np.exp(-x))`` or
+ ``-1j * np.sin(1j*x)``.
+
+ Parameters
+ ----------
+ x : array_like
+ Input array.
+
+ Returns
+ -------
+ out : ndarray
+ Output array of same shape as `x`.
""")
add_newdoc('numpy.core.umath', 'sqrt',
"""
- Square-root elementwise. For real x, the domain is restricted to x>=0.
+ Return the positive square-root of an array, element-wise.
+
+ Parameters
+ ----------
+ x : array_like
+ The square root of each element in this array is calculated.
+
+ Returns
+ -------
+ y : ndarray
+ The square-root of each element in `x`. If any element in `x`
+ is complex, a complex array is returned. If all of the elements
+ of `x` are real, negative elements will return numpy.nan elements.
+
+ See Also
+ --------
+ numpy.lib.scimath.sqrt
+ A version which will return complex numbers when given negative reals.
+
+ Notes
+ -----
+ `sqrt` has a branch cut ``[-inf, 0)`` and is continuous from above on it.
+
+ Examples
+ --------
+ >>> np.sqrt([1,4,9])
+ array([ 1., 2., 3.])
+
+ >>> np.sqrt([4, -1, -3+4J])
+ array([ 2.+0.j, 0.+1.j, 1.+2.j])
+
+ >>> np.sqrt([4, -1, numpy.inf])
+ array([ 2., NaN, Inf])
""")
add_newdoc('numpy.core.umath', 'square',
"""
- Compute x**2.
+ Compute `x` squared, or `x` to the power of two.
+
+ Parameters
+ ----------
+ x : array_like or scalar
+ Input data.
+
+ Returns
+ -------
+ out : ndarray or scalar
+ Element-wise `x*x`, of the same shape and dtype as `x`.
+ `out` is a scalar if `x` is a scalar.
+
+ See Also
+ --------
+ numpy.linalg.matrix_power
+ sqrt
+ power
+
+ Examples
+ --------
+ >>> np.square([-1j, 1])
+ array([-1.-0.j, 1.+0.j])
""")
add_newdoc('numpy.core.umath', 'subtract',
"""
- Subtracts the arguments elementwise.
+ Subtract arguments elementwise.
+
+ Parameters
+ ----------
+ x1, x2 : {array_like, scalar}
+ The arrays to be subtracted from each other. If type is 'array_like'
+ the `x1` and `x2` shapes must be identical.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The difference of `x1` and `x2`, elementwise. Returns a scalar if
+ both `x1` and `x2` are scalars.
+
+ Notes
+ -----
+ Equivalent to `x1` - `x2` in terms of array-broadcasting.
+
+ Examples
+ --------
+ >>> np.subtract(1.0, 4.0)
+ -3.0
+
+ >>> x1 = np.arange(9.0).reshape((3, 3))
+ >>> x2 = np.arange(3.0)
+ >>> np.subtract(x1, x2)
+ array([[ 0., 0., 0.],
+ [ 3., 3., 3.],
+ [ 6., 6., 6.]])
""")
add_newdoc('numpy.core.umath', 'tan',
"""
- Tangent elementwise.
+ Compute tangent elementwise.
+
+ Parameters
+ ----------
+ x : array_like
+ Angles in radians.
+
+ Returns
+ -------
+ y : ndarray or scalar
+ The corresponding tangent values.
+
+
+ Examples
+ --------
+ >>> from math import pi
+ >>> np.tan(np.array([-pi,pi/2,pi]))
+ array([ 1.22460635e-16, 1.63317787e+16, -1.22460635e-16])
""")
@@ -393,11 +2190,48 @@ add_newdoc('numpy.core.umath', 'tanh',
"""
Hyperbolic tangent elementwise.
+ Parameters
+ ----------
+ x : array_like
+ Input array.
+
+ Returns
+ -------
+ y : ndarray or scalar
+ The corresponding hyperbolic tangent values.
+
""")
add_newdoc('numpy.core.umath', 'true_divide',
"""
- True divides the arguments elementwise.
+ Returns an elementwise, true division of the inputs.
+
+ Instead of the Python traditional 'floor division', this returns a true
+ division. True division adjusts the output type to present the best
+ answer, regardless of input types.
+
+ Parameters
+ ----------
+ x1 : array_like
+ Dividend
+ x2 : array_like
+ Divisor
+
+ Returns
+ -------
+ out : {ndarray, scalar}
+ Result is scalar if both inputs are scalar, ndarray otherwise.
+
+ Notes
+ -----
+ The floor division operator ('//') was added in Python 2.2 making '//'
+ and '/' equivalent operators. The default floor division operation of
+ '/' can be replaced by true division with
+ 'from __future__ import division'.
+
+ In Python 3.0, '//' will be the floor division operator and '/' will be
+ the true division operator. The 'true_divide(`x1`, `x2`)' function is
+ equivalent to true division in Python.
""")
diff --git a/numpy/core/defmatrix.py b/numpy/core/defmatrix.py
index 073f63388..1707e49fd 100644
--- a/numpy/core/defmatrix.py
+++ b/numpy/core/defmatrix.py
@@ -41,14 +41,40 @@ def _convert_from_string(data):
return newdata
def asmatrix(data, dtype=None):
- """ Returns 'data' as a matrix. Unlike matrix(), no copy is performed
- if 'data' is already a matrix or array. Equivalent to:
- matrix(data, copy=False)
+ """
+ Interpret the input as a matrix.
+
+ Unlike `matrix`, `asmatrix` does not make a copy if the input is already
+ a matrix or an ndarray. Equivalent to ``matrix(data, copy=False)``.
+
+ Parameters
+ ----------
+ data : array_like
+ Input data.
+
+ Returns
+ -------
+ mat : matrix
+ `data` interpreted as a matrix.
+
+ Examples
+ --------
+ >>> x = np.array([[1, 2], [3, 4]])
+
+ >>> m = np.asmatrix(x)
+
+ >>> x[0,0] = 5
+
+ >>> m
+ matrix([[5, 2],
+ [3, 4]])
+
"""
return matrix(data, dtype=dtype, copy=False)
def matrix_power(M,n):
- """Raise a square matrix to the (integer) power n.
+ """
+ Raise a square matrix to the (integer) power n.
For positive integers n, the power is computed by repeated matrix
squarings and matrix multiplications. If n=0, the identity matrix
@@ -57,7 +83,7 @@ def matrix_power(M,n):
Parameters
----------
- M : array-like
+ M : array_like
Must be a square array (that is, of dimension two and with
equal sizes).
n : integer
@@ -87,6 +113,7 @@ def matrix_power(M,n):
>>> np.linalg.matrix_power(np.array([[0,1],[-1,0]]),10)
array([[-1, 0],
[ 0, -1]])
+
"""
if len(M.shape) != 2 or M.shape[0] != M.shape[1]:
raise ValueError("input must be a square array")
@@ -126,25 +153,29 @@ def matrix_power(M,n):
class matrix(N.ndarray):
"""
- mat = matrix(data, dtype=None, copy=True)
+ matrix(data, dtype=None, copy=True)
- Returns a matrix from an array-like object, or a string of
- data. A matrix is a specialized 2-d array that retains
- its 2-d nature through operations and where '*' means matrix
- multiplication and '**' means matrix power.
+ Returns a matrix from an array-like object, or from a string
+ of data. A matrix is a specialized 2-d array that retains
+ its 2-d nature through operations. It has certain special
+ operators, such as ``*`` (matrix multiplication) and
+ ``**`` (matrix power).
Parameters
----------
- data : array-like or string
- If data is a string, then interpret the string as a matrix
- with commas or spaces separating columns and semicolons
+ data : array_like or string
+ If data is a string, the string is interpreted as a matrix
+ with commas or spaces separating columns, and semicolons
separating rows.
- If data is array-like than convert the array to a matrix.
dtype : data-type
- Anything that can be interpreted as a NumPy datatype.
+ Data-type of the output matrix.
copy : bool
If data is already an ndarray, then this flag determines whether
- or not the data will be copied
+ the data is copied, or whether a view is constructed.
+
+ See Also
+ --------
+ array
Examples
--------
@@ -153,6 +184,10 @@ class matrix(N.ndarray):
[[1 2]
[3 4]]
+ >>> np.matrix([[1, 2], [3, 4]])
+ matrix([[1, 2],
+ [3, 4]])
+
"""
__array_priority__ = 10.0
def __new__(subtype, data, dtype=None, copy=True):
@@ -486,6 +521,26 @@ class matrix(N.ndarray):
return self.__array__().ravel()
def getT(self):
+ """
+ m.T
+
+ Returns the transpose of m.
+
+ Examples
+ --------
+ >>> m = np.matrix('[1, 2; 3, 4]')
+ >>> m
+ matrix([[1, 2],
+ [3, 4]])
+ >>> m.T
+ matrix([[1, 3],
+ [2, 4]])
+
+ See Also
+ --------
+ transpose
+
+ """
return self.transpose()
def getH(self):
@@ -527,20 +582,42 @@ def _from_string(str,gdict,ldict):
def bmat(obj, ldict=None, gdict=None):
"""
- Build a matrix object from string, nested sequence, or array.
+ Build a matrix object from a string, nested sequence, or array.
- Examples
- --------
- F = bmat('A, B; C, D')
- F = bmat([[A,B],[C,D]])
- F = bmat(r_[c_[A,B],c_[C,D]])
-
- All of these produce the same matrix::
+ Parameters
+ ----------
+ obj : string, sequence or array
+ Input data. Variables names in the current scope may
+ be referenced, even if `obj` is a string.
- [ A B ]
- [ C D ]
+ See Also
+ --------
+ matrix
- if A, B, C, and D are appropriately shaped 2-d arrays.
+ Examples
+ --------
+ >>> A = np.mat('1 1; 1 1')
+ >>> B = np.mat('2 2; 2 2')
+ >>> C = np.mat('3 4; 5 6')
+ >>> D = np.mat('7 8; 9 0')
+
+ All the following expressions construct the same block matrix:
+
+ >>> np.bmat([[A, B], [C, D]])
+ matrix([[1, 1, 2, 2],
+ [1, 1, 2, 2],
+ [3, 4, 7, 8],
+ [5, 6, 9, 0]])
+ >>> np.bmat(np.r_[np.c_[A, B], np.c_[C, D]])
+ matrix([[1, 1, 2, 2],
+ [1, 1, 2, 2],
+ [3, 4, 7, 8],
+ [5, 6, 9, 0]])
+ >>> np.bmat('A,B; C,D')
+ matrix([[1, 1, 2, 2],
+ [1, 1, 2, 2],
+ [3, 4, 7, 8],
+ [5, 6, 9, 0]])
"""
if isinstance(obj, str):
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index d3d94b891..073614495 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -43,22 +43,24 @@ def _wrapit(obj, method, *args, **kwds):
def take(a, indices, axis=None, out=None, mode='raise'):
- """Return an array formed from the elements of a at the given indices.
+ """
+ Take elements from an array along a given axis.
- This function does the same thing as "fancy" indexing; however, it can
- be easier to use if you need to specify a given axis.
+ This function does the same thing as "fancy" indexing (indexing arrays
+ using arrays); however, it can be easier to use if you need to specify
+ a given axis.
Parameters
----------
- a : array
- The source array
+ a : ndarray
+ The source array.
indices : int array
The indices of the values to extract.
- axis : {None, int}, optional
- The axis over which to select values. None signifies that the
- operation should be performed over the flattened array.
- out : {None, array}, optional
- If provided, the result will be inserted into this array. It should
+ axis : int, optional
+ The axis over which to select values. By default, the
+ flattened input array is used.
+ out : ndarray, optional
+ If provided, the result will be placed in this array. It should
be of the appropriate shape and dtype.
mode : {'raise', 'wrap', 'clip'}, optional
Specifies how out-of-bounds indices will behave.
@@ -68,8 +70,8 @@ def take(a, indices, axis=None, out=None, mode='raise'):
Returns
-------
- subarray : array
- The returned array has the same type as a.
+ subarray : ndarray
+ The returned array has the same type as `a`.
See Also
--------
@@ -85,22 +87,23 @@ def take(a, indices, axis=None, out=None, mode='raise'):
# not deprecated --- copy if necessary, view otherwise
def reshape(a, newshape, order='C'):
- """Returns an array containing the data of a, but with a new shape.
+ """
+ Returns an array containing the data of a, but with a new shape.
Parameters
----------
- a : array
+ a : ndarray
Array to be reshaped.
- newshape : shape tuple or int
- The new shape should be compatible with the original shape. If an
- integer, then the result will be a 1D array of that length.
- order : {'C', 'FORTRAN'}, optional
+ newshape : {tuple, int}
+ The new shape should be compatible with the original shape. If an
+ integer, then the result will be a 1-D array of that length.
+ order : {'C', 'F'}, optional
Determines whether the array data should be viewed as in C
(row-major) order or FORTRAN (column-major) order.
Returns
-------
- reshaped_array : array
+ reshaped_array : ndarray
This will be a new view object if possible; otherwise, it will
be a copy.
@@ -108,6 +111,19 @@ def reshape(a, newshape, order='C'):
--------
ndarray.reshape : Equivalent method.
+ Examples
+ --------
+ >>> a = np.array([[1,2], [3,4]])
+ >>> a.reshape(4)
+ array([1, 2, 3, 4])
+ >>> a.reshape(4, order='F')
+ array([1, 3, 2, 4])
+ >>> a.reshape((4,1))
+ array([[1],
+ [2],
+ [3],
+ [4]])
+
"""
try:
reshape = a.reshape
@@ -117,8 +133,8 @@ def reshape(a, newshape, order='C'):
def choose(a, choices, out=None, mode='raise'):
- """Use an index array to construct a new array from a set of
- choices.
+ """
+ Use an index array to construct a new array from a set of choices.
Given an array of integers and a set of n choice arrays, this function
will create a new array that merges each of the choice arrays. Where a
@@ -137,14 +153,16 @@ def choose(a, choices, out=None, mode='raise'):
If provided, the result will be inserted into this array. It should
be of the appropriate shape and dtype
mode : {'raise', 'wrap', 'clip'}, optional
- Specifies how out-of-bounds indices will behave.
- 'raise' : raise an error
- 'wrap' : wrap around
- 'clip' : clip to the range
+ Specifies how out-of-bounds indices will behave:
+
+ * 'raise' : raise an error
+ * 'wrap' : wrap around
+ * 'clip' : clip to the range
Returns
-------
merged_array : array
+ The merged results.
See Also
--------
@@ -171,29 +189,29 @@ def choose(a, choices, out=None, mode='raise'):
def repeat(a, repeats, axis=None):
- """Repeat elements of an array.
+ """
+ Repeat elements of an array.
Parameters
----------
- a : {array_like}
+ a : array_like
Input array.
- repeats : {integer, integer_array}
- The number of repetitions for each element. If a plain integer, then
- it is applied to all elements. If an array, it needs to be of the
- same length as the chosen axis.
- axis : {None, integer}, optional
- The axis along which to repeat values. If None, then this function
- will operated on the flattened array `a` and return a similarly flat
- result.
+ repeats : {int, array of ints}
+ The number of repetitions for each element. `repeats` is broadcasted
+ to fit the shape of the given axis.
+ axis : int, optional
+ The axis along which to repeat values. By default, use the
+ flattened input array, and return a flat output array.
Returns
-------
- repeated_array : array
+ repeated_array : ndarray
+ Output array which has the same shape as `a`, except along
+ the given axis.
See Also
--------
- ndarray.repeat : equivalent method
- tile : tile an array
+ tile : Tile an array.
Examples
--------
@@ -217,8 +235,10 @@ def repeat(a, repeats, axis=None):
def put(a, ind, v, mode='raise'):
- """Set a.flat[n] = v[n] for all n in ind.
- If v is shorter than ind, it will repeat.
+ """
+ Set a.flat[n] = v[n] for all n in ind.
+
+ If `v` is shorter than `ind`, it will repeat.
Parameters
----------
@@ -230,15 +250,18 @@ def put(a, ind, v, mode='raise'):
Values to place in `a` at target indices.
mode : {'raise', 'wrap', 'clip'}, optional
Specifies how out-of-bounds indices will behave.
- 'raise' -- raise an error
- 'wrap' -- wrap around
- 'clip' -- clip to the range
+
+ * 'raise' -- raise an error
+ * 'wrap' -- wrap around
+ * 'clip' -- clip to the range
Notes
-----
- If v is shorter than mask it will be repeated as necessary. In particular v
- can be a scalar or length 1 array. The routine put is the equivalent of the
- following (although the loop is in C for speed):
+ If `v` is shorter than `mask` it will be repeated as necessary. In
+ particular `v` can be a scalar or length 1 array. The routine put
+ is the equivalent of the following (although the loop is in C for
+ speed):
+ ::
ind = array(indices, copy=False)
v = array(values, copy=False).astype(a.dtype)
@@ -256,7 +279,8 @@ def put(a, ind, v, mode='raise'):
def swapaxes(a, axis1, axis2):
- """Return a view of array a with axis1 and axis2 interchanged.
+ """
+ Interchange two axes of an array.
Parameters
----------
@@ -267,6 +291,12 @@ def swapaxes(a, axis1, axis2):
axis2 : int
Second axis.
+ Returns
+ -------
+ a_swapped : ndarray
+ If `a` is an ndarray, then a view on `a` is returned, otherwise
+ a new array is created.
+
Examples
--------
>>> x = np.array([[1,2,3]])
@@ -279,13 +309,14 @@ def swapaxes(a, axis1, axis2):
>>> x
array([[[0, 1],
[2, 3]],
-
+ <BLANKLINE>
[[4, 5],
[6, 7]]])
+
>>> np.swapaxes(x,0,2)
array([[[0, 4],
[2, 6]],
-
+ <BLANKLINE>
[[1, 5],
[3, 7]]])
@@ -298,15 +329,26 @@ def swapaxes(a, axis1, axis2):
def transpose(a, axes=None):
- """Return a view of the array with dimensions permuted.
+ """
+ Permute the dimensions of an array.
Parameters
----------
a : array_like
Input array.
- axes : {None, list of int}, optional
- If None (the default), reverse dimensions, otherwise permute
- axes according to the values given.
+ axes : list of ints, optional
+ By default, reverse the dimensions, otherwise permute the axes
+ according to the values given.
+
+ Returns
+ -------
+ p : ndarray
+ `a` with its axes permuted. A view is returned whenever
+ possible.
+
+ See Also
+ --------
+ rollaxis
Examples
--------
@@ -319,9 +361,9 @@ def transpose(a, axes=None):
array([[0, 2],
[1, 3]])
- >>> np.transpose(x,(0,1)) # no change, axes are kept in current order
- array([[0, 1],
- [2, 3]])
+ >>> x = np.ones((1, 2, 3))
+ >>> np.transpose(x, (1, 0, 2)).shape
+ (2, 1, 3)
"""
try:
@@ -332,28 +374,27 @@ def transpose(a, axes=None):
def sort(a, axis=-1, kind='quicksort', order=None):
- """Return copy of 'a' sorted along the given axis.
-
- Perform an inplace sort along the given axis using the algorithm
- specified by the kind keyword.
+ """
+ Return a sorted copy of an array.
Parameters
----------
- a : array
+ a : array-like
Array to be sorted.
- axis : {None, int} optional
- Axis along which to sort. None indicates that the flattened
- array should be used.
+ axis : int, optional
+ Axis along which to sort. If not specified, the flattened array
+ is used.
kind : {'quicksort', 'mergesort', 'heapsort'}, optional
- Sorting algorithm to use.
- order : {None, list type}, optional
- When a is an array with fields defined, this argument specifies
+ Sorting algorithm.
+ order : list, optional
+ When `a` is an ndarray with fields defined, this argument specifies
which fields to compare first, second, etc. Not all fields need be
specified.
Returns
-------
- sorted_array : array of same type as a
+ sorted_array : ndarray
+ Array of same type and shape as `a`.
See Also
--------
@@ -363,8 +404,8 @@ def sort(a, axis=-1, kind='quicksort', order=None):
Notes
-----
- The various sorts are characterized by average speed, worst case
- performance, need for work space, and whether they are stable. A
+ The various sorting algorithms are characterized by their average speed,
+ worst case performance, work space size, and whether they are stable. A
stable sort keeps items with the same key in the same relative
order. The three available algorithms have the following
properties:
@@ -378,9 +419,21 @@ def sort(a, axis=-1, kind='quicksort', order=None):
=========== ======= ============= ============ =======
All the sort algorithms make temporary copies of the data when
- the sort is not along the last axis. Consequently, sorts along
- the last axis are faster and use less space than sorts along
- other axis.
+ sorting along any but the last axis. Consequently, sorting along
+ the last axis is faster and uses less space than sorting along
+ any other axis.
+
+ Examples
+ --------
+ >>> a=np.array([[1,4],[3,1]])
+ >>> a.sort(1)
+ >>> a
+ array([[1, 4],
+ [1, 3]])
+ >>> a.sort(0)
+ >>> a
+ array([[1, 3],
+ [1, 4]])
"""
if axis is None:
@@ -393,58 +446,77 @@ def sort(a, axis=-1, kind='quicksort', order=None):
def argsort(a, axis=-1, kind='quicksort', order=None):
- """Returns array of indices that index 'a' in sorted order.
+ """
+ Returns the indices that would sort an array.
Perform an indirect sort along the given axis using the algorithm specified
- by the kind keyword. It returns an array of indices of the same shape as a
- that index data along the given axis in sorted order.
+ by the `kind` keyword. It returns an array of indices of the same shape as
+ `a` that index data along the given axis in sorted order.
Parameters
----------
- a : array
- Array to be sorted.
- axis : {None, int} optional
- Axis along which to sort. None indicates that the flattened
- array should be used.
+ a : array_like
+ Array to sort.
+ axis : int, optional
+ Axis along which to sort. If not given, the flattened array is used.
kind : {'quicksort', 'mergesort', 'heapsort'}, optional
- Sorting algorithm to use.
- order : {None, list type}, optional
- When a is an array with fields defined, this argument specifies
+ Sorting algorithm.
+ order : list, optional
+ When `a` is an array with fields defined, this argument specifies
which fields to compare first, second, etc. Not all fields need be
specified.
Returns
-------
- index_array : {integer_array}
- Array of indices that sort 'a' along the specified axis.
+ index_array : ndarray of ints
+ Array of indices that sort `a` along the specified axis.
+ In other words, ``a[index_array]`` yields a sorted `a`.
See Also
--------
+ sort : Describes sorting algorithms used.
lexsort : Indirect stable sort with multiple keys.
- sort : Inplace sort.
+ ndarray.sort : Inplace sort.
Notes
-----
- The various sorts are characterized by average speed, worst case
- performance, need for work space, and whether they are stable. A
- stable sort keeps items with the same key in the same relative
- order. The three available algorithms have the following
- properties:
+ See `sort` for notes on the different sorting algorithms.
- +-----------+-------+-------------+------------+-------+
- | kind | speed | worst case | work space | stable|
- +===========+=======+=============+============+=======+
- | quicksort | 1 | O(n^2) | 0 | no |
- +-----------+-------+-------------+------------+-------+
- | mergesort | 2 | O(n*log(n)) | ~n/2 | yes |
- +-----------+-------+-------------+------------+-------+
- | heapsort | 3 | O(n*log(n)) | 0 | no |
- +-----------+-------+-------------+------------+-------+
+ Examples
+ --------
+ One dimensional array:
- All the sort algorithms make temporary copies of the data when
- the sort is not along the last axis. Consequently, sorts along
- the last axis are faster and use less space than sorts along
- other axis.
+ >>> x = np.array([3, 1, 2])
+ >>> np.argsort(x)
+ array([1, 2, 0])
+
+ Two-dimensional array:
+
+ >>> x = np.array([[0, 3], [2, 2]])
+ >>> x
+ array([[0, 3],
+ [2, 2]])
+
+ >>> np.argsort(x, axis=0)
+ array([[0, 1],
+ [1, 0]])
+
+ >>> np.argsort(x, axis=1)
+ array([[0, 1],
+ [0, 1]])
+
+ Sorting with keys:
+
+ >>> x = np.array([(1, 0), (0, 1)], dtype=[('x', '<i4'), ('y', '<i4')])
+ >>> x
+ array([(1, 0), (0, 1)],
+ dtype=[('x', '<i4'), ('y', '<i4')])
+
+ >>> np.argsort(x, order=('x','y'))
+ array([1, 0])
+
+ >>> np.argsort(x, order=('y','x'))
+ array([0, 1])
"""
try:
@@ -455,28 +527,36 @@ def argsort(a, axis=-1, kind='quicksort', order=None):
def argmax(a, axis=None):
- """Returns array of indices of the maximum values of along the given axis.
+ """
+ Indices of the maximum values along a given axis.
Parameters
----------
- a : {array_like}
- Array to look in.
- axis : {None, integer}
- If None, the index is into the flattened array, otherwise along
- the specified axis
+ a : array_like
+ Input array.
+ axis : int, optional
+ By default, the index is into the flattened array, otherwise
+ along the specified axis.
Returns
-------
- index_array : {integer_array}
+ index_array : ndarray of ints
+ Array of indices into the array. It has the same shape `a`,
+ except with `axis` removed.
+
+ See Also
+ --------
+ amax : The maximum along a given axis.
+ unravel_index : Convert a flat index into an index tuple.
Examples
- --------
+ --------
>>> a = np.arange(6).reshape(2,3)
>>> np.argmax(a)
5
- >>> np.argmax(a,0)
+ >>> np.argmax(a, axis=0)
array([1, 1, 1])
- >>> np.argmax(a,1)
+ >>> np.argmax(a, axis=1)
array([2, 2])
"""
@@ -488,29 +568,10 @@ def argmax(a, axis=None):
def argmin(a, axis=None):
- """Return array of indices to the minimum values along the given axis.
-
- Parameters
- ----------
- a : {array_like}
- Array to look in.
- axis : {None, integer}
- If None, the index is into the flattened array, otherwise along
- the specified axis
-
- Returns
- -------
- index_array : {integer_array}
+ """
+ Return the indices of the minimum values along the given axis of `a`.
- Examples
- --------
- >>> a = np.arange(6).reshape(2,3)
- >>> np.argmin(a)
- 0
- >>> np.argmin(a,0)
- array([0, 0, 0])
- >>> np.argmin(a,1)
- array([0, 0])
+ Refer to `numpy.argmax` for detailed documentation.
"""
try:
@@ -521,47 +582,46 @@ def argmin(a, axis=None):
def searchsorted(a, v, side='left'):
- """Return indices where keys in v should be inserted to maintain order.
+ """
+ Find indices where elements should be inserted to maintain order.
- Find the indices into a sorted array such that if the corresponding keys in
- v were inserted before the indices the order of a would be preserved. If
- side='left', then the first such index is returned. If side='right', then
- the last such index is returned. If there is no such index because the key
- is out of bounds, then the length of a is returned, i.e., the key would need
- to be appended. The returned index array has the same shape as v.
+ Find the indices into a sorted array `a` such that, if the corresponding
+ elements in `v` were inserted before the indices, the order of `a` would
+ be preserved.
Parameters
----------
- a : 1-d array
- Array must be sorted in ascending order.
- v : array or list type
- Array of keys to be searched for in a.
+ a : 1-D array_like of shape (N,)
+ Input array, sorted in ascending order.
+ v : array_like
+ Values to insert into `a`.
side : {'left', 'right'}, optional
- If 'left', the index of the first location where the key could be
- inserted is found, if 'right', the index of the last such element is
- returned. If the is no such element, then either 0 or N is returned,
- where N is the size of the array.
+ If 'left', the index of the first suitable location found is given. If
+ 'right', return the last such index. If there is no suitable
+ index, return either 0 or N (where N is the length of `a`).
Returns
-------
- indices : integer array
- Array of insertion points with the same shape as v.
+ indices : array of ints
+ Array of insertion points with the same shape as `v`.
See Also
--------
- sort : Inplace sort.
- histogram : Produce histogram from 1-d data.
+ sort : In-place sort.
+ histogram : Produce histogram from 1-D data.
Notes
-----
- The array a must be 1-d and is assumed to be sorted in ascending
- order. Searchsorted uses binary search to find the required
- insertion points.
+ Binary search is used to find the required insertion points.
Examples
--------
- >>> np.searchsorted([1,2,3,4,5],[6,4,0])
- array([5, 3, 0])
+ >>> np.searchsorted([1,2,3,4,5], 3)
+ 2
+ >>> np.searchsorted([1,2,3,4,5], 3, side='right')
+ 3
+ >>> np.searchsorted([1,2,3,4,5], [-10, 10, 2, 3])
+ array([0, 5, 1, 2])
"""
try:
@@ -572,28 +632,40 @@ def searchsorted(a, v, side='left'):
def resize(a, new_shape):
- """Return a new array with the specified shape.
-
- The original array's total size can be any size. The new array is
- filled with repeated copies of a.
+ """
+ Return a new array with the specified shape.
- Note that a.resize(new_shape) will fill the array with 0's beyond
- current definition of a.
+ If the new array is larger than the original array, then the new array
+ is filled with repeated copied of `a`. Note that this behavior is different
+ from a.resize(new_shape) which fills with zeros instead of repeated
+ copies of `a`.
Parameters
----------
- a : {array_like}
- Array to be reshaped.
+ a : array_like
+ Array to be resized.
- new_shape : {tuple}
- Shape of reshaped array.
+ new_shape : {tuple, int}
+ Shape of resized array.
Returns
-------
- reshaped_array : {array}
+ reshaped_array : ndarray
The new array is formed from the data in the old array, repeated if
- necessary to fill out the required number of elements, with the new
- shape.
+ necessary to fill out the required number of elements.
+
+ See Also
+ --------
+ ndarray.resize : resize an array in-place.
+
+ Examples
+ --------
+ >>> a=np.array([[0,1],[2,3]])
+ >>> np.resize(a,(1,4))
+ array([[0, 1, 2, 3]])
+ >>> np.resize(a,(2,4))
+ array([[0, 1, 2, 3],
+ [0, 1, 2, 3]])
"""
if isinstance(new_shape, (int, nt.integer)):
@@ -620,15 +692,27 @@ def resize(a, new_shape):
def squeeze(a):
- """Remove single-dimensional entries from the shape of a.
+ """
+ Remove single-dimensional entries from the shape of an array.
+
+ Parameters
+ ----------
+ a : array-like
+ Input data.
+
+ Returns
+ -------
+ squeezed : ndarray
+ The input array, but with with all dimensions of length 1
+ removed. Whenever possible, a view on `a` is returned.
Examples
--------
- >>> x = np.array([[[1,1,1],[2,2,2],[3,3,3]]])
+ >>> x = np.array([[[0], [1], [2]]])
>>> x.shape
- (1, 3, 3)
+ (1, 3, 1)
>>> np.squeeze(x).shape
- (3, 3)
+ (3,)
"""
try:
@@ -639,39 +723,46 @@ def squeeze(a):
def diagonal(a, offset=0, axis1=0, axis2=1):
- """Return specified diagonals.
+ """
+ Return specified diagonals.
- If a is 2-d, returns the diagonal of self with the given offset, i.e., the
- collection of elements of the form a[i,i+offset]. If a has more than two
- dimensions, then the axes specified by axis1 and axis2 are used to determine
- the 2-d subarray whose diagonal is returned. The shape of the resulting
- array can be determined by removing axis1 and axis2 and appending an index
- to the right equal to the size of the resulting diagonals.
+ If `a` is 2-D, returns the diagonal of self with the given offset,
+ i.e., the collection of elements of the form `a[i,i+offset]`.
+ If `a` has more than two dimensions, then the axes specified
+ by `axis1` and `axis2` are used to determine the 2-D subarray
+ whose diagonal is returned. The shape of the resulting array
+ can be determined by removing `axis1` and `axis2` and appending
+ an index to the right equal to the size of the resulting diagonals.
Parameters
----------
- a : {array_like}
- Array from whis the diagonals are taken.
- offset : {0, integer}, optional
+ a : array_like
+ Array from which the diagonals are taken.
+ offset : int, optional
Offset of the diagonal from the main diagonal. Can be both positive
- and negative. Defaults to main diagonal.
- axis1 : {0, integer}, optional
- Axis to be used as the first axis of the 2-d subarrays from which
- the diagonals should be taken. Defaults to first axis.
- axis2 : {1, integer}, optional
- Axis to be used as the second axis of the 2-d subarrays from which
- the diagonals should be taken. Defaults to second axis.
+ and negative. Defaults to main diagonal (0).
+ axis1 : int, optional
+ Axis to be used as the first axis of the 2-D subarrays from which
+ the diagonals should be taken. Defaults to first axis (0).
+ axis2 : int, optional
+ Axis to be used as the second axis of the 2-D subarrays from which
+ the diagonals should be taken. Defaults to second axis (1).
Returns
-------
- array_of_diagonals : array of same type as a
- If a is 2-d, a 1-d array containing the diagonal is
- returned. If a has larger dimensions, then an array of
+ array_of_diagonals : ndarray
+ If `a` is 2-D, a 1-D array containing the diagonal is
+ returned. If `a` has larger dimensions, then an array of
diagonals is returned.
+ Raises
+ ------
+ ValueError
+ If the dimension of `a` is less than 2.
+
See Also
--------
- diag : Matlab workalike for 1-d and 2-d arrays.
+ diag : Matlab workalike for 1-D and 2-D arrays.
diagflat : Create diagonal arrays.
trace : Sum along diagonals.
@@ -690,7 +781,7 @@ def diagonal(a, offset=0, axis1=0, axis2=1):
>>> a
array([[[0, 1],
[2, 3]],
-
+ <BLANKLINE>
[[4, 5],
[6, 7]]])
>>> a.diagonal(0,-2,-1)
@@ -702,35 +793,37 @@ def diagonal(a, offset=0, axis1=0, axis2=1):
def trace(a, offset=0, axis1=0, axis2=1, dtype=None, out=None):
- """Return the sum along diagonals of the array.
+ """
+ Return the sum along diagonals of the array.
- If a is 2-d, returns the sum along the diagonal of self with the given offset, i.e., the
- collection of elements of the form a[i,i+offset]. If a has more than two
- dimensions, then the axes specified by axis1 and axis2 are used to determine
- the 2-d subarray whose trace is returned. The shape of the resulting
- array can be determined by removing axis1 and axis2 and appending an index
- to the right equal to the size of the resulting diagonals.
+ If a is 2-d, returns the sum along the diagonal of self with the given
+ offset, i.e., the collection of elements of the form a[i,i+offset]. If
+ a has more than two dimensions, then the axes specified by axis1 and
+ axis2 are used to determine the 2-d subarray whose trace is returned.
+ The shape of the resulting array can be determined by removing axis1
+ and axis2 and appending an index to the right equal to the size of the
+ resulting diagonals.
Parameters
----------
- a : {array_like}
+ a : array_like
Array from whis the diagonals are taken.
- offset : {0, integer}, optional
+ offset : integer, optional
Offset of the diagonal from the main diagonal. Can be both positive
and negative. Defaults to main diagonal.
- axis1 : {0, integer}, optional
+ axis1 : integer, optional
Axis to be used as the first axis of the 2-d subarrays from which
the diagonals should be taken. Defaults to first axis.
- axis2 : {1, integer}, optional
+ axis2 : integer, optional
Axis to be used as the second axis of the 2-d subarrays from which
the diagonals should be taken. Defaults to second axis.
- dtype : {None, dtype}, optional
+ dtype : dtype, optional
Determines the type of the returned array and of the accumulator
where the elements are summed. If dtype has the value None and a is
of integer type of precision less than the default integer
precision, then the default integer precision is used. Otherwise,
the precision is the same as that of a.
- out : {None, array}, optional
+ out : array, optional
Array into which the sum can be placed. Its type is preserved and
it must be of the right shape to hold the output.
@@ -753,61 +846,112 @@ def trace(a, offset=0, axis1=0, axis2=1, dtype=None, out=None):
return asarray(a).trace(offset, axis1, axis2, dtype, out)
def ravel(a, order='C'):
- """Return a 1d array containing the elements of a (copy only if needed).
+ """
+ Return a flattened array.
- Returns the elements of a as a 1d array. The elements in the new array
- are taken in the order specified by the order keyword. The new array is
- a view of a if possible, otherwise it is a copy.
+ A 1-d array, containing the elements of the input, is returned. A copy is
+ made only if needed.
Parameters
----------
- a : {array_like}
-
+ a : array_like
+ Input array. The elements in `a` are read in the order specified by
+ `order`, and packed as a 1-dimensional array.
order : {'C','F'}, optional
- If order is 'C' the elements are taken in row major order. If order
- is 'F' they are taken in column major order.
+ The elements of `a` are read in this order. It can be either
+ 'C' for row-major order, or `F` for column-major order.
+ By default, row-major order is used.
Returns
-------
- 1d_array : {array}
+ 1d_array : ndarray
+ Output of the same dtype as `a`, and of shape ``(a.size(),)`` (or
+ ``(np.prod(a.shape),)``).
See Also
--------
- ndarray.flat : 1d iterator over the array.
- ndarray.flatten : 1d array copy of the elements of a in C order.
+ ndarray.flat : 1-D iterator over an array.
+ ndarray.flatten : 1-D array copy of the elements of an array
+ in row-major order.
+
+ Notes
+ -----
+ In row-major order, the row index varies the slowest, and the column
+ index the quickest. This can be generalised to multiple dimensions,
+ where row-major order implies that the index along the first axis
+ varies slowest, and the index along the last quickest. The opposite holds
+ for Fortran-, or column-major, mode.
Examples
--------
- >>> x = np.array([[1,2,3],[4,5,6]])
- >>> x
- array([[1, 2, 3],
- [4, 5, 6]])
- >>> np.ravel(x)
- array([1, 2, 3, 4, 5, 6])
+ If an array is in C-order (default), then `ravel` is equivalent
+ to ``reshape(-1)``:
+
+ >>> x = np.array([[1, 2, 3], [4, 5, 6]])
+ >>> print x.reshape(-1)
+ [1 2 3 4 5 6]
+
+ >>> print np.ravel(x)
+ [1 2 3 4 5 6]
+
+ When flattening using Fortran-order, however, we see
+
+ >>> print np.ravel(x, order='F')
+ [1 4 2 5 3 6]
"""
return asarray(a).ravel(order)
def nonzero(a):
- """Return the indices of the elements of a which are not zero.
+ """
+ Return the indices of the elements that are non-zero.
+
+ Returns a tuple of arrays, one for each dimension of `a`, containing
+ the indices of the non-zero elements in that dimension. The
+ corresponding non-zero values can be obtained with::
+
+ a[nonzero(a)]
+
+ To group the indices by element, rather than dimension, use::
+
+ transpose(nonzero(a))
+
+ The result of this is always a 2-D array, with a row for
+ each non-zero element.
Parameters
----------
- a : {array_like}
+ a : array_like
+ Input array.
Returns
-------
- tuple_of_arrays : {tuple}
+ tuple_of_arrays : tuple
+ Indices of elements that are non-zero.
+
+ See Also
+ --------
+ flatnonzero :
+ Return indices that are non-zero in the flattened version of the input
+ array.
Examples
--------
- >>> np.eye(3)[np.nonzero(np.eye(3))]
- array([ 1., 1., 1.])
- >>> np.nonzero(np.eye(3))
+ >>> x = np.eye(3)
+ >>> x
+ array([[ 1., 0., 0.],
+ [ 0., 1., 0.],
+ [ 0., 0., 1.]])
+ >>> np.nonzero(x)
(array([0, 1, 2]), array([0, 1, 2]))
- >>> np.eye(3)[np.nonzero(np.eye(3))]
+
+ >>> x[np.nonzero(x)]
array([ 1., 1., 1.])
+ >>> np.transpose(np.nonzero(x))
+ array([[0, 0],
+ [1, 1],
+ [2, 2]])
"""
try:
@@ -820,19 +964,23 @@ def nonzero(a):
def shape(a):
- """Return the shape of a.
+ """
+ Return the shape of an array.
Parameters
----------
- a : {array_like}
- Array whose shape is desired. If a is not an array, a conversion is
- attempted.
+ a : array_like
+ Input array.
Returns
-------
- tuple_of_integers :
- The elements of the tuple are the length of the corresponding array
- dimension.
+ shape : tuple
+ The elements of the tuple give the lengths of the corresponding array
+ dimensions.
+
+ See Also
+ --------
+ ndarray.shape : array method
Examples
--------
@@ -840,6 +988,16 @@ def shape(a):
(3, 3)
>>> np.shape([[1,2]])
(1, 2)
+ >>> np.shape([0])
+ (1,)
+ >>> np.shape(0)
+ ()
+
+ >>> x = np.array([(1,2),(3,4)], dtype=[('x', 'i4'), ('y', 'i4')])
+ >>> np.shape(x)
+ (2,)
+ >>> x.shape
+ (2,)
"""
try:
@@ -850,7 +1008,8 @@ def shape(a):
def compress(condition, a, axis=None, out=None):
- """Return selected slices of an array along given axis.
+ """
+ Return selected slices of an array along given axis.
Parameters
----------
@@ -869,7 +1028,8 @@ def compress(condition, a, axis=None, out=None):
Returns
-------
compressed_array : array
- A copy of a, without the slices along axis for which condition is false.
+ A copy of `a` without the slices along axis for which `condition`
+ is false.
Examples
--------
@@ -891,25 +1051,34 @@ def compress(condition, a, axis=None, out=None):
def clip(a, a_min, a_max, out=None):
- """Return an array whose values are limited to [a_min, a_max].
+ """
+ Clip (limit) the values in an array.
+
+ Given an interval, values outside the interval are clipped to
+ the interval edges. For example, if an interval of ``[0, 1]``
+ is specified, values smaller than 0 become 0, and values larger
+ than 1 become 1.
Parameters
----------
- a : {array_like}
+ a : array_like
Array containing elements to clip.
- a_min :
- Minimum value
- a_max :
- Maximum value
- out : array, optional
- The results will be placed in this array. It may be the input array for
- inplace clipping.
+ a_min : scalar or array_like
+ Minimum value.
+ a_max : scalar or array_like
+ Maximum value. If `a_min` or `a_max` are array_like, then they will
+ be broadcasted to the shape of `a`.
+ out : ndarray, optional
+ The results will be placed in this array. It may be the input
+ array for in-place clipping. `out` must be of the right shape
+ to hold the output. Its type is preserved.
Returns
-------
- clipped_array : {array}
- A new array whose elements are same as for a, but values
- < a_min are replaced with a_min, and > a_max with a_max.
+ clipped_array : ndarray
+ An array with the elements of `a`, but where values
+ < `a_min` are replaced with `a_min`, and those > `a_max`
+ with `a_max`.
Examples
--------
@@ -922,6 +1091,8 @@ def clip(a, a_min, a_max, out=None):
array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
>>> a
array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
+ >>> np.clip(a, [3,4,1,1,1,4,4,4,4,4], 8)
+ array([3, 4, 2, 3, 4, 5, 6, 7, 8, 8])
"""
try:
@@ -932,37 +1103,45 @@ def clip(a, a_min, a_max, out=None):
def sum(a, axis=None, dtype=None, out=None):
- """Return the sum of the array elements over the given axis
+ """
+ Return the sum of array elements over a given axis.
Parameters
----------
- a : {array_type}
- Array containing elements whose sum is desired. If a is not an array, a
- conversion is attempted.
- axis : {None, integer}
- Axis over which the sum is taken. If None is used, then the sum is
- over all the array elements.
- dtype : {None, dtype}, optional
- Determines the type of the returned array and of the accumulator
- where the elements are summed. If dtype has the value None and the
- type of a is an integer type of precision less than the default
- platform integer, then the default platform integer precision is
- used. Otherwise, the dtype is the same as that of a.
- out : {None, array}, optional
- Array into which the sum can be placed. Its type is preserved and
- it must be of the right shape to hold the output.
+ a : array_like
+ Elements to sum.
+ axis : integer, optional
+ Axis over which the sum is taken. By default `axis` is None,
+ and all elements are summed.
+ dtype : dtype, optional
+ The type of the returned array and of the accumulator in which
+ the elements are summed. By default, the dtype of `a` is used.
+ An exception is when `a` has an integer type with less precision
+ than the default platform integer. In that case, the default
+ platform integer is used instead.
+ out : ndarray, optional
+ Array into which the output is placed. By default, a new array is
+ created. If `out` is given, it must be of the appropriate shape
+ (the shape of `a` with `axis` removed, i.e.,
+ ``numpy.delete(a.shape, axis)``). Its type is preserved.
Returns
-------
- sum_along_axis : {array, scalar}, see dtype parameter above.
- Returns an array whose shape is the same as a with the specified
- axis removed. Returns a 0d array when a is 1d or axis=None.
- Returns a reference to the specified output array if specified.
+ sum_along_axis : ndarray or scalar
+ An array with the same shape as `a`, with the specified
+ axis removed. If `a` is a 0-d array, or if `axis` is None, a scalar
+ is returned. If an output array is specified, a reference to
+ `out` is returned.
See Also
--------
ndarray.sum : equivalent method
+ Notes
+ -----
+ Arithmetic is modular when using integer types, and no error is
+ raised on overflow.
+
Examples
--------
>>> np.sum([0.5, 1.5])
@@ -973,13 +1152,11 @@ def sum(a, axis=None, dtype=None, out=None):
6
>>> np.sum([[0, 1], [0, 5]], axis=1)
array([1, 5])
- >>> np.ones(128, dtype=np.int8).sum(dtype=np.int8) # overflow!
- -128
- Notes
- -----
- Arithmetic is modular when using integer types, and no error is
- raised on overflow.
+ If the accumulator is too small, overflow occurs:
+
+ >>> np.ones(128, dtype=np.int8).sum(dtype=np.int8)
+ -128
"""
if isinstance(a, _gentype):
@@ -996,53 +1173,14 @@ def sum(a, axis=None, dtype=None, out=None):
def product (a, axis=None, dtype=None, out=None):
- """Return the product of the array elements over the given axis
-
- Parameters
- ----------
- a : {array_like}
- Array containing elements whose product is desired. If a is not an array, a
- conversion is attempted.
- axis : {None, integer}
- Axis over which the product is taken. If None is used, then the
- product is over all the array elements.
- dtype : {None, dtype}, optional
- Determines the type of the returned array and of the accumulator
- where the elements are multiplied. If dtype has the value None and
- the type of a is an integer type of precision less than the default
- platform integer, then the default platform integer precision is
- used. Otherwise, the dtype is the same as that of a.
- out : {None, array}, optional
- Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
+ """
+ Return the product of array elements over a given axis.
- Returns
- -------
- product_along_axis : {array, scalar}, see dtype parameter above.
- Returns an array whose shape is the same as a with the specified
- axis removed. Returns a 0d array when a is 1d or axis=None.
- Returns a reference to the specified output array if specified.
+ Refer to `numpy.prod` for full documentation.
See Also
--------
- ndarray.prod : equivalent method
-
- Examples
- --------
- >>> np.product([1.,2.])
- 2.0
- >>> np.product([1.,2.], dtype=np.int32)
- 2
- >>> np.product([[1.,2.],[3.,4.]])
- 24.0
- >>> np.product([[1.,2.],[3.,4.]], axis=1)
- array([ 2., 12.])
-
- Notes
- -----
- Arithmetic is modular when using integer types, and no error is
- raised on overflow.
+ prod : equivalent function
"""
try:
@@ -1054,33 +1192,13 @@ def product (a, axis=None, dtype=None, out=None):
def sometrue(a, axis=None, out=None):
"""
- Assert whether some values are true.
-
- `sometrue` performs a logical_or over the given axis.
+ Check whether some values are true.
- Parameters
- ----------
- a : array_like
- Array on which to operate.
- axis : {None, integer}
- Axis to perform the operation over.
- If `None` (default), perform over flattened array.
- out : {None, array}, optional
- Array into which the product can be placed. Its type is preserved
- and it must be of the right shape to hold the output.
+ Refer to `any` for full documentation.
See Also
--------
- ndarray.any : equivalent method
-
- Examples
- --------
- >>> b = np.array([True, False, True, True])
- >>> np.sometrue(b)
- True
- >>> a = np.array([1, 5, 2, 7])
- >>> np.sometrue(a >= 5)
- True
+ any : equivalent function
"""
try:
@@ -1091,23 +1209,15 @@ def sometrue(a, axis=None, out=None):
def alltrue (a, axis=None, out=None):
- """Check if all of the elements of `a` are true.
-
- Performs a logical_and over the given axis and returns the result
+ """
+ Check if all of the elements of `a` are true.
- Parameters
- ----------
- a : array_like
- axis : {None, integer}
- Axis to perform the operation over.
- If None, perform over flattened array.
- out : {None, array}, optional
- Array into which the product can be placed. Its type is preserved
- and it must be of the right shape to hold the output.
+ Please refer to the `numpy.all` documentation. `numpy.all` is
+ the same function.
See Also
--------
- ndarray.all : equivalent method
+ numpy.all : equivalent function
"""
try:
@@ -1118,24 +1228,48 @@ def alltrue (a, axis=None, out=None):
def any(a,axis=None, out=None):
- """Check if any of the elements of `a` are true.
-
- Performs a logical_or over the given axis and returns the result
+ """
+ Test whether any elements of an array evaluate to true along a given axis.
Parameters
----------
a : array_like
- axis : {None, integer}
- Axis to perform the operation over.
- If None, perform over flattened array and return a scalar.
- out : {None, array}, optional
- Array into which the product can be placed. Its type is preserved
+ Input array.
+ axis : int, optional
+ Axis over which to perform the operation.
+ If None, use a flattened input array and return a bool.
+ out : ndarray, optional
+ Array into which the result is placed. Its type is preserved
and it must be of the right shape to hold the output.
+ Returns
+ -------
+ out : ndarray
+ A logical OR is performed along `axis`, and the result placed
+ in `out`. If `out` was not specified, a new output array is created.
+
See Also
--------
ndarray.any : equivalent method
+ Notes
+ -----
+ Since NaN is not equal to zero, NaN evaluates to True.
+
+ Examples
+ --------
+ >>> np.any([[True, False], [True, True]])
+ True
+
+ >>> np.any([[True, False], [False, False]], axis=0)
+ array([ True, False], dtype=bool)
+
+ >>> np.any([-1, 0, 5])
+ True
+
+ >>> np.any(np.nan)
+ True
+
"""
try:
any = a.any
@@ -1145,24 +1279,48 @@ def any(a,axis=None, out=None):
def all(a,axis=None, out=None):
- """Check if all of the elements of `a` are true.
-
- Performs a logical_and over the given axis and returns the result
+ """
+ Test whether all elements of an array evaluate to true along a given axis.
Parameters
----------
a : array_like
- axis : {None, integer}
- Axis to perform the operation over.
- If None, perform over flattened array and return a scalar.
- out : {None, array}, optional
- Array into which the product can be placed. Its type is preserved
+ Input array.
+ axis : int, optional
+ Axis over which to perform the operation.
+ If None, use a flattened input array and return a bool.
+ out : ndarray, optional
+ Array into which the result is placed. Its type is preserved
and it must be of the right shape to hold the output.
+ Returns
+ -------
+ out : ndarray
+ A logical AND is performed along `axis`, and the result placed
+ in `out`. If `out` was not specified, a new output array is created.
+
See Also
--------
ndarray.all : equivalent method
+ Notes
+ -----
+ Since NaN is not equal to zero, NaN evaluates to True.
+
+ Examples
+ --------
+ >>> np.all([[True,False],[True,True]])
+ False
+
+ >>> np.all([[True,False],[True,True]], axis=0)
+ array([ True, False], dtype=bool)
+
+ >>> np.all([-1, 4, 5])
+ True
+
+ >>> np.all([1.0, np.nan])
+ True
+
"""
try:
all = a.all
@@ -1179,10 +1337,12 @@ def cumsum (a, axis=None, dtype=None, out=None):
----------
a : array-like
Input array or object that can be converted to an array.
- axis : {None, -1, int}, optional
- Axis along which the sum is computed. The default
- (`axis` = `None`) is to compute over the flattened array.
- dtype : {None, dtype}, optional
+ axis : int, optional
+ Axis along which the cumulative sum is computed. The default
+ (`axis` = `None`) is to compute the cumsum over the flattened
+ array. `axis` may be negative, in which case it counts from the
+ last to the first axis.
+ dtype : dtype, optional
Type of the returned array and of the accumulator in which the
elements are summed. If `dtype` is not specified, it defaults
to the dtype of `a`, unless `a` has an integer dtype with a
@@ -1204,11 +1364,10 @@ def cumsum (a, axis=None, dtype=None, out=None):
Arithmetic is modular when using integer types, and no error is
raised on overflow.
-
Examples
--------
- >>> a=np.array([[1,2,3],[4,5,6]])
- >>> np.cumsum(a) # cumulative sum = intermediate summing results & total sum. Default axis=None results in raveling the array first.
+ >>> a = np.array([[1,2,3],[4,5,6]])
+ >>> np.cumsum(a)
array([ 1, 3, 6, 10, 15, 21])
>>> np.cumsum(a,dtype=float) # specifies type of output value(s)
array([ 1., 3., 6., 10., 15., 21.])
@@ -1228,7 +1387,10 @@ def cumsum (a, axis=None, dtype=None, out=None):
def cumproduct(a, axis=None, dtype=None, out=None):
- """Return the cumulative product over the given axis.
+ """
+ Return the cumulative product over the given axis.
+
+ See `cumprod` for full documentation.
See Also
--------
@@ -1243,26 +1405,26 @@ def cumproduct(a, axis=None, dtype=None, out=None):
def ptp(a, axis=None, out=None):
- """Return (maximum - minimum) along the the given dimension
- (i.e. peak-to-peak value).
+ """
+ Peak to peak (maximum - minimum) value along a given axis.
Parameters
----------
a : array_like
Input values.
- axis : {None, int}, optional
- Axis along which to find the peaks. If None (default) the
- flattened array is used.
+ axis : int, optional
+ Axis along which to find the peaks. By default, flatten the
+ array.
out : array_like
Alternative output array in which to place the result. It must
- have the same shape and buffer length as the expected output
- but the type will be cast if necessary.
+ have the same shape and buffer length as the expected output,
+ but the type of the output values will be cast if necessary.
Returns
-------
- ptp : ndarray.
- A new array holding the result, unless ``out`` was
- specified, in which case a reference to ``out`` is returned.
+ ptp : ndarray
+ A new array holding the result, unless `out` was
+ specified, in which case a reference to `out` is returned.
Examples
--------
@@ -1270,9 +1432,11 @@ def ptp(a, axis=None, out=None):
>>> x
array([[0, 1],
[2, 3]])
- >>> np.ptp(x,0)
+
+ >>> np.ptp(x, axis=0)
array([2, 2])
- >>> np.ptp(x,1)
+
+ >>> np.ptp(x, axis=1)
array([1, 1])
"""
@@ -1284,23 +1448,24 @@ def ptp(a, axis=None, out=None):
def amax(a, axis=None, out=None):
- """Return the maximum along a given axis.
+ """
+ Return the maximum along a given axis.
Parameters
----------
a : array_like
Input data.
- axis : {None, int}, optional
- Axis along which to operate. By default, ``axis`` is None and the
- flattened input is used.
- out : array_like, optional
+ axis : int, optional
+ Axis along which to operate. By default flattened input is used.
+ out : ndarray, optional
Alternative output array in which to place the result. Must
be of the same shape and buffer length as the expected output.
Returns
-------
- amax : array_like
- New array holding the result, unless ``out`` was specified.
+ amax : {ndarray, scalar}
+ A new array or a scalar with the result, or a reference to `out`
+ if it was specified.
Examples
--------
@@ -1322,23 +1487,24 @@ def amax(a, axis=None, out=None):
def amin(a, axis=None, out=None):
- """Return the minimum along a given axis.
+ """
+ Return the minimum along a given axis.
Parameters
----------
a : array_like
Input data.
- axis : {None, int}, optional
- Axis along which to operate. By default, ``axis`` is None and the
- flattened input is used.
- out : array_like, optional
+ axis : int, optional
+ Axis along which to operate. By default a flattened input is used.
+ out : ndarray, optional
Alternative output array in which to place the result. Must
be of the same shape and buffer length as the expected output.
Returns
-------
- amin : array_like
- New array holding the result, unless ``out`` was specified.
+ amin : {ndarray, scalar}
+ A new array or a scalar with the result, or a reference to `out` if it
+ was specified.
Examples
--------
@@ -1361,12 +1527,12 @@ def amin(a, axis=None, out=None):
def alen(a):
"""
- Return the length of a Python object interpreted as an array
- of at least 1 dimension.
+ Return the length of an array_like as an array of at least 1 dimension.
Parameters
----------
a : array_like
+ Input array.
Returns
-------
@@ -1389,53 +1555,74 @@ def alen(a):
def prod(a, axis=None, dtype=None, out=None):
- """Return the product of the array elements over the given axis
+ """
+ Return the product of array elements over a given axis.
Parameters
----------
- a : {array_like}
- Array containing elements whose product is desired. If a is not an array, a
- conversion is attempted.
- axis : {None, integer}
- Axis over which the product is taken. If None is used, then the
- product is over all the array elements.
- dtype : {None, dtype}, optional
- Determines the type of the returned array and of the accumulator
- where the elements are multiplied. If dtype has the value None and
- the type of a is an integer type of precision less than the default
- platform integer, then the default platform integer precision is
- used. Otherwise, the dtype is the same as that of a.
- out : {None, array}, optional
+ a : array_like
+ Input data.
+ axis : int, optional
+ Axis over which the product is taken. By default, the product
+ of all elements is calculated.
+ dtype : data-type, optional
+ The data-type of the returned array, as well as of the accumulator
+ in which the elements are multiplied. By default, if `a` is of
+ integer type, `dtype` is the default platform integer (note: if
+ the type of `a` is unsigned, then so is `dtype`). Otherwise,
+ the dtype is the same as that of `a`.
+ out : ndarray, optional
Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
+ the same shape as the expected output, but the type of the
+ output values will be cast if necessary.
Returns
-------
- product_along_axis : {array, scalar}, see dtype parameter above.
- Returns an array whose shape is the same as a with the specified
- axis removed. Returns a 0d array when a is 1d or axis=None.
- Returns a reference to the specified output array if specified.
+ product_along_axis : {ndarray, scalar}, see `dtype` parameter above.
+ An array shaped as `a` but with the specified axis removed.
+ Returns a reference to `out` if specified.
See Also
--------
ndarray.prod : equivalent method
+ Notes
+ -----
+ Arithmetic is modular when using integer types, and no error is
+ raised on overflow. That means that, on a 32-bit platform:
+
+ >>> x = np.array([536870910, 536870910, 536870910, 536870910])
+ >>> np.prod(x) #random
+ 16
+
Examples
--------
+ By default, calculate the product of all elements:
+
>>> np.prod([1.,2.])
2.0
- >>> np.prod([1.,2.], dtype=np.int32)
- 2
+
+ Even when the input array is two-dimensional:
+
>>> np.prod([[1.,2.],[3.,4.]])
24.0
+
+ But we can also specify the axis over which to multiply:
+
>>> np.prod([[1.,2.],[3.,4.]], axis=1)
array([ 2., 12.])
- Notes
- -----
- Arithmetic is modular when using integer types, and no error is
- raised on overflow.
+ If the type of `x` is unsigned, then the output type is
+ the unsigned platform integer:
+
+ >>> x = np.array([1, 2, 3], dtype=np.uint8)
+ >>> np.prod(x).dtype == np.uint
+
+ If `x` is of a signed integer type, then the output type
+ is the default platform integer:
+
+ >>> x = np.array([1, 2, 3], dtype=np.int8)
+ >>> np.prod(x).dtype == np.int
"""
try:
@@ -1447,28 +1634,25 @@ def prod(a, axis=None, dtype=None, out=None):
def cumprod(a, axis=None, dtype=None, out=None):
"""
- Return the cumulative product of the elements along the given axis.
-
- The cumulative product is taken over the flattened array by
- default, otherwise over the specified axis.
+ Return the cumulative product of elements along a given axis.
Parameters
----------
a : array-like
- Input array or object that can be converted to an array.
- axis : {None, -1, int}, optional
- Axis along which the product is computed. The default
- (`axis` = `None`) is to compute over the flattened array.
- dtype : {None, dtype}, optional
- Type of the returned array and of the accumulator
- where the elements are multiplied. If `dtype` has the value `None` and
- the type of `a` is an integer type of precision less than the default
- platform integer, then the default platform integer precision is
- used. Otherwise, the `dtype` is the same as that of `a`.
+ Input array.
+ axis : int, optional
+ Axis along which the cumulative product is computed. By default the
+ input is flattened.
+ dtype : dtype, optional
+ Type of the returned array, as well as of the accumulator in which
+ the elements are multiplied. If dtype is not specified, it defaults
+ to the dtype of `a`, unless `a` has an integer dtype with a precision
+ less than that of the default platform integer. In that case, the
+ default platform integer is used instead.
out : ndarray, optional
Alternative output array in which to place the result. It must
have the same shape and buffer length as the expected output
- but the type will be cast if necessary.
+ but the type of the resulting values will be cast if necessary.
Returns
-------
@@ -1483,20 +1667,25 @@ def cumprod(a, axis=None, dtype=None, out=None):
Examples
--------
- >>> a=np.array([[1,2,3],[4,5,6]])
- >>> a=np.array([1,2,3])
+ >>> a = np.array([1,2,3])
>>> np.cumprod(a) # intermediate results 1, 1*2
- ... # total product 1*2*3 = 6
+ ... # total product 1*2*3 = 6
array([1, 2, 6])
- >>> a=np.array([[1,2,3],[4,5,6]])
- >>> np.cumprod(a,dtype=float) # specify type of output
+ >>> a = np.array([[1, 2, 3], [4, 5, 6]])
+ >>> np.cumprod(a, dtype=float) # specify type of output
array([ 1., 2., 6., 24., 120., 720.])
- >>> np.cumprod(a,axis=0) # for each of the 3 columns:
- ... # product and intermediate results
+
+ The cumulative product for each column (i.e., over the rows of)
+ `a`:
+
+ >>> np.cumprod(a, axis=0)
array([[ 1, 2, 3],
[ 4, 10, 18]])
- >>> np.cumprod(a,axis=1) # for each of the two rows:
- ... # product and intermediate results
+
+ The cumulative product for each row (i.e. over the columns of)
+ `a`:
+
+ >>> np.cumprod(a,axis=1)
array([[ 1, 2, 6],
[ 4, 20, 120]])
@@ -1509,25 +1698,22 @@ def cumprod(a, axis=None, dtype=None, out=None):
def ndim(a):
- """Return the number of dimensions of a.
-
- If a is not already an array, a conversion is attempted. Scalars are zero
- dimensional.
+ """
+ Return the number of dimensions of an array.
Parameters
----------
- a : {array_like}
- Array whose number of dimensions are desired. If a is not an
- array, a conversion is attempted.
+ a : array_like
+ Input array. If it is not already an ndarray, a conversion is
+ attempted.
Returns
-------
- number_of_dimensions : {integer}
- Returns the number of dimensions.
+ number_of_dimensions : int
+ The number of dimensions in `a`. Scalars are zero-dimensional.
See Also
--------
- rank : equivalent function.
ndarray.ndim : equivalent method
shape : dimensions of array
ndarray.shape : dimensions of array
@@ -1549,34 +1735,39 @@ def ndim(a):
def rank(a):
- """Return the number of dimensions of a.
+ """
+ Return the number of dimensions of an array.
- In old Numeric, rank was the term used for the number of dimensions. If a is
- not already an array, a conversion is attempted. Scalars are zero
- dimensional.
+ If `a` is not already an array, a conversion is attempted.
+ Scalars are zero dimensional.
Parameters
----------
- a : {array_like}
- Array whose number of dimensions is desired. If a is not an array, a
- conversion is attempted.
+ a : array_like
+ Array whose number of dimensions is desired. If `a` is not an array,
+ a conversion is attempted.
Returns
-------
- number_of_dimensions : {integer}
- Returns the number of dimensions.
+ number_of_dimensions : int
+ The number of dimensions in the array.
See Also
--------
ndim : equivalent function
- ndarray.ndim : equivalent method
+ ndarray.ndim : equivalent property
shape : dimensions of array
ndarray.shape : dimensions of array
+ Notes
+ -----
+ In the old Numeric package, `rank` was the term used for the number of
+ dimensions, but in Numpy `ndim` is used instead.
+
Examples
--------
- >>> np.rank([[1,2,3],[4,5,6]])
- 2
+ >>> np.rank([1,2,3])
+ 1
>>> np.rank(np.array([[1,2,3],[4,5,6]]))
2
>>> np.rank(1)
@@ -1590,21 +1781,21 @@ def rank(a):
def size(a, axis=None):
- """Return the number of elements along given axis.
+ """
+ Return the number of elements along a given axis.
Parameters
----------
- a : {array_like}
- Array whose axis size is desired. If a is not an array, a
- conversion is attempted.
- axis : {None, integer}, optional
- Axis along which the elements are counted. None means all
- elements in the array.
+ a : array_like
+ Input data.
+ axis : int, optional
+ Axis along which the elements are counted. By default, give
+ the total number of elements.
Returns
-------
- element_count : {integer}
- Count of elements along specified axis.
+ element_count : int
+ Number of elements along the specified axis.
See Also
--------
@@ -1636,44 +1827,52 @@ def size(a, axis=None):
def around(a, decimals=0, out=None):
- """Round a to the given number of decimals.
-
- The real and imaginary parts of complex numbers are rounded separately. The
- result of rounding a float is a float so the type must be cast if integers
- are desired. Nothing is done if the input is an integer array and the
- decimals parameter has a value >= 0.
+ """
+ Evenly round to the given number of decimals.
Parameters
----------
- a : {array_like}
- Array containing numbers whose rounded values are desired. If a is
- not an array, a conversion is attempted.
- decimals : {0, int}, optional
- Number of decimal places to round to. When decimals is negative it
- specifies the number of positions to the left of the decimal point.
- out : {None, array}, optional
+ a : array_like
+ Input data.
+ decimals : int, optional
+ Number of decimal places to round to (default: 0). If
+ decimals is negative, it specifies the number of positions to
+ the left of the decimal point.
+ out : ndarray, optional
Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary. Numpy rounds floats to floats by default.
+ the same shape as the expected output, but the type of the output
+ values will be cast if necessary.
Returns
-------
rounded_array : {array}
- If out=None, returns a new array of the same type as a containing
- the rounded values, otherwise a reference to the output array is
- returned.
+ An array of the same type as `a`, containing the rounded values.
+ Unless `a` was specified, a new array is created. A reference to
+ the result is returned.
+
+ The real and imaginary parts of complex numbers are rounded
+ separately. The result of rounding a float is a float.
See Also
--------
- round_ : equivalent function
ndarray.round : equivalent method
Notes
-----
- Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round
- to 0.0, etc. Results may also be surprising due to the inexact
- representation of decimal fractions in IEEE floating point and the
- errors introduced when scaling by powers of ten.
+ For values exactly halfway between rounded decimal values, Numpy
+ rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0,
+ -0.5 and 0.5 round to 0.0, etc. Results may also be surprising due
+ to the inexact representation of decimal fractions in the IEEE
+ floating point standard [1]_ and errors introduced when scaling
+ by powers of ten.
+
+ References
+ ----------
+ .. [1] "Lecture Notes on the Status of IEEE 754", William Kahan,
+ http://www.cs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF
+ .. [2] "How Futile are Mindless Assessments of
+ Roundoff in Floating-Point Computation?", William Kahan,
+ http://www.cs.berkeley.edu/~wkahan/Mindless.pdf
Examples
--------
@@ -1693,53 +1892,14 @@ def around(a, decimals=0, out=None):
def round_(a, decimals=0, out=None):
- """Round a to the given number of decimals.
-
- The real and imaginary parts of complex numbers are rounded separately. The
- result of rounding a float is a float so the type must be cast if integers
- are desired. Nothing is done if the input is an integer array and the
- decimals parameter has a value >= 0.
-
- Parameters
- ----------
- a : {array_like}
- Array containing numbers whose rounded values are desired. If a is
- not an array, a conversion is attempted.
- decimals : {0, integer}, optional
- Number of decimal places to round to. When decimals is negative it
- specifies the number of positions to the left of the decimal point.
- out : {None, array}, optional
- Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
+ """
+ Round an array to the given number of decimals.
- Returns
- -------
- rounded_array : {array}
- If out=None, returns a new array of the same type as a containing
- the rounded values, otherwise a reference to the output array is
- returned.
+ Refer to `around` for full documentation.
See Also
--------
around : equivalent function
- ndarray.round : equivalent method
-
- Notes
- -----
- Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round
- to 0.0, etc. Results may also be surprising due to the inexact
- representation of decimal fractions in IEEE floating point and the
- errors introduced when scaling by powers of ten.
-
- Examples
- --------
- >>> np.round_([.5, 1.5, 2.5, 3.5, 4.5])
- array([ 0., 2., 2., 4., 4.])
- >>> np.round_([1,2,3,11], decimals=1)
- array([ 1, 2, 3, 11])
- >>> np.round_([1,2,3,11], decimals=-1)
- array([ 0, 0, 0, 10])
"""
try:
@@ -1750,33 +1910,35 @@ def round_(a, decimals=0, out=None):
def mean(a, axis=None, dtype=None, out=None):
- """Compute the mean along the specified axis.
+ """
+ Compute the arithmetic mean along the specified axis.
Returns the average of the array elements. The average is taken
over the flattened array by default, otherwise over the specified
- axis. The dtype returned for integer type arrays is float.
+ axis. float64 intermediate and return values are used for integer
+ inputs.
Parameters
----------
- a : {array_like}
- Array containing numbers whose mean is desired. If a is not an
+ a : array_like
+ Array containing numbers whose mean is desired. If `a` is not an
array, a conversion is attempted.
- axis : {None, integer}, optional
+ axis : {None, int}, optional
Axis along which the means are computed. The default is to compute
the mean of the flattened array.
dtype : {None, dtype}, optional
- Type to use in computing the mean. For arrays of integer type the
- default is float32, for arrays of float types it is the same as the
- array type.
- out : {None, array}, optional
+ Type to use in computing the mean. For integer inputs the default
+ is float64; for floating point inputs it is the same as the input
+ dtype.
+ out : {None, ndarray}, optional
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.
Returns
-------
- mean : {array, scalar}, see dtype parameter above
- If out=None, returns a new array containing the mean values,
+ mean : {ndarray, scalar}, see dtype parameter above
+ If `out=None`, returns a new array containing the mean values,
otherwise a reference to the output array is returned.
See Also
@@ -1785,8 +1947,8 @@ def mean(a, axis=None, dtype=None, out=None):
Notes
-----
- The mean is the sum of the elements along the axis divided by the
- number of elements.
+ The arithmetic mean is the sum of the elements along the axis divided
+ by the number of elements.
Examples
--------
@@ -1807,60 +1969,64 @@ def mean(a, axis=None, dtype=None, out=None):
def std(a, axis=None, dtype=None, out=None, ddof=0):
- """Compute the standard deviation along the specified axis.
+ """
+ Compute the standard deviation along the specified axis.
- Returns the standard deviation of the array elements, a measure of the
- spread of a distribution. The standard deviation is computed for the
+ Returns the standard deviation, a measure of the spread of a distribution,
+ of the array elements. The standard deviation is computed for the
flattened array by default, otherwise over the specified axis.
Parameters
----------
- a : {array_like}
- Array containing numbers whose standard deviation is desired. If a
- is not an array, a conversion is attempted.
- axis : {None, integer}, optional
+ a : array_like
+ Calculate the standard deviation of these values.
+ axis : int, optional
Axis along which the standard deviation is computed. The default is
to compute the standard deviation of the flattened array.
- dtype : {None, dtype}, optional
+ dtype : dtype, optional
Type to use in computing the standard deviation. For arrays of
- integer type the default is float32, for arrays of float types it is
+ integer type the default is float64, for arrays of float types it is
the same as the array type.
- out : {None, array}, optional
+ out : ndarray, optional
Alternative output array in which to place the result. It must have
- the same shape as the expected output but the type will be cast if
- necessary.
- ddof : {0, integer}
+ the same shape as the expected output but the type (of the calculated
+ values) will be cast if necessary.
+ ddof : int, optional
Means Delta Degrees of Freedom. The divisor used in calculations
- is N-ddof.
+ is ``N - ddof``, where ``N`` represents the number of elements.
+ By default `ddof` is zero (biased estimate).
Returns
-------
- standard_deviation : {array, scalar}, see dtype parameter above.
- If out=None, returns a new array containing the standard deviation,
- otherwise a reference to the output array is returned.
+ standard_deviation : {ndarray, scalar}; see dtype parameter above.
+ If `out` is None, return a new array containing the standard deviation,
+ otherwise return a reference to the output array.
See Also
--------
- var : Variance
- mean : Average
+ numpy.var : Variance
+ numpy.mean : Average
Notes
-----
The standard deviation is the square root of the average of the squared
- deviations from the mean, i.e. var = sqrt(mean(abs(x - x.mean())**2)).
- The computed standard deviation is computed by dividing by the number of
- elements, N-ddof. The option ddof defaults to zero, that is, a
- biased estimate. Note that for complex numbers std takes the absolute
+ deviations from the mean, i.e., ``var = sqrt(mean(abs(x - x.mean())**2))``.
+
+ The mean is normally calculated as ``x.sum() / N``, where
+ ``N = len(x)``. If, however, `ddof` is specified, the divisor ``N - ddof``
+ is used instead.
+
+ Note that, for complex numbers, std takes the absolute
value before squaring, so that the result is always real and nonnegative.
Examples
--------
- >>> a = np.array([[1,2],[3,4]])
+ >>> a = np.array([[1, 2], [3, 4]])
>>> np.std(a)
1.1180339887498949
- >>> np.std(a,0)
+ >>> np.std(a, 0)
array([ 1., 1.])
- >>> np.std(a,1)
+ >>> np.std(a, 1)
array([ 0.5, 0.5])
"""
@@ -1872,7 +2038,8 @@ def std(a, axis=None, dtype=None, out=None, ddof=0):
def var(a, axis=None, dtype=None, out=None, ddof=0):
- """Compute the variance along the specified axis.
+ """
+ Compute the variance along the specified axis.
Returns the variance of the array elements, a measure of the spread of a
distribution. The variance is computed for the flattened array by default,
@@ -1880,27 +2047,27 @@ def var(a, axis=None, dtype=None, out=None, ddof=0):
Parameters
----------
- a : {array_like}
+ a : array_like
Array containing numbers whose variance is desired. If a is not an
array, a conversion is attempted.
- axis : {None, integer}, optional
+ axis : int, optional
Axis along which the variance is computed. The default is to compute
the variance of the flattened array.
- dtype : {None, dtype}, optional
+ dtype : dtype, optional
Type to use in computing the variance. For arrays of integer type
the default is float32, for arrays of float types it is the same as
the array type.
- out : {None, array}, optional
+ out : ndarray, optional
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.
- ddof : {0, integer},
+ ddof : positive int,optional
Means Delta Degrees of Freedom. The divisor used in calculation is
N - ddof.
Returns
-------
- variance : {array, scalar}, see dtype parameter above
+ variance : {ndarray, scalar}, see dtype parameter above
If out=None, returns a new array containing the variance, otherwise
a reference to the output array is returned.
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py
index 14aa409c4..3a9a345dc 100644
--- a/numpy/core/memmap.py
+++ b/numpy/core/memmap.py
@@ -16,12 +16,13 @@ mode_equivalents = {
}
class memmap(ndarray):
- """Create a memory-map to an array stored in a file on disk.
+ """
+ Create a memory-map to an array stored in a file on disk.
Memory-mapped files are used for accessing small segments of large files
- on disk, without reading the entire file into memory. Numpy's memmaps are
- array-like objects. This differs from python's mmap module which are
- file-like objects.
+ on disk, without reading the entire file into memory. Numpy's
+ memmap's are array-like objects. This differs from Python's ``mmap``
+ module, which uses file-like objects.
Parameters
----------
@@ -30,107 +31,131 @@ class memmap(ndarray):
buffer.
dtype : data-type, optional
The data-type used to interpret the file contents.
- Default is uint8
- mode : {'r', 'r+', 'w+', 'c'}, optional
- The mode to open the file.
- 'r', open existing file for read-only
- 'r+', open existing file for read-write
- 'w+', create or overwrite existing file and open for read-write
- 'c', copy-on-write, assignments effect data in memory, but changes
- are not saved to disk. File on disk is read-only.
- Default is 'r+'
+ Default is `uint8`
+ mode : {'r+', 'r', 'w+', 'c'}, optional
+ The file is opened in this mode:
+
+ +------+-------------------------------------------------------------+
+ | 'r' | Open existing file for reading only. |
+ +------+-------------------------------------------------------------+
+ | 'r+' | Open existing file for reading and writing. |
+ +------+-------------------------------------------------------------+
+ | 'w+' | Create or overwrite existing file for reading and writing. |
+ +------+-------------------------------------------------------------+
+ | 'c' | Copy-on-write: assignments affect data in memory, but |
+ | | changes are not saved to disk. The file on disk is |
+ | | read-only. |
+ +------+-------------------------------------------------------------+
+
+ Default is 'r+'.
offset : integer, optional
- Byte offset into the file to start the array data. Should be a
- multiple of the data-type of the data. Requires shape=None.
- Default is 0
+ In the file, array data starts at this offset. `offset` should be
+ a multiple of the byte-size of `dtype`. Requires `shape=None`.
+ The default is 0.
shape : tuple, optional
- The desired shape of the array. If None, the returned array will be 1-D
- with the number of elements determined by file size and data-type.
- Default is None
+ The desired shape of the array. By default, the returned array will be
+ 1-D with the number of elements determined by file size and data-type.
order : {'C', 'F'}, optional
- Specify the order of the N-D array, C or Fortran ordered. This only
- has an effect if the shape is greater than 2-D.
- Default is 'C'
+ Specify the order of the ndarray memory layout: C (row-major) or
+ Fortran (column-major). This only has an effect if the shape is
+ greater than 1-D. The defaullt order is 'C'.
Methods
-------
- close : close the memmap file
- flush : flush any changes in memory to file on disk
+ close
+ Close the memmap file.
+ flush
+ Flush any changes in memory to file on disk.
When you delete a memmap object, flush is called first to write
changes to disk before removing the object.
- Returns
- -------
- memmap : array-like memmap object
- The memmap object can be used anywhere an ndarray is accepted.
- If fp is a memmap, isinstance(fp, numpy.ndarray) will return True.
+ Notes
+ -----
+ The memmap object can be used anywhere an ndarray is accepted.
+ Given a memmap ``fp``, ``isinstance(fp, numpy.ndarray)`` returns
+ ``True``.
Examples
--------
>>> data = np.arange(12, dtype='float32')
>>> data.resize((3,4))
- >>> # Using a tempfile so doctest doesn't write files to your directory.
- >>> # You would use a 'normal' filename.
+ This example uses a temporary file so that doctest doesn't write
+ files to your directory. You would use a 'normal' filename.
+
>>> from tempfile import mkdtemp
>>> import os.path as path
>>> filename = path.join(mkdtemp(), 'newfile.dat')
- >>> # Create a memmap with dtype and shape that matches our data
+ Create a memmap with dtype and shape that matches our data:
+
>>> fp = np.memmap(filename, dtype='float32', mode='w+', shape=(3,4))
>>> fp
memmap([[ 0., 0., 0., 0.],
- [ 0., 0., 0., 0.],
- [ 0., 0., 0., 0.]], dtype=float32)
+ [ 0., 0., 0., 0.],
+ [ 0., 0., 0., 0.]], dtype=float32)
+
+ Write data to memmap array:
- >>> # Write data to memmap array
>>> fp[:] = data[:]
>>> fp
memmap([[ 0., 1., 2., 3.],
- [ 4., 5., 6., 7.],
- [ 8., 9., 10., 11.]], dtype=float32)
+ [ 4., 5., 6., 7.],
+ [ 8., 9., 10., 11.]], dtype=float32)
+
+ Deletion flushes memory changes to disk before removing the object:
- >>> # Deletion flushes memory changes to disk before removing the object.
>>> del fp
- >>> # Load the memmap and verify data was stored
+
+ Load the memmap and verify data was stored:
+
>>> newfp = np.memmap(filename, dtype='float32', mode='r', shape=(3,4))
>>> newfp
memmap([[ 0., 1., 2., 3.],
- [ 4., 5., 6., 7.],
- [ 8., 9., 10., 11.]], dtype=float32)
+ [ 4., 5., 6., 7.],
+ [ 8., 9., 10., 11.]], dtype=float32)
+
+ Read-only memmap:
- >>> # read-only memmap
>>> fpr = np.memmap(filename, dtype='float32', mode='r', shape=(3,4))
>>> fpr.flags.writeable
False
- >>> # Cannot assign to read-only, obviously
+
+ Cannot assign to read-only, obviously:
+
>>> fpr[0, 3] = 56
Traceback (most recent call last):
...
RuntimeError: array is not writeable
- >>> # copy-on-write memmap
+ Copy-on-write memmap:
+
>>> fpc = np.memmap(filename, dtype='float32', mode='c', shape=(3,4))
>>> fpc.flags.writeable
True
- >>> # Can assign to copy-on-write array, but values are only written
- >>> # into the memory copy of the array, and not written to disk.
+
+ It's possible to assign to copy-on-write array, but values are only
+ written into the memory copy of the array, and not written to disk:
+
>>> fpc
memmap([[ 0., 1., 2., 3.],
- [ 4., 5., 6., 7.],
- [ 8., 9., 10., 11.]], dtype=float32)
+ [ 4., 5., 6., 7.],
+ [ 8., 9., 10., 11.]], dtype=float32)
>>> fpc[0,:] = 0
>>> fpc
memmap([[ 0., 0., 0., 0.],
- [ 4., 5., 6., 7.],
- [ 8., 9., 10., 11.]], dtype=float32)
- >>> # file on disk is unchanged
+ [ 4., 5., 6., 7.],
+ [ 8., 9., 10., 11.]], dtype=float32)
+
+ File on disk is unchanged:
+
>>> fpr
memmap([[ 0., 1., 2., 3.],
- [ 4., 5., 6., 7.],
- [ 8., 9., 10., 11.]], dtype=float32)
+ [ 4., 5., 6., 7.],
+ [ 8., 9., 10., 11.]], dtype=float32)
+
+ Offset into a memmap:
- >>> # offset into a memmap
>>> fpo = np.memmap(filename, dtype='float32', mode='r', offset=16)
>>> fpo
memmap([ 4., 5., 6., 7., 8., 9., 10., 11.], dtype=float32)
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 8fe1f9220..40f14cd79 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -46,10 +46,41 @@ ufunc = type(sin)
# originally from Fernando Perez's IPython
def zeros_like(a):
- """Return an array of zeros of the shape and data-type of a.
+ """
+ Returns an array of zeros with the same shape and type as a given array.
+
+ Equivalent to ``a.copy().fill(0)``.
+
+ Parameters
+ ----------
+ a : array_like
+ The shape and data-type of `a` defines the parameters of
+ the returned array.
+
+ Returns
+ -------
+ out : ndarray
+ Array of zeros with same shape and type as `a`.
+
+ See Also
+ --------
+ numpy.ones_like : Return an array of ones with shape and type of input.
+ numpy.empty_like : Return an empty array with shape and type of input.
+ numpy.zeros : Return a new array setting values to zero.
+ numpy.ones : Return a new array setting values to one.
+ numpy.empty : Return a new uninitialized array.
+
+ Examples
+ --------
+ >>> x = np.arange(6)
+ >>> x = x.reshape((2, 3))
+ >>> x
+ array([[0, 1, 2],
+ [3, 4, 5]])
+ >>> np.zeros_like(x)
+ array([[0, 0, 0],
+ [0, 0, 0]])
- If you don't explicitly need the array to be zeroed, you should instead
- use empty_like(), which is a bit faster as it only allocates memory.
"""
if isinstance(a, ndarray):
res = ndarray.__new__(type(a), a.shape, a.dtype, order=a.flags.fnc)
@@ -66,10 +97,30 @@ def zeros_like(a):
return res
def empty_like(a):
- """Return an empty (uninitialized) array of the shape and data-type of a.
+ """
+ Create a new array with the same shape and type as another.
- Note that this does NOT initialize the returned array. If you require
- your array to be initialized, you should use zeros_like().
+ Parameters
+ ----------
+ a : ndarray
+ Returned array will have same shape and type as `a`.
+
+ See Also
+ --------
+ zeros_like, ones_like, zeros, ones, empty
+
+ Notes
+ -----
+ This function does *not* initialize the returned array; to do that use
+ `zeros_like` or `ones_like` instead.
+
+ Examples
+ --------
+ >>> a = np.array([[1,2,3],[4,5,6]])
+ >>> np.empty_like(a)
+ >>> np.empty_like(a)
+ array([[-1073741821, -1067702173, 65538], #random data
+ [ 25670, 23454291, 71800]])
"""
if isinstance(a, ndarray):
@@ -127,51 +178,186 @@ compare_chararrays = multiarray.compare_chararrays
putmask = multiarray.putmask
def asarray(a, dtype=None, order=None):
- """Returns a as an array.
+ """
+ Convert the input to an array.
+
+ Parameters
+ ----------
+ a : array_like
+ Input data, in any form that can be converted to an array. This
+ includes lists, lists of tuples, tuples, tuples of tuples, tuples
+ of lists and ndarrays.
+ dtype : data-type, optional
+ By default, the data-type is inferred from the input data.
+ order : {'C', 'F'}, optional
+ Whether to use row-major ('C') or column-major ('FORTRAN') memory
+ representation. Defaults to 'C'.
+
+ Returns
+ -------
+ out : ndarray
+ Array interpretation of `a`. No copy is performed if the input
+ is already an ndarray. If `a` is a subclass of ndarray, a base
+ class ndarray is returned.
+
+ See Also
+ --------
+ asanyarray : Similar function which passes through subclasses.
+ ascontiguousarray : Convert input to a contiguous array.
+ asfarray : Convert input to a floating point ndarray.
+ asfortranarray : Convert input to an ndarray with column-major
+ memory order.
+ asarray_chkfinite : Similar function which checks input for NaNs and Infs.
+ fromiter : Create an array from an iterator.
+ fromfunction : Construct an array by executing a function on grid
+ positions.
+
+ Examples
+ --------
+ Convert a list into an array:
+
+ >>> a = [1, 2]
+ >>> np.asarray(a)
+ array([1, 2])
+
+ Existing arrays are not copied:
+
+ >>> a = np.array([1, 2])
+ >>> np.asarray(a) is a
+ True
- Unlike array(), no copy is performed if a is already an array. Subclasses
- are converted to base class ndarray.
"""
return array(a, dtype, copy=False, order=order)
def asanyarray(a, dtype=None, order=None):
- """Returns a as an array, but will pass subclasses through.
+ """
+ Convert the input to a ndarray, but pass ndarray subclasses through.
+
+ Parameters
+ ----------
+ a : array_like
+ Input data, in any form that can be converted to an array. This
+ includes scalars, lists, lists of tuples, tuples, tuples of tuples,
+ tuples of lists and ndarrays.
+ dtype : data-type, optional
+ By default, the data-type is inferred from the input data.
+ order : {'C', 'F'}, optional
+ Whether to use row-major ('C') or column-major ('F') memory
+ representation. Defaults to 'C'.
+
+ Returns
+ -------
+ out : ndarray or an ndarray subclass
+ Array interpretation of `a`. If `a` is an ndarray or a subclass
+ of ndarray, it is returned as-is and no copy is performed.
+
+ See Also
+ --------
+ asarray : Similar function which always returns ndarrays.
+ ascontiguousarray : Convert input to a contiguous array.
+ asfarray : Convert input to a floating point ndarray.
+ asfortranarray : Convert input to an ndarray with column-major
+ memory order.
+ asarray_chkfinite : Similar function which checks input for NaNs and Infs.
+ fromiter : Create an array from an iterator.
+ fromfunction : Construct an array by executing a function on grid
+ positions.
+
+ Examples
+ --------
+ Convert a list into an array:
+
+ >>> a = [1, 2]
+ >>> np.asanyarray(a)
+ array([1, 2])
+
+ Instances of `ndarray` subclasses are passed through as-is:
+
+ >>> a = np.matrix([1, 2])
+ >>> np.asanyarray(a) is a
+ True
+
"""
return array(a, dtype, copy=False, order=order, subok=True)
def ascontiguousarray(a, dtype=None):
- """Return 'a' as an array contiguous in memory (C order).
+ """
+ Return a contiguous array in memory (C order).
+
+ Parameters
+ ----------
+ a : array_like
+ Input array.
+ dtype : string
+ Type code of returned array.
+
+ Returns
+ -------
+ out : ndarray
+ Contiguous array of same shape and content as `a` with type `dtype`.
+
"""
return array(a, dtype, copy=False, order='C', ndmin=1)
def asfortranarray(a, dtype=None):
- """Return 'a' as an array laid out in Fortran-order in memory.
+ """
+ Return an array laid out in Fortran-order in memory.
+
+ Parameters
+ ----------
+ a : array-like
+ Input array.
+ dtype : data-type, optional
+ By default, the data-type is inferred from the input data.
+
+ Returns
+ -------
+ out : ndarray
+ Array interpretation of `a` in Fortran (column-order).
+
+ See Also
+ --------
+ asarray : Similar function which always returns ndarrays.
+ ascontiguousarray : Convert input to a contiguous array.
+ asfarray : Convert input to a floating point ndarray.
+ asanyarray : Convert input to an ndarray with either row or
+ column-major memory order.
+ asarray_chkfinite : Similar function which checks input for NaNs and Infs.
+ fromiter : Create an array from an iterator.
+ fromfunction : Construct an array by executing a function on grid
+ positions.
+
"""
return array(a, dtype, copy=False, order='F', ndmin=1)
def require(a, dtype=None, requirements=None):
- """Return an ndarray of the provided type that satisfies requirements.
+ """
+ Return an ndarray of the provided type that satisfies requirements.
This function is useful to be sure that an array with the correct flags
is returned for passing to compiled code (perhaps through ctypes).
Parameters
----------
- a : array-like
+ a : array-like
The object to be converted to a type-and-requirement satisfying array
- dtype : data-type
+ dtype : data-type
The required data-type (None is the default data-type -- float64)
- requirements : list of strings
- The requirements list can be any of the
- 'ENSUREARRAY' ('E') - ensure that a base-class ndarray
- 'F_CONTIGUOUS' ('F') - ensure a Fortran-contiguous array
- 'C_CONTIGUOUS' ('C') - ensure a C-contiguous array
- 'ALIGNED' ('A') - ensure a data-type aligned array
- 'WRITEABLE' ('W') - ensure a writeable array
- 'OWNDATA' ('O') - ensure an array that owns its own data
-
- The returned array will be guaranteed to have the listed requirements
- by making a copy if needed.
+ requirements : list of strings
+ The requirements list can be any of the following
+
+ * 'ENSUREARRAY' ('E') - ensure that a base-class ndarray
+ * 'F_CONTIGUOUS' ('F') - ensure a Fortran-contiguous array
+ * 'C_CONTIGUOUS' ('C') - ensure a C-contiguous array
+ * 'ALIGNED' ('A') - ensure a data-type aligned array
+ * 'WRITEABLE' ('W') - ensure a writeable array
+ * 'OWNDATA' ('O') - ensure an array that owns its own data
+
+ Notes
+ -----
+ The returned array will be guaranteed to have the listed requirements
+ by making a copy if needed.
+
"""
if requirements is None:
requirements = []
@@ -205,7 +391,14 @@ def require(a, dtype=None, requirements=None):
return arr
def isfortran(a):
- """Returns True if 'a' is arranged in Fortran-order in memory with a.ndim > 1
+ """
+ Returns True if array is arranged in Fortran-order and dimension > 1.
+
+ Parameters
+ ----------
+ a : ndarray
+ Input array to test.
+
"""
return a.flags.fnc
@@ -223,14 +416,38 @@ def argwhere(a):
return asarray(a.nonzero()).T
def flatnonzero(a):
- """Return indicies that are not-zero in flattened version of a
+ """
+ Return indices that are non-zero in the flattened version of a.
- Equivalent to a.ravel().nonzero()[0]
+ This is equivalent to a.ravel().nonzero()[0].
- >>> np.arange(-2, 3)
+ Parameters
+ ----------
+ a : ndarray
+ Input array.
+
+ Returns
+ -------
+ res : ndarray
+ Output array, containing the indices of the elements of `a.ravel()`
+ that are non-zero.
+
+ See Also
+ --------
+ nonzero : Return the indices of the non-zero elements of the input array.
+ ravel : Return a 1-D array containing the elements of the input array.
+
+ Examples
+ --------
+ >>> x = np.arange(-2, 3)
+ >>> x
array([-2, -1, 0, 1, 2])
- >>> np.flatnonzero(np.arange(-2, 3))
+ >>> np.flatnonzero(x)
array([0, 1, 3, 4])
+
+ >>> x.ravel()[np.flatnonzero(x)]
+ array([-2, -1, 1, 2])
+
"""
return a.ravel().nonzero()[0]
@@ -244,17 +461,115 @@ def _mode_from_name(mode):
return mode
def correlate(a,v,mode='valid'):
- """Return the discrete, linear correlation of 1-D sequences a and v; mode
- can be 'valid', 'same', or 'full' to specify the size of the resulting
- sequence
+ """
+ Discrete, linear correlation of two 1-dimensional sequences.
+
+ This function is equivalent to
+
+ >>> np.convolve(a, v[::-1], mode=mode)
+
+ where ``v[::-1]`` is the reverse of `v`.
+
+ Parameters
+ ----------
+ a, v : array_like
+ Input sequences.
+ mode : {'valid', 'same', 'full'}, optional
+ Refer to the `convolve` docstring. Note that the default
+ is `valid`, unlike `convolve`, which uses `full`.
+
+ See Also
+ --------
+ convolve : Discrete, linear convolution of two
+ one-dimensional sequences.
+
"""
mode = _mode_from_name(mode)
return multiarray.correlate(a,v,mode)
def convolve(a,v,mode='full'):
- """Returns the discrete, linear convolution of 1-D sequences a and v; mode
- can be 'valid', 'same', or 'full' to specify size of the resulting sequence.
+ """
+ Returns the discrete, linear convolution of two one-dimensional sequences.
+
+ The convolution operator is often seen in signal processing, where it
+ models the effect of a linear time-invariant system on a signal [1]_. In
+ probability theory, the sum of two independent random variables is
+ distributed according to the convolution of their individual
+ distributions.
+
+ Parameters
+ ----------
+ a : (N,) array_like
+ First one-dimensional input array.
+ v : (M,) array_like
+ Second one-dimensional input array.
+ mode : {'full', 'valid', 'same'}, optional
+ 'full':
+ By default, mode is 'full'. This returns the convolution
+ at each point of overlap, with an output shape of (N+M-1,). At
+ the end-points of the convolution, the signals do not overlap
+ completely, and boundary effects may be seen.
+
+ 'same':
+ Mode `same` returns output of length ``max(M, N)``. Boundary
+ effects are still visible.
+
+ 'valid':
+ Mode `valid` returns output of length
+ ``max(M, N) - min(M, N) + 1``. The convolution product is only given
+ for points where the signals overlap completely. Values outside
+ the signal boundary have no effect.
+
+ Returns
+ -------
+ out : ndarray
+ Discrete, linear convolution of `a` and `v`.
+
+ See Also
+ --------
+ scipy.signal.fftconv : Convolve two arrays using the Fast Fourier
+ Transform.
+ scipy.linalg.toeplitz : Used to construct the convolution operator.
+
+ Notes
+ -----
+ The discrete convolution operation is defined as
+
+ .. math:: (f * g)[n] = \\sum_{m = -\\infty}^{\\infty} f[m] f[n - m]
+
+ It can be shown that a convolution :math:`x(t) * y(t)` in time/space
+ is equivalent to the multiplication :math:`X(f) Y(f)` in the Fourier
+ domain, after appropriate padding (padding is necessary to prevent
+ circular convolution). Since multiplication is more efficient (faster)
+ than convolution, the function `scipy.signal.fftconvolve` exploits the
+ FFT to calculate the convolution of large data-sets.
+
+ References
+ ----------
+ .. [1] Wikipedia, "Convolution", http://en.wikipedia.org/wiki/Convolution.
+
+ Examples
+ --------
+ Note how the convolution operator flips the second array
+ before "sliding" the two across one another:
+
+ >>> np.convolve([1, 2, 3], [0, 1, 0.5])
+ array([ 0. , 1. , 2.5, 4. , 1.5])
+
+ Only return the middle values of the convolution.
+ Contains boundary effects, where zeros are taken
+ into account:
+
+ >>> np.convolve([1,2,3],[0,1,0.5], 'same')
+ array([ 1. , 2.5, 4. ])
+
+ The two arrays are of the same length, so there
+ is only one position where they completely overlap:
+
+ >>> np.convolve([1,2,3],[0,1,0.5], 'valid')
+ array([ 2.5])
+
"""
a,v = array(a,ndmin=1),array(v,ndmin=1)
if (len(v) > len(a)):
@@ -268,21 +583,98 @@ inner = multiarray.inner
dot = multiarray.dot
def outer(a,b):
- """Returns the outer product of two vectors.
+ """
+ Returns the outer product of two vectors.
+
+ Given two vectors, ``[a0, a1, ..., aM]`` and ``[b0, b1, ..., bN]``,
+ the outer product becomes::
+
+ [[a0*b0 a0*b1 ... a0*bN ]
+ [a1*b0 .
+ [ ... .
+ [aM*b0 aM*bN ]]
+
+ Parameters
+ ----------
+ a : array_like, shaped (M,)
+ First input vector. If either of the input vectors are not
+ 1-dimensional, they are flattened.
+ b : array_like, shaped (N,)
+ Second input vector.
+
+ Returns
+ -------
+ out : ndarray, shaped (M, N)
+ ``out[i, j] = a[i] * b[j]``
+
+ Notes
+ -----
+ The outer product of vectors is a special case of the Kronecker product.
+
+ Examples
+ --------
+ >>> x = np.array(['a', 'b', 'c'], dtype=object)
+
+ >>> np.outer(x, [1, 2, 3])
+ array([[a, aa, aaa],
+ [b, bb, bbb],
+ [c, cc, ccc]], dtype=object)
- result[i,j] = a[i]*b[j] when a and b are vectors.
- Will accept any arguments that can be made into vectors.
"""
a = asarray(a)
b = asarray(b)
return a.ravel()[:,newaxis]*b.ravel()[newaxis,:]
def vdot(a, b):
- """Returns the dot product of 2 vectors (or anything that can be made into
- a vector).
+ """
+ Return the dot product of two vectors.
+
+ The vdot(`a`, `b`) function handles complex numbers differently than
+ dot(`a`, `b`). If the first argument is complex the complex conjugate
+ of the first argument is used for the calculation of the dot product.
- Note: this is not the same as `dot`, as it takes the conjugate of its first
- argument if complex and always returns a scalar."""
+ Parameters
+ ----------
+ a : array_like
+ If `a` is complex the complex conjugate is taken before calculation
+ of the dot product.
+ b : array_like
+ Second argument to the dot product.
+
+ Returns
+ -------
+ output : scalar
+ Returns dot product of `a` and `b`. Can be an int, float, or
+ complex depending on the types of `a` and `b`.
+
+ See Also
+ --------
+ dot : Return the dot product without using the complex conjugate of the
+ first argument.
+
+ Notes
+ -----
+ The dot product is the summation of element wise multiplication.
+
+ .. math::
+ a \\cdot b = \\sum_{i=1}^n a_i^*b_i = a_1^*b_1+a_2^*b_2+\\cdots+a_n^*b_n
+
+ Examples
+ --------
+ >>> a = np.array([1+2j,3+4j])
+ >>> b = np.array([5+6j,7+8j])
+ >>> np.vdot(a, b)
+ (70-8j)
+ >>> np.vdot(b, a)
+ (70+8j)
+ >>> a = np.array([[1, 4], [5, 6]])
+ >>> b = np.array([[4, 1], [2, 2]])
+ >>> np.vdot(a, b)
+ 30
+ >>> np.vdot(b, a)
+ 30
+
+ """
return dot(asarray(a).ravel().conj(), asarray(b).ravel())
# try to import blas optimized dot if available
@@ -292,30 +684,101 @@ try:
from _dotblas import dot, vdot, inner, alterdot, restoredot
except ImportError:
def alterdot():
- "Does Nothing"
+ """
+ Change `dot`, `vdot`, and `innerproduct` to use accelerated BLAS
+ functions.
+
+ When numpy is built with an accelerated BLAS like ATLAS, the above
+ functions will be replaced to make use of the faster implementations.
+ The faster implementations only affect float32, float64, complex64, and
+ complex128 arrays. Furthermore, only matrix-matrix, matrix-vector, and
+ vector-vector products are accelerated. Products of arrays with larger
+ dimensionalities will not be accelerated since the BLAS API only
+ includes these.
+
+ Typically, the user will never have to call this function. If numpy was
+ built with an accelerated BLAS, this function will be called when numpy
+ is imported.
+
+ See Also
+ --------
+ restoredot : `restoredot` undoes the effects of `alterdot`.
+
+ """
pass
def restoredot():
- "Does Nothing"
+ """
+ Restore `dot`, `vdot`, and `innerproduct` to the default non-BLAS
+ implementations.
+
+ Typically, the user will only need to call this when troubleshooting and
+ installation problem, reproducing the conditions of a build without an
+ accelerated BLAS, or when being very careful about benchmarking linear
+ algebra operations.
+
+ See Also
+ --------
+ alterdot : `restoredot` undoes the effects of `alterdot`.
+
+ """
pass
def tensordot(a, b, axes=2):
- """tensordot returns the product for any (ndim >= 1) arrays.
+ """
+ Returns the tensor dot product for (ndim >= 1) arrays along specified axes.
+
+ The first element of the sequence determines the axis or axes
+ in `a` to sum over, and the second element in `axes` argument sequence
+ determines the axis or axes in `b` to sum over.
+
+ Parameters
+ ----------
+ a : array_like
+ Input array.
+ b : array_like
+ Input array.
+ axes : shape tuple
+ Axes to be summed over.
- r_{xxx, yyy} = \sum_k a_{xxx,k} b_{k,yyy} where
+ See Also
+ --------
+ dot
- the axes to be summed over are given by the axes argument.
- the first element of the sequence determines the axis or axes
- in arr1 to sum over, and the second element in axes argument sequence
- determines the axis or axes in arr2 to sum over.
+ Notes
+ -----
+ r_{xxx, yyy} = \\sum_k a_{xxx,k} b_{k,yyy}
When there is more than one axis to sum over, the corresponding
arguments to axes should be sequences of the same length with the first
axis to sum over given first in both sequences, the second axis second,
and so forth.
- If the axes argument is an integer, N, then the last N dimensions of a
- and first N dimensions of b are summed over.
+ If the `axes` argument is an integer, N, then the last N dimensions of `a`
+ and first N dimensions of `b` are summed over.
+
+ Examples
+ --------
+ >>> a = np.arange(60.).reshape(3,4,5)
+ >>> b = np.arange(24.).reshape(4,3,2)
+ >>> c = np.tensordot(a,b, axes=([1,0],[0,1]))
+ >>> c.shape
+ (5,2)
+ >>> c
+ array([[ 4400., 4730.],
+ [ 4532., 4874.],
+ [ 4664., 5018.],
+ [ 4796., 5162.],
+ [ 4928., 5306.]])
+
+ >>> # A slower but equivalent way of computing the same...
+ >>> c = zeros((5,2))
+ >>> for i in range(5):
+ ... for j in range(2):
+ ... for k in range(3):
+ ... for n in range(4):
+ ... c[i,j] += a[k,n,i] * b[n,k,j]
+
"""
try:
iter(axes)
@@ -380,13 +843,53 @@ def tensordot(a, b, axes=2):
return res.reshape(olda + oldb)
def roll(a, shift, axis=None):
- """Roll the elements in the array by 'shift' positions along
- the given axis.
+ """
+ Roll array elements along a given axis.
+
+ Elements that roll beyond the last position are re-introduced at
+ the first.
- >>> np.arange(10)
- array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
- >>> np.roll(np.arange(10), 2)
+ Parameters
+ ----------
+ a : array_like
+ Input array.
+ shift : int
+ The number of places by which elements are shifted.
+ axis : int, optional
+ The axis along which elements are shifted. By default, the array
+ is flattened before shifting, after which the original
+ shape is restored.
+
+ Returns
+ -------
+ res : ndarray
+ Output array, with the same shape as `a`.
+
+ See Also
+ --------
+ rollaxis : Roll the specified axis backwards, until it lies in a
+ given position.
+
+ Examples
+ --------
+ >>> x = np.arange(10)
+ >>> np.roll(x, 2)
array([8, 9, 0, 1, 2, 3, 4, 5, 6, 7])
+
+ >>> x2 = np.reshape(x, (2,5))
+ >>> x2
+ array([[0, 1, 2, 3, 4],
+ [5, 6, 7, 8, 9]])
+ >>> np.roll(x2, 1)
+ array([[9, 0, 1, 2, 3],
+ [4, 5, 6, 7, 8]])
+ >>> np.roll(x2, 1, axis=0)
+ array([[5, 6, 7, 8, 9],
+ [0, 1, 2, 3, 4]])
+ >>> np.roll(x2, 1, axis=1)
+ array([[4, 0, 1, 2, 3],
+ [9, 5, 6, 7, 8]])
+
"""
a = asanyarray(a)
if axis is None:
@@ -404,15 +907,39 @@ def roll(a, shift, axis=None):
return res
def rollaxis(a, axis, start=0):
- """Return transposed array so that axis is rolled before start.
+ """
+ Roll the specified axis backwards, until it lies in a given position.
+ Parameters
+ ----------
+ a : ndarray
+ Input array.
+ axis : int
+ The axis to roll backwards. The positions of the other axes do not
+ change relative to one another.
+ start : int, optional
+ The axis is rolled until it lies before this position.
+
+ Returns
+ -------
+ res : ndarray
+ Output array.
+
+ See Also
+ --------
+ roll : Roll the elements of an array by a number of positions along a
+ given axis.
+
+ Examples
+ --------
>>> a = np.ones((3,4,5,6))
>>> np.rollaxis(a, 3, 1).shape
(3, 6, 4, 5)
- >>> np.rollaxis(a, 2, 0).shape
+ >>> np.rollaxis(a, 2).shape
(5, 3, 4, 6)
>>> np.rollaxis(a, 1, 4).shape
(3, 5, 6, 4)
+
"""
n = a.ndim
if axis < 0:
@@ -491,6 +1018,37 @@ if issubclass(longlong, int):
_typelessdata.append(longlong)
def array_repr(arr, max_line_width=None, precision=None, suppress_small=None):
+ """
+ Return the string representation of an array.
+
+ Parameters
+ ----------
+ arr : ndarray
+ Input array.
+ max_line_width : int
+ The maximum number of columns the string should span. Newline
+ characters splits the string appropriately after array elements.
+ precision : int
+ Floating point precision.
+ suppress_small : bool
+ Represent very small numbers as zero.
+
+ Returns
+ -------
+ string : str
+ The string representation of an array.
+
+
+ Examples
+ --------
+ >>> np.array_repr(np.array([1,2]))
+ 'array([1, 2])'
+ >>> np.array_repr(np.ma.array([0.]))
+ 'MaskedArray([ 0.])'
+ >>> np.array_repr(np.array([], np.int32))
+ 'array([], dtype=int32)'
+
+ """
if arr.size > 0 or arr.shape==(0,):
lst = array2string(arr, max_line_width, precision, suppress_small,
', ', "array(")
@@ -516,6 +1074,30 @@ def array_repr(arr, max_line_width=None, precision=None, suppress_small=None):
return cName + "(%s, %sdtype=%s)" % (lst, lf, typename)
def array_str(a, max_line_width=None, precision=None, suppress_small=None):
+ """
+ Return a string representation of an array.
+
+ Parameters
+ ----------
+ a : ndarray
+ Input array.
+ max_line_width : int, optional
+ Inserts newlines if text is longer than `max_line_width`.
+ precision : int, optional
+ If `a` is float, `precision` sets loating point precision.
+ suppress_small : boolean, optional
+ Represent very small numbers as zero.
+
+ See Also
+ --------
+ array2string, array_repr
+
+ Examples
+ --------
+ >>> np.array_str(np.arange(3))
+ >>> '[0 1 2]'
+
+ """
return array2string(a, max_line_width, precision, suppress_small, ' ', "", str)
set_string_function = multiarray.set_string_function
@@ -526,8 +1108,41 @@ little_endian = (sys.byteorder == 'little')
def indices(dimensions, dtype=int):
- """Returns an array representing a grid of indices with row-only, and
- column-only variation.
+ """
+ Return an array representing the coordinates of a grid.
+
+ Parameters
+ ----------
+ shape : (N,) tuple of ints
+
+ Returns
+ -------
+ grid : ndarray
+ The output shape is ``(N,) + shape``. I.e., if `shape` is ``(2,4,5)``,
+ the output shape is ``(3, 2, 4, 5)``. Each subarray, ``grid[i,...]``
+ contains values that vary only along the ``i-th`` axis.
+
+ Examples
+ --------
+ >>> grid = np.indices((2,3))
+
+ The row-positions are given by:
+
+ >>> grid[0]
+ array([[0, 0, 0],
+ [1, 1, 1]])
+
+ and the column-positions by
+
+ >>> grid[1]
+ array([[0, 1, 2],
+ [0, 1, 2]])
+
+
+ See Also
+ --------
+ mgrid, meshgrid, ndindex
+
"""
dimensions = tuple(dimensions)
N = len(dimensions)
@@ -543,24 +1158,76 @@ def indices(dimensions, dtype=int):
return res
def fromfunction(function, shape, **kwargs):
- """Returns an array constructed by calling a function on a tuple of number
- grids.
+ """
+ Construct an array by executing a function over each coordinate.
+
+ The resulting array therefore has a value ``fn(x, y, z)`` at
+ coordinate ``(x, y, z)``.
- The function should accept as many arguments as the length of shape and
- work on array inputs. The shape argument is a sequence of numbers
- indicating the length of the desired output for each axis.
+ Parameters
+ ----------
+ fn : callable
+ The function is called with N parameters, each of which
+ represents the coordinates of the array varying along a
+ specific axis. For example, if `shape` were ``(2, 2)``, then
+ the parameters would be two arrays, ``[[0, 0], [1, 1]]`` and
+ ``[[0, 1], [0, 1]]``. `fn` must be capable of operating on
+ arrays, and should return a scalar value.
+ shape : (N,) tuple of ints
+ Shape of the output array, which also determines the shape of
+ the coordinate arrays passed to `fn`.
+ dtype : data-type, optional
+ Data-type of the coordinate arrays passed to `fn`. By default,
+ `dtype` is float.
+
+ See Also
+ --------
+ indices, meshgrid
+
+ Notes
+ -----
+ Keywords other than `shape` and `dtype` are passed to the function.
+
+ Examples
+ --------
+ >>> np.fromfunction(lambda i, j: i == j, (3, 3), dtype=int)
+ array([[ True, False, False],
+ [False, True, False],
+ [False, False, True]], dtype=bool)
+
+ >>> np.fromfunction(lambda i, j: i + j, (3, 3), dtype=int)
+ array([[0, 1, 2],
+ [1, 2, 3],
+ [2, 3, 4]])
- The function can also accept keyword arguments (except dtype), which will
- be passed through fromfunction to the function itself. The dtype argument
- (default float) determines the data-type of the index grid passed to the
- function.
"""
dtype = kwargs.pop('dtype', float)
args = indices(shape, dtype=dtype)
return function(*args,**kwargs)
def isscalar(num):
- """Returns True if the type of num is a scalar type.
+ """
+ Returns True if the type of num is a scalar type.
+
+ Parameters
+ ----------
+ num : any
+ Input argument.
+
+ Returns
+ -------
+ val : bool
+ True if `num` is a scalar type, False if it is not.
+
+ Examples
+ --------
+ >>> np.isscalar(3.1)
+ True
+ >>> np.isscalar([3.1])
+ False
+ >>> np.isscalar(False)
+ True
+
"""
if isinstance(num, generic):
return True
@@ -593,14 +1260,61 @@ _lkup = {
'L':''}
def binary_repr(num, width=None):
- """Return the binary representation of the input number as a string.
-
- This is equivalent to using base_repr with base 2, but about 25x
- faster.
+ """
+ Return the binary representation of the input number as a string.
- For negative numbers, if width is not given, a - sign is added to the
+ For negative numbers, if width is not given, a minus sign is added to the
front. If width is given, the two's complement of the number is
returned, with respect to that width.
+
+ In a two's-complement system negative numbers are represented by the two's
+ complement of the absolute value. This is the most common method of
+ representing signed integers on computers [1]_. A N-bit two's-complement
+ system can represent every integer in the range
+ :math:`-2^{N-1}` to :math:`+2^{N-1}-1`.
+
+ Parameters
+ ----------
+ num : int
+ Only an integer decimal number can be used.
+ width : int, optional
+ The length of the returned string if `num` is positive, the length of
+ the two's complement if `num` is negative.
+
+ Returns
+ -------
+ bin : str
+ Binary representation of `num` or two's complement of `num`.
+
+ See Also
+ --------
+ base_repr
+
+ Notes
+ -----
+ `binary_repr` is equivalent to using `base_repr` with base 2, but about 25x
+ faster.
+
+ References
+ ----------
+ .. [1] Wikipedia, "Two's complement",
+ http://en.wikipedia.org/wiki/Two's_complement
+
+ Examples
+ --------
+ >>> np.binary_repr(3)
+ '11'
+ >>> np.binary_repr(-3)
+ '-11'
+ >>> np.binary_repr(3, width=4)
+ '0011'
+
+ The two's complement is returned when the input number is negative and
+ width is specified:
+
+ >>> np.binary_repr(-3, width=4)
+ '1101'
+
"""
sign = ''
if num < 0:
@@ -620,9 +1334,38 @@ def binary_repr(num, width=None):
return sign + bin
def base_repr (number, base=2, padding=0):
- """Return the representation of a number in the given base.
+ """
+ Return a string representation of a number in the given base system.
+
+ Parameters
+ ----------
+ number : scalar
+ The value to convert. Only positive values are handled.
+ base : int
+ Convert `number` to the `base` number system. The valid range is 2-36,
+ the default value is 2.
+ padding : int, optional
+ Number of zeros padded on the left.
+
+ Returns
+ -------
+ out : str
+ String representation of `number` in `base` system.
+
+ See Also
+ --------
+ binary_repr : Faster version of `base_repr` for base 2 that also handles
+ negative numbers.
+
+ Examples
+ --------
+ >>> np.base_repr(3, 5)
+ '3'
+ >>> np.base_repr(6, 5)
+ '11'
+ >>> np.base_repr(7, 5, padding=3)
+ '00012'
- Base can't be larger than 36.
"""
if number < 0:
raise ValueError("negative numbers not handled in base_repr")
@@ -670,8 +1413,32 @@ def _maketup(descr, val):
return tuple(res)
def ones(shape, dtype=None, order='C'):
- """Returns an array of the given dimensions which is initialized to all
- ones.
+ """
+ Return a new array of given shape and type, filled with ones.
+
+ Please refer to the documentation for `zeros`.
+
+ See Also
+ --------
+ zeros
+
+ Examples
+ --------
+ >>> np.ones(5)
+ array([ 1., 1., 1., 1., 1.])
+
+ >>> np.ones((5,), dtype=np.int)
+ array([1, 1, 1, 1, 1])
+
+ >>> np.ones((2, 1))
+ array([[ 1.],
+ [ 1.]])
+
+ >>> s = (2,2)
+ >>> np.ones(s)
+ array([[ 1., 1.],
+ [ 1., 1.]])
+
"""
a = empty(shape, dtype, order)
try:
@@ -685,10 +1452,32 @@ def ones(shape, dtype=None, order='C'):
return a
def identity(n, dtype=None):
- """Returns the identity 2-d array of shape n x n.
+ """
+ Return the identity array.
+
+ The identity array is a square array with ones on
+ the main diagonal.
+
+ Parameters
+ ----------
+ n : int
+ Number of rows (and columns) in `n` x `n` output.
+ dtype : data-type, optional
+ Data-type of the output. Defaults to ``float``.
+
+ Returns
+ -------
+ out : ndarray
+ `n` x `n` array with its main diagonal set to one,
+ and all other elements 0.
+
+ Examples
+ --------
+ >>> np.identity(3)
+ array([[ 1., 0., 0.],
+ [ 0., 1., 0.],
+ [ 0., 0., 1.]])
- identity(n)[i,j] == 1 for all i == j
- == 0 for all i != j
"""
a = array([1]+n*[0],dtype=dtype)
b = empty((n,n),dtype=dtype)
@@ -701,12 +1490,36 @@ def identity(n, dtype=None):
return b
def allclose(a, b, rtol=1.e-5, atol=1.e-8):
- """Returns True if all components of a and b are equal subject to given
- tolerances.
+ """
+ Returns True if all elements are equal subject to given tolerances.
+
+ The tolerance values are positive, typically very small numbers. The
+ relative difference (`rtol` * `b`) and the absolute difference (`atol`)
+ are added together to compare against the absolute difference between `a`
+ and `b`.
+
+ Parameters
+ ----------
+ a, b : array_like
+ Input arrays to compare.
+ rtol : Relative tolerance
+ The relative difference is equal to `rtol` * `b`.
+ atol : Absolute tolerance
+ The absolute difference is equal to `atol`.
+
+ See Also
+ --------
+ all, any, alltrue, sometrue
+
+ Examples
+ --------
+ >>> allclose(array([1e10,1e-7]), array([1.00001e10,1e-8]))
+ False
+ >>> allclose(array([1e10,1e-8]), array([1.00001e10,1e-9]))
+ True
+ >>> allclose(array([1e10,1e-8]), array([1.0001e10,1e-9]))
+ False
- The relative error rtol must be positive and << 1.0
- The absolute error atol usually comes into play for those elements of b that
- are very small or zero; it says how small a must be also.
"""
x = array(a, copy=False)
y = array(b, copy=False)
@@ -722,8 +1535,32 @@ def allclose(a, b, rtol=1.e-5, atol=1.e-8):
return all(less_equal(absolute(x-y), atol + rtol * absolute(y)))
def array_equal(a1, a2):
- """Returns True if a1 and a2 have identical shapes
- and all elements equal and False otherwise.
+ """
+ True if two arrays have the same shape and elements, False otherwise.
+
+ Parameters
+ ----------
+ a1 : array-like
+ First input array.
+ a2 : array-like
+ Second input array.
+
+ Returns
+ -------
+ b : {True, False}
+ Returns True if the arrays are equal.
+
+ Examples
+ --------
+ >>> np.array_equal([1,2],[1,2])
+ True
+ >>> np.array_equal(np.array([1,2]),np.array([1,2]))
+ True
+ >>> np.array_equal([1,2],[1,2,3])
+ False
+ >>> np.array_equal([1,2],[1,4])
+ False
+
"""
try:
a1, a2 = asarray(a1), asarray(a2)
@@ -849,15 +1686,75 @@ def getbufsize():
return umath.geterrobj()[0]
def seterrcall(func):
- """Set the callback function used when a floating-point error handler
- is set to 'call' or the object with a write method for use when
- the floating-point error handler is set to 'log'
+ """
+ Set the floating-point error callback function or log object.
+
+ There are two ways to capture floating-point error messages. The first
+ is to set the error-handler to 'call', using `seterr`. Then, set
+ the function to call using this function.
+
+ The second is to set the error-handler to `log`, using `seterr`.
+ Floating-point errors then trigger a call to the 'write' method of
+ the provided object.
+
+ Parameters
+ ----------
+ log_func_or_obj : callable f(err, flag) or object with write method
+ Function to call upon floating-point errors ('call'-mode) or
+ object whose 'write' method is used to log such message ('log'-mode).
+
+ The call function takes two arguments. The first is the
+ type of error (one of "divide", "over", "under", or "invalid"),
+ and the second is the status flag. The flag is a byte, whose
+ least-significant bits indicate the status::
+
+ [0 0 0 0 invalid over under invalid]
+
+ In other words, ``flags = divide + 2*over + 4*under + 8*invalid``.
+
+ If an object is provided, it's write method should take one argument,
+ a string.
+
+ Returns
+ -------
+ h : callable or log instance
+ The old error handler.
+
+ Examples
+ --------
+ Callback upon error:
+
+ >>> def err_handler(type, flag):
+ print "Floating point error (%s), with flag %s" % (type, flag)
+ ...
+
+ >>> saved_handler = np.seterrcall(err_handler)
+ >>> save_err = np.seterr(all='call')
+
+ >>> np.array([1,2,3])/0.0
+ Floating point error (divide by zero), with flag 1
+ array([ Inf, Inf, Inf])
+
+ >>> np.seterrcall(saved_handler)
+ >>> np.seterr(**save_err)
+
+ Log error message:
+
+ >>> class Log(object):
+ def write(self, msg):
+ print "LOG: %s" % msg
+ ...
+
+ >>> log = Log()
+ >>> saved_handler = np.seterrcall(log)
+ >>> save_err = np.seterr(all='log')
+
+ >>> np.array([1,2,3])/0.0
+ LOG: Warning: divide by zero encountered in divide
- 'func' should be a function that takes two arguments. The first is
- type of error ("divide", "over", "under", or "invalid"), and the second
- is the status flag (= divide + 2*over + 4*under + 8*invalid).
+ >>> np.seterrcall(saved_handler)
+ >>> np.seterr(**save_err)
- Returns the old handler.
"""
if func is not None and not callable(func):
if not hasattr(func, 'write') or not callable(func.write):
diff --git a/numpy/core/records.py b/numpy/core/records.py
index 8d870eb22..545330a30 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -1,3 +1,39 @@
+"""
+Record Arrays
+=============
+Record arrays expose the fields of structured arrays as properties.
+
+Most commonly, ndarrays contain elements of a single type, e.g. floats, integers,
+bools etc. However, it is possible for elements to be combinations of these,
+such as::
+
+ >>> a = np.array([(1, 2.0), (1, 2.0)], dtype=[('x', int), ('y', float)])
+ >>> a
+ array([(1, 2.0), (1, 2.0)],
+ dtype=[('x', '<i4'), ('y', '<f8')])
+
+Here, each element consists of two fields: x (and int), and y (a float).
+This is known as a structured array. The different fields are analogous
+to columns in a spread-sheet. The different fields can be accessed as
+one would a dictionary::
+
+ >>> a['x']
+ array([1, 1])
+
+ >>> a['y']
+ array([ 2., 2.])
+
+Record arrays allow us to access fields as properties::
+
+ >>> ar = a.view(np.recarray)
+
+ >>> ar.x
+ array([1, 1])
+
+ >>> ar.y
+ array([ 2., 2.])
+
+"""
# All of the functions allow formats to be a dtype
__all__ = ['record', 'recarray', 'format_parser']
@@ -214,27 +250,107 @@ class record(nt.void):
# the fields (and any subfields)
class recarray(ndarray):
- """recarray(shape, dtype=None, buf=None, **kwds)
+ """
+ Construct an ndarray that allows field access using attributes.
- Subclass of ndarray that allows field access using attribute lookup.
+ Arrays may have a data-types containing fields, analagous
+ to columns in a spread sheet. An example is ``[(x, int), (y, float)]``,
+ where each entry in the array is a pair of ``(int, float)``. Normally,
+ these attributes are accessed using dictionary lookups such as ``arr['x']``
+ and ``arr['y']``. Record arrays allow the fields to be accessed as members
+ of the array, using ``arr.x`` and ``arr.y``.
Parameters
----------
shape : tuple
- shape of record array
- dtype : data-type or None
- The desired data-type. If this is None, then the data-type is determined
- by the *formats*, *names*, *titles*, *aligned*, and *byteorder* keywords.
- buf : [buffer] or None
- If this is None, then a new array is created of the given shape and data-type
- If this is an object exposing the buffer interface, then the array will
- use the memory from an existing buffer. In this case, the *offset* and
- *strides* keywords can also be used.
+ Shape of output array.
+ dtype : data-type, optional
+ The desired data-type. By default, the data-type is determined
+ from `formats`, `names`, `titles`, `aligned` and `byteorder`.
+ formats : list of data-types, optional
+ A list containing the data-types for the different columns, e.g.
+ ``['i4', 'f8', 'i4']``. `formats` does *not* support the new
+ convention of using types directly, i.e. ``(int, float, int)``.
+ Note that `formats` must be a list, not a tuple.
+ Given that `formats` is somewhat limited, we recommend specifying
+ `dtype` instead.
+ names : tuple of strings, optional
+ The name of each column, e.g. ``('x', 'y', 'z')``.
+ buf : buffer, optional
+ By default, a new array is created of the given shape and data-type.
+ If `buf` is specified and is an object exposing the buffer interface,
+ the array will use the memory from the existing buffer. In this case,
+ the `offset` and `strides` keywords are available.
+
+ Other Parameters
+ ----------------
+ titles : tuple of strings, optional
+ Aliases for column names. For example, if `names` were
+ ``('x', 'y', 'z')`` and `titles` is
+ ``('x_coordinate', 'y_coordinate', 'z_coordinate')``, then
+ ``arr['x']`` is equivalent to both ``arr.x`` and ``arr.x_coordinate``.
+ byteorder : {'<', '>', '='}, optional
+ Byte-order for all fields.
+ aligned : {True, False}, optional
+ Align the fields in memory as the C-compiler would.
+ strides : tuple of ints, optional
+ Buffer (`buf`) is interpreted according to these strides (strides
+ define how many bytes each array element, row, column, etc.
+ occupy in memory).
+ offset : int, optional
+ Start reading buffer (`buf`) from this offset onwards.
+
+ Returns
+ -------
+ rec : recarray
+ Empty array of the given shape and type.
See Also
--------
- format_parser : determine a data-type from formats, names, titles
+ rec.fromrecords : Construct a record array from data.
record : fundamental data-type for recarray
+ format_parser : determine a data-type from formats, names, titles
+
+ Notes
+ -----
+ This constructor can be compared to ``empty``: it creates a new record
+ array but does not fill it with data. To create a reccord array from data,
+ use one of the following methods:
+
+ 1. Create a standard ndarray and convert it to a record array,
+ using ``arr.view(np.recarray)``
+ 2. Use the `buf` keyword.
+ 3. Use `np.rec.fromrecords`.
+
+ Examples
+ --------
+ Create an array with two fields, ``x`` and ``y``:
+
+ >>> x = np.array([(1.0, 2), (3.0, 4)], dtype=[('x', float), ('y', int)])
+ >>> x
+ array([(1.0, 2), (3.0, 4)],
+ dtype=[('x', '<f8'), ('y', '<i4')])
+
+ >>> x['x']
+ array([ 1., 3.])
+
+ View the array as a record array:
+
+ >>> x = x.view(np.recarray)
+
+ >>> x.x
+ array([ 1., 3.])
+
+ >>> x.y
+ array([2, 4])
+
+ Create a new, empty record array:
+
+ >>> np.recarray((2,),
+ ... dtype=[('x', int), ('y', float), ('z', int)]) #doctest: +SKIP
+ rec.array([(-1073741821, 1.2249118382103472e-301, 24547520),
+ (3471280, 1.2134086255804012e-316, 0)],
+ dtype=[('x', '<i4'), ('y', '<f8'), ('z', '<i4')])
"""
def __new__(subtype, shape, dtype=None, buf=None, offset=0, strides=None,
diff --git a/numpy/ctypeslib.py b/numpy/ctypeslib.py
index d64fd43e4..2d868d017 100644
--- a/numpy/ctypeslib.py
+++ b/numpy/ctypeslib.py
@@ -1,3 +1,54 @@
+"""
+============================
+``ctypes`` Utility Functions
+============================
+
+See Also
+---------
+load_library : Load a C library.
+ndpointer : Array restype/argtype with verification.
+as_ctypes : Create a ctypes array from an ndarray.
+as_array : Create an ndarray from a ctypes array.
+
+References
+----------
+.. [1] "SciPy Cookbook: ctypes", http://www.scipy.org/Cookbook/Ctypes
+
+Examples
+--------
+Load the C library:
+
+>>> _lib = np.ctypeslib.load_library('libmystuff', '.') #DOCTEST: +ignore
+
+Our result type, an ndarray that must be of type double, be 1-dimensional
+and is C-contiguous in memory:
+
+>>> array_1d_double = np.ctypeslib.ndpointer(
+... dtype=np.double,
+... ndim=1, flags='CONTIGUOUS') #DOCTEST: +ignore
+
+Our C-function typically takes an array and updates its values
+in-place. For example::
+
+ void foo_func(double* x, int length)
+ {
+ int i;
+ for (i = 0; i < length; i++) {
+ x[i] = i*i;
+ }
+ }
+
+We wrap it using:
+
+>>> lib.foo_func.restype = None #DOCTEST: +ignore
+>>> lib.foo.argtypes = [array_1d_double, c_int] #DOCTEST: +ignore
+
+Then, we're ready to call ``foo_func``:
+
+>>> out = np.empty(15, dtype=np.double)
+>>> _lib.foo_func(out, len(out)) #DOCTEST: +ignore
+
+"""
__all__ = ['load_library', 'ndpointer', 'test', 'ctypes_load_library',
'c_intp', 'as_ctypes', 'as_array']
@@ -104,26 +155,41 @@ class _ndptr(object):
# use with ctypes argtypes mechanism
_pointer_type_cache = {}
def ndpointer(dtype=None, ndim=None, shape=None, flags=None):
- """Array-checking restype/argtypes.
+ """
+ Array-checking restype/argtypes.
An ndpointer instance is used to describe an ndarray in restypes
and argtypes specifications. This approach is more flexible than
- using, for example,
-
- POINTER(c_double)
-
- since several restrictions can be specified, which are verified
- upon calling the ctypes function. These include data type
- (dtype), number of dimensions (ndim), shape and flags (e.g.
- 'C_CONTIGUOUS' or 'F_CONTIGUOUS'). If a given array does not satisfy the
- specified restrictions, a TypeError is raised.
-
- Example:
-
- clib.somefunc.argtypes = [ndpointer(dtype=float64,
- ndim=1,
- flags='C_CONTIGUOUS')]
- clib.somefunc(array([1,2,3],dtype=float64))
+ using, for example, ``POINTER(c_double)``, since several restrictions
+ can be specified, which are verified upon calling the ctypes function.
+ These include data type, number of dimensions, shape and flags. If a
+ given array does not satisfy the specified restrictions,
+ a ``TypeError`` is raised.
+
+ Parameters
+ ----------
+ dtype : data-type, optional
+ Array data-type.
+ ndim : int, optional
+ Number of array dimensions.
+ shape : tuple of ints, optional
+ Array shape.
+ flags : string or tuple of strings
+ Array flags; may be one or more of:
+
+ - C_CONTIGUOUS / C / CONTIGUOUS
+ - F_CONTIGUOUS / F / FORTRAN
+ - OWNDATA / O
+ - WRITEABLE / W
+ - ALIGNED / A
+ - UPDATEIFCOPY / U
+
+ Examples
+ --------
+ >>> clib.somefunc.argtypes = [np.ctypeslib.ndpointer(dtype=float64,
+ ... ndim=1,
+ ... flags='C_CONTIGUOUS')]
+ >>> clib.somefunc(np.array([1, 2, 3], dtype=np.float64))
"""
diff --git a/numpy/doc/reference/basics.py b/numpy/doc/reference/basics.py
index 6b86f6741..dfb8fe74d 100644
--- a/numpy/doc/reference/basics.py
+++ b/numpy/doc/reference/basics.py
@@ -1,9 +1,137 @@
"""
-
============
Array basics
============
-Placeholder for array basics documentation.
+Array types and conversions between types
+=========================================
+
+Numpy supports a much greater variety of numerical types than Python does.
+This section shows which are available, and how to modify an array's data-type.
+
+========== =========================================================
+Data type Description
+========== =========================================================
+bool Boolean (True or False) stored as a byte
+int Platform integer (normally either ``int32`` or ``int64``)
+int8 Byte (-128 to 127)
+int16 Integer (-32768 to 32767)
+int32 Integer (-2147483648 to 2147483647)
+int64 Integer (9223372036854775808 to 9223372036854775807)
+uint8 Unsigned integer (0 to 255)
+uint16 Unsigned integer (0 to 65535)
+uint32 Unsigned integer (0 to 4294967295)
+uint64 Unsigned integer (0 to 18446744073709551615)
+float Shorthand for ``float64``.
+float32 Single precision float: sign bit, 8 bits exponent,
+ 23 bits mantissa
+float64 Double precision float: sign bit, 11 bits exponent,
+ 52 bits mantissa
+complex Shorthand for ``complex128``.
+complex64 Complex number, represented by two 32-bit floats (real
+ and imaginary components)
+complex128 Complex number, represented by two 64-bit floats (real
+ and imaginary components)
+========== =========================================================
+
+Numpy numerical types are instances of ``dtype`` (data-type) objects, each
+having unique characteristics. Once you have imported NumPy using
+
+ ::
+
+ >>> import numpy as np
+
+the dtypes are available as ``np.bool``, ``np.float32``, etc.
+
+Advanced types, not listed in the table above, are explored in
+section `link_here`.
+
+There are 5 basic numerical types representing booleans (bool), integers (int),
+unsigned integers (uint) floating point (float) and complex. Those with numbers
+in their name indicate the bitsize of the type (i.e. how many bits are needed
+to represent a single value in memory). Some types, such as ``int`` and
+``intp``, have differing bitsizes, dependent on the platforms (e.g. 32-bit
+vs. 64-bit machines). This should be taken into account when interfacing
+with low-level code (such as C or Fortran) where the raw memory is addressed.
+
+Data-types can be used as functions to convert python numbers to array scalars
+(see the array scalar section for an explanation), python sequences of numbers
+to arrays of that type, or as arguments to the dtype keyword that many numpy
+functions or methods accept. Some examples::
+
+ >>> import numpy as np
+ >>> x = np.float32(1.0)
+ >>> x
+ 1.0
+ >>> y = np.int_([1,2,4])
+ >>> y
+ array([1, 2, 4])
+ >>> z = np.arange(3, dtype=np.uint8)
+ array([0, 1, 2], dtype=uint8)
+
+Array types can also be referred to by character codes, mostly to retain
+backward compatibility with older packages such as Numeric. Some
+documentation may still refer to these, for example::
+
+ >>> np.array([1, 2, 3], dtype='f')
+ array([ 1., 2., 3.], dtype=float32)
+
+We recommend using dtype objects instead.
+
+To convert the type of an array, use the .astype() method (preferred) or
+the type itself as a function. For example: ::
+
+ >>> z.astype(float)
+ array([0., 1., 2.])
+ >>> np.int8(z)
+ array([0, 1, 2], dtype=int8)
+
+Note that, above, we use the *Python* float object as a dtype. NumPy knows
+that ``int`` refers to ``np.int``, ``bool`` means ``np.bool`` and
+that ``float`` is ``np.float``. The other data-types do not have Python
+equivalents.
+
+To determine the type of an array, look at the dtype attribute::
+
+ >>> z.dtype
+ dtype('uint8')
+
+dtype objects also contain information about the type, such as its bit-width
+and its byte-order. See xxx for details. The data type can also be used
+indirectly to query properties of the type, such as whether it is an integer::
+
+ >>> d = np.dtype(int)
+ >>> d
+ dtype('int32')
+
+ >>> np.issubdtype(d, int)
+ True
+
+ >>> np.issubdtype(d, float)
+ False
+
+
+Array Scalars
+=============
+
+Numpy generally returns elements of arrays as array scalars (a scalar
+with an associated dtype). Array scalars differ from Python scalars, but
+for the most part they can be used interchangeably (the primary
+exception is for versions of Python older than v2.x, where integer array
+scalars cannot act as indices for lists and tuples). There are some
+exceptions, such as when code requires very specific attributes of a scalar
+or when it checks specifically whether a value is a Python scalar. Generally,
+problems are easily fixed by explicitly converting array scalars
+to Python scalars, using the corresponding Python type function
+(e.g., ``int``, ``float``, ``complex``, ``str``, ``unicode``).
+
+The primary advantage of using array scalars is that
+they preserve the array type (Python may not have a matching scalar type
+available, e.g. ``int16``). Therefore, the use of array scalars ensures
+identical behaviour between arrays and scalars, irrespective of whether the
+value is inside an array or not. NumPy scalars also have many of the same
+methods arrays do.
+
+See xxx for details.
"""
diff --git a/numpy/doc/reference/broadcasting.py b/numpy/doc/reference/broadcasting.py
index 797d0edba..95e9b67f9 100644
--- a/numpy/doc/reference/broadcasting.py
+++ b/numpy/doc/reference/broadcasting.py
@@ -1,9 +1,176 @@
"""
-
========================
Broadcasting over arrays
========================
-Placeholder for broadcasting documentation.
+The term broadcasting describes how numpy treats arrays with different
+shapes during arithmetic operations. Subject to certain constraints,
+the smaller array is "broadcast" across the larger array so that they
+have compatible shapes. Broadcasting provides a means of vectorizing
+array operations so that looping occurs in C instead of Python. It does
+this without making needless copies of data and usually leads to
+efficient algorithm implementations. There are, however, cases where
+broadcasting is a bad idea because it leads to inefficient use of memory
+that slows computation.
+
+NumPy operations are usually done element-by-element, which requires two
+arrays to have exactly the same shape::
+
+ >>> a = np.array([1.0, 2.0, 3.0])
+ >>> b = np.array([2.0, 2.0, 2.0])
+ >>> a * b
+ array([ 2., 4., 6.])
+
+NumPy's broadcasting rule relaxes this constraint when the arrays'
+shapes meet certain constraints. The simplest broadcasting example occurs
+when an array and a scalar value are combined in an operation:
+
+>>> a = np.array([1.0, 2.0, 3.0])
+>>> b = 2.0
+>>> a * b
+array([ 2., 4., 6.])
+
+The result is equivalent to the previous example where ``b`` was an array.
+We can think of the scalar ``b`` being *stretched* during the arithmetic
+operation into an array with the same shape as ``a``. The new elements in
+``b`` are simply copies of the original scalar. The stretching analogy is
+only conceptual. NumPy is smart enough to use the original scalar value
+without actually making copies, so that broadcasting operations are as
+memory and computationally efficient as possible.
+
+The second example is more effective than the first, since here broadcasting
+moves less memory around during the multiplication (``b`` is a scalar,
+not an array).
+
+General Broadcasting Rules
+==========================
+When operating on two arrays, NumPy compares their shapes element-wise.
+It starts with the trailing dimensions, and works its way forward. Two
+dimensions are compatible when
+
+1) they are equal, or
+2) one of them is 1
+
+If these conditions are not met, a
+``ValueError: frames are not aligned`` exception is thrown, indicating that
+the arrays have incompatible shapes. The size of the resulting array
+is the maximum size along each dimension of the input arrays.
+
+Arrays do not need to have the same *number* of dimensions. For example,
+if you have a ``256x256x3`` array of RGB values, and you want to scale
+each color in the image by a different value, you can multiply the image
+by a one-dimensional array with 3 values. Lining up the sizes of the
+trailing axes of these arrays according to the broadcast rules, shows that
+they are compatible::
+
+ Image (3d array): 256 x 256 x 3
+ Scale (1d array): 3
+ Result (3d array): 256 x 256 x 3
+
+When either of the dimensions compared is one, the larger of the two is
+used. In other words, the smaller of two axes is stretched or "copied"
+to match the other.
+
+In the following example, both the ``A`` and ``B`` arrays have axes with
+length one that are expanded to a larger size during the broadcast
+operation::
+
+ A (4d array): 8 x 1 x 6 x 1
+ B (3d array): 7 x 1 x 5
+ Result (4d array): 8 x 7 x 6 x 5
+
+Here are some more examples::
+
+ A (2d array): 5 x 4
+ B (1d array): 1
+ Result (2d array): 5 x 4
+
+ A (2d array): 5 x 4
+ B (1d array): 4
+ Result (2d array): 5 x 4
+
+ A (3d array): 15 x 3 x 5
+ B (3d array): 15 x 1 x 5
+ Result (3d array): 15 x 3 x 5
+
+ A (3d array): 15 x 3 x 5
+ B (2d array): 3 x 5
+ Result (3d array): 15 x 3 x 5
+
+ A (3d array): 15 x 3 x 5
+ B (2d array): 3 x 1
+ Result (3d array): 15 x 3 x 5
+
+Here are examples of shapes that do not broadcast::
+
+ A (1d array): 3
+ B (1d array): 4 # trailing dimensions do not match
+
+ A (2d array): 2 x 1
+ B (3d array): 8 x 4 x 3 # second from last dimensions mismatch
+
+An example of broadcasting in practice::
+
+ >>> x = np.arange(4)
+ >>> xx = x.reshape(4,1)
+ >>> y = np.ones(5)
+ >>> z = np.ones((3,4))
+
+ >>> x.shape
+ (4,)
+
+ >>> y.shape
+ (5,)
+
+ >>> x + y
+ <type 'exceptions.ValueError'>: shape mismatch: objects cannot be broadcast to a single shape
+
+ >>> xx.shape
+ (4, 1)
+
+ >>> y.shape
+ (5,)
+
+ >>> (xx + y).shape
+ (4, 5)
+
+ >>> xx + y
+ array([[ 1., 1., 1., 1., 1.],
+ [ 2., 2., 2., 2., 2.],
+ [ 3., 3., 3., 3., 3.],
+ [ 4., 4., 4., 4., 4.]])
+
+ >>> x.shape
+ (4,)
+
+ >>> z.shape
+ (3, 4)
+
+ >>> (x + z).shape
+ (3, 4)
+
+ >>> x + z
+ array([[ 1., 2., 3., 4.],
+ [ 1., 2., 3., 4.],
+ [ 1., 2., 3., 4.]])
+
+Broadcasting provides a convenient way of taking the outer product (or
+any other outer operation) of two arrays. The following example shows an
+outer addition operation of two 1-d arrays::
+
+ >>> a = np.array([0.0, 10.0, 20.0, 30.0])
+ >>> b = np.array([1.0, 2.0, 3.0])
+ >>> a[:, np.newaxis] + b
+ array([[ 1., 2., 3.],
+ [ 11., 12., 13.],
+ [ 21., 22., 23.],
+ [ 31., 32., 33.]])
+
+Here the ``newaxis`` index operator inserts a new axis into ``a``,
+making it a two-dimensional ``4x1`` array. Combining the ``4x1`` array
+with ``b``, which has shape ``(3,)``, yields a ``4x3`` array.
+
+See `this article <http://www.scipy.org/EricsBroadcastingDoc>`_
+for illustrations of broadcasting concepts.
"""
diff --git a/numpy/doc/reference/creation.py b/numpy/doc/reference/creation.py
index 052cd86d7..1e80e5115 100644
--- a/numpy/doc/reference/creation.py
+++ b/numpy/doc/reference/creation.py
@@ -1,9 +1,132 @@
"""
-
==============
Array creation
==============
-Placeholder for array creation documentation.
+Introduction
+============
+
+There are 5 general mechanisms for creating arrays:
+
+1) Conversion from other Python structures (e.g., lists, tuples)
+2) Intrinsic numpy array array creation objects (e.g., arange, ones, zeros, etc.)
+3) Reading arrays from disk, either from standard or custom formats
+4) Creating arrays from raw bytes through the use of strings or buffers
+5) Use of special library functions (e.g., random)
+
+This section will not cover means of replicating, joining, or otherwise
+expanding or mutating existing arrays. Nor will it cover creating object
+arrays or record arrays. Both of those are covered in their own sections.
+
+Converting Python array-like objects to numpy arrays
+====================================================
+
+In general, numerical data arranged in an array-like structure in Python can
+be converted to arrays through the use of the array() function. The most obvious
+examples are lists and tuples. See the documentation for array() for details for
+its use. Some
+objects may support the array-protocol and allow conversion to arrays this
+way. A simple way to find out if the object can be converted to a numpy array
+using array() is simply to try it interactively and see if it works! (The
+Python Way).
+
+Examples: ::
+
+ >>> x = np.array([2,3,1,0])
+ >>> x = np.array([2, 3, 1, 0])
+ >>> x = np.array([[1,2.0],[0,0],(1+1j,3.)]) # note mix of tuple and lists, and types
+ >>> x = np.array([[ 1.+0.j, 2.+0.j], [ 0.+0.j, 0.+0.j], [ 1.+1.j, 3.+0.j]])
+
+Intrinsic numpy array creation
+==============================
+
+Numpy has built-in functions for creating arrays from scratch:
+
+zeros(shape) will create an array filled with 0 values with the specified
+shape. The default dtype is float64.
+
+``>>> np.zeros((2, 3))
+array([[ 0., 0., 0.], [ 0., 0., 0.]])``
+
+ones(shape) will create an array filled with 1 values. It is identical to
+zeros in all other respects.
+
+arange() will create arrays with regularly incrementing values. Check the
+docstring for complete information on the various ways it can be used. A few
+examples will be given here: ::
+
+ >>> np.arange(10)
+ array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ >>> np.arange(2, 10, dtype=np.float)
+ array([ 2., 3., 4., 5., 6., 7., 8., 9.])
+ >>> np.arange(2, 3, 0.1)
+ array([ 2. , 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9])
+
+Note that there are some subtleties regarding the last usage that the user
+should be aware of that are described in the arange docstring.
+
+indices() will create a set of arrays (stacked as a one-higher dimensioned
+array), one per dimension with each representing variation in that dimension.
+An examples illustrates much better than a verbal description: ::
+
+ >>> np.indices((3,3))
+ array([[[0, 0, 0], [1, 1, 1], [2, 2, 2]], [[0, 1, 2], [0, 1, 2], [0, 1, 2]]])
+
+This is particularly useful for evaluating functions of multiple dimensions on
+a regular grid.
+
+Reading arrays from disk
+========================
+
+This is presumably the most common case of large array creation. The details,
+of course, depend greatly on the format of data on disk and so this section
+can only give general pointers on how to handle various formats.
+
+Standard binary formats
+-----------------------
+
+Various fields have standard formats for array data. The following lists the
+ones with known python libraries to read them and return numpy arrays (there
+may be others for which it is possible to read and convert to numpy arrays so
+check the last section as well)
+
+HDF5: PyTables
+FITS: PyFITS
+Others? xxx
+
+Examples of formats that cannot be read directly but for which it is not hard
+to convert are libraries like PIL (able to read and write many image formats
+such as jpg, png, etc).
+
+Common ascii formats
+--------------------
+
+Comma Separated Value files (CSV) are widely used (and an export and import
+option for programs like Excel). There are a number of ways of reading these
+files in Python. The most convenient ways of reading these are found in pylab
+(part of matplotlib) in the xxx function. (list alternatives xxx)
+
+More generic ascii files can be read using the io package in scipy. xxx a few
+more details needed...
+
+Custom binary formats
+---------------------
+
+There are a variety of approaches one can use. If the file has a relatively
+simple format then one can write a simple I/O library and use the numpy
+fromfile() function and .tofile() method to read and write numpy arrays
+directly (mind your byteorder though!) If a good C or C++ library exists that
+read the data, one can wrap that library with a variety of techniques (see
+xxx) though that certainly is much more work and requires significantly more
+advanced knowledge to interface with C or C++.
+
+Use of special libraries
+------------------------
+
+There are libraries that can be used to generate arrays for special purposes
+and it isn't possible to enumerate all of them. The most common uses are use
+of the many array generation functions in random that can generate arrays of
+random values, and some utility functions to generate special matrices (e.g.
+diagonal, see xxx)
"""
diff --git a/numpy/doc/reference/glossary.py b/numpy/doc/reference/glossary.py
index c060378d4..6a182adf4 100644
--- a/numpy/doc/reference/glossary.py
+++ b/numpy/doc/reference/glossary.py
@@ -1,9 +1,367 @@
"""
-
=================
Glossary
=================
-Place-holder for a glossary.
+along an axis
+ Axes are defined for arrays with more than one dimension. A
+ 2-dimensional array has two corresponding axes: the first running
+ vertically downwards across rows (axis 0), and the second running
+ horizontally across columns (axis 1).
+
+ Many operation can take place along one of these axes. For example,
+ we can sum each row of an array, in which case we operate along
+ columns, or axis 1::
+
+ >>> x = np.arange(12).reshape((3,4))
+
+ >>> x
+ array([[ 0, 1, 2, 3],
+ [ 4, 5, 6, 7],
+ [ 8, 9, 10, 11]])
+
+ >>> x.sum(axis=1)
+ array([ 6, 22, 38])
+
+array or ndarray
+ A homogeneous container of numerical elements. Each element in the
+ array occupies a fixed amount of memory (hence homogeneous), and
+ can be a numerical element of a single type (such as float, int
+ or complex) or a combination (such as ``(float, int, float)``). Each
+ array has an associated data-type (or ``dtype``), which describes
+ the numerical type of its elements::
+
+ >>> x = np.array([1, 2, 3], float)
+
+ >>> x
+ array([ 1., 2., 3.])
+
+ >>> x.dtype # floating point number, 64 bits of memory per element
+ dtype('float64')
+
+
+ # More complicated data type: each array element is a combination of
+ # and integer and a floating point number
+ >>> np.array([(1, 2.0), (3, 4.0)], dtype=[('x', int), ('y', float)])
+ array([(1, 2.0), (3, 4.0)],
+ dtype=[('x', '<i4'), ('y', '<f8')])
+
+ Fast element-wise operations, called `ufuncs`_, operate on arrays.
+
+array_like
+ Any sequence that can be interpreted as an ndarray. This includes
+ nested lists, tuples, scalars and existing arrays.
+
+attribute
+ A property of an object that can be accessed using ``obj.attribute``,
+ e.g., ``shape`` is an attribute of an array::
+
+ >>> x = np.array([1, 2, 3])
+ >>> x.shape
+ (3,)
+
+broadcast
+ NumPy can do operations on arrays whose shapes are mismatched::
+
+ >>> x = np.array([1, 2])
+ >>> y = np.array([[3], [4]])
+
+ >>> x
+ array([1, 2])
+
+ >>> y
+ array([[3],
+ [4]])
+
+ >>> x + y
+ array([[4, 5],
+ [5, 6]])
+
+ See `doc.broadcasting`_ for more information.
+
+decorator
+ An operator that transforms a function. For example, a ``log``
+ decorator may be defined to print debugging information upon
+ function execution::
+
+ >>> def log(f):
+ ... def new_logging_func(*args, **kwargs):
+ ... print "Logging call with parameters:", args, kwargs
+ ... return f(*args, **kwargs)
+ ...
+ ... return new_logging_func
+
+ Now, when we define a function, we can "decorate" it using ``log``::
+
+ >>> @log
+ ... def add(a, b):
+ ... return a + b
+
+ Calling ``add`` then yields:
+
+ >>> add(1, 2)
+ Logging call with parameters: (1, 2) {}
+ 3
+
+dictionary
+ Resembling a language dictionary, which provides a mapping between
+ words and descriptions thereof, a Python dictionary is a mapping
+ between two objects::
+
+ >>> x = {1: 'one', 'two': [1, 2]}
+
+ Here, `x` is a dictionary mapping keys to values, in this case
+ the integer 1 to the string "one", and the string "two" to
+ the list ``[1, 2]``. The values may be accessed using their
+ corresponding keys::
+
+ >>> x[1]
+ 'one'
+
+ >>> x['two']
+ [1, 2]
+
+ Note that dictionaries are not stored in any specific order. Also,
+ most mutable (see *immutable* below) objects, such as lists, may not
+ be used as keys.
+
+ For more information on dictionaries, read the
+ `Python tutorial <http://docs.python.org/tut>`_.
+
+immutable
+ An object that cannot be modified after execution is called
+ immutable. Two common examples are strings and tuples.
+
+instance
+ A class definition gives the blueprint for constructing an object::
+
+ >>> class House(object):
+ ... wall_colour = 'white'
+
+ Yet, we have to *build* a house before it exists::
+
+ >>> h = House() # build a house
+
+ Now, ``h`` is called a ``House`` instance. An instance is therefore
+ a specific realisation of a class.
+
+iterable
+ A sequence that allows "walking" (iterating) over items, typically
+ using a loop such as::
+
+ >>> x = [1, 2, 3]
+ >>> [item**2 for item in x]
+ [1, 4, 9]
+
+ It is often used in combintion with ``enumerate``::
+
+ >>> for n, k in enumerate(keys):
+ ... print "Key %d: %s" % (n, k)
+ ...
+ Key 0: a
+ Key 1: b
+ Key 2: c
+
+list
+ A Python container that can hold any number of objects or items.
+ The items do not have to be of the same type, and can even be
+ lists themselves::
+
+ >>> x = [2, 2.0, "two", [2, 2.0]]
+
+ The list `x` contains 4 items, each which can be accessed individually::
+
+ >>> x[2] # the string 'two'
+ 'two'
+
+ >>> x[3] # a list, containing an integer 2 and a float 2.0
+ [2, 2.0]
+
+ It is also possible to select more than one item at a time,
+ using *slicing*::
+
+ >>> x[0:2] # or, equivalently, x[:2]
+ [2, 2.0]
+
+ In code, arrays are often conveniently expressed as nested lists::
+
+
+ >>> np.array([[1, 2], [3, 4]])
+ array([[1, 2],
+ [3, 4]])
+
+ For more information, read the section on lists in the `Python
+ tutorial <http://docs.python.org/tut>`_. For a mapping
+ type (key-value), see *dictionary*.
+
+mask
+ A boolean array, used to select only certain elements for an operation::
+
+ >>> x = np.arange(5)
+ >>> x
+ array([0, 1, 2, 3, 4])
+
+ >>> mask = (x > 2)
+ >>> mask
+ array([False, False, False, True, True], dtype=bool)
+
+ >>> x[mask] = -1
+ >>> x
+ array([ 0, 1, 2, -1, -1])
+
+masked array
+ Array that suppressed values indicated by a mask::
+
+ >>> x = np.ma.masked_array([np.nan, 2, np.nan], [True, False, True])
+ >>> x
+ masked_array(data = [-- 2.0 --],
+ mask = [ True False True],
+ fill_value=1e+20)
+
+ >>> x + [1, 2, 3]
+ masked_array(data = [-- 4.0 --],
+ mask = [ True False True],
+ fill_value=1e+20)
+
+ Masked arrays are often used when operating on arrays containing
+ missing or invalid entries.
+
+matrix
+ A 2-dimensional ndarray that preserves its two-dimensional nature
+ throughout operations. It has certain special operations, such as ``*``
+ (matrix multiplication) and ``**`` (matrix power), defined::
+
+ >>> x = np.mat([[1, 2], [3, 4]])
+
+ >>> x
+ matrix([[1, 2],
+ [3, 4]])
+
+ >>> x**2
+ matrix([[ 7, 10],
+ [15, 22]])
+
+method
+ A function associated with an object. For example, each ndarray has a
+ method called ``repeat``::
+
+ >>> x = np.array([1, 2, 3])
+
+ >>> x.repeat(2)
+ array([1, 1, 2, 2, 3, 3])
+
+reference
+ If ``a`` is a reference to ``b``, then ``(a is b) == True``. Therefore,
+ ``a`` and ``b`` are different names for the same Python object.
+
+self
+ Often seen in method signatures, ``self`` refers to the instance
+ of the associated class. For example:
+
+ >>> class Paintbrush(object):
+ ... color = 'blue'
+ ...
+ ... def paint(self):
+ ... print "Painting the city %s!" % self.color
+ ...
+ >>> p = Paintbrush()
+ >>> p.color = 'red'
+ >>> p.paint() # self refers to 'p'
+ Painting the city red!
+
+slice
+ Used to select only certain elements from a sequence::
+
+ >>> x = range(5)
+ >>> x
+ [0, 1, 2, 3, 4]
+
+ >>> x[1:3] # slice from 1 to 3 (excluding 3 itself)
+ [1, 2]
+
+ >>> x[1:5:2] # slice from 1 to 5, but skipping every second element
+ [1, 3]
+
+ >>> x[::-1] # slice a sequence in reverse
+ [4, 3, 2, 1, 0]
+
+ Arrays may have more than one dimension, each which can be sliced
+ individually::
+
+ >>> x = np.array([[1, 2], [3, 4]])
+ >>> x
+ array([[1, 2],
+ [3, 4]])
+
+ >>> x[:, 1]
+ array([2, 4])
+
+tuple
+ A sequence that may contain a variable number of types of any
+ kind. A tuple is immutable, i.e., once constructed it cannot be
+ changed. Similar to a list, it can be indexed and sliced::
+
+ >>> x = (1, 'one', [1, 2])
+
+ >>> x
+ (1, 'one', [1, 2])
+
+ >>> x[0]
+ 1
+
+ >>> x[:2]
+ (1, 'one')
+
+ A useful concept is "tuple unpacking", which allows variables to
+ be assigned to the contents of a tuple::
+
+ >>> x, y = (1, 2)
+ >>> x, y = 1, 2
+
+ This is often used when a function returns multiple values:
+
+ >>> def return_many():
+ ... return 1, 'alpha'
+
+ >>> a, b, c = return_many()
+ >>> a, b, c
+ (1, 'alpha', None)
+
+ >>> a
+ 1
+ >>> b
+ 'alpha'
+
+ufunc
+ Universal function. A fast element-wise array operation. Examples include
+ ``add``, ``sin`` and ``logical_or``.
+
+view
+ An array that does not own its data, but refers to another array's
+ data instead. For example, we may create a view that only shows
+ every second element of another array::
+
+ >>> x = np.arange(5)
+ >>> x
+ array([0, 1, 2, 3, 4])
+
+ >>> y = x[::2]
+ >>> y
+ array([0, 2, 4])
+
+ >>> x[0] = 3 # changing x changes y as well, since y is a view on x
+ >>> y
+ array([3, 2, 4])
+
+wrapper
+ Python is a high-level (highly abstracted, or English-like) language.
+ This abstraction comes at a price in execution speed, and sometimes
+ it becomes necessary to use lower level languages to do fast
+ computations. A wrapper is code that provides a bridge between
+ high and the low level languages, allowing, e.g., Python to execute
+ code written in C or Fortran.
+
+ Examples include ctypes, SWIG and Cython (which wraps C and C++)
+ and f2py (which wraps Fortran).
"""
diff --git a/numpy/doc/reference/indexing.py b/numpy/doc/reference/indexing.py
index bc13611e8..365edd67a 100644
--- a/numpy/doc/reference/indexing.py
+++ b/numpy/doc/reference/indexing.py
@@ -1,9 +1,384 @@
"""
-
==============
Array indexing
==============
-Placeholder for array indexing documentation.
+Array indexing refers to any use of the square brackets ([]) to index
+array values. There are many options to indexing, which give numpy
+indexing great power, but with power comes some complexity and the
+potential for confusion. This section is just an overview of the
+various options and issues related to indexing. Aside from single
+element indexing, the details on most of these options are to be
+found in related sections.
+
+Assignment vs referencing
+=========================
+
+Most of the following examples show the use of indexing when referencing
+data in an array. The examples work just as well when assigning to an
+array. See the section at the end for specific examples and explanations
+on how assignments work.
+
+Single element indexing
+=======================
+
+Single element indexing for a 1-D array is what one expects. It work
+exactly like that for other standard Python sequences. It is 0-based,
+and accepts negative indices for indexing from the end of the array. ::
+
+ >>> x = np.arange(10)
+ >>> x[2]
+ 2
+ >>> x[-2]
+ 8
+
+Unlike lists and tuples, numpy arrays support multidimensional indexing
+for multidimensional arrays. That means that it is not necessary to
+separate each dimension's index into its own set of square brackets. ::
+
+ >>> x.shape = (2,5) # now x is 2-dimensional
+ >>> x[1,3]
+ 8
+ >>> x[1,-1]
+ 9
+
+Note that if one indexes a multidimensional array with fewer indices
+than dimensions, one gets a subdimensional array. For example: ::
+
+ >>> x[0]
+ array([0, 1, 2, 3, 4])
+
+That is, each index specified selects the array corresponding to the rest
+of the dimensions selected. In the above example, choosing 0 means that
+remaining dimension of lenth 5 is being left unspecified, and that what
+is returned is an array of that dimensionality and size. It must be noted
+that the returned array is not a copy of the original, but points to the
+same values in memory as does the original array (a new view of the same
+data in other words, see xxx for details). In this case,
+the 1-D array at the first position (0) is returned. So using a single
+index on the returned array, results in a single element being returned.
+That is: ::
+
+ >>> x[0][2]
+ 2
+
+So note that ``x[0,2] = x[0][2]`` though the second case is more inefficient
+a new temporary array is created after the first index that is subsequently
+indexed by 2.
+
+Note to those used to IDL or Fortran memory order as it relates to indexing.
+Numpy uses C-order indexing. That means that the last index usually (see
+xxx for exceptions) represents the most rapidly changing memory location,
+unlike Fortran or IDL, where the first index represents the most rapidly
+changing location in memory. This difference represents a great potential
+for confusion.
+
+Other indexing options
+======================
+
+It is possible to slice and stride arrays to extract arrays of the same
+number of dimensions, but of different sizes than the original. The slicing
+and striding works exactly the same way it does for lists and tuples except
+that they can be applied to multiple dimensions as well. A few
+examples illustrates best: ::
+
+ >>> x = np.arange(10)
+ >>> x[2:5]
+ array([2, 3, 4])
+ >>> x[:-7]
+ array([0, 1, 2])
+ >>> x[1:7:2]
+ array([1,3,5])
+ >>> y = np.arange(35).reshape(5,7)
+ >>> y[1:5:2,::3]
+ array([[ 7, 10, 13],
+ [21, 24, 27]])
+
+Note that slices of arrays do not copy the internal array data but
+also produce new views of the original data (see xxx for more
+explanation of this issue).
+
+It is possible to index arrays with other arrays for the purposes of
+selecting lists of values out of arrays into new arrays. There are two
+different ways of accomplishing this. One uses one or more arrays of
+index values (see xxx for details). The other involves giving a boolean
+array of the proper shape to indicate the values to be selected.
+Index arrays are a very powerful tool that allow one to avoid looping
+over individual elements in arrays and thus greatly improve performance
+(see xxx for examples)
+
+It is possible to use special features to effectively increase the
+number of dimensions in an array through indexing so the resulting
+array aquires the shape needed for use in an expression or with a
+specific function. See xxx.
+
+Index arrays
+============
+
+Numpy arrays may be indexed with other arrays (or any other sequence-like
+object that can be converted to an array, such as lists, with the exception
+of tuples; see the end of this document for why this is). The use of index
+arrays ranges from simple, straightforward cases to complex, hard-to-understand
+cases. For all cases of index arrays, what is returned is a copy of the
+original data, not a view as one gets for slices.
+
+Index arrays must be of integer type. Each value in the array indicates which
+value in the array to use in place of the index. To illustrate: ::
+
+ >>> x = np.arange(10,1,-1)
+ >>> x
+ array([10, 9, 8, 7, 6, 5, 4, 3, 2])
+ >>> x[np.array([3, 3, 1, 8])]
+ array([7, 7, 9, 2])
+
+
+The index array consisting of the values 3, 3, 1 and 8 correspondingly create
+an array of length 4 (same as the index array) where each index is replaced by
+the value the index array has in the array being indexed.
+
+Negative values are permitted and work as they do with single indices or slices: ::
+
+ >>> x[np.array([3,3,-3,8])]
+ array([7, 7, 4, 2])
+
+It is an error to have index values out of bounds: ::
+
+ >>> x[np.array([3, 3, 20, 8])]
+ <type 'exceptions.IndexError'>: index 20 out of bounds 0<=index<9
+
+Generally speaking, what is returned when index arrays are used is an array with
+the same shape as the index array, but with the type and values of the array being
+indexed. As an example, we can use a multidimensional index array instead: ::
+
+ >>> x[np.array([[1,1],[2,3]])]
+ array([[9, 9],
+ [8, 7]])
+
+Indexing Multi-dimensional arrays
+=================================
+
+Things become more complex when multidimensional arrays are indexed, particularly
+with multidimensional index arrays. These tend to be more unusal uses, but they
+are permitted, and they are useful for some problems. We'll start with the
+simplest multidimensional case (using the array y from the previous examples): ::
+
+ >>> y[np.array([0,2,4]), np.array([0,1,2])]
+ array([ 0, 15, 30])
+
+In this case, if the index arrays have a matching shape, and there is an index
+array for each dimension of the array being indexed, the resultant array has the
+same shape as the index arrays, and the values correspond to the index set for each
+position in the index arrays. In this example, the first index value is 0 for both
+index arrays, and thus the first value of the resultant array is y[0,0]. The next
+value is y[2,1], and the last is y[4,2].
+
+If the index arrays do not have the same shape, there is an attempt to broadcast
+them to the same shape. Broadcasting won't be discussed here but is discussed in
+detail in xxx. If they cannot be broadcast to the same shape, an exception is
+raised: ::
+
+ >>> y[np.array([0,2,4]), np.array([0,1])]
+ <type 'exceptions.ValueError'>: shape mismatch: objects cannot be broadcast to a single shape
+
+The broadcasting mechanism permits index arrays to be combined with scalars for
+other indices. The effect is that the scalar value is used for all the corresponding
+values of the index arrays: ::
+
+ >>> y[np.array([0,2,4]), 1]
+ array([ 1, 15, 29])
+
+Jumping to the next level of complexity, it is possible to only partially index an array
+with index arrays. It takes a bit of thought to understand what happens in such cases.
+For example if we just use one index array with y: ::
+
+ >>> y[np.array([0,2,4])]
+ array([[ 0, 1, 2, 3, 4, 5, 6],
+ [14, 15, 16, 17, 18, 19, 20],
+ [28, 29, 30, 31, 32, 33, 34]])
+
+What results is the construction of a new array where each value of the index array
+selects one row from the array being indexed and the resultant array has the resulting
+shape (size of row, number index elements).
+
+An example of where this may be useful is for a color lookup table where we want to map
+the values of an image into RGB triples for display. The lookup table could have a shape
+(nlookup, 3). Indexing such an array with an image with shape (ny, nx) with dtype=np.uint8
+(or any integer type so long as values are with the bounds of the lookup table) will
+result in an array of shape (ny, nx, 3) where a triple of RGB values is associated with
+each pixel location.
+
+In general, the shape of the resulant array will be the concatenation of the shape of
+the index array (or the shape that all the index arrays were broadcast to) with the
+shape of any unused dimensions (those not indexed) in the array being indexed.
+
+Boolean or "mask" index arrays
+==============================
+
+Boolean arrays used as indices are treated in a different manner entirely than index
+arrays. Boolean arrays must be of the same shape as the array being indexed, or
+broadcastable to the same shape. In the most straightforward case, the boolean array
+has the same shape: ::
+
+ >>> b = y>20
+ >>> y[b]
+ array([21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34])
+
+The result is a 1-D array containing all the elements in the indexed array corresponding
+to all the true elements in the boolean array. As with index arrays, what is returned
+is a copy of the data, not a view as one gets with slices.
+
+With broadcasting, multidimesional arrays may be the result. For example: ::
+
+ >>> b[:,5] # use a 1-D boolean that broadcasts with y
+ array([False, False, False, True, True], dtype=bool)
+ >>> y[b[:,5]]
+ array([[21, 22, 23, 24, 25, 26, 27],
+ [28, 29, 30, 31, 32, 33, 34]])
+
+Here the 4th and 5th rows are selected from the indexed array and combined to make a
+2-D array.
+
+Combining index arrays with slices
+==================================
+
+Index arrays may be combined with slices. For example: ::
+
+ >>> y[np.array([0,2,4]),1:3]
+ array([[ 1, 2],
+ [15, 16],
+ [29, 30]])
+
+In effect, the slice is converted to an index array np.array([[1,2]]) (shape (1,2)) that is
+broadcast with the index array to produce a resultant array of shape (3,2).
+
+Likewise, slicing can be combined with broadcasted boolean indices: ::
+
+ >>> y[b[:,5],1:3]
+ array([[22, 23],
+ [29, 30]])
+
+Structural indexing tools
+=========================
+
+To facilitate easy matching of array shapes with expressions and in
+assignments, the np.newaxis object can be used within array indices
+to add new dimensions with a size of 1. For example: ::
+
+ >>> y.shape
+ (5, 7)
+ >>> y[:,np.newaxis,:].shape
+ (5, 1, 7)
+
+Note that there are no new elements in the array, just that the
+dimensionality is increased. This can be handy to combine two
+arrays in a way that otherwise would require explicitly reshaping
+operations. For example: ::
+
+ >>> x = np.arange(5)
+ >>> x[:,np.newaxis] + x[np.newaxis,:]
+ array([[0, 1, 2, 3, 4],
+ [1, 2, 3, 4, 5],
+ [2, 3, 4, 5, 6],
+ [3, 4, 5, 6, 7],
+ [4, 5, 6, 7, 8]])
+
+The ellipsis syntax maybe used to indicate selecting in full any
+remaining unspecified dimensions. For example: ::
+
+ >>> z = np.arange(81).reshape(3,3,3,3)
+ >>> z[1,...,2]
+ array([[29, 32, 35],
+ [38, 41, 44],
+ [47, 50, 53]])
+
+This is equivalent to: ::
+
+ >>> z[1,:,:,2]
+
+Assigning values to indexed arrays
+==================================
+
+As mentioned, one can select a subset of an array to assign to using
+a single index, slices, and index and mask arrays. The value being
+assigned to the indexed array must be shape consistent (the same shape
+or broadcastable to the shape the index produces). For example, it is
+permitted to assign a constant to a slice: ::
+
+ >>> x[2:7] = 1
+
+or an array of the right size: ::
+
+ >>> x[2:7] = np.arange(5)
+
+Note that assignments may result in changes if assigning
+higher types to lower types (like floats to ints) or even
+exceptions (assigning complex to floats or ints): ::
+
+ >>> x[1] = 1.2
+ >>> x[1]
+ 1
+ >>> x[1] = 1.2j
+ <type 'exceptions.TypeError'>: can't convert complex to long; use long(abs(z))
+
+
+Unlike some of the references (such as array and mask indices)
+assignments are always made to the original data in the array
+(indeed, nothing else would make sense!). Note though, that some
+actions may not work as one may naively expect. This particular
+example is often surprising to people: ::
+
+ >>> x[np.array([1, 1, 3, 1]) += 1
+
+Where people expect that the 1st location will be incremented by 3.
+In fact, it will only be incremented by 1. The reason is because
+a new array is extracted from the original (as a temporary) containing
+the values at 1, 1, 3, 1, then the value 1 is added to the temporary,
+and then the temporary is assigned back to the original array. Thus
+the value of the array at x[1]+1 is assigned to x[1] three times,
+rather than being incremented 3 times.
+
+Dealing with variable numbers of indices within programs
+========================================================
+
+The index syntax is very powerful but limiting when dealing with
+a variable number of indices. For example, if you want to write
+a function that can handle arguments with various numbers of
+dimensions without having to write special case code for each
+number of possible dimensions, how can that be done? If one
+supplies to the index a tuple, the tuple will be interpreted
+as a list of indices. For example (using the previous definition
+for the array z): ::
+
+ >>> indices = (1,1,1,1)
+ >>> z[indices]
+ 40
+
+So one can use code to construct tuples of any number of indices
+and then use these within an index.
+
+Slices can be specified within programs by using the slice() function
+in Python. For example: ::
+
+ >>> indices = (1,1,1,slice(0,2)) # same as [1,1,1,0:2]
+ array([39, 40])
+
+Likewise, ellipsis can be specified by code by using the Ellipsis object: ::
+
+ >>> indices = (1, Ellipsis, 1) # same as [1,...,1]
+ >>> z[indices]
+ array([[28, 31, 34],
+ [37, 40, 43],
+ [46, 49, 52]])
+
+For this reason it is possible to use the output from the np.where()
+function directly as an index since it always returns a tuple of index arrays.
+
+Because the special treatment of tuples, they are not automatically converted
+to an array as a list would be. As an example: ::
+
+ >>> z[[1,1,1,1]]
+ ... # produces a large array
+ >>> z[(1,1,1,1)]
+ 40 # returns a single value
"""
diff --git a/numpy/doc/reference/internals.py b/numpy/doc/reference/internals.py
index 1e1a072cb..a74429368 100644
--- a/numpy/doc/reference/internals.py
+++ b/numpy/doc/reference/internals.py
@@ -1,9 +1,162 @@
"""
-
===============
Array Internals
===============
-Placeholder for Array Internals documentation.
+Internal organization of numpy arrays
+=====================================
+
+It helps to understand a bit about how numpy arrays are handled under the covers to help understand numpy better. This section will not go into great detail. Those wishing to understand the full details are referred to Travis Oliphant's book "Guide to Numpy".
+
+Numpy arrays consist of two major components, the raw array data (from now on,
+referred to as the data buffer), and the information about the raw array data.
+The data buffer is typically what people think of as arrays in C or Fortran,
+a contiguous (and fixed) block of memory containing fixed sized data items.
+Numpy also contains a significant set of data that describes how to interpret
+the data in the data buffer. This extra information contains (among other things):
+
+ 1) The basic data element's size in bytes
+ 2) The start of the data within the data buffer (an offset relative to the
+ beginning of the data buffer).
+ 3) The number of dimensions and the size of each dimension
+ 4) The separation between elements for each dimension (the 'stride'). This
+ does not have to be a multiple of the element size
+ 5) The byte order of the data (which may not be the native byte order)
+ 6) Whether the buffer is read-only
+ 7) Information (via the dtype object) about the interpretation of the basic
+ data element. The basic data element may be as simple as a int or a float,
+ or it may be a compound object (e.g., struct-like), a fixed character field,
+ or Python object pointers.
+ 8) Whether the array is to interpreted as C-order or Fortran-order.
+
+This arrangement allow for very flexible use of arrays. One thing that it allows
+is simple changes of the metadata to change the interpretation of the array buffer.
+Changing the byteorder of the array is a simple change involving no rearrangement
+of the data. The shape of the array can be changed very easily without changing
+anything in the data buffer or any data copying at all
+
+Among other things that are made possible is one can create a new array metadata
+object that uses the same data buffer
+to create a new view of that data buffer that has a different interpretation
+of the buffer (e.g., different shape, offset, byte order, strides, etc) but
+shares the same data bytes. Many operations in numpy do just this such as
+slices. Other operations, such as transpose, don't move data elements
+around in the array, but rather change the information about the shape and strides so that the indexing of the array changes, but the data in the doesn't move.
+
+Typically these new versions of the array metadata but the same data buffer are
+new 'views' into the data buffer. There is a different ndarray object, but it
+uses the same data buffer. This is why it is necessary to force copies through
+use of the .copy() method if one really wants to make a new and independent
+copy of the data buffer.
+
+New views into arrays mean the the object reference counts for the data buffer
+increase. Simply doing away with the original array object will not remove the
+data buffer if other views of it still exist.
+
+Multidimensional Array Indexing Order Issues
+============================================
+
+What is the right way to index
+multi-dimensional arrays? Before you jump to conclusions about the one and
+true way to index multi-dimensional arrays, it pays to understand why this is
+a confusing issue. This section will try to explain in detail how numpy
+indexing works and why we adopt the convention we do for images, and when it
+may be appropriate to adopt other conventions.
+
+The first thing to understand is
+that there are two conflicting conventions for indexing 2-dimensional arrays.
+Matrix notation uses the first index to indicate which row is being selected and
+the second index to indicate which column is selected. This is opposite the
+geometrically oriented-convention for images where people generally think the
+first index represents x position (i.e., column) and the second represents y
+position (i.e., row). This alone is the source of much confusion;
+matrix-oriented users and image-oriented users expect two different things with
+regard to indexing.
+
+The second issue to understand is how indices correspond
+to the order the array is stored in memory. In Fortran the first index is the
+most rapidly varying index when moving through the elements of a two
+dimensional array as it is stored in memory. If you adopt the matrix
+convention for indexing, then this means the matrix is stored one column at a
+time (since the first index moves to the next row as it changes). Thus Fortran
+is considered a Column-major language. C has just the opposite convention. In
+C, the last index changes most rapidly as one moves through the array as
+stored in memory. Thus C is a Row-major language. The matrix is stored by
+rows. Note that in both cases it presumes that the matrix convention for
+indexing is being used, i.e., for both Fortran and C, the first index is the
+row. Note this convention implies that the indexing convention is invariant
+and that the data order changes to keep that so.
+
+But that's not the only way
+to look at it. Suppose one has large two-dimensional arrays (images or
+matrices) stored in data files. Suppose the data are stored by rows rather than
+by columns. If we are to preserve our index convention (whether matrix or
+image) that means that depending on the language we use, we may be forced to
+reorder the data if it is read into memory to preserve our indexing
+convention. For example if we read row-ordered data into memory without
+reordering, it will match the matrix indexing convention for C, but not for
+Fortran. Conversely, it will match the image indexing convention for Fortran,
+but not for C. For C, if one is using data stored in row order, and one wants
+to preserve the image index convention, the data must be reordered when
+reading into memory.
+
+In the end, which you do for Fortran or C depends on
+which is more important, not reordering data or preserving the indexing
+convention. For large images, reordering data is potentially expensive, and
+often the indexing convention is inverted to avoid that.
+
+The situation with
+numpy makes this issue yet more complicated. The internal machinery of numpy
+arrays is flexible enough to accept any ordering of indices. One can simply
+reorder indices by manipulating the internal stride information for arrays
+without reordering the data at all. Numpy will know how to map the new index
+order to the data without moving the data.
+
+So if this is true, why not choose
+the index order that matches what you most expect? In particular, why not define
+row-ordered images to use the image convention? (This is sometimes referred
+to as the Fortran convention vs the C convention, thus the 'C' and 'FORTRAN'
+order options for array ordering in numpy.) The drawback of doing this is
+potential performance penalties. It's common to access the data sequentially,
+either implicitly in array operations or explicitly by looping over rows of an
+image. When that is done, then the data will be accessed in non-optimal order.
+As the first index is incremented, what is actually happening is that elements
+spaced far apart in memory are being sequentially accessed, with usually poor
+memory access speeds. For example, for a two dimensional image 'im' defined so
+that im[0, 10] represents the value at x=0, y=10. To be consistent with usual
+Python behavior then im[0] would represent a column at x=0. Yet that data
+would be spread over the whole array since the data are stored in row order.
+Despite the flexibility of numpy's indexing, it can't really paper over the fact
+basic operations are rendered inefficient because of data order or that getting
+contiguous subarrays is still awkward (e.g., im[:,0] for the first row, vs
+im[0]), thus one can't use an idiom such as for row in im; for col in im does
+work, but doesn't yield contiguous column data.
+
+As it turns out, numpy is
+smart enough when dealing with ufuncs to determine which index is the most
+rapidly varying one in memory and uses that for the innermost loop. Thus for
+ufuncs there is no large intrinsic advantage to either approach in most cases.
+On the other hand, use of .flat with an FORTRAN ordered array will lead to
+non-optimal memory access as adjacent elements in the flattened array (iterator,
+actually) are not contiguous in memory.
+
+Indeed, the fact is that Python
+indexing on lists and other sequences naturally leads to an outside-to inside
+ordering (the first index gets the largest grouping, the next the next largest,
+and the last gets the smallest element). Since image data are normally stored
+by rows, this corresponds to position within rows being the last item indexed.
+
+If you do want to use Fortran ordering realize that
+there are two approaches to consider: 1) accept that the first index is just not
+the most rapidly changing in memory and have all your I/O routines reorder
+your data when going from memory to disk or visa versa, or use numpy's
+mechanism for mapping the first index to the most rapidly varying data. We
+recommend the former if possible. The disadvantage of the latter is that many
+of numpy's functions will yield arrays without Fortran ordering unless you are
+careful to use the 'order' keyword. Doing this would be highly inconvenient.
+
+Otherwise we recommend simply learning to reverse the usual order of indices
+when accessing elements of an array. Granted, it goes against the grain, but
+it is more in line with Python semantics and the natural order of the data.
"""
diff --git a/numpy/doc/reference/structured_arrays.py b/numpy/doc/reference/structured_arrays.py
index 708d2ea2c..7bbd0deda 100644
--- a/numpy/doc/reference/structured_arrays.py
+++ b/numpy/doc/reference/structured_arrays.py
@@ -1,9 +1,176 @@
"""
+=====================================
+Structured Arrays (aka Record Arrays)
+=====================================
-=================
-Structured Arrays
-=================
+Introduction
+============
-Placeholder for structured array documentation.
+Numpy provides powerful capabilities to create arrays of structs or records.
+These arrays permit one to manipulate the data by the structs or by fields of
+the struct. A simple example will show what is meant.: ::
+
+ >>> x = np.zeros((2,),dtype=('i4,f4,a10'))
+ >>> x[:] = [(1,2.,'Hello'),(2,3.,"World")]
+ >>> x
+ array([(1, 2.0, 'Hello'), (2, 3.0, 'World')],
+ dtype=[('f0', '>i4'), ('f1', '>f4'), ('f2', '|S10')])
+
+Here we have created a one-dimensional array of length 2. Each element of
+this array is a record that contains three items, a 32-bit integer, a 32-bit
+float, and a string of length 10 or less. If we index this array at the second
+position we get the second record: ::
+
+ >>> x[1]
+ (2,3.,"World")
+
+The interesting aspect is that we can reference the different fields of the
+array simply by indexing the array with the string representing the name of
+the field. In this case the fields have received the default names of 'f0', 'f1'
+and 'f2'.
+
+ >>> y = x['f1']
+ >>> y
+ array([ 2., 3.], dtype=float32)
+ >>> y[:] = 2*y
+ >>> y
+ array([ 4., 6.], dtype=float32)
+ >>> x
+ array([(1, 4.0, 'Hello'), (2, 6.0, 'World')],
+ dtype=[('f0', '>i4'), ('f1', '>f4'), ('f2', '|S10')])
+
+In these examples, y is a simple float array consisting of the 2nd field
+in the record. But it is not a copy of the data in the structured array,
+instead it is a view. It shares exactly the same data. Thus when we updated
+this array by doubling its values, the structured array shows the
+corresponding values as doubled as well. Likewise, if one changes the record,
+the field view changes: ::
+
+ >>> x[1] = (-1,-1.,"Master")
+ >>> x
+ array([(1, 4.0, 'Hello'), (-1, -1.0, 'Master')],
+ dtype=[('f0', '>i4'), ('f1', '>f4'), ('f2', '|S10')])
+ >>> y
+ array([ 4., -1.], dtype=float32)
+
+Defining Structured Arrays
+==========================
+
+The definition of a structured array is all done through the dtype object.
+There are a **lot** of different ways one can define the fields of a
+record. Some of variants are there to provide backward compatibility with
+Numeric or numarray, or another module, and should not be used except for
+such purposes. These will be so noted. One defines records by specifying
+the structure by 4 general ways, using an argument (as supplied to a dtype
+function keyword or a dtype object constructor itself) in the form of a:
+1) string, 2) tuple, 3) list, or 4) dictionary. Each of these will be briefly
+described.
+
+1) String argument (as used in the above examples).
+In this case, the constructor is expecting a comma
+separated list of type specifiers, optionally with extra shape information.
+The type specifiers can take 4 different forms: ::
+
+ a) b1, i1, i2, i4, i8, u1, u2, u4, u8, f4, f8, c8, c16, a<n>
+ (representing bytes, ints, unsigned ints, floats, complex and
+ fixed length strings of specified byte lengths)
+ b) int8,...,uint8,...,float32, float64, complex64, complex128
+ (this time with bit sizes)
+ c) older Numeric/numarray type specifications (e.g. Float32).
+ Don't use these in new code!
+ d) Single character type specifiers (e.g H for unsigned short ints).
+ Avoid using these unless you must. Details can be found in the
+ Numpy book
+
+These different styles can be mixed within the same string (but why would you
+want to do that?). Furthermore, each type specifier can be prefixed
+with a repetition number, or a shape. In these cases an array
+element is created, i.e., an array within a record. That array
+is still referred to as a single field. An example: ::
+
+ >>> x = np.zeros(3, dtype='3int8, float32, (2,3)float64')
+ >>> x
+ array([([0, 0, 0], 0.0, [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),
+ ([0, 0, 0], 0.0, [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),
+ ([0, 0, 0], 0.0, [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]])],
+ dtype=[('f0', '|i1', 3), ('f1', '>f4'), ('f2', '>f8', (2, 3))])
+
+By using strings to define the record structure, it precludes being
+able to name the fields in the original definition. The names can
+be changed as shown later, however.
+
+2) Tuple argument: The only relevant tuple case that applies to record
+structures is when a structure is mapped to an existing data type. This
+is done by pairing in a tuple, the existing data type with a matching
+dtype definition (using any of the variants being described here). As
+an example (using a definition using a list, so see 3) for further
+details): ::
+
+ >>> x = zeros(3, dtype=('i4',[('r','u1'), ('g','u1'), ('b','u1'), ('a','u1')]))
+ >>> x
+ array([0, 0, 0])
+ >>> x['r']
+ array([0, 0, 0], dtype=uint8)
+
+In this case, an array is produced that looks and acts like a simple int32 array,
+but also has definitions for fields that use only one byte of the int32 (a bit
+like Fortran equivalencing).
+
+3) List argument: In this case the record structure is defined with a list of
+tuples. Each tuple has 2 or 3 elements specifying: 1) The name of the field
+('' is permitted), 2) the type of the field, and 3) the shape (optional).
+For example:
+
+ >>> x = np.zeros(3, dtype=[('x','f4'),('y',np.float32),('value','f4',(2,2))])
+ >>> x
+ array([(0.0, 0.0, [[0.0, 0.0], [0.0, 0.0]]),
+ (0.0, 0.0, [[0.0, 0.0], [0.0, 0.0]]),
+ (0.0, 0.0, [[0.0, 0.0], [0.0, 0.0]])],
+ dtype=[('x', '>f4'), ('y', '>f4'), ('value', '>f4', (2, 2))])
+
+4) Dictionary argument: two different forms are permitted. The first consists
+of a dictionary with two required keys ('names' and 'formats'), each having an
+equal sized list of values. The format list contains any type/shape specifier
+allowed in other contexts. The names must be strings. There are two optional
+keys: 'offsets' and 'titles'. Each must be a correspondingly matching list to
+the required two where offsets contain integer offsets for each field, and
+titles are objects containing metadata for each field (these do not have
+to be strings), where the value of None is permitted. As an example: ::
+
+ >>> x = np.zeros(3, dtype={'names':['col1', 'col2'], 'formats':['i4','f4']})
+ >>> x
+ array([(0, 0.0), (0, 0.0), (0, 0.0)],
+ dtype=[('col1', '>i4'), ('col2', '>f4')])
+
+The other dictionary form permitted is a dictionary of name keys with tuple
+values specifying type, offset, and an optional title.
+
+ >>> x = np.zeros(3, dtype={'col1':('i1',0,'title 1'), 'col2':('f4',1,'title 2')})
+ array([(0, 0.0), (0, 0.0), (0, 0.0)],
+ dtype=[(('title 1', 'col1'), '|i1'), (('title 2', 'col2'), '>f4')])
+
+Accessing and modifying field names
+===================================
+
+The field names are an attribute of the dtype object defining the record structure.
+For the last example: ::
+
+ >>> x.dtype.names
+ ('col1', 'col2')
+ >>> x.dtype.names = ('x', 'y')
+ >>> x
+ array([(0, 0.0), (0, 0.0), (0, 0.0)],
+ dtype=[(('title 1', 'x'), '|i1'), (('title 2', 'y'), '>f4')])
+ >>> x.dtype.names = ('x', 'y', 'z') # wrong number of names
+ <type 'exceptions.ValueError'>: must replace all names at once with a sequence of length 2
+
+Accessing field titles
+====================================
+
+The field titles provide a standard place to put associated info for fields.
+They do not have to be strings.
+
+ >>> x.dtype.fields['x'][2]
+ 'title 1'
"""
diff --git a/numpy/doc/reference/ufuncs.py b/numpy/doc/reference/ufuncs.py
index a7f349aa9..4819e5268 100644
--- a/numpy/doc/reference/ufuncs.py
+++ b/numpy/doc/reference/ufuncs.py
@@ -1,9 +1,135 @@
"""
-
===================
Universal Functions
===================
-Placeholder for ufunc documentation.
+Ufuncs are, generally speaking, mathematical functions or operations that are
+applied element-by-element to the contents of an array. That is, the result
+in each output array element only depends on the value in the corresponding
+input array (or arrays) and on no other array elements. Numpy comes with a
+large suite of ufuncs, and scipy extends that suite substantially. The simplest
+example is the addition operator: ::
+
+ >>> np.array([0,2,3,4]) + np.array([1,1,-1,2])
+ array([1, 3, 2, 6])
+
+The unfunc module lists all the available ufuncs in numpy. Additional ufuncts
+available in xxx in scipy. Documentation on the specific ufuncs may be found
+in those modules. This documentation is intended to address the more general
+aspects of unfuncs common to most of them. All of the ufuncs that make use of
+Python operators (e.g., +, -, etc.) have equivalent functions defined
+(e.g. add() for +)
+
+Type coercion
+=============
+
+What happens when a binary operator (e.g., +,-,\\*,/, etc) deals with arrays of
+two different types? What is the type of the result? Typically, the result is
+the higher of the two types. For example: ::
+
+ float32 + float64 -> float64
+ int8 + int32 -> int32
+ int16 + float32 -> float32
+ float32 + complex64 -> complex64
+
+There are some less obvious cases generally involving mixes of types
+(e.g. uints, ints and floats) where equal bit sizes for each are not
+capable of saving all the information in a different type of equivalent
+bit size. Some examples are int32 vs float32 or uint32 vs int32.
+Generally, the result is the higher type of larger size than both
+(if available). So: ::
+
+ int32 + float32 -> float64
+ uint32 + int32 -> int64
+
+Finally, the type coercion behavior when expressions involve Python
+scalars is different than that seen for arrays. Since Python has a
+limited number of types, combining a Python int with a dtype=np.int8
+array does not coerce to the higher type but instead, the type of the
+array prevails. So the rules for Python scalars combined with arrays is
+that the result will be that of the array equivalent the Python scalar
+if the Python scalar is of a higher 'kind' than the array (e.g., float
+vs. int), otherwise the resultant type will be that of the array.
+For example: ::
+
+ Python int + int8 -> int8
+ Python float + int8 -> float64
+
+ufunc methods
+=============
+
+Binary ufuncs support 4 methods. These methods are explained in detail in xxx
+(or are they, I don't see anything in the ufunc docstring that is useful?).
+
+**.reduce(arr)** applies the binary operator to elements of the array in sequence. For example: ::
+
+ >>> np.add.reduce(np.arange(10)) # adds all elements of array
+ 45
+
+For multidimensional arrays, the first dimension is reduced by default: ::
+
+ >>> np.add.reduce(np.arange(10).reshape(2,5))
+ array([ 5, 7, 9, 11, 13])
+
+The axis keyword can be used to specify different axes to reduce: ::
+
+ >>> np.add.reduce(np.arange(10).reshape(2,5),axis=1)
+ array([10, 35])
+
+**.accumulate(arr)** applies the binary operator and generates an an equivalently
+shaped array that includes the accumulated amount for each element of the
+array. A couple examples: ::
+
+ >>> np.add.accumulate(np.arange(10))
+ array([ 0, 1, 3, 6, 10, 15, 21, 28, 36, 45])
+ >>> np.multiply.accumulate(np.arange(1,9))
+ array([ 1, 2, 6, 24, 120, 720, 5040, 40320])
+
+The behavior for multidimensional arrays is the same as for .reduce(), as is the use of the axis keyword).
+
+**.reduceat(arr,indices)** allows one to apply reduce to selected parts of an array.
+It is a difficult method to understand. See the documentation at:
+
+**.outer(arr1,arr2)** generates an outer operation on the two arrays arr1 and arr2. It will work on multidimensional arrays (the shape of the result is the
+concatenation of the two input shapes.: ::
+
+ >>> np.multiply.outer(np.arange(3),np.arange(4))
+ array([[0, 0, 0, 0],
+ [0, 1, 2, 3],
+ [0, 2, 4, 6]])
+
+Output arguments
+================
+
+All ufuncs accept an optional output array. The array must be of the expected output shape. Beware that if the type of the output array is of a
+different (and lower) type than the output result, the results may be silently
+truncated or otherwise corrupted in the downcast to the lower type. This usage
+is useful when one wants to avoid creating large temporary arrays and instead
+allows one to reuse the same array memory repeatedly (at the expense of not
+being able to use more convenient operator notation in expressions). Note that
+when the output argument is used, the ufunc still returns a reference to the
+result.
+
+ >>> x = np.arange(2)
+ >>> np.add(np.arange(2),np.arange(2.),x)
+ array([0, 2])
+ >>> x
+ array([0, 2])
+
+and & or as ufuncs
+==================
+
+Invariably people try to use the python 'and' and 'or' as logical operators
+(and quite understandably). But these operators do not behave as normal
+operators since Python treats these quite differently. They cannot be
+overloaded with array equivalents. Thus using 'and' or 'or' with an array
+results in an error. There are two alternatives:
+
+ 1) use the ufunc functions logical_and() and logical_or().
+ 2) use the bitwise operators & and \\|. The drawback of these is that if
+ the arguments to these operators are not boolean arrays, the result is
+ likely incorrect. On the other hand, most usages of logical_and and
+ logical_or are with boolean arrays. As long as one is careful, this is
+ a convenient way to apply these operators.
"""
diff --git a/numpy/doc/reference/zen.py b/numpy/doc/reference/zen.py
deleted file mode 100644
index bf6873f68..000000000
--- a/numpy/doc/reference/zen.py
+++ /dev/null
@@ -1,9 +0,0 @@
-"""
-
-============
-Zen of NumPy
-============
-
-Placehold for Zen of NumPy documentation.
-
-"""
diff --git a/numpy/dual.py b/numpy/dual.py
index c47f8f820..3c863bf6f 100644
--- a/numpy/dual.py
+++ b/numpy/dual.py
@@ -1,3 +1,15 @@
+"""
+Aliases for functions which may be accelerated by Scipy.
+
+Scipy_ can be built to use accelerated or otherwise improved libraries
+for FFTs, linear algebra, and special functions. This module allows
+developers to transparently support these accelerated functions when
+scipy is available but still support users who have only installed
+Numpy.
+
+.. _Scipy : http://www.scipy.org
+
+"""
# This module should be used for functions both in numpy and scipy if
# you want to use the numpy version if available but the scipy version
# otherwise.
diff --git a/numpy/fft/__init__.py b/numpy/fft/__init__.py
index 324e39f4d..1171a6026 100644
--- a/numpy/fft/__init__.py
+++ b/numpy/fft/__init__.py
@@ -1,3 +1,37 @@
+"""
+Discrete Fast Fourier Transform (FFT)
+=====================================
+
+========= =========================================================
+Standard FFTs
+===================================================================
+fft Discrete Fourier transform.
+ifft Inverse discrete Fourier transform.
+fft2 Discrete Fourier transform in two dimensions.
+ifft2 Inverse discrete Fourier transform in two dimensions.
+fftn Discrete Fourier transform in N-dimensions.
+ifftn Inverse discrete Fourier transform in N dimensions.
+========= =========================================================
+
+========= ==========================================================
+Real FFTs
+====================================================================
+rfft Real discrete Fourier transform.
+irfft Inverse real discrete Fourier transform.
+rfft2 Real discrete Fourier transform in two dimensions.
+irfft2 Inverse real discrete Fourier transform in two dimensions.
+rfftn Real discrete Fourier transform in N dimensions.
+irfftn Inverse real discrete Fourier transform in N dimensions.
+========= ==========================================================
+
+========= =========================================================
+Hermite FFTs
+===================================================================
+hfft Hermite discrete Fourier transform.
+ihfft Inverse hermite discrete Fourier transform.
+========= =========================================================
+
+"""
# To get sub-modules
from info import __doc__
diff --git a/numpy/fft/fftpack.py b/numpy/fft/fftpack.py
index 6a0d3ab05..12c207cb0 100644
--- a/numpy/fft/fftpack.py
+++ b/numpy/fft/fftpack.py
@@ -70,12 +70,26 @@ def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti,
def fft(a, n=None, axis=-1):
- """fft(a, n=None, axis=-1)
+ """
+ Compute the one dimensional fft on a given axis.
- Return the n point discrete Fourier transform of a. n defaults to
- the length of a. If n is larger than the length of a, then a will
- be zero-padded to make up the difference. If n is smaller than
- the length of a, only the first n items in a will be used.
+ Return the n point discrete Fourier transform of a. n defaults to the
+ length of a. If n is larger than the length of a, then a will be
+ zero-padded to make up the difference. If n is smaller than the length of
+ a, only the first n items in a will be used.
+
+ Parameters
+ ----------
+
+ a : array
+ input array
+ n : int
+ length of the fft
+ axis : int
+ axis over which to compute the fft
+
+ Notes
+ -----
The packing of the result is "standard": If A = fft(a, n), then A[0]
contains the zero-frequency term, A[1:n/2+1] contains the
@@ -86,13 +100,16 @@ def fft(a, n=None, axis=-1):
This is most efficient for n a power of two. This also stores a cache of
working memory for different sizes of fft's, so you could theoretically
run into memory problems if you call this too many times with too many
- different n's."""
+ different n's.
+
+ """
return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf, _fft_cache)
def ifft(a, n=None, axis=-1):
- """ifft(a, n=None, axis=-1)
+ """
+ Compute the one-dimensonal inverse fft on a given axis.
Return the n point inverse discrete Fourier transform of a. n
defaults to the length of a. If n is larger than the length of a,
@@ -100,8 +117,20 @@ def ifft(a, n=None, axis=-1):
smaller than the length of a, then a will be truncated to reduce
its size.
+ Parameters
+ ----------
+
+ a : array
+ input array
+ n : int
+ length of the fft
+ axis : int
+ axis over which to compute the inverse fft
+
+ Notes
+ -----
The input array is expected to be packed the same way as the output of
- fft, as discussed in it's documentation.
+ fft, as discussed in the fft documentation.
This is the inverse of fft: ifft(fft(a)) == a within numerical
accuracy.
@@ -109,7 +138,9 @@ def ifft(a, n=None, axis=-1):
This is most efficient for n a power of two. This also stores a cache of
working memory for different sizes of fft's, so you could theoretically
run into memory problems if you call this too many times with too many
- different n's."""
+ different n's.
+
+ """
a = asarray(a).astype(complex)
if n is None:
@@ -118,12 +149,26 @@ def ifft(a, n=None, axis=-1):
def rfft(a, n=None, axis=-1):
- """rfft(a, n=None, axis=-1)
+ """
+ Compute the one-dimensional fft for real input.
Return the n point discrete Fourier transform of the real valued
array a. n defaults to the length of a. n is the length of the
input, not the output.
+ Parameters
+ ----------
+
+ a : array
+ input array with real data type
+ n : int
+ length of the fft
+ axis : int
+ axis over which to compute the fft
+
+ Notes
+ -----
+
The returned array will be the nonnegative frequency terms of the
Hermite-symmetric, complex transform of the real array. So for an 8-point
transform, the frequencies in the result are [ 0, 1, 2, 3, 4]. The first
@@ -132,14 +177,20 @@ def rfft(a, n=None, axis=-1):
positive frequency terms. (This is what I mean when I say
Hermite-symmetric.)
- This is most efficient for n a power of two."""
+ This is most efficient for n a power of two.
+
+ """
a = asarray(a).astype(float)
return _raw_fft(a, n, axis, fftpack.rffti, fftpack.rfftf, _real_fft_cache)
def irfft(a, n=None, axis=-1):
- """irfft(a, n=None, axis=-1)
+ """
+ Compute the one-dimensional inverse fft for real input.
+
+ Notes
+ -----
Return the real valued n point inverse discrete Fourier transform
of a, where a contains the nonnegative frequency terms of a
@@ -147,14 +198,27 @@ def irfft(a, n=None, axis=-1):
input. If n is not supplied, the default is 2*(len(a)-1). If you
want the length of the result to be odd, you have to say so.
+ Parameters
+ ----------
+
+ a : array
+ input array with real data type
+ n : int
+ length of the fft
+ axis : int
+ axis over which to compute the fft
+
+ Notes
+ -----
+
If you specify an n such that a must be zero-padded or truncated, the
extra/removed values will be added/removed at high frequencies. One can
thus resample a series to m points via Fourier interpolation by: a_resamp
= irfft(rfft(a), m).
- This is the inverse of rfft:
- irfft(rfft(a), len(a)) == a
- within numerical accuracy."""
+ This is the inverse of rfft: irfft(rfft(a), len(a)) == a within numerical accuracy.
+
+ """
a = asarray(a).astype(complex)
if n is None:
@@ -164,16 +228,34 @@ def irfft(a, n=None, axis=-1):
def hfft(a, n=None, axis=-1):
- """hfft(a, n=None, axis=-1)
- ihfft(a, n=None, axis=-1)
-
+ """
+ Compute the fft of a signal which spectrum has Hermitian symmetry.
+
+ Parameters
+ ----------
+ a : array
+ input array
+ n : int
+ length of the hfft
+ axis : int
+ axis over which to compute the hfft
+
+ Notes
+ -----
These are a pair analogous to rfft/irfft, but for the
opposite case: here the signal is real in the frequency domain and has
Hermite symmetry in the time domain. So here it's hermite_fft for which
you must supply the length of the result if it is to be odd.
ihfft(hfft(a), len(a)) == a
- within numerical accuracy."""
+ within numerical accuracy.
+
+ See also
+ --------
+ rfft
+ ihfft
+
+ """
a = asarray(a).astype(complex)
if n is None:
@@ -182,16 +264,35 @@ def hfft(a, n=None, axis=-1):
def ihfft(a, n=None, axis=-1):
- """hfft(a, n=None, axis=-1)
- ihfft(a, n=None, axis=-1)
-
+ """
+ Compute the inverse fft of a signal which spectrum has Hermitian
+ symmetry.
+
+ Parameters
+ ----------
+ a : array
+ input array
+ n : int
+ length of the ihfft
+ axis : int
+ axis over which to compute the ihfft
+
+ Notes
+ -----
These are a pair analogous to rfft/irfft, but for the
opposite case: here the signal is real in the frequency domain and has
- Hermite symmetry in the time domain. So here it's hfft for which
+ Hermite symmetry in the time domain. So here it's hermite_fft for which
you must supply the length of the result if it is to be odd.
ihfft(hfft(a), len(a)) == a
- within numerical accuracy."""
+ within numerical accuracy.
+
+ See also
+ --------
+ rfft
+ hfft
+
+ """
a = asarray(a).astype(float)
if n is None:
@@ -229,9 +330,53 @@ def _raw_fftnd(a, s=None, axes=None, function=fft):
def fftn(a, s=None, axes=None):
- """fftn(a, s=None, axes=None)
+ """
+ Compute the N-dimensional Fast Fourier Transform.
+
+ Parameters
+ ----------
+ a : array_like
+ Input array.
+ s : sequence of ints
+ Shape of each axis of the input (s[0] refers to axis 0, s[1] to
+ axis 1, etc.). This corresponds to `n` for `fft(x, n)`.
+ Along any axis, if the given shape is smaller than that of the input,
+ the input is cropped. If it is larger, the input is padded with zeros.
+ axes : tuple of int
+ Axes over which to compute the FFT.
+
+ Notes
+ -----
+ Analogously to `fft`, the term for zero frequency in all axes is in the
+ low-order corner, while the term for the Nyquist frequency in all axes is
+ in the middle.
- The n-dimensional fft of a. s is a sequence giving the shape of the input
+ If neither `s` nor `axes` is specified, the transform is taken along all
+ axes. If `s` is specified and `axes` is not, the last ``len(s)`` axes are
+ used. If `axes` is specified and `s` is not, the input shape along the
+ specified axes is used. If `s` and `axes` are both specified and are not
+ the same length, an exception is raised.
+
+ """
+
+ return _raw_fftnd(a,s,axes,fft)
+
+def ifftn(a, s=None, axes=None):
+ """
+ Compute the inverse of fftn.
+
+ Parameters
+ ----------
+ a : array
+ input array
+ s : sequence (int)
+ shape of the ifft
+ axis : int
+ axis over which to compute the ifft
+
+ Notes
+ -----
+ The n-dimensional ifft of a. s is a sequence giving the shape of the input
an result along the transformed axes, as n for fft. Results are packed
analogously to fft: the term for zero frequency in all axes is in the
low-order corner, while the term for the Nyquist frequency in all axes is
@@ -241,43 +386,77 @@ def fftn(a, s=None, axes=None):
axes. If s is specified and axes is not, the last len(s) axes are used.
If axes are specified and s is not, the input shape along the specified
axes is used. If s and axes are both specified and are not the same
- length, an exception is raised."""
-
- return _raw_fftnd(a,s,axes,fft)
-
-def ifftn(a, s=None, axes=None):
- """ifftn(a, s=None, axes=None)
+ length, an exception is raised.
- The inverse of fftn."""
+ """
return _raw_fftnd(a, s, axes, ifft)
def fft2(a, s=None, axes=(-2,-1)):
- """fft2(a, s=None, axes=(-2,-1))
+ """
+ Compute the 2d fft of an array.
+
+ Parameters
+ ----------
+ a : array
+ input array
+ s : sequence (int)
+ shape of the fft
+ axis : int
+ axis over which to compute the fft
+
+ Notes
+ -----
+ This is really just fftn with different default behavior.
- The 2d fft of a. This is really just fftn with different default
- behavior."""
+ """
return _raw_fftnd(a,s,axes,fft)
def ifft2(a, s=None, axes=(-2,-1)):
- """ifft2(a, s=None, axes=(-2, -1))
+ """
+ Compute the inverse 2d fft of an array.
- The inverse of fft2d. This is really just ifftn with different
- default behavior."""
+ Parameters
+ ----------
+ a : array
+ input array
+ s : sequence (int)
+ shape of the ifft
+ axis : int
+ axis over which to compute the ifft
+
+ Notes
+ -----
+ This is really just ifftn with different default behavior.
+
+ """
return _raw_fftnd(a, s, axes, ifft)
def rfftn(a, s=None, axes=None):
- """rfftn(a, s=None, axes=None)
-
- The n-dimensional discrete Fourier transform of a real array a. A real
- transform as rfft is performed along the axis specified by the last
+ """
+ Compute the n-dimensional fft of a real array.
+
+ Parameters
+ ----------
+ a : array (real)
+ input array
+ s : sequence (int)
+ shape of the fft
+ axis : int
+ axis over which to compute the fft
+
+ Notes
+ -----
+ A real transform as rfft is performed along the axis specified by the last
element of axes, then complex transforms as fft are performed along the
- other axes."""
+ other axes.
+
+ """
a = asarray(a).astype(float)
s, axes = _cook_nd_args(a, s, axes)
@@ -287,21 +466,48 @@ def rfftn(a, s=None, axes=None):
return a
def rfft2(a, s=None, axes=(-2,-1)):
- """rfft2(a, s=None, axes=(-2,-1))
+ """
+ Compute the 2-dimensional fft of a real array.
+
+ Parameters
+ ----------
+ a : array (real)
+ input array
+ s : sequence (int)
+ shape of the fft
+ axis : int
+ axis over which to compute the fft
+
+ Notes
+ -----
+ The 2-D fft of the real valued array a. This is really just rfftn with
+ different default behavior.
- The 2d fft of the real valued array a. This is really just rfftn with
- different default behavior."""
+ """
return rfftn(a, s, axes)
def irfftn(a, s=None, axes=None):
- """irfftn(a, s=None, axes=None)
-
- The inverse of rfftn. The transform implemented in ifft is
- applied along all axes but the last, then the transform implemented in
- irfft is performed along the last axis. As with
- irfft, the length of the result along that axis must be
- specified if it is to be odd."""
+ """
+ Compute the n-dimensional inverse fft of a real array.
+
+ Parameters
+ ----------
+ a : array (real)
+ input array
+ s : sequence (int)
+ shape of the inverse fft
+ axis : int
+ axis over which to compute the inverse fft
+
+ Notes
+ -----
+ The transform implemented in ifftn is applied along
+ all axes but the last, then the transform implemented in irfft is performed
+ along the last axis. As with irfft, the length of the result along that
+ axis must be specified if it is to be odd.
+
+ """
a = asarray(a).astype(complex)
s, axes = _cook_nd_args(a, s, axes, invreal=1)
@@ -311,10 +517,23 @@ def irfftn(a, s=None, axes=None):
return a
def irfft2(a, s=None, axes=(-2,-1)):
- """irfft2(a, s=None, axes=(-2, -1))
-
- The inverse of rfft2. This is really just irfftn with
- different default behavior."""
+ """
+ Compute the 2-dimensional inverse fft of a real array.
+
+ Parameters
+ ----------
+ a : array (real)
+ input array
+ s : sequence (int)
+ shape of the inverse fft
+ axis : int
+ axis over which to compute the inverse fft
+
+ Notes
+ -----
+ This is really irfftn with different default.
+
+ """
return irfftn(a, s, axes)
diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py
index e026f6816..1201f3d7e 100644
--- a/numpy/lib/_datasource.py
+++ b/numpy/lib/_datasource.py
@@ -402,12 +402,13 @@ class DataSource (object):
class Repository (DataSource):
- """A data Repository where multiple DataSource's share a base URL/directory.
+ """
+ A data Repository where multiple DataSource's share a base URL/directory.
Repository extends DataSource by prepending a base URL (or directory) to
all the files it handles. Use a Repository when you will be working with
multiple files from one base URL. Initialize the Respository with the
- base URL, then refer to each file by it's filename only.
+ base URL, then refer to each file by its filename only.
*Methods*:
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index 8fec23cd3..8bd76d17f 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -39,8 +39,8 @@ import time
import numpy as np
def ediff1d(ary, to_end=None, to_begin=None):
- """The differences between consecutive elements of an array, possibly with
- prefixed and/or appended values.
+ """
+ The differences between consecutive elements of an array.
Parameters
----------
@@ -75,31 +75,38 @@ def ediff1d(ary, to_end=None, to_begin=None):
return ed
def unique1d(ar1, return_index=False):
- """Find the unique elements of 1D array.
-
- Most of the other array set operations operate on the unique arrays
- generated by this function.
+ """
+ Find the unique elements of an array.
Parameters
----------
- ar1 : array
- This array will be flattened if it is not already 1D.
+ ar1 : array-like
+ This array will be flattened if it is not already 1-D.
return_index : bool, optional
- If True, also return the indices against ar1 that result in the unique
- array.
+ If True, also return the indices against `ar1` that result in the
+ unique array.
Returns
-------
- unique : array
+ unique : ndarray
The unique values.
- unique_indices : int array, optional
- The indices of the unique values. Only provided if return_index is True.
+ unique_indices : ndarray, optional
+ The indices of the unique values. Only provided if `return_index` is
+ True.
See Also
--------
numpy.lib.arraysetops : Module with a number of other functions
for performing set operations on arrays.
+ Examples
+ --------
+ >>> np.unique1d([1, 1, 2, 2, 3, 3])
+ array([1, 2, 3])
+ >>> a = np.array([[1, 1], [2, 3]])
+ >>> np.unique1d(a)
+ array([1, 2, 3])
+
"""
ar = np.asarray(ar1).flatten()
if ar.size == 0:
@@ -118,50 +125,60 @@ def unique1d(ar1, return_index=False):
return ar[flag]
def intersect1d(ar1, ar2):
- """Intersection of 1D arrays with unique elements.
-
- Use unique1d() to generate arrays with only unique elements to use as inputs
- to this function. Alternatively, use intersect1d_nu() which will find the
- unique values for you.
+ """
+ Intersection returning repeated or unique elements common to both arrays.
Parameters
----------
- ar1 : array
- ar2 : array
+ ar1,ar2 : array_like
+ Input arrays.
Returns
-------
- intersection : array
+ out : ndarray, shape(N,)
+ Sorted 1D array of common elements with repeating elements.
See Also
--------
+ intersect1d_nu : Returns only unique common elements.
numpy.lib.arraysetops : Module with a number of other functions for
performing set operations on arrays.
+ Examples
+ --------
+ >>> np.intersect1d([1,3,3],[3,1,1])
+ array([1, 1, 3, 3])
+
"""
aux = np.concatenate((ar1,ar2))
aux.sort()
return aux[aux[1:] == aux[:-1]]
def intersect1d_nu(ar1, ar2):
- """Intersection of 1D arrays with any elements.
-
- The input arrays do not have unique elements like intersect1d() requires.
+ """
+ Intersection returning unique elements common to both arrays.
Parameters
----------
- ar1 : array
- ar2 : array
+ ar1,ar2 : array_like
+ Input arrays.
Returns
-------
- intersection : array
+ out : ndarray, shape(N,)
+ Sorted 1D array of common and unique elements.
See Also
--------
+ intersect1d : Returns repeated or unique common elements.
numpy.lib.arraysetops : Module with a number of other functions for
performing set operations on arrays.
+ Examples
+ --------
+ >>> np.intersect1d_nu([1,3,3],[3,1,1])
+ array([1, 3])
+
"""
# Might be faster than unique1d( intersect1d( ar1, ar2 ) )?
aux = np.concatenate((unique1d(ar1), unique1d(ar2)))
@@ -169,15 +186,18 @@ def intersect1d_nu(ar1, ar2):
return aux[aux[1:] == aux[:-1]]
def setxor1d(ar1, ar2):
- """Set exclusive-or of 1D arrays with unique elements.
+ """
+ Set exclusive-or of 1D arrays with unique elements.
- Use unique1d() to generate arrays with only unique elements to use as inputs
- to this function.
+ Use unique1d() to generate arrays with only unique elements to use as
+ inputs to this function.
Parameters
----------
ar1 : array
+ Input array.
ar2 : array
+ Input array.
Returns
-------
@@ -202,20 +222,25 @@ def setxor1d(ar1, ar2):
return aux[flag2]
def setmember1d(ar1, ar2):
- """Return a boolean array of shape of ar1 containing True where the elements
- of ar1 are in ar2 and False otherwise.
+ """
+ Return a boolean array set True where first element is in second array.
+
+ Boolean array is the shape of `ar1` containing True where the elements
+ of `ar1` are in `ar2` and False otherwise.
- Use unique1d() to generate arrays with only unique elements to use as inputs
- to this function.
+ Use unique1d() to generate arrays with only unique elements to use as
+ inputs to this function.
Parameters
----------
ar1 : array
+ Input array.
ar2 : array
+ Input array.
Returns
-------
- mask : bool array
+ mask : bool-array
The values ar1[mask] are in ar2.
See Also
@@ -252,17 +277,20 @@ def union1d(ar1, ar2):
"""
Union of 1D arrays with unique elements.
- Use unique1d() to generate arrays with only unique elements to use as inputs
- to this function.
+ Use unique1d() to generate arrays with only unique elements to use as
+ inputs to this function.
Parameters
----------
- ar1 : array
- ar2 : array
+ ar1 : array_like, shape(M,)
+ Input array.
+ ar2 : array_like, shape(N,)
+ Input array.
Returns
-------
union : array
+ Unique union of input arrays.
See also
--------
@@ -273,15 +301,18 @@ def union1d(ar1, ar2):
return unique1d( np.concatenate( (ar1, ar2) ) )
def setdiff1d(ar1, ar2):
- """Set difference of 1D arrays with unique elements.
+ """
+ Set difference of 1D arrays with unique elements.
- Use unique1d() to generate arrays with only unique elements to use as inputs
- to this function.
+ Use unique1d() to generate arrays with only unique elements to use as
+ inputs to this function.
Parameters
----------
ar1 : array
+ Input array.
ar2 : array
+ Input comparison array.
Returns
-------
diff --git a/numpy/lib/financial.py b/numpy/lib/financial.py
index 9c5d2753a..a997cf6c9 100644
--- a/numpy/lib/financial.py
+++ b/numpy/lib/financial.py
@@ -52,7 +52,45 @@ def _convert_when(when):
def fv(rate, nper, pmt, pv, when='end'):
- """future value computed by solving the equation
+ """
+ Compute the future value.
+
+ Parameters
+ ----------
+ rate : array-like
+ Rate of interest (per period)
+ nper : array-like
+ Number of compounding periods
+ pmt : array-like
+ Payment
+ pv : array-like
+ Present value
+ when : array-like
+ When payments are due ('begin' (1) or 'end' (0))
+
+ Notes
+ -----
+ The future value is computed by solving the equation::
+
+ fv + pv*(1+rate)**nper + pmt*(1+rate*when)/rate * ((1+rate)**nper - 1) == 0
+
+ or, when ``rate == 0``::
+
+ fv + pv + pmt * nper == 0
+
+ Examples
+ --------
+ What is the future value after 10 years of saving $100 now, with
+ an additional monthly savings of $100. Assume the interest rate is
+ 5% (annually) compounded monthly?
+
+ >>> np.fv(0.05/12, 10*12, -100, -100)
+ 15692.928894335748
+
+ By convention, the negative sign represents cash flow out (i.e. money not
+ available today). Thus, saving $100 a month at 5% annual interest leads
+ to $15,692.93 available to spend in 10 years.
+
"""
when = _convert_when(when)
rate, nper, pmt, pv, when = map(np.asarray, [rate, nper, pmt, pv, when])
@@ -78,7 +116,43 @@ By convention, the negative sign represents cash flow out (i.e. money not
"""
def pmt(rate, nper, pv, fv=0, when='end'):
- """Payment computed by solving the equation
+ """
+ Compute the payment.
+
+ Parameters
+ ----------
+ rate : array-like
+ Rate of interest (per period)
+ nper : array-like
+ Number of compounding periods
+ pv : array-like
+ Present value
+ fv : array-like
+ Future value
+ when : array-like
+ When payments are due ('begin' (1) or 'end' (0))
+
+ Notes
+ -----
+ The payment ``pmt`` is computed by solving the equation::
+
+ fv + pv*(1+rate)**nper + pmt*(1+rate*when)/rate * ((1+rate)**nper - 1) == 0
+
+ or, when ``rate == 0``::
+
+ fv + pv + pmt * nper == 0
+
+ Examples
+ --------
+ What would the monthly payment need to be to pay off a $200,000 loan in 15
+ years at an annual interest rate of 7.5%?
+
+ >>> np.pmt(0.075/12, 12*15, 200000)
+ -1854.0247200054619
+
+ In order to pay-off (i.e. have a future-value of 0) the $200,000 obtained
+ today, a monthly payment of $1,854.02 would be required.
+
"""
when = _convert_when(when)
rate, nper, pv, fv, when = map(np.asarray, [rate, nper, pv, fv, when])
@@ -102,7 +176,52 @@ In order to pay-off (i.e. have a future-value of 0) the $200,000 obtained
"""
def nper(rate, pmt, pv, fv=0, when='end'):
- """Number of periods found by solving the equation
+ """
+ Compute the number of periods.
+
+ Parameters
+ ----------
+ rate : array_like
+ Rate of interest (per period)
+ pmt : array_like
+ Payment
+ pv : array_like
+ Present value
+ fv : array_like
+ Future value
+ when : array_like
+ When payments are due ('begin' (1) or 'end' (0))
+
+ Notes
+ -----
+ The number of periods ``nper`` is computed by solving the equation::
+
+ fv + pv*(1+rate)**nper + pmt*(1+rate*when)/rate * ((1+rate)**nper - 1) == 0
+
+ or, when ``rate == 0``::
+
+ fv + pv + pmt * nper == 0
+
+ Examples
+ --------
+ If you only had $150 to spend as payment, how long would it take to pay-off
+ a loan of $8,000 at 7% annual interest?
+
+ >>> np.nper(0.07/12, -150, 8000)
+ 64.073348770661852
+
+ So, over 64 months would be required to pay off the loan.
+
+ The same analysis could be done with several different interest rates and/or
+ payments and/or total amounts to produce an entire table.
+
+ >>> np.nper(*(np.ogrid[0.06/12:0.071/12:0.01/12, -200:-99:100, 6000:7001:1000]))
+ array([[[ 32.58497782, 38.57048452],
+ [ 71.51317802, 86.37179563]],
+ <BLANKLINE>
+ [[ 33.07413144, 39.26244268],
+ [ 74.06368256, 90.22989997]]])
+
"""
when = _convert_when(when)
rate, pmt, pv, fv, when = map(np.asarray, [rate, pmt, pv, fv, when])
@@ -139,6 +258,10 @@ array([[[ 32.58497782, 38.57048452],
"""
def ipmt(rate, per, nper, pv, fv=0.0, when='end'):
+ """
+ Not implemented.
+
+ """
total = pmt(rate, nper, pv, fv, when)
# Now, compute the nth step in the amortization
raise NotImplementedError
@@ -148,7 +271,32 @@ def ppmt(rate, per, nper, pv, fv=0.0, when='end'):
return total - ipmt(rate, per, nper, pv, fv, when)
def pv(rate, nper, pmt, fv=0.0, when='end'):
- """Number of periods found by solving the equation
+ """
+ Compute the present value.
+
+ Parameters
+ ----------
+ rate : array-like
+ Rate of interest (per period)
+ nper : array-like
+ Number of compounding periods
+ pmt : array-like
+ Payment
+ fv : array-like
+ Future value
+ when : array-like
+ When payments are due ('begin' (1) or 'end' (0))
+
+ Notes
+ -----
+ The present value ``pv`` is computed by solving the equation::
+
+ fv + pv*(1+rate)**nper + pmt*(1+rate*when)/rate * ((1+rate)**nper - 1) = 0
+
+ or, when ``rate = 0``::
+
+ fv + pv + pmt * nper = 0
+
"""
when = _convert_when(when)
rate, nper, pmt, fv, when = map(np.asarray, [rate, nper, pmt, fv, when])
@@ -175,7 +323,38 @@ def _g_div_gp(r, n, p, x, y, w):
# g(r) is the formula
# g'(r) is the derivative with respect to r.
def rate(nper, pmt, pv, fv, when='end', guess=0.10, tol=1e-6, maxiter=100):
- """Number of periods found by solving the equation
+ """
+ Compute the rate of interest per period.
+
+ Parameters
+ ----------
+ nper : array_like
+ Number of compounding periods
+ pmt : array_like
+ Payment
+ pv : array_like
+ Present value
+ fv : array_like
+ Future value
+ when : array_like, optional
+ When payments are due ('begin' (1) or 'end' (0))
+ guess : float, optional
+ Starting guess for solving the rate of interest
+ tol : float, optional
+ Required tolerance for the solution
+ maxiter : int, optional
+ Maximum iterations in finding the solution
+
+ Notes
+ -----
+ The rate of interest ``rate`` is computed by solving the equation::
+
+ fv + pv*(1+rate)**nper + pmt*(1+rate*when)/rate * ((1+rate)**nper - 1) = 0
+
+ or, if ``rate = 0``::
+
+ fv + pv + pmt * nper = 0
+
"""
when = _convert_when(when)
nper, pmt, pv, fv, when = map(np.asarray, [nper, pmt, pv, fv, when])
diff --git a/numpy/lib/format.py b/numpy/lib/format.py
index 00281bf9b..4192e1225 100644
--- a/numpy/lib/format.py
+++ b/numpy/lib/format.py
@@ -1,5 +1,4 @@
-"""Define a simple format for saving numpy arrays to disk.
-
+"""
Define a simple format for saving numpy arrays to disk with the full
information about them.
@@ -14,13 +13,13 @@ restored by using the `loadedarray.view(correct_dtype)` method.
Format Version 1.0
------------------
-The first 6 bytes are a magic string: exactly "\\x93NUMPY".
+The first 6 bytes are a magic string: exactly "\\\\x93NUMPY".
The next 1 byte is an unsigned byte: the major version number of the file
-format, e.g. \\x01.
+format, e.g. \\\\x01.
The next 1 byte is an unsigned byte: the minor version number of the file
-format, e.g. \\x00. Note: the version of the file format is not tied to the
+format, e.g. \\\\x00. Note: the version of the file format is not tied to the
version of the numpy package.
The next 2 bytes form a little-endian unsigned short int: the length of the
@@ -28,8 +27,8 @@ header data HEADER_LEN.
The next HEADER_LEN bytes form the header data describing the array's format.
It is an ASCII string which contains a Python literal expression of a
-dictionary. It is terminated by a newline ('\\n') and padded with spaces
-('\\x20') to make the total length of the magic string + 4 + HEADER_LEN be
+dictionary. It is terminated by a newline ('\\\\n') and padded with spaces
+('\\\\x20') to make the total length of the magic string + 4 + HEADER_LEN be
evenly divisible by 16 for alignment purposes.
The dictionary contains three keys:
@@ -46,7 +45,7 @@ The dictionary contains three keys:
For repeatability and readability, the dictionary keys are sorted in alphabetic
order. This is for convenience only. A writer SHOULD implement this if
-possible. A reader MUST NOT depend on this.
+possible. A reader MUST NOT depend on this.
Following the header comes the array data. If the dtype contains Python objects
(i.e. dtype.hasobject is True), then the data is a Python pickle of the array.
@@ -112,13 +111,26 @@ def read_magic(fp):
return major, minor
def dtype_to_descr(dtype):
- """ Get a serializable descriptor from the dtype.
+ """
+ Get a serializable descriptor from the dtype.
- The .descr attribute of a dtype object cannot be round-tripped through the
- dtype() constructor. Simple types, like dtype('float32'), have a descr
- which looks like a record array with one field with '' as a name. The
- dtype() constructor interprets this as a request to give a default name.
- Instead, we construct descriptor that can be passed to dtype().
+ The .descr attribute of a dtype object cannot be round-tripped through
+ the dtype() constructor. Simple types, like dtype('float32'), have
+ a descr which looks like a record array with one field with '' as
+ a name. The dtype() constructor interprets this as a request to give
+ a default name. Instead, we construct descriptor that can be passed to
+ dtype().
+
+ Parameters
+ ----------
+ dtype : dtype
+ The dtype of the array that will be written to disk.
+
+ Returns
+ -------
+ descr : object
+ An object that can be passed to `numpy.dtype()` in order to
+ replicate the input dtype.
"""
if dtype.names is not None:
@@ -188,7 +200,8 @@ def write_array_header_1_0(fp, d):
fp.write(header)
def read_array_header_1_0(fp):
- """ Read an array header from a filelike object using the 1.0 file format
+ """
+ Read an array header from a filelike object using the 1.0 file format
version.
This will leave the file object located just after the header.
@@ -196,6 +209,7 @@ def read_array_header_1_0(fp):
Parameters
----------
fp : filelike object
+ A file object or something with a `.read()` method like a file.
Returns
-------
@@ -206,10 +220,13 @@ def read_array_header_1_0(fp):
or Fortran-contiguous. Otherwise, it will be made contiguous before
writing it out.
dtype : dtype
+ The dtype of the file's data.
Raises
------
- ValueError if the data is invalid.
+ ValueError :
+ If the data is invalid.
+
"""
# Read an unsigned, little-endian short int which has the length of the
# header.
@@ -259,23 +276,31 @@ def read_array_header_1_0(fp):
return d['shape'], d['fortran_order'], dtype
def write_array(fp, array, version=(1,0)):
- """ Write an array to a file, including a header.
+ """
+ Write an array to an NPY file, including a header.
If the array is neither C-contiguous or Fortran-contiguous AND if the
- filelike object is not a real file object, then this function will have to
- copy data in memory.
+ filelike object is not a real file object, then this function will have
+ to copy data in memory.
Parameters
----------
fp : filelike object
+ An open, writable file object or similar object with a `.write()`
+ method.
array : numpy.ndarray
+ The array to write to disk.
version : (int, int), optional
The version number of the format.
Raises
------
- ValueError if the array cannot be persisted. Various other errors from
- pickling if the array contains Python objects as part of its dtype.
+ ValueError
+ If the array cannot be persisted.
+ Various other errors
+ If the array contains Python objects as part of its dtype, the
+ process of pickling them may raise arbitrary errors if the objects
+ are not picklable.
"""
if version != (1, 0):
@@ -300,7 +325,8 @@ def write_array(fp, array, version=(1,0)):
fp.write(array.tostring('C'))
def read_array(fp):
- """ Read an array from a file.
+ """
+ Read an array from an NPY file.
Parameters
----------
@@ -311,10 +337,12 @@ def read_array(fp):
Returns
-------
array : numpy.ndarray
+ The array from the data on disk.
Raises
------
- ValueError if the data is invalid.
+ ValueError
+ If the data is invalid.
"""
version = read_magic(fp)
@@ -353,19 +381,28 @@ def read_array(fp):
def open_memmap(filename, mode='r+', dtype=None, shape=None,
fortran_order=False, version=(1,0)):
- """ Open a .npy file as a memory-mapped array.
+ """
+ Open a .npy file as a memory-mapped array.
+
+ This may be used to read an existing file or create a new one.
Parameters
----------
filename : str
+ The name of the file on disk. This may not be a filelike object.
mode : str, optional
The mode to open the file with. In addition to the standard file modes,
- 'c' is also accepted to mean "copy on write".
+ 'c' is also accepted to mean "copy on write". See `numpy.memmap` for
+ the available mode strings.
dtype : dtype, optional
+ The data type of the array if we are creating a new file in "write"
+ mode.
shape : tuple of int, optional
+ The shape of the array if we are creating a new file in "write"
+ mode.
fortran_order : bool, optional
- If the mode is a "write" mode, then the file will be created using this
- dtype, shape, and contiguity.
+ Whether the array should be Fortran-contiguous (True) or
+ C-contiguous (False) if we are creating a new file in "write" mode.
version : tuple of int (major, minor)
If the mode is a "write" mode, then this is the version of the file
format used to create the file.
@@ -373,11 +410,19 @@ def open_memmap(filename, mode='r+', dtype=None, shape=None,
Returns
-------
marray : numpy.memmap
+ The memory-mapped array.
Raises
------
- ValueError if the data or the mode is invalid.
- IOError if the file is not found or cannot be opened correctly.
+ ValueError
+ If the data or the mode is invalid.
+ IOError
+ If the file is not found or cannot be opened correctly.
+
+ See Also
+ --------
+ numpy.memmap
+
"""
if 'w' in mode:
# We are creating the file, not reading it.
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index f0b941872..3a0212a0e 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -33,42 +33,68 @@ import numpy as np
#end Fernando's utilities
def linspace(start, stop, num=50, endpoint=True, retstep=False):
- """Return evenly spaced numbers.
+ """
+ Return evenly spaced numbers.
- Return num evenly spaced samples from start to stop. If
- endpoint is True, the last sample is stop. If retstep is
- True then return (seq, step_value), where step_value used.
+ `linspace` returns `num` evenly spaced samples, calculated over the
+ interval ``[start, stop]``. The endpoint of the interval can optionally
+ be excluded.
Parameters
----------
- start : {float}
- The value the sequence starts at.
- stop : {float}
- The value the sequence stops at. If ``endpoint`` is false, then
- this is not included in the sequence. Otherwise it is
- guaranteed to be the last value.
- num : {integer}
+ start : float
+ The starting value of the sequence.
+ stop : float
+ The end value of the sequence, unless `endpoint` is set to False.
+ In that case, the sequence consists of all but the last of ``num + 1``
+ evenly spaced samples, so that `stop` is excluded. Note that the step
+ size changes when `endpoint` is False.
+ num : int
Number of samples to generate. Default is 50.
- endpoint : {boolean}
- If true, ``stop`` is the last sample. Otherwise, it is not
- included. Default is true.
- retstep : {boolean}
- If true, return ``(samples, step)``, where ``step`` is the
- spacing used in generating the samples.
+ endpoint : bool
+ If true, `stop` is the last sample. Otherwise, it is not included.
+ Default is True.
+ retstep : bool
+ If True, return (`samples`, `step`), where `step` is the spacing
+ between samples.
Returns
-------
- samples : {array}
- ``num`` equally spaced samples from the range [start, stop]
- or [start, stop).
- step : {float} (Only if ``retstep`` is true)
+ samples : ndarray
+ `num` equally spaced samples in the closed interval
+ ``[start, stop]`` or the half-open interval ``[start, stop)``
+ (depending on whether `endpoint` is True or False).
+ step : float (only if `retstep` is True)
Size of spacing between samples.
+
See Also
--------
- arange : Similiar to linspace, however, when used with
- a float endpoint, that endpoint may or may not be included.
- logspace
+ arange : Similiar to `linspace`, but uses a step size (instead of the
+ number of samples). Note that, when used with a float
+ endpoint, the endpoint may or may not be included.
+ logspace : Samples uniformly distributed in log space.
+
+ Examples
+ --------
+ >>> np.linspace(2.0, 3.0, num=5)
+ array([ 2. , 2.25, 2.5 , 2.75, 3. ])
+ >>> np.linspace(2.0, 3.0, num=5, endpoint=False)
+ array([ 2. , 2.2, 2.4, 2.6, 2.8])
+ >>> np.linspace(2.0, 3.0, num=5, retstep=True)
+ (array([ 2. , 2.25, 2.5 , 2.75, 3. ]), 0.25)
+
+ Graphical illustration:
+
+ >>> import matplotlib.pyplot as plt
+ >>> N = 8
+ >>> y = np.zeros(N)
+ >>> x1 = np.linspace(0, 10, N, endpoint=True)
+ >>> x2 = np.linspace(0, 10, N, endpoint=False)
+ >>> plt.plot(x1, y, 'o')
+ >>> plt.plot(x2, y + 0.5, 'o')
+ >>> plt.ylim([-0.5, 1])
+ >>> plt.show()
"""
num = int(num)
@@ -89,10 +115,73 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False):
return y
def logspace(start,stop,num=50,endpoint=True,base=10.0):
- """Evenly spaced numbers on a logarithmic scale.
+ """
+ Return numbers spaced evenly on a log scale.
+
+ In linear space, the sequence starts at ``base ** start``
+ (`base` to the power of `start`) and ends with ``base ** stop``
+ (see `endpoint` below).
+
+ Parameters
+ ----------
+ start : float
+ ``base ** start`` is the starting value of the sequence.
+ stop : float
+ ``base ** stop`` is the final value of the sequence, unless `endpoint`
+ is False. In that case, ``num + 1`` values are spaced over the
+ interval in log-space, of which all but the last (a sequence of
+ length ``num``) are returned.
+ num : integer, optional
+ Number of samples to generate. Default is 50.
+ endpoint : boolean, optional
+ If true, `stop` is the last sample. Otherwise, it is not included.
+ Default is True.
+ base : float, optional
+ The base of the log space. The step size between the elements in
+ ``ln(samples) / ln(base)`` (or ``log_base(samples)``) is uniform.
+ Default is 10.0.
+
+ Returns
+ -------
+ samples : ndarray
+ `num` samples, equally spaced on a log scale.
+
+ See Also
+ --------
+ arange : Similiar to linspace, with the step size specified instead of the
+ number of samples. Note that, when used with a float endpoint, the
+ endpoint may or may not be included.
+ linspace : Similar to logspace, but with the samples uniformly distributed
+ in linear space, instead of log space.
+
+ Notes
+ -----
+ Logspace is equivalent to the code
+
+ >>> y = linspace(start, stop, num=num, endpoint=endpoint)
+ >>> power(base, y)
+
+ Examples
+ --------
+ >>> np.logspace(2.0, 3.0, num=4)
+ array([ 100. , 215.443469 , 464.15888336, 1000. ])
+ >>> np.logspace(2.0, 3.0, num=4, endpoint=False)
+ array([ 100. , 177.827941 , 316.22776602, 562.34132519])
+ >>> np.logspace(2.0, 3.0, num=4, base=2.0)
+ array([ 4. , 5.0396842 , 6.34960421, 8. ])
+
+ Graphical illustration:
+
+ >>> import matplotlib.pyplot as plt
+ >>> N = 10
+ >>> x1 = np.logspace(0.1, 1, N, endpoint=True)
+ >>> x2 = np.logspace(0.1, 1, N, endpoint=False)
+ >>> y = np.zeros(N)
+ >>> plt.plot(x1, y, 'o')
+ >>> plt.plot(x2, y + 0.5, 'o')
+ >>> plt.ylim([-0.5, 1])
+ >>> plt.show()
- Computes int(num) evenly spaced exponents from base**start to
- base**stop. If endpoint=True, then last number is base**stop
"""
y = linspace(start,stop,num=num,endpoint=endpoint)
return _nx.power(base,y)
@@ -103,43 +192,40 @@ def iterable(y):
return 1
def histogram(a, bins=10, range=None, normed=False, weights=None, new=False):
- """Compute the histogram from a set of data.
+ """
+ Compute the histogram of a set of data.
Parameters
----------
- a : array
- The data to histogram.
-
- bins : int or sequence
- If an int, then the number of equal-width bins in the given
- range. If new=True, bins can also be the bin edges, allowing
- for non-constant bin widths.
-
- range : (float, float)
- The lower and upper range of the bins. If not provided, range
- is simply (a.min(), a.max()). Using new=False, lower than
- range are ignored, and values higher than range are tallied in
- the rightmost bin. Using new=True, both lower and upper
- outliers are ignored.
-
- normed : bool
- If False, the result array will contain the number of samples
- in each bin. If True, the result array is the value of the
- probability *density* function at the bin normalized such that
- the *integral* over the range is 1. Note that the sum of all
- of the histogram values will not usually be 1; it is not a
+ a : array_like
+ Input data.
+ bins : int or sequence of scalars, optional
+ If `bins` is an int, it gives the number of equal-width bins in the
+ given range (10, by default). If `new` is True, bins can also be
+ the bin edges, allowing for non-uniform bin widths.
+ range : (float, float), optional
+ The lower and upper range of the bins. If not provided, range
+ is simply ``(a.min(), a.max())``. With `new` set to True, values
+ outside the range are ignored. With `new` set to False, values
+ below the range are ignored, and those above the range are tallied
+ in the rightmost bin.
+ normed : bool, optional
+ If False, the result will contain the number of samples
+ in each bin. If True, the result is the value of the
+ probability *density* function at the bin, normalized such that
+ the *integral* over the range is 1. Note that the sum of the
+ histogram values will often not be equal to 1; it is not a
probability *mass* function.
-
- weights : array
- An array of weights, the same shape as a. If normed is False,
- the histogram is computed by summing the weights of the values
- falling into each bin. If normed is True, the weights are
- normalized, so that the integral of the density over the range
- is 1. This option is only available with new=True.
-
- new : bool
- Compatibility argument to transition from the old version
- (v1.1) to the new version (v1.2).
+ weights : array_like, optional
+ An array of weights, of the same shape as `a`. Each value in `a`
+ only contributes its associated weight towards the bin count
+ (instead of 1). If `normed` is True, the weights are normalized,
+ so that the integral of the density over the range remains 1.
+ The `weights` keyword is only available with `new` set to True.
+ new : bool, optional
+ Compatibility argument to aid in the transition between the old
+ (v1.1) and the new (v1.2) implementations. In version 1.2,
+ `new` will be True by default.
Returns
-------
@@ -147,14 +233,30 @@ def histogram(a, bins=10, range=None, normed=False, weights=None, new=False):
The values of the histogram. See `normed` and `weights` for a
description of the possible semantics.
- bin_edges : float array
- With new=False, return the left bin edges (length(hist)).
- With new=True, return the bin edges (length(hist)+1).
+ bin_edges : array of dtype float
+ With ``new = False``, return the left bin edges (``length(hist)``).
+ With ``new = True``, return the bin edges ``(length(hist)+1)``.
See Also
--------
histogramdd
+ Notes
+ -----
+ All but the last (righthand-most) bin is half-open. In other words, if
+ `bins` is::
+
+ [1, 2, 3, 4]
+
+ then the first bin is ``[1, 2)`` (including 1, but excluding 2) and the
+ second ``[2, 3)``. The last bin, however, is ``[3, 4]``, which *includes*
+ 4.
+
+ Examples
+ --------
+ >>> np.histogram([1,2,1], bins=[0,1,2,3], new=True)
+ (array([0, 2, 1]), array([0, 1, 2, 3]))
+
"""
# Old behavior
if new is False:
@@ -280,47 +382,53 @@ def histogram(a, bins=10, range=None, normed=False, weights=None, new=False):
def histogramdd(sample, bins=10, range=None, normed=False, weights=None):
- """histogramdd(sample, bins=10, range=None, normed=False, weights=None)
-
- Return the N-dimensional histogram of the sample.
+ """
+ Compute the multidimensional histogram of some data.
Parameters
----------
- sample : sequence or array
- A sequence containing N arrays or an NxM array. Input data.
-
- bins : sequence or scalar
- A sequence of edge arrays, a sequence of bin counts, or a scalar
- which is the bin count for all dimensions. Default is 10.
-
- range : sequence
- A sequence of lower and upper bin edges. Default is [min, max].
-
- normed : boolean
- If False, return the number of samples in each bin, if True,
- returns the density.
-
- weights : array
- Array of weights. The weights are normed only if normed is True.
- Should the sum of the weights not equal N, the total bin count will
- not be equal to the number of samples.
+ sample : array-like
+ Data to histogram passed as a sequence of D arrays of length N, or
+ as an (N,D) array.
+ bins : sequence or int, optional
+ The bin specification:
+
+ * A sequence of arrays describing the bin edges along each dimension.
+ * The number of bins for each dimension (nx, ny, ... =bins)
+ * The number of bins for all dimensions (nx=ny=...=bins).
+
+ range : sequence, optional
+ A sequence of lower and upper bin edges to be used if the edges are
+ not given explicitely in `bins`. Defaults to the minimum and maximum
+ values along each dimension.
+ normed : boolean, optional
+ If False, returns the number of samples in each bin. If True, returns
+ the bin density, ie, the bin count divided by the bin hypervolume.
+ weights : array-like (N,), optional
+ An array of values `w_i` weighing each sample `(x_i, y_i, z_i, ...)`.
+ Weights are normalized to 1 if normed is True. If normed is False, the
+ values of the returned histogram are equal to the sum of the weights
+ belonging to the samples falling into each bin.
Returns
-------
- hist : array
- Histogram array.
-
+ H : array
+ The multidimensional histogram of sample x. See normed and weights for
+ the different possible semantics.
edges : list
- List of arrays defining the lower bin edges.
+ A list of D arrays describing the bin edges for each dimension.
See Also
--------
- histogram
+ histogram: 1D histogram
+ histogram2d: 2D histogram
Examples
--------
- >>> x = np.random.randn(100,3)
- >>> hist3d, edges = np.lib.histogramdd(x, bins = (5, 6, 7))
+ >>> r = np.random.randn(100,3)
+ >>> H, edges = np.histogramdd(r, bins = (5, 8, 4))
+ >>> H.shape, edges[0].size, edges[1].size, edges[2].size
+ ((5,8,4), 6, 9, 5)
"""
@@ -439,7 +547,8 @@ def histogramdd(sample, bins=10, range=None, normed=False, weights=None):
def average(a, axis=None, weights=None, returned=False):
- """Return the weighted average of array a over the given axis.
+ """
+ Return the weighted average of array over the specified axis.
Parameters
@@ -447,42 +556,52 @@ def average(a, axis=None, weights=None, returned=False):
a : array_like
Data to be averaged.
axis : {None, integer}, optional
- Axis along which to average a. If None, averaging is done over the
+ Axis along which to average `a`. If `None`, averaging is done over the
entire array irrespective of its shape.
weights : {None, array_like}, optional
- The importance each datum has in the computation of the
- average. The weights array can either be 1D, in which case its length
- must be the size of a along the given axis, or of the same shape as a.
- If weights=None, all data are assumed to have weight equal to one.
- returned :{False, boolean}, optional
- If True, the tuple (average, sum_of_weights) is returned,
- otherwise only the average is returmed. Note that if weights=None, then
- the sum of the weights is also the number of elements averaged over.
+ The importance that each datum has in the computation of the average.
+ The weights array can either be 1D (in which case its length must be
+ the size of `a` along the given axis) or of the same shape as `a`.
+ If `weights=None`, then all data in `a` are assumed to have a
+ weight equal to one.
+ returned : {False, boolean}, optional
+ If `True`, the tuple (`average`, `sum_of_weights`) is returned,
+ otherwise only the average is returned. Note that if `weights=None`,
+ `sum_of_weights` is equivalent to the number of elements over which
+ the average is taken.
Returns
-------
average, [sum_of_weights] : {array_type, double}
- Return the average along the specified axis. When returned is True,
+ Return the average along the specified axis. When returned is `True`,
return a tuple with the average as the first element and the sum
- of the weights as the second element. The return type is Float if a is
- of integer type, otherwise it is of the same type as a.
- sum_of_weights is has the same type as the average.
-
-
- Examples
- --------
- >>> np.average(range(1,11), weights=range(10,0,-1))
- 4.0
+ of the weights as the second element. The return type is `Float`
+ if `a` is of integer type, otherwise it is of the same type as `a`.
+ `sum_of_weights` is of the same type as `average`.
Raises
------
ZeroDivisionError
- When all weights along axis are zero. See numpy.ma.average for a
+ When all weights along axis are zero. See `numpy.ma.average` for a
version robust to this type of error.
TypeError
- When the length of 1D weights is not the same as the shape of a
+ When the length of 1D `weights` is not the same as the shape of `a`
along axis.
+ See Also
+ --------
+ ma.average : average for masked arrays
+
+ Examples
+ --------
+ >>> data = range(1,5)
+ >>> data
+ [1, 2, 3, 4]
+ >>> np.average(data)
+ 2.5
+ >>> np.average(range(1,11), weights=range(10,0,-1))
+ 4.0
+
"""
if not isinstance(a, np.matrix) :
a = np.asarray(a)
@@ -528,37 +647,79 @@ def asarray_chkfinite(a):
return a
def piecewise(x, condlist, funclist, *args, **kw):
- """Return a piecewise-defined function.
+ """
+ Evaluate a piecewise-defined function.
+
+ Given a set of conditions and corresponding functions, evaluate each
+ function on the input data wherever its condition is true.
+
+ Parameters
+ ----------
+ x : (N,) ndarray
+ The input domain.
+ condlist : list of M (N,)-shaped boolean arrays
+ Each boolean array corresponds to a function in `funclist`. Wherever
+ `condlist[i]` is True, `funclist[i](x)` is used as the output value.
+
+ Each boolean array in `condlist` selects a piece of `x`,
+ and should therefore be of the same shape as `x`.
+
+ The length of `condlist` must correspond to that of `funclist`.
+ If one extra function is given, i.e. if the length of `funclist` is
+ M+1, then that extra function is the default value, used wherever
+ all conditions are false.
+ funclist : list of M or M+1 callables, f(x,*args,**kw), or values
+ Each function is evaluated over `x` wherever its corresponding
+ condition is True. It should take an array as input and give an array
+ or a scalar value as output. If, instead of a callable,
+ a value is provided then a constant function (``lambda x: value``) is
+ assumed.
+ args : tuple, optional
+ Any further arguments given to `piecewise` are passed to the functions
+ upon execution, i.e., if called ``piecewise(...,...,1,'a')``, then
+ each function is called as ``f(x,1,'a')``.
+ kw : dictionary, optional
+ Keyword arguments used in calling `piecewise` are passed to the
+ functions upon execution, i.e., if called
+ ``piecewise(...,...,lambda=1)``, then each function is called as
+ ``f(x,lambda=1)``.
+
+ Returns
+ -------
+ out : ndarray
+ The output is the same shape and type as x and is found by
+ calling the functions in `funclist` on the appropriate portions of `x`,
+ as defined by the boolean arrays in `condlist`. Portions not covered
+ by any condition have undefined values.
+
+ Notes
+ -----
+ This is similar to choose or select, except that functions are
+ evaluated on elements of `x` that satisfy the corresponding condition from
+ `condlist`.
- x is the domain
+ The result is::
- condlist is a list of boolean arrays or a single boolean array
- The length of the condition list must be n2 or n2-1 where n2
- is the length of the function list. If len(condlist)==n2-1, then
- an 'otherwise' condition is formed by |'ing all the conditions
- and inverting.
+ |--
+ |funclist[0](x[condlist[0]])
+ out = |funclist[1](x[condlist[1]])
+ |...
+ |funclist[n2](x[condlist[n2]])
+ |--
- funclist is a list of functions to call of length (n2).
- Each function should return an array output for an array input
- Each function can take (the same set) of extra arguments and
- keyword arguments which are passed in after the function list.
- A constant may be used in funclist for a function that returns a
- constant (e.g. val and lambda x: val are equivalent in a funclist).
+ Examples
+ --------
+ Define the sigma function, which is -1 for ``x < 0`` and +1 for ``x >= 0``.
- The output is the same shape and type as x and is found by
- calling the functions on the appropriate portions of x.
+ >>> x = np.arange(6) - 2.5 # x runs from -2.5 to 2.5 in steps of 1
+ >>> np.piecewise(x, [x < 0, x >= 0.5], [-1,1])
+ array([-1., -1., -1., 1., 1., 1.])
- Note: This is similar to choose or select, except
- the the functions are only evaluated on elements of x
- that satisfy the corresponding condition.
+ Define the absolute value, which is ``-x`` for ``x <0`` and ``x`` for
+ ``x >= 0``.
- The result is
- |--
- | f1(x) for condition1
- y = --| f2(x) for condition2
- | ...
- | fn(x) for conditionn
- |--
+ >>> np.piecewise(x, [x < 0, x >= 0], [lambda x: -x, lambda x: x])
+ array([ 2.5, 1.5, 0.5, 0.5, 1.5, 2.5])
"""
x = asanyarray(x)
@@ -608,25 +769,30 @@ def piecewise(x, condlist, funclist, *args, **kw):
return y
def select(condlist, choicelist, default=0):
- """Return an array composed of different elements in choicelist,
- depending on the list of conditions.
+ """
+ Return an array drawn from elements in choicelist, depending on conditions.
- :Parameters:
- condlist : list of N boolean arrays of length M
+ Parameters
+ ----------
+ condlist : list of N boolean arrays of length M
The conditions C_0 through C_(N-1) which determine
from which vector the output elements are taken.
- choicelist : list of N arrays of length M
+ choicelist : list of N arrays of length M
Th vectors V_0 through V_(N-1), from which the output
elements are chosen.
- :Returns:
- output : 1-dimensional array of length M
+ Returns
+ -------
+ output : 1-dimensional array of length M
The output at position m is the m-th element of the first
vector V_n for which C_n[m] is non-zero. Note that the
output depends on the order of conditions, since the
first satisfied condition is used.
- Equivalent to:
+ Notes
+ -----
+ Equivalent to:
+ ::
output = []
for m in range(M):
@@ -658,28 +824,76 @@ def select(condlist, choicelist, default=0):
return choose(S, tuple(choicelist))
def copy(a):
- """Return an array copy of the given object.
+ """
+ Return an array copy of the given object.
+
+ Parameters
+ ----------
+ a : array_like
+ Input data.
+
+ Returns
+ -------
+ arr : ndarray
+ Array interpretation of `a`.
+
+ Notes
+ -----
+ This is equivalent to
+
+ >>> np.array(a, copy=True)
+
+ Examples
+ --------
+ Create an array x, with a reference y and a copy z:
+
+ >>> x = np.array([1, 2, 3])
+ >>> y = x
+ >>> z = np.copy(x)
+
+ Note that, when we modify x, y changes, but not z:
+
+ >>> x[0] = 10
+ >>> x[0] == y[0]
+ True
+ >>> x[0] == z[0]
+ False
+
"""
return array(a, copy=True)
# Basic operations
def gradient(f, *varargs):
- """Calculate the gradient of an N-dimensional scalar function.
-
- Uses central differences on the interior and first differences on boundaries
- to give the same shape.
+ """
+ Return the gradient of an N-dimensional array.
- Inputs:
+ The gradient is computed using central differences in the interior
+ and first differences at the boundaries. The returned gradient hence has
+ the same shape as the input array.
- f -- An N-dimensional array giving samples of a scalar function
+ Parameters
+ ----------
+ f : array_like
+ An N-dimensional array containing samples of a scalar function.
+ `*varargs` : scalars
+ 0, 1, or N scalars specifying the sample distances in each direction,
+ that is: `dx`, `dy`, `dz`, ... The default distance is 1.
- varargs -- 0, 1, or N scalars giving the sample distances in each direction
- Outputs:
+ Returns
+ -------
+ g : ndarray
+ N arrays of the same shape as `f` giving the derivative of `f` with
+ respect to each dimension.
- N arrays of the same shape as f giving the derivative of f with respect
- to each dimension.
+ Examples
+ --------
+ >>> np.gradient(np.array([[1,1],[3,4]]))
+ [array([[ 2., 3.],
+ [ 2., 3.]]),
+ array([[ 0., 0.],
+ [ 1., 1.]])]
"""
N = len(f.shape) # number of dimensions
@@ -740,7 +954,38 @@ def gradient(f, *varargs):
def diff(a, n=1, axis=-1):
- """Calculate the nth order discrete difference along given axis.
+ """
+ Calculate the nth order discrete difference along given axis.
+
+ Parameters
+ ----------
+ a : array_like
+ Input array
+ n : int, optional
+ The number of times values are differenced.
+ axis : int, optional
+ The axis along which the difference is taken.
+
+ Returns
+ -------
+ out : ndarray
+ The `n` order differences. The shape of the output is the same as `a`
+ except along `axis` where the dimension is `n` less.
+
+ Examples
+ --------
+ >>> x = np.array([0,1,3,9,5,10])
+ >>> np.diff(x)
+ array([ 1, 2, 6, -4, 5])
+ >>> np.diff(x,n=2)
+ array([ 1, 4, -10, 9])
+ >>> x = np.array([[1,3,6,10],[0,5,6,8]])
+ >>> np.diff(x)
+ array([[2, 3, 4],
+ [5, 1, 2]])
+ >>> np.diff(x,axis=0)
+ array([[-1, 2, 0, -2]])
+
"""
if n == 0:
return a
@@ -807,16 +1052,60 @@ except RuntimeError:
def interp(x, xp, fp, left=None, right=None):
- """Return the value of a piecewise-linear function at each value in x.
+ """
+ One-dimensional linear interpolation.
+
+ Returns the one-dimensional piecewise linear interpolant to a function
+ with given values at discrete data-points.
+
+ Parameters
+ ----------
+ x : array_like
+ The x-coordinates of the interpolated values.
+
+ xp : 1-D sequence of floats
+ The x-coordinates of the data points, must be increasing.
+
+ fp : 1-D sequence of floats
+ The y-coordinates of the data points, same length as `xp`.
- The piecewise-linear function, f, is defined by the known data-points
- fp=f(xp). The xp points must be sorted in increasing order but this is
- not checked.
+ left : float, optional
+ Value to return for `x < xp[0]`, default is `fp[0]`.
+
+ right : float, optional
+ Value to return for `x > xp[-1]`, defaults is `fp[-1]`.
+
+ Returns
+ -------
+ y : {float, ndarray}
+ The interpolated values, same shape as `x`.
+
+ Raises
+ ------
+ ValueError
+ If `xp` and `fp` have different length
+
+ Notes
+ -----
+ Does not check that the x-coordinate sequence `xp` is increasing.
+ If `xp` is not increasing, the results are nonsense.
+ A simple check for increasingness is::
+
+ np.all(np.diff(xp) > 0)
+
+
+ Examples
+ --------
+ >>> xp = [1, 2, 3]
+ >>> fp = [3, 2, 0]
+ >>> np.interp(2.5, xp, fp)
+ 1.0
+ >>> np.interp([0, 1, 1.5, 2.72, 3.14], xp, fp)
+ array([ 3. , 3. , 2.5, 0.56, 0. ])
+ >>> UNDEF = -99.0
+ >>> np.interp(3.14, xp, fp, right=UNDEF)
+ -99.0
- For values of x < xp[0] return the value given by left. If left is None,
- then return fp[0].
- For values of x > xp[-1] return the value given by right. If right is
- None, then return fp[-1].
"""
if isinstance(x, (float, int, number)):
return compiled_interp([x], xp, fp, left, right).item()
@@ -826,13 +1115,26 @@ def interp(x, xp, fp, left=None, right=None):
def angle(z, deg=0):
"""
- Return the angle of the complex argument z.
+ Return the angle of the complex argument.
+
+ Parameters
+ ----------
+ z : array_like
+ A complex number or sequence of complex numbers.
+ deg : bool, optional
+ Return angle in degrees if True, radians if False. Default is False.
+
+ Returns
+ -------
+ angle : {ndarray, scalar}
+ The angle is defined as counterclockwise from the positive real axis on
+ the complex plane, with dtype as numpy.float64.
Examples
--------
- >>> np.angle(1+1j) # in radians
- 0.78539816339744828
- >>> np.angle(1+1j,deg=True) # in degrees
+ >>> np.angle([1.0, 1.0j, 1+1j]) # in radians
+ array([ 0. , 1.57079633, 0.78539816])
+ >>> np.angle(1+1j, deg=True) # in degrees
45.0
"""
@@ -850,8 +1152,26 @@ def angle(z, deg=0):
return arctan2(zimag, zreal) * fact
def unwrap(p, discont=pi, axis=-1):
- """Unwrap radian phase p by changing absolute jumps greater than
- 'discont' to their 2*pi complement along the given axis.
+ """
+ Unwrap by changing deltas between values to 2*pi complement.
+
+ Unwrap radian phase `p` by changing absolute jumps greater than
+ `discont` to their 2*pi complement along the given axis.
+
+ Parameters
+ ----------
+ p : array_like
+ Input array.
+ discont : float
+ Maximum discontinuity between values.
+ axis : integer
+ Axis along which unwrap will operate.
+
+ Returns
+ -------
+ out : ndarray
+ Output array
+
"""
p = asarray(p)
nd = len(p.shape)
@@ -867,10 +1187,18 @@ def unwrap(p, discont=pi, axis=-1):
return up
def sort_complex(a):
- """ Sort 'a' as a complex array using the real part first and then
- the imaginary part if the real part is equal (the default sort order
- for complex arrays). This function is a wrapper ensuring a complex
- return type.
+ """
+ Sort a complex array using the real part first, then the imaginary part.
+
+ Parameters
+ ----------
+ a : array_like
+ Input array
+
+ Returns
+ -------
+ out : complex ndarray
+ Always returns a sorted complex array.
"""
b = array(a,copy=True)
@@ -886,7 +1214,16 @@ def sort_complex(a):
return b
def trim_zeros(filt, trim='fb'):
- """ Trim the leading and trailing zeros from a 1D array.
+ """
+ Trim the leading and trailing zeros from a 1D array.
+
+ Parameters
+ ----------
+ filt : array_like
+ Input array.
+ trim : string, optional
+ A string with 'f' representing trim from front and 'b' to trim from
+ back.
Examples
--------
@@ -914,12 +1251,25 @@ if sys.hexversion < 0x2040000:
def unique(x):
"""
- Return sorted unique items from an array or sequence.
+ Return the sorted, unique elements of an array or sequence.
+
+ Parameters
+ ----------
+ x : array_like
+ Input array.
+
+ Returns
+ -------
+ y : ndarray
+ The sorted, unique elements are returned in a 1-D array.
Examples
--------
- >>> np.unique([5,2,4,0,4,4,2,2,1])
- array([0, 1, 2, 4, 5])
+ >>> np.unique([1, 1, 2, 2, 3, 3])
+ array([1, 2, 3])
+ >>> a = np.array([[1, 1], [2, 3]])
+ >>> np.unique(a)
+ array([1, 2, 3])
"""
try:
@@ -935,10 +1285,44 @@ def unique(x):
return asarray(items)
def extract(condition, arr):
- """Return the elements of ravel(arr) where ravel(condition) is True
- (in 1D).
+ """
+ Return the elements of an array that satisfy some condition.
+
+ This is equivalent to ``np.compress(ravel(condition), ravel(arr))``. If
+ `condition` is boolean ``np.extract`` is equivalent to ``arr[condition]``.
+
+ Parameters
+ ----------
+ condition : array_like
+ An array whose nonzero or True entries indicate the elements of `arr`
+ to extract.
+ arr : array_like
+ Input array of the same size as `condition`.
+
+ See Also
+ --------
+ take, put, putmask
+
+ Examples
+ --------
+ >>> arr = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
+ >>> arr
+ array([[ 1, 2, 3, 4],
+ [ 5, 6, 7, 8],
+ [ 9, 10, 11, 12]])
+ >>> condition = np.mod(arr, 3)==0
+ >>> condition
+ array([[False, False, True, False],
+ [False, True, False, False],
+ [ True, False, False, True]], dtype=bool)
+ >>> np.extract(condition, arr)
+ array([ 3, 6, 9, 12])
+
+ If `condition` is boolean:
+
+ >>> arr[condition]
+ array([ 3, 6, 9, 12])
- Equivalent to compress(ravel(condition), ravel(arr)).
"""
return _nx.take(ravel(arr), nonzero(ravel(condition))[0])
@@ -951,7 +1335,29 @@ def place(arr, mask, vals):
return _insert(arr, mask, vals)
def nansum(a, axis=None):
- """Sum the array over the given axis, treating NaNs as 0.
+ """
+ Sum the array along the given axis, treating NaNs as zero.
+
+ Parameters
+ ----------
+ a : array-like
+ Input array.
+ axis : {int, None}, optional
+ Axis along which the sum is computed. By default `a` is flattened.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The sum ignoring NaNs.
+
+ Examples
+ --------
+ >>> np.nansum([np.nan, 1])
+ 1.0
+ >>> a = np.array([[1, 1], [1, np.nan]])
+ >>> np.nansum(a, axis=0)
+ array([ 2., 1.])
+
"""
y = array(a,subok=True)
if not issubclass(y.dtype.type, _nx.integer):
@@ -959,7 +1365,31 @@ def nansum(a, axis=None):
return y.sum(axis)
def nanmin(a, axis=None):
- """Find the minimium over the given axis, ignoring NaNs.
+ """
+ Find the minimum along the given axis, ignoring NaNs.
+
+ Parameters
+ ----------
+ a : array_like
+ Input array.
+ axis : int, optional
+ Axis along which the minimum is computed. By default `a` is flattened.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The minimum ignoring NaNs.
+
+ Examples
+ --------
+ >>> a = np.array([[1, 2], [3, np.nan]])
+ >>> np.nanmin(a)
+ 1.0
+ >>> np.nanmin(a, axis=0)
+ array([ 1., 2.])
+ >>> np.nanmin(a, axis=1)
+ array([ 1., 3.])
+
"""
y = array(a,subok=True)
if not issubclass(y.dtype.type, _nx.integer):
@@ -967,7 +1397,12 @@ def nanmin(a, axis=None):
return y.min(axis)
def nanargmin(a, axis=None):
- """Find the indices of the minimium over the given axis ignoring NaNs.
+ """
+ Return indices of the minimum values along the given axis of `a`,
+ ignoring NaNs.
+
+ Refer to `numpy.nanargmax` for detailed documentation.
+
"""
y = array(a, subok=True)
if not issubclass(y.dtype.type, _nx.integer):
@@ -975,7 +1410,31 @@ def nanargmin(a, axis=None):
return y.argmin(axis)
def nanmax(a, axis=None):
- """Find the maximum over the given axis ignoring NaNs.
+ """
+ Find the maximum along the given axis, ignoring NaNs.
+
+ Parameters
+ ----------
+ a : array-like
+ Input array.
+ axis : {int, None}, optional
+ Axis along which the maximum is computed. By default `a` is flattened.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The maximum ignoring NaNs.
+
+ Examples
+ --------
+ >>> a = np.array([[1, 2], [3, np.nan]])
+ >>> np.nanmax(a)
+ 3.0
+ >>> np.nanmax(a, axis=0)
+ array([ 3., 2.])
+ >>> np.nanmax(a, axis=1)
+ array([ 2., 3.])
+
"""
y = array(a, subok=True)
if not issubclass(y.dtype.type, _nx.integer):
@@ -983,7 +1442,38 @@ def nanmax(a, axis=None):
return y.max(axis)
def nanargmax(a, axis=None):
- """Find the maximum over the given axis ignoring NaNs.
+ """
+ Return indices of the maximum values over the given axis of 'a',
+ ignoring NaNs.
+
+ Parameters
+ ----------
+ a : array-like
+ Input data.
+ axis : int, optional
+ Axis along which to operate. By default flattened input is used.
+
+ Returns
+ -------
+ index_array : {ndarray, int}
+ An array of indices or a single index value.
+
+ See Also
+ --------
+ argmax
+
+ Examples
+ --------
+ >>> a = np.array([[np.nan, 4], [2, 3]])
+ >>> np.argmax(a)
+ 0
+ >>> np.nanargmax(a)
+ 1
+ >>> np.nanargmax(a, axis=0)
+ array([1, 1])
+ >>> np.nanargmax(a, axis=1)
+ array([1, 0])
+
"""
y = array(a,subok=True)
if not issubclass(y.dtype.type, _nx.integer):
@@ -1144,20 +1634,77 @@ class vectorize(object):
return _res
def cov(m, y=None, rowvar=1, bias=0):
- """Estimate the covariance matrix.
+ """
+ Estimate a covariance matrix, given data.
- If m is a vector, return the variance. For matrices return the
- covariance matrix.
+ Covariance indicates the level to which two variables vary together.
+ If we examine N-dimensional samples, :math:`X = [x_1, x_2, ... x_N]^T`,
+ then the covariance matrix element :math:`C_{ij}` is the covariance of
+ :math:`x_i` and :math:`x_j`. The element :math:`C_{ii}` is the variance
+ of :math:`x_i`.
- If y is given it is treated as an additional (set of)
- variable(s).
+ Parameters
+ ----------
+ m : array-like
+ A 1D or 2D array containing multiple variables and observations.
+ Each row of `m` represents a variable, and each column a single
+ observation of all those variables. Also see `rowvar` below.
+ y : array-like, optional
+ An additional set of variables and observations. `y` has the same
+ form as that of `m`.
+ rowvar : int, optional
+ If `rowvar` is non-zero (default), then each row represents a
+ variable, with observations in the columns. Otherwise, the relationship
+ is transposed: each column represents a variable, while the rows
+ contain observations.
+ bias : int, optional
+ Default normalization is by ``(N-1)``, where ``N`` is the number of
+ observations given (unbiased estimate). If `bias` is 1, then
+ normalization is by ``N``.
- Normalization is by (N-1) where N is the number of observations
- (unbiased estimate). If bias is 1 then normalization is by N.
+ Returns
+ -------
+ out : ndarray
+ The covariance matrix of the variables.
+
+ See Also
+ --------
+ corrcoef : Normalized covariance matrix
+
+ Examples
+ --------
+ Consider two variables, :math:`x_0` and :math:`x_1`, which
+ correlate perfectly, but in opposite directions:
+
+ >>> x = np.array([[0, 2], [1, 1], [2, 0]]).T
+ >>> x
+ array([[0, 1, 2],
+ [2, 1, 0]])
+
+ Note how :math:`x_0` increases while :math:`x_1` decreases. The covariance
+ matrix shows this clearly:
+
+ >>> np.cov(x)
+ array([[ 1., -1.],
+ [-1., 1.]])
+
+ Note that element :math:`C_{0,1}`, which shows the correlation between
+ :math:`x_0` and :math:`x_1`, is negative.
+
+ Further, note how `x` and `y` are combined:
+
+ >>> x = [-2.1, -1, 4.3]
+ >>> y = [3, 1.1, 0.12]
+ >>> X = np.vstack((x,y))
+ >>> print np.cov(X)
+ [[ 11.71 -4.286 ]
+ [ -4.286 2.14413333]]
+ >>> print np.cov(x, y)
+ [[ 11.71 -4.286 ]
+ [ -4.286 2.14413333]]
+ >>> print np.cov(x)
+ 11.71
- If rowvar is non-zero (default), then each row is a variable with
- observations in the columns, otherwise each column
- is a variable and the observations are in the rows.
"""
X = array(m, ndmin=2, dtype=float)
@@ -1192,7 +1739,21 @@ def cov(m, y=None, rowvar=1, bias=0):
return (dot(X, X.T.conj()) / fact).squeeze()
def corrcoef(x, y=None, rowvar=1, bias=0):
- """The correlation coefficients
+ """
+ Correlation coefficients.
+
+ Please refer to the documentation for `cov` for more detail. The
+ relationship between the correlation coefficient matrix, P, and the
+ covariance matrix, C, is
+
+ .. math:: P_{ij} = \\frac{ C_{ij} } { \\sqrt{ C_{ii} * C_{jj} } }
+
+ The values of P are between -1 and 1.
+
+ See Also
+ --------
+ cov : Covariance matrix
+
"""
c = cov(x, y, rowvar, bias)
try:
@@ -1202,7 +1763,88 @@ def corrcoef(x, y=None, rowvar=1, bias=0):
return c/sqrt(multiply.outer(d,d))
def blackman(M):
- """blackman(M) returns the M-point Blackman window.
+ """
+ Return the Blackman window.
+
+ The Blackman window is a taper formed by using the the first
+ three terms of a summation of cosines. It was designed to have close
+ to the minimal leakage possible.
+ It is close to optimal, only slightly worse than a Kaiser window.
+
+ Parameters
+ ----------
+ M : int
+ Number of points in the output window. If zero or less, an
+ empty array is returned.
+
+ Returns
+ -------
+ out : array
+ The window, normalized to one (the value one
+ appears only if the number of samples is odd).
+
+ See Also
+ --------
+ bartlett, hamming, hanning, kaiser
+
+ Notes
+ -----
+ The Blackman window is defined as
+
+ .. math:: w(n) = 0.42 - 0.5 \\cos(2\\pi n/M) + 0.08 \\cos(4\\pi n/M)
+
+
+ Most references to the Blackman window come from the signal processing
+ literature, where it is used as one of many windowing functions for
+ smoothing values. It is also known as an apodization (which means
+ "removing the foot", i.e. smoothing discontinuities at the beginning
+ and end of the sampled signal) or tapering function. It is known as a
+ "near optimal" tapering function, almost as good (by some measures)
+ as the kaiser window.
+
+ References
+ ----------
+ .. [1] Blackman, R.B. and Tukey, J.W., (1958) The measurement of power
+ spectra, Dover Publications, New York.
+ .. [2] Wikipedia, "Window function",
+ http://en.wikipedia.org/wiki/Window_function
+ .. [3] Oppenheim, A.V., and R.W. Schafer. Discrete-Time Signal Processing.
+ Upper Saddle River, NJ: Prentice-Hall, 1999, pp. 468-471.
+
+ Examples
+ --------
+ >>> from numpy import blackman
+ >>> blackman(12)
+ array([ -1.38777878e-17, 3.26064346e-02, 1.59903635e-01,
+ 4.14397981e-01, 7.36045180e-01, 9.67046769e-01,
+ 9.67046769e-01, 7.36045180e-01, 4.14397981e-01,
+ 1.59903635e-01, 3.26064346e-02, -1.38777878e-17])
+
+
+ Plot the window and the frequency response:
+
+ >>> from numpy import clip, log10, array, bartlett
+ >>> from scipy.fftpack import fft, fftshift
+ >>> import matplotlib.pyplot as plt
+
+ >>> window = blackman(51)
+ >>> plt.plot(window)
+ >>> plt.title("Blackman window")
+ >>> plt.ylabel("Amplitude")
+ >>> plt.xlabel("Sample")
+ >>> plt.show()
+
+ >>> A = fft(window, 2048) / 25.5
+ >>> mag = abs(fftshift(A))
+ >>> freq = linspace(-0.5,0.5,len(A))
+ >>> response = 20*log10(mag)
+ >>> response = clip(response,-100,100)
+ >>> plt.plot(freq, response)
+ >>> plt.title("Frequency response of Bartlett window")
+ >>> plt.ylabel("Magnitude [dB]")
+ >>> plt.xlabel("Normalized frequency [cycles per sample]")
+ >>> plt.axis('tight'); plt.show()
+
"""
if M < 1:
return array([])
@@ -1241,7 +1883,7 @@ def bartlett(M):
-----
The Bartlett window is defined as
- .. math:: w(n) = \\frac{2}{M-1} \left(
+ .. math:: w(n) = \\frac{2}{M-1} \\left(
\\frac{M-1}{2} - \\left|n - \\frac{M-1}{2}\\right|
\\right)
@@ -1251,19 +1893,24 @@ def bartlett(M):
window produces linear interpolation. It is also known as an
apodization (which means"removing the foot", i.e. smoothing
discontinuities at the beginning and end of the sampled signal) or
- tapering function.
+ tapering function. The fourier transform of the Bartlett is the product
+ of two sinc functions.
+ Note the excellent discussion in Kanasewich.
References
----------
.. [1] M.S. Bartlett, "Periodogram Analysis and Continuous Spectra",
Biometrika 37, 1-16, 1950.
- .. [2] A.V. Oppenheim and R.W. Schafer, "Discrete-Time Signal
+ .. [2] E.R. Kanasewich, "Time Sequence Analysis in Geophysics",
+ The University of Alberta Press, 1975, pp. 109-110.
+ .. [3] A.V. Oppenheim and R.W. Schafer, "Discrete-Time Signal
Processing", Prentice-Hall, 1999, pp. 468-471.
- .. [3] Wikipedia, "Window function",
+ .. [4] Wikipedia, "Window function",
http://en.wikipedia.org/wiki/Window_function
- .. [4] W.H. Press, B.P. Flannery, S.A. Teukolsky, and W.T. Vetterling,
+ .. [5] W.H. Press, B.P. Flannery, S.A. Teukolsky, and W.T. Vetterling,
"Numerical Recipes", Cambridge University Press, 1986, page 429.
+
Examples
--------
>>> np.bartlett(12)
@@ -1273,26 +1920,27 @@ def bartlett(M):
Plot the window and its frequency response (requires SciPy and matplotlib):
- from scipy.fftpack import fft
- from matplotlib import pyplot as plt
-
- window = np.bartlett(51)
- plt.plot(window) #doctest: SKIP
- plt.title("Bartlett window")
- plt.ylabel("Amplitude")
- plt.xlabel("Sample")
- plt.show()
-
- A = fft(window, 2048) / 25.5
- mag = abs(np.fft.fftshift(A))
- freq = linspace(-0.5,0.5,len(A))
- response = 20*np.log10(mag)
- response = np.clip(response,-100,100)
- plt.plot(freq, response)
- plt.title("Frequency response of Bartlett window")
- plt.ylabel("Magnitude [dB]")
- plt.xlabel("Normalized frequency [cycles per sample]")
- plt.axis('tight'); plt.show()
+ >>> from numpy import clip, log10, array, bartlett
+ >>> from numpy.fft import fft
+ >>> import matplotlib.pyplot as plt
+
+ >>> window = bartlett(51)
+ >>> plt.plot(window)
+ >>> plt.title("Bartlett window")
+ >>> plt.ylabel("Amplitude")
+ >>> plt.xlabel("Sample")
+ >>> plt.show()
+
+ >>> A = fft(window, 2048) / 25.5
+ >>> mag = abs(fftshift(A))
+ >>> freq = linspace(-0.5,0.5,len(A))
+ >>> response = 20*log10(mag)
+ >>> response = clip(response,-100,100)
+ >>> plt.plot(freq, response)
+ >>> plt.title("Frequency response of Bartlett window")
+ >>> plt.ylabel("Magnitude [dB]")
+ >>> plt.xlabel("Normalized frequency [cycles per sample]")
+ >>> plt.axis('tight'); plt.show()
"""
if M < 1:
@@ -1303,7 +1951,87 @@ def bartlett(M):
return where(less_equal(n,(M-1)/2.0),2.0*n/(M-1),2.0-2.0*n/(M-1))
def hanning(M):
- """hanning(M) returns the M-point Hanning window.
+ """
+ Return the Hanning window.
+
+ The Hanning window is a taper formed by using a weighted cosine.
+
+ Parameters
+ ----------
+ M : int
+ Number of points in the output window. If zero or less, an
+ empty array is returned.
+
+ Returns
+ -------
+ out : array
+ The window, normalized to one (the value one
+ appears only if the number of samples is odd).
+
+ See Also
+ --------
+ bartlett, blackman, hamming, kaiser
+
+ Notes
+ -----
+ The Hanning window is defined as
+
+ .. math:: w(n) = 0.5 - 0.5cos\\left(\\frac{2\\pi{n}}{M-1}\\right)
+ \\qquad 0 \\leq n \\leq M-1
+
+ The Hanning was named for Julius van Hann, an Austrian meterologist. It is
+ also known as the Cosine Bell. Some authors prefer that it be called a
+ Hann window, to help avoid confusion with the very similar Hamming window.
+
+ Most references to the Hanning window come from the signal processing
+ literature, where it is used as one of many windowing functions for
+ smoothing values. It is also known as an apodization (which means
+ "removing the foot", i.e. smoothing discontinuities at the beginning
+ and end of the sampled signal) or tapering function.
+
+ References
+ ----------
+ .. [1] Blackman, R.B. and Tukey, J.W., (1958) The measurement of power
+ spectra, Dover Publications, New York.
+ .. [2] E.R. Kanasewich, "Time Sequence Analysis in Geophysics",
+ The University of Alberta Press, 1975, pp. 106-108.
+ .. [3] Wikipedia, "Window function",
+ http://en.wikipedia.org/wiki/Window_function
+ .. [4] W.H. Press, B.P. Flannery, S.A. Teukolsky, and W.T. Vetterling,
+ "Numerical Recipes", Cambridge University Press, 1986, page 425.
+
+ Examples
+ --------
+ >>> from numpy import hanning
+ >>> hanning(12)
+ array([ 0. , 0.07937323, 0.29229249, 0.57115742, 0.82743037,
+ 0.97974649, 0.97974649, 0.82743037, 0.57115742, 0.29229249,
+ 0.07937323, 0. ])
+
+ Plot the window and its frequency response:
+
+ >>> from numpy.fft import fft, fftshift
+ >>> import matplotlib.pyplot as plt
+
+ >>> window = np.hanning(51)
+ >>> plt.subplot(121)
+ >>> plt.plot(window)
+ >>> plt.title("Hann window")
+ >>> plt.ylabel("Amplitude")
+ >>> plt.xlabel("Sample")
+
+ >>> A = fft(window, 2048) / 25.5
+ >>> mag = abs(fftshift(A))
+ >>> freq = np.linspace(-0.5,0.5,len(A))
+ >>> response = 20*np.log10(mag)
+ >>> response = np.clip(response,-100,100)
+ >>> plt.subplot(122)
+ >>> plt.plot(freq, response)
+ >>> plt.title("Frequency response of the Hann window")
+ >>> plt.ylabel("Magnitude [dB]")
+ >>> plt.xlabel("Normalized frequency [cycles per sample]")
+ >>> plt.axis('tight'); plt.show()
+
"""
if M < 1:
return array([])
@@ -1313,7 +2041,86 @@ def hanning(M):
return 0.5-0.5*cos(2.0*pi*n/(M-1))
def hamming(M):
- """hamming(M) returns the M-point Hamming window.
+ """
+ Return the Hamming window.
+
+ The Hamming window is a taper formed by using a weighted cosine.
+
+ Parameters
+ ----------
+ M : int
+ Number of points in the output window. If zero or less, an
+ empty array is returned.
+
+ Returns
+ -------
+ out : ndarray
+ The window, normalized to one (the value one
+ appears only if the number of samples is odd).
+
+ See Also
+ --------
+ bartlett, blackman, hanning, kaiser
+
+ Notes
+ -----
+ The Hamming window is defined as
+
+ .. math:: w(n) = 0.54 + 0.46cos\\left(\\frac{2\\pi{n}}{M-1}\\right)
+ \\qquad 0 \\leq n \\leq M-1
+
+ The Hamming was named for R. W. Hamming, an associate of J. W. Tukey and
+ is described in Blackman and Tukey. It was recommended for smoothing the
+ truncated autocovariance function in the time domain.
+ Most references to the Hamming window come from the signal processing
+ literature, where it is used as one of many windowing functions for
+ smoothing values. It is also known as an apodization (which means
+ "removing the foot", i.e. smoothing discontinuities at the beginning
+ and end of the sampled signal) or tapering function.
+
+ References
+ ----------
+ .. [1] Blackman, R.B. and Tukey, J.W., (1958) The measurement of power
+ spectra, Dover Publications, New York.
+ .. [2] E.R. Kanasewich, "Time Sequence Analysis in Geophysics", The
+ University of Alberta Press, 1975, pp. 109-110.
+ .. [3] Wikipedia, "Window function",
+ http://en.wikipedia.org/wiki/Window_function
+ .. [4] W.H. Press, B.P. Flannery, S.A. Teukolsky, and W.T. Vetterling,
+ "Numerical Recipes", Cambridge University Press, 1986, page 425.
+
+ Examples
+ --------
+ >>> from numpy import hamming
+ >>> hamming(12)
+ array([ 0.08 , 0.15302337, 0.34890909, 0.60546483, 0.84123594,
+ 0.98136677, 0.98136677, 0.84123594, 0.60546483, 0.34890909,
+ 0.15302337, 0.08 ])
+
+ Plot the window and the frequency response:
+
+ >>> from numpy import clip, log10, array, hamming
+ >>> from scipy.fftpack import fft, fftshift
+ >>> import matplotlib.pyplot as plt
+
+ >>> window = hamming(51)
+ >>> plt.plot(window)
+ >>> plt.title("Hamming window")
+ >>> plt.ylabel("Amplitude")
+ >>> plt.xlabel("Sample")
+ >>> plt.show()
+
+ >>> A = fft(window, 2048) / 25.5
+ >>> mag = abs(fftshift(A))
+ >>> freq = linspace(-0.5,0.5,len(A))
+ >>> response = 20*log10(mag)
+ >>> response = clip(response,-100,100)
+ >>> plt.plot(freq, response)
+ >>> plt.title("Frequency response of Hamming window")
+ >>> plt.ylabel("Magnitude [dB]")
+ >>> plt.xlabel("Normalized frequency [cycles per sample]")
+ >>> plt.axis('tight'); plt.show()
+
"""
if M < 1:
return array([])
@@ -1401,6 +2208,27 @@ def _i0_2(x):
return exp(x) * _chbevl(32.0/x - 2.0, _i0B) / sqrt(x)
def i0(x):
+ """
+ Modified Bessel function of the first kind, order 0, :math:`I_0`
+
+ Parameters
+ ----------
+ x : array-like, dtype float or complex
+ Argument of the Bessel function.
+
+ Returns
+ -------
+ out : ndarray, shape z.shape, dtype z.dtype
+ The modified Bessel function evaluated for all elements of `x`.
+
+ Examples
+ --------
+ >>> np.i0([0.])
+ array(1.0)
+ >>> np.i0([0., 1. + 2j])
+ array([ 1.00000000+0.j , 0.18785373+0.64616944j])
+
+ """
x = atleast_1d(x).copy()
y = empty_like(x)
ind = (x<0)
@@ -1414,8 +2242,117 @@ def i0(x):
## End of cephes code for i0
def kaiser(M,beta):
- """kaiser(M, beta) returns a Kaiser window of length M with shape parameter
- beta.
+ """
+ Return the Kaiser window.
+
+ The Kaiser window is a taper formed by using a Bessel function.
+
+ Parameters
+ ----------
+ M : int
+ Number of points in the output window. If zero or less, an
+ empty array is returned.
+ beta : float
+ Shape parameter for window.
+
+ Returns
+ -------
+ out : array
+ The window, normalized to one (the value one
+ appears only if the number of samples is odd).
+
+ See Also
+ --------
+ bartlett, blackman, hamming, hanning
+
+ Notes
+ -----
+ The Kaiser window is defined as
+
+ .. math:: w(n) = I_0\\left( \\beta \\sqrt{1-\\frac{4n^2}{(M-1)^2}}
+ \\right)/I_0(\\beta)
+
+ with
+
+ .. math:: \\quad -\\frac{M-1}{2} \\leq n \\leq \\frac{M-1}{2},
+
+ where :math:`I_0` is the modified zeroth-order Bessel function.
+
+ The Kaiser was named for Jim Kaiser, who discovered a simple approximation
+ to the DPSS window based on Bessel functions.
+ The Kaiser window is a very good approximation to the Digital Prolate
+ Spheroidal Sequence, or Slepian window, which is the transform which
+ maximizes the energy in the main lobe of the window relative to total
+ energy.
+
+ The Kaiser can approximate many other windows by varying the beta
+ parameter.
+
+ ==== =======================
+ beta Window shape
+ ==== =======================
+ 0 Rectangular
+ 5 Similar to a Hamming
+ 6 Similar to a Hanning
+ 8.6 Similar to a Blackman
+ ==== =======================
+
+ A beta value of 14 is probably a good starting point. Note that as beta
+ gets large, the window narrows, and so the number of samples needs to be
+ large enough to sample the increasingly narrow spike, otherwise nans will
+ get returned.
+
+
+ Most references to the Kaiser window come from the signal processing
+ literature, where it is used as one of many windowing functions for
+ smoothing values. It is also known as an apodization (which means
+ "removing the foot", i.e. smoothing discontinuities at the beginning
+ and end of the sampled signal) or tapering function.
+
+ References
+ ----------
+ .. [1] J. F. Kaiser, "Digital Filters" - Ch 7 in "Systems analysis by
+ digital computer", Editors: F.F. Kuo and J.F. Kaiser, p 218-285.
+ John Wiley and Sons, New York, (1966).
+ .. [2]\tE.R. Kanasewich, "Time Sequence Analysis in Geophysics", The
+ University of Alberta Press, 1975, pp. 177-178.
+ .. [3] Wikipedia, "Window function",
+ http://en.wikipedia.org/wiki/Window_function
+
+ Examples
+ --------
+ >>> from numpy import kaiser
+ >>> kaiser(12, 14)
+ array([ 7.72686684e-06, 3.46009194e-03, 4.65200189e-02,
+ 2.29737120e-01, 5.99885316e-01, 9.45674898e-01,
+ 9.45674898e-01, 5.99885316e-01, 2.29737120e-01,
+ 4.65200189e-02, 3.46009194e-03, 7.72686684e-06])
+
+
+ Plot the window and the frequency response:
+
+ >>> from numpy import clip, log10, array, kaiser
+ >>> from scipy.fftpack import fft, fftshift
+ >>> import matplotlib.pyplot as plt
+
+ >>> window = kaiser(51, 14)
+ >>> plt.plot(window)
+ >>> plt.title("Kaiser window")
+ >>> plt.ylabel("Amplitude")
+ >>> plt.xlabel("Sample")
+ >>> plt.show()
+
+ >>> A = fft(window, 2048) / 25.5
+ >>> mag = abs(fftshift(A))
+ >>> freq = linspace(-0.5,0.5,len(A))
+ >>> response = 20*log10(mag)
+ >>> response = clip(response,-100,100)
+ >>> plt.plot(freq, response)
+ >>> plt.title("Frequency response of Kaiser window")
+ >>> plt.ylabel("Magnitude [dB]")
+ >>> plt.xlabel("Normalized frequency [cycles per sample]")
+ >>> plt.axis('tight'); plt.show()
+
"""
from numpy.dual import i0
n = arange(0,M)
@@ -1423,7 +2360,74 @@ def kaiser(M,beta):
return i0(beta * sqrt(1-((n-alpha)/alpha)**2.0))/i0(beta)
def sinc(x):
- """sinc(x) returns sin(pi*x)/(pi*x) at all points of array x.
+ """
+ Return the sinc function.
+
+ The sinc function is :math:`\\sin(\\pi x)/(\\pi x)`.
+
+ Parameters
+ ----------
+ x : ndarray
+ Array (possibly multi-dimensional) of values for which to to
+ calculate ``sinc(x)``.
+
+ Returns
+ -------
+ out : ndarray
+ ``sinc(x)``, which has the same shape as the input.
+
+ Notes
+ -----
+ ``sinc(0)`` is the limit value 1.
+
+ The name sinc is short for "sine cardinal" or "sinus cardinalis".
+
+ The sinc function is used in various signal processing applications,
+ including in anti-aliasing, in the construction of a
+ Lanczos resampling filter, and in interpolation.
+
+ For bandlimited interpolation of discrete-time signals, the ideal
+ interpolation kernel is proportional to the sinc function.
+
+ References
+ ----------
+ .. [1] Weisstein, Eric W. "Sinc Function." From MathWorld--A Wolfram Web
+ Resource. http://mathworld.wolfram.com/SincFunction.html
+ .. [2] Wikipedia, "Sinc function",
+ http://en.wikipedia.org/wiki/Sinc_function
+
+ Examples
+ --------
+ >>> x = np.arange(-20., 21.)/5.
+ >>> np.sinc(x)
+ array([ -3.89804309e-17, -4.92362781e-02, -8.40918587e-02,
+ -8.90384387e-02, -5.84680802e-02, 3.89804309e-17,
+ 6.68206631e-02, 1.16434881e-01, 1.26137788e-01,
+ 8.50444803e-02, -3.89804309e-17, -1.03943254e-01,
+ -1.89206682e-01, -2.16236208e-01, -1.55914881e-01,
+ 3.89804309e-17, 2.33872321e-01, 5.04551152e-01,
+ 7.56826729e-01, 9.35489284e-01, 1.00000000e+00,
+ 9.35489284e-01, 7.56826729e-01, 5.04551152e-01,
+ 2.33872321e-01, 3.89804309e-17, -1.55914881e-01,
+ -2.16236208e-01, -1.89206682e-01, -1.03943254e-01,
+ -3.89804309e-17, 8.50444803e-02, 1.26137788e-01,
+ 1.16434881e-01, 6.68206631e-02, 3.89804309e-17,
+ -5.84680802e-02, -8.90384387e-02, -8.40918587e-02,
+ -4.92362781e-02, -3.89804309e-17])
+
+ >>> import matplotlib.pyplot as plt
+ >>> plt.plot(x, sinc(x))
+ >>> plt.title("Sinc Function")
+ >>> plt.ylabel("Amplitude")
+ >>> plt.xlabel("X")
+ >>> plt.show()
+
+ It works in 2-D as well:
+
+ >>> x = np.arange(-200., 201.)/50.
+ >>> xx = np.outer(x, x)
+ >>> plt.imshow(sinc(xx))
+
"""
y = pi* where(x == 0, 1.0e-20, x)
return sin(y)/y
@@ -1434,7 +2438,8 @@ def msort(a):
return b
def median(a, axis=0, out=None, overwrite_input=False):
- """Compute the median along the specified axis.
+ """
+ Compute the median along the specified axis.
Returns the median of the array elements. The median is taken
over the first axis of the array by default, otherwise over
@@ -1442,44 +2447,44 @@ def median(a, axis=0, out=None, overwrite_input=False):
Parameters
----------
- a : array-like
- Input array or object that can be converted to an array
+ a : array_like
+ Input array or object that can be converted to an array.
axis : {int, None}, optional
Axis along which the medians are computed. The default is to
- compute the median along the first dimension. axis=None
- returns the median of the flattened array
-
+ compute the median along the first dimension. If `axis` is
+ set to None, return the median of the flattened array.
out : ndarray, optional
Alternative output array in which to place the result. It must
- have the same shape and buffer length as the expected output
- but the type will be cast if necessary.
-
+ have the same shape and buffer length as the expected output,
+ but the type (of the output) will be cast if necessary.
overwrite_input : {False, True}, optional
If True, then allow use of memory of input array (a) for
calculations. The input array will be modified by the call to
median. This will save memory when you do not need to preserve
the contents of the input array. Treat the input as undefined,
but it will probably be fully or partially sorted. Default is
- False. Note that, if overwrite_input is true, and the input
+ False. Note that, if `overwrite_input` is True and the input
is not already an ndarray, an error will be raised.
Returns
-------
- median : ndarray.
- A new array holding the result is returned unless out is
- specified, in which case a reference to out is returned.
- Return datatype is float64 for ints and floats smaller than
- float64, or the input datatype otherwise.
+ median : ndarray
+ A new array holding the result (unless `out` is specified, in
+ which case that array is returned instead). If the input contains
+ integers, or floats of smaller precision than 64, then the output
+ data-type is float64. Otherwise, the output data-type is the same
+ as that of the input.
See Also
- -------
+ --------
mean
Notes
-----
- Given a vector V length N, the median of V is the middle value of
- a sorted copy of V (Vs) - i.e. Vs[(N-1)/2], when N is odd. It is
- the mean of the two middle values of Vs, when N is even.
+ Given a vector V of length N, the median of V is the middle value of
+ a sorted copy of V, ``V_sorted`` - i.e., ``V_sorted[(N-1)/2]``, when N is
+ odd. When N is even, it is the average of the two middle values of
+ ``V_sorted``.
Examples
--------
@@ -1507,6 +2512,7 @@ def median(a, axis=0, out=None, overwrite_input=False):
>>> np.median(b, axis=None, overwrite_input=True)
3.5
>>> assert not np.all(a==b)
+
"""
if overwrite_input:
if axis is None:
@@ -1531,8 +2537,29 @@ def median(a, axis=0, out=None, overwrite_input=False):
return mean(sorted[indexer], axis=axis, out=out)
def trapz(y, x=None, dx=1.0, axis=-1):
- """Integrate y(x) using samples along the given axis and the composite
- trapezoidal rule. If x is None, spacing given by dx is assumed.
+ """
+ Integrate along the given axis using the composite trapezoidal rule.
+
+ Integrate `y` (`x`) along given axis.
+
+ Parameters
+ ----------
+ y : array_like
+ Input array to integrate.
+ x : {array_like, None}, optional
+ If `x` is None, then spacing between all `y` elements is 1.
+ dx : scalar, optional
+ If `x` is None, spacing given by `dx` is assumed.
+ axis : int, optional
+ Specify the axis.
+
+ Examples
+ --------
+ >>> np.trapz([1,2,3])
+ >>> 4.0
+ >>> np.trapz([1,2,3], [4,6,8])
+ >>> 8.0
+
"""
y = asarray(y)
if x is None:
@@ -1579,27 +2606,44 @@ def add_newdoc(place, obj, doc):
# From matplotlib
def meshgrid(x,y):
"""
- For vectors x, y with lengths Nx=len(x) and Ny=len(y), return X, Y
- where X and Y are (Ny, Nx) shaped arrays with the elements of x
- and y repeated to fill the matrix
+ Return coordinate matrices from two coordinate vectors.
+
+
- EG,
- [X, Y] = meshgrid([1,2,3], [4,5,6,7])
+ Parameters
+ ----------
+ x, y : ndarray
+ Two 1D arrays representing the x and y coordinates
- X =
- 1 2 3
- 1 2 3
- 1 2 3
- 1 2 3
+ Returns
+ -------
+ X, Y : ndarray
+ For vectors `x`, `y` with lengths Nx=len(`x`) and Ny=len(`y`),
+ return `X`, `Y` where `X` and `Y` are (Ny, Nx) shaped arrays
+ with the elements of `x` and y repeated to fill the matrix along
+ the first dimension for `x`, the second for `y`.
+ See Also
+ --------
+ numpy.mgrid : Construct a multi-dimensional "meshgrid"
+ using indexing notation.
+
+ Examples
+ --------
+ >>> X, Y = numpy.meshgrid([1,2,3], [4,5,6,7])
+ >>> X
+ array([[1, 2, 3],
+ [1, 2, 3],
+ [1, 2, 3],
+ [1, 2, 3]])
+ >>> Y
+ array([[4, 4, 4],
+ [5, 5, 5],
+ [6, 6, 6],
+ [7, 7, 7]])
- Y =
- 4 4 4
- 5 5 5
- 6 6 6
- 7 7 7
- """
+ """
x = asarray(x)
y = asarray(y)
numRows, numCols = len(y), len(x) # yes, reversed
@@ -1611,30 +2655,41 @@ def meshgrid(x,y):
return X, Y
def delete(arr, obj, axis=None):
- """Return a new array with sub-arrays along an axis deleted.
-
- Return a new array with the sub-arrays (i.e. rows or columns)
- deleted along the given axis as specified by obj
+ """
+ Return a new array with sub-arrays along an axis deleted.
- obj may be a slice_object (s_[3:5:2]) or an integer
- or an array of integers indicated which sub-arrays to
- remove.
+ Parameters
+ ----------
+ arr : array-like
+ Input array.
+ obj : slice, integer or an array of integers
+ Indicate which sub-arrays to remove.
+ axis : integer or None
+ The axis along which to delete the subarray defined by `obj`.
+ If `axis` is None, `obj` is applied to the flattened array.
- If axis is None, then ravel the array first.
+ See Also
+ --------
+ insert : Insert values into an array.
+ append : Append values at the end of an array.
Examples
--------
- >>> arr = [[3,4,5],
- ... [1,2,3],
- ... [6,7,8]]
-
- >>> np.delete(arr, 1, 1)
- array([[3, 5],
- [1, 3],
- [6, 8]])
+ >>> arr = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
+ >>> arr
+ array([[ 1, 2, 3, 4],
+ [ 5, 6, 7, 8],
+ [ 9, 10, 11, 12]])
>>> np.delete(arr, 1, 0)
- array([[3, 4, 5],
- [6, 7, 8]])
+ array([[ 1, 2, 3, 4],
+ [ 9, 10, 11, 12]])
+ >>> np.delete(arr, np.s_[::2], 1)
+ array([[ 2, 4],
+ [ 6, 8],
+ [10, 12]])
+ >>> np.delete(arr, [1,3,5], None)
+ array([ 1, 3, 5, 7, 8, 9, 10, 11, 12])
+
"""
wrap = None
if type(arr) is not ndarray:
@@ -1718,26 +2773,33 @@ def delete(arr, obj, axis=None):
return new
def insert(arr, obj, values, axis=None):
- """Return a new array with values inserted along the given axis
- before the given indices
-
- If axis is None, then ravel the array first.
+ """
+ Insert values along the given axis before the given indices.
- The obj argument can be an integer, a slice, or a sequence of
- integers.
+ Parameters
+ ----------
+ arr : array_like
+ Input array.
+ obj : {integer, slice, integer array_like}
+ Insert `values` before `obj` indices.
+ values :
+ Values to insert into `arr`.
+ axis : int, optional
+ Axis along which to insert `values`. If `axis` is None then ravel
+ `arr` first.
Examples
--------
>>> a = np.array([[1,2,3],
... [4,5,6],
... [7,8,9]])
-
>>> np.insert(a, [1,2], [[4],[5]], axis=0)
array([[1, 2, 3],
[4, 4, 4],
[4, 5, 6],
[5, 5, 5],
[7, 8, 9]])
+
"""
wrap = None
if type(arr) is not ndarray:
@@ -1807,7 +2869,38 @@ def insert(arr, obj, values, axis=None):
return new
def append(arr, values, axis=None):
- """Append to the end of an array along axis (ravel first if None)
+ """
+ Append values to the end of an array.
+
+ Parameters
+ ----------
+ arr : array_like
+ Values are appended to a copy of this array.
+ values : array_like
+ These values are appended to a copy of `arr`. It must be of the
+ correct shape (the same shape as `arr`, excluding `axis`). If `axis`
+ is not specified, `values` can be any shape and will be flattened
+ before use.
+ axis : int, optional
+ The axis along which `values` are appended. If `axis` is not given,
+ both `arr` and `values` are flattened before use.
+
+ Returns
+ -------
+ out : ndarray
+ A copy of `arr` with `values` appended to `axis`. Note that `append`
+ does not occur in-place: a new array is allocated and filled.
+
+ Examples
+ --------
+ >>> np.append([1, 2, 3], [[4, 5, 6], [7, 8, 9]])
+ array([1, 2, 3, 4, 5, 6, 7, 8, 9])
+
+ >>> np.append([[1, 2, 3], [4, 5, 6]], [[7, 8, 9]], axis=0)
+ array([[1, 2, 3],
+ [4, 5, 6],
+ [7, 8, 9]])
+
"""
arr = asanyarray(arr)
if axis is None:
diff --git a/numpy/lib/getlimits.py b/numpy/lib/getlimits.py
index cab741e2e..4c432c0e4 100644
--- a/numpy/lib/getlimits.py
+++ b/numpy/lib/getlimits.py
@@ -21,7 +21,46 @@ _convert_to_float = {
}
class finfo(object):
- """ Machine limits for floating point types.
+ """
+ Machine limits for floating point types.
+
+ Attributes
+ ----------
+ eps : floating point number of the appropriate type
+ The smallest representable number such that ``1.0 + eps != 1.0``.
+ epsneg : floating point number of the appropriate type
+ The smallest representable number such that ``1.0 - epsneg != 1.0``.
+ iexp : int
+ The number of bits in the exponent portion of the floating point
+ representation.
+ machar : MachAr
+ The object which calculated these parameters and holds more detailed
+ information.
+ machep : int
+ The exponent that yields ``eps``.
+ max : floating point number of the appropriate type
+ The largest representable number.
+ maxexp : int
+ The smallest positive power of the base (2) that causes overflow.
+ min : floating point number of the appropriate type
+ The smallest representable number, typically ``-max``.
+ minexp : int
+ The most negative power of the base (2) consistent with there being
+ no leading 0s in the mantissa.
+ negep : int
+ The exponent that yields ``epsneg``.
+ nexp : int
+ The number of bits in the exponent including its sign and bias.
+ nmant : int
+ The number of bits in the mantissa.
+ precision : int
+ The approximate number of decimal digits to which this kind of float
+ is precise.
+ resolution : floating point number of the appropriate type
+ The approximate decimal resolution of this type, i.e.
+ ``10**-precision``.
+ tiny : floating point number of the appropriate type
+ The smallest-magnitude usable number.
Parameters
----------
@@ -30,14 +69,18 @@ class finfo(object):
See Also
--------
- numpy.lib.machar.MachAr
+ numpy.lib.machar.MachAr :
+ The implementation of the tests that produce this information.
+ iinfo :
+ The equivalent for integer data types.
Notes
-----
For developers of numpy: do not instantiate this at the module level. The
initial calculation of these parameters is expensive and negatively impacts
- import times. These objects are cached, so calling `finfo()` repeatedly
+ import times. These objects are cached, so calling ``finfo()`` repeatedly
inside your functions is not a problem.
+
"""
_finfo_cache = {}
@@ -126,10 +169,47 @@ nexp =%(nexp)6s min= -max
class iinfo:
- """Limits for integer types.
+ """
+ Machine limits for integer types.
+
+ Attributes
+ ----------
+ min : int
+ The smallest integer expressible by the type.
+ max : int
+ The largest integer expressible by the type.
+
+ Parameters
+ ----------
+ type : integer type, dtype, or instance
+ The kind of integer data type to get information about.
+
+ See Also
+ --------
+ finfo : The equivalent for floating point data types.
+
+ Examples
+ --------
+ With types:
+
+ >>> ii16 = np.iinfo(np.int16)
+ >>> ii16.min
+ -32768
+ >>> ii16.max
+ 32767
+ >>> ii32 = np.iinfo(np.int32)
+ >>> ii32.min
+ -2147483648
+ >>> ii32.max
+ 2147483647
+
+ With instances:
- :Parameters:
- type : integer type or instance
+ >>> ii32 = np.iinfo(np.int32(10))
+ >>> ii32.min
+ -2147483648
+ >>> ii32.max
+ 2147483647
"""
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index 2024584d4..af87b24a6 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -17,19 +17,41 @@ makemat = matrix.matrix
# contributed by Stefan van der Walt
def unravel_index(x,dims):
- """Convert a flat index into an index tuple for an array of given shape.
+ """
+ Convert a flat index into an index tuple for an array of given shape.
e.g. for a 2x2 array, unravel_index(2,(2,2)) returns (1,0).
- Example usage:
- p = x.argmax()
- idx = unravel_index(p,x.shape)
- x[idx] == x.max()
+ Parameters
+ ----------
+ x : int
+ Flattened index.
+ dims : shape tuple
+ Input shape.
- Note: x.flat[p] == x.max()
+ Notes
+ -----
+ Since x.flat[p] == x.max() it may be easier to use flattened indexing
+ than to re-map the index to a tuple.
+
+ Examples
+ --------
+ >>> x = np.ones((5,4))
+ >>> x
+ array([[ 0, 1, 2, 3],
+ [ 4, 5, 6, 7],
+ [ 8, 9, 10, 11],
+ [12, 13, 14, 15],
+ [16, 17, 18, 19]])
+ >>> p = x.argmax()
+ >>> p
+ 19
+ >>> idx = np.unravel_index(p, x.shape)
+ >>> idx
+ (4, 3)
+ >>> x[idx] == x.max()
+ True
- Thus, it may be easier to use flattened indexing than to re-map
- the index to a tuple.
"""
if x > _nx.prod(dims)-1 or x < 0:
raise ValueError("Invalid index, must be 0 <= x <= number of elements.")
@@ -92,7 +114,7 @@ class nd_grid(object):
complex number, then the stop is not inclusive.
However, if the step length is a **complex number** (e.g. 5j), then the
- integer part of it's magnitude is interpreted as specifying the
+ integer part of its magnitude is interpreted as specifying the
number of points to create between the start and stop values, where
the stop value **is inclusive**.
@@ -342,9 +364,17 @@ c_ = CClass()
class ndenumerate(object):
"""
- A simple nd index iterator over an array.
+ Multidimensional index iterator.
- Example:
+ Return an iterator yielding pairs of array coordinates and values.
+
+ Parameters
+ ----------
+ a : ndarray
+ Input array.
+
+ Examples
+ --------
>>> a = np.array([[1,2],[3,4]])
>>> for index, x in np.ndenumerate(a):
... print index, x
@@ -352,6 +382,7 @@ class ndenumerate(object):
(0, 1) 2
(1, 0) 3
(1, 1) 4
+
"""
def __init__(self, arr):
self.iter = asarray(arr).flat
diff --git a/numpy/lib/io.py b/numpy/lib/io.py
index cc9cf65e0..41ffc51b8 100644
--- a/numpy/lib/io.py
+++ b/numpy/lib/io.py
@@ -80,33 +80,43 @@ class NpzFile(object):
raise KeyError, "%s is not a file in the archive" % key
def load(file, memmap=False):
- """Load a binary file.
-
- Read a binary file (either a pickle, or a binary .npy/.npz file) and
- return the result.
+ """
+ Load pickled, ``.npy``, and ``.npz`` binary files.
Parameters
----------
file : file-like object or string
- the file to read. It must support seek and read methods
+ The file to read. It must support seek and read methods.
memmap : bool
- If true, then memory-map the .npy file or unzip the .npz file into
- a temporary directory and memory-map each component
- This has no effect for a pickle.
+ If True, then memory-map the ``.npy`` file (or unzip the ``.npz`` file
+ into a temporary directory and memory-map each component). This has no
+ effect for a pickled file.
Returns
-------
result : array, tuple, dict, etc.
- data stored in the file.
- If file contains pickle data, then whatever is stored in the pickle is
- returned.
- If the file is .npy file, then an array is returned.
- If the file is .npz file, then a dictionary-like object is returned
- which has a filename:array key:value pair for every file in the zip.
+ Data stored in the file.
+
+ - If file contains pickle data, then whatever is stored in the
+ pickle is returned.
+
+ - If the file is a ``.npy`` file, then an array is returned.
+
+ - If the file is a ``.npz`` file, then a dictionary-like object is
+ returned, containing {filename: array} key-value pairs, one for
+ every file in the archive.
Raises
------
IOError
+ If the input file does not exist or cannot be read.
+
+ Examples
+ --------
+ >>> np.save('/tmp/123', np.array([1, 2, 3])
+ >>> np.load('/tmp/123.npy')
+ array([1, 2, 3])
+
"""
if isinstance(file, basestring):
fid = _file(file,"rb")
@@ -133,19 +143,29 @@ def load(file, memmap=False):
"Failed to interpret file %s as a pickle" % repr(file)
def save(file, arr):
- """Save an array to a binary file (a string or file-like object).
-
- If the file is a string, then if it does not have the .npy extension,
- it is appended and a file open.
+ """
+ Save an array to a binary file in NumPy format.
- Data is saved to the open file in NumPy-array format
+ Parameters
+ ----------
+ f : file or string
+ File or filename to which the data is saved. If the filename
+ does not already have a ``.npy`` extension, it is added.
+ x : array_like
+ Array data.
Examples
--------
- import numpy as np
- ...
- np.save('myfile', a)
- a = np.load('myfile.npy')
+ >>> from tempfile import TemporaryFile
+ >>> outfile = TemporaryFile()
+
+ >>> x = np.arange(10)
+ >>> np.save(outfile, x)
+
+ >>> outfile.seek(0)
+ >>> np.load(outfile)
+ array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+
"""
if isinstance(file, basestring):
if not file.endswith('.npy'):
@@ -226,53 +246,70 @@ def _string_like(obj):
def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters=None,
skiprows=0, usecols=None, unpack=False):
"""
- Load ASCII data from fname into an array and return the array.
+ Load data from a text file.
- The data must be regular, same number of values in every row
+ Each row in the text file must have the same number of values.
Parameters
----------
- fname : filename or a file handle.
- Support for gzipped files is automatic, if the filename ends in .gz
-
+ fname : file or string
+ File or filename to read. If the filename extension is ``.gz``,
+ the file is first decompressed.
dtype : data-type
- Data type of the resulting array. If this is a record data-type, the
- resulting array will be 1-d and each row will be interpreted as an
- element of the array. The number of columns used must match the number
- of fields in the data-type in this case.
-
- comments : str
- The character used to indicate the start of a comment in the file.
-
- delimiter : str
- A string-like character used to separate values in the file. If delimiter
- is unspecified or none, any whitespace string is a separator.
-
+ Data type of the resulting array. If this is a record data-type,
+ the resulting array will be 1-dimensional, and each row will be
+ interpreted as an element of the array. In this case, the number
+ of columns used must match the number of fields in the data-type.
+ comments : string, optional
+ The character used to indicate the start of a comment.
+ delimiter : string, optional
+ The string used to separate values. By default, this is any
+ whitespace.
converters : {}
- A dictionary mapping column number to a function that will convert that
- column to a float. Eg, if column 0 is a date string:
- converters={0:datestr2num}. Converters can also be used to provide
- a default value for missing data: converters={3:lambda s: float(s or 0)}.
-
+ A dictionary mapping column number to a function that will convert
+ that column to a float. E.g., if column 0 is a date string:
+ ``converters = {0: datestr2num}``. Converters can also be used to
+ provide a default value for missing data:
+ ``converters = {3: lambda s: float(s or 0)}``.
skiprows : int
- The number of rows from the top to skip.
-
+ Skip the first `skiprows` lines.
usecols : sequence
- A sequence of integer column indexes to extract where 0 is the first
- column, eg. usecols=(1,4,5) will extract the 2nd, 5th and 6th columns.
-
+ Which columns to read, with 0 being the first. For example,
+ ``usecols = (1,4,5)`` will extract the 2nd, 5th and 6th columns.
unpack : bool
- If True, will transpose the matrix allowing you to unpack into named
- arguments on the left hand side.
+ If True, the returned array is transposed, so that arguments may be
+ unpacked using ``x, y, z = loadtxt(...)``
+
+ Returns
+ -------
+ out : ndarray
+ Data read from the text file.
+
+ See Also
+ --------
+ scipy.io.loadmat : reads Matlab(R) data files
Examples
--------
- >>> X = loadtxt('test.dat') # data in two columns
- >>> x,y,z = load('somefile.dat', usecols=(3,5,7), unpack=True)
- >>> r = np.loadtxt('record.dat', dtype={'names':('gender','age','weight'),
- ... 'formats': ('S1','i4', 'f4')})
+ >>> from StringIO import StringIO # StringIO behaves like a file object
+ >>> c = StringIO("0 1\\n2 3")
+ >>> np.loadtxt(c)
+ array([[ 0., 1.],
+ [ 2., 3.]])
+
+ >>> d = StringIO("M 21 72\\nF 35 58")
+ >>> np.loadtxt(d, dtype={'names': ('gender', 'age', 'weight'),
+ ... 'formats': ('S1', 'i4', 'f4')})
+ array([('M', 21, 72.0), ('F', 35, 58.0)],
+ dtype=[('gender', '|S1'), ('age', '<i4'), ('weight', '<f4')])
+
+ >>> c = StringIO("1,0,2\\n3,0,4")
+ >>> x,y = np.loadtxt(c, delimiter=',', usecols=(0,2), unpack=True)
+ >>> x
+ array([ 1., 3.])
+ >>> y
+ array([ 2., 4.])
- SeeAlso: scipy.io.loadmat to read and write matfiles.
"""
user_converters = converters
@@ -373,8 +410,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters=None,
def savetxt(fname, X, fmt='%.18e',delimiter=' '):
"""
- Save the data in X to file fname using fmt string to convert the
- data to strings
+ Save an array to file.
Parameters
----------
@@ -382,8 +418,8 @@ def savetxt(fname, X, fmt='%.18e',delimiter=' '):
If the filename ends in .gz, the file is automatically saved in
compressed gzip format. The load() command understands gzipped
files transparently.
- X : array or sequence
- Data to write to file.
+ X : array_like
+ Data.
fmt : string or sequence of strings
A single format (%10.5f), a sequence of formats, or a
multi-format string, e.g. 'Iteration %d -- %10.5f', in which
@@ -391,43 +427,59 @@ def savetxt(fname, X, fmt='%.18e',delimiter=' '):
delimiter : str
Character separating columns.
- Examples
- --------
- >>> np.savetxt('test.out', x, delimiter=',') # X is an array
- >>> np.savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays
- >>> np.savetxt('test.out', x, fmt='%1.4e') # use exponential notation
+ Notes
+ -----
+ Further explanation of the `fmt` parameter
+ (``%[flag]width[.precision]specifier``):
- Notes on fmt
- ------------
flags:
- - : left justify
- + : Forces to preceed result with + or -.
- 0 : Left pad the number with zeros instead of space (see width).
+ ``-`` : left justify
+
+ ``+`` : Forces to preceed result with + or -.
+
+ ``0`` : Left pad the number with zeros instead of space (see width).
width:
- Minimum number of characters to be printed. The value is not truncated.
+ Minimum number of characters to be printed. The value is not truncated
+ if it has more characters.
precision:
- - For integer specifiers (eg. d,i,o,x), the minimum number of
+ - For integer specifiers (eg. ``d,i,o,x``), the minimum number of
digits.
- - For e, E and f specifiers, the number of digits to print
+ - For ``e, E`` and ``f`` specifiers, the number of digits to print
after the decimal point.
- - For g and G, the maximum number of significant digits.
- - For s, the maximum number of charac ters.
+ - For ``g`` and ``G``, the maximum number of significant digits.
+ - For ``s``, the maximum number of characters.
specifiers:
- c : character
- d or i : signed decimal integer
- e or E : scientific notation with e or E.
- f : decimal floating point
- g,G : use the shorter of e,E or f
- o : signed octal
- s : string of characters
- u : unsigned decimal integer
- x,X : unsigned hexadecimal integer
+ ``c`` : character
+
+ ``d`` or ``i`` : signed decimal integer
+
+ ``e`` or ``E`` : scientific notation with ``e`` or ``E``.
+
+ ``f`` : decimal floating point
+
+ ``g,G`` : use the shorter of ``e,E`` or ``f``
+
+ ``o`` : signed octal
+
+ ``s`` : string of characters
+
+ ``u`` : unsigned decimal integer
+
+ ``x,X`` : unsigned hexadecimal integer
This is not an exhaustive specification.
+
+
+ Examples
+ --------
+ >>> savetxt('test.out', x, delimiter=',') # X is an array
+ >>> savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays
+ >>> savetxt('test.out', x, fmt='%1.4e') # use exponential notation
+
"""
if _string_like(fname):
@@ -478,8 +530,7 @@ def savetxt(fname, X, fmt='%.18e',delimiter=' '):
import re
def fromregex(file, regexp, dtype):
"""
- Construct an array from a text file, using regular-expressions
- parsing.
+ Construct an array from a text file, using regular-expressions parsing.
Array is constructed from all matches of the regular expression
in the file. Groups in the regular expression are converted to fields.
diff --git a/numpy/lib/machar.py b/numpy/lib/machar.py
index 72fde37f2..facade612 100644
--- a/numpy/lib/machar.py
+++ b/numpy/lib/machar.py
@@ -13,40 +13,62 @@ from numpy.core.numeric import seterr
# Need to speed this up...especially for longfloat
class MachAr(object):
- """Diagnosing machine parameters.
+ """
+ Diagnosing machine parameters.
- The following attributes are available:
+ Attributes
+ ----------
+ ibeta : int
+ Radix in which numbers are represented.
+ it : int
+ Number of base-`ibeta` digits in the floating point mantissa M.
+ machep : int
+ Exponent of the smallest (most negative) power of `ibeta` that,
+ added to 1.0, gives something different from 1.0
+ eps : float
+ Floating-point number ``beta**machep`` (floating point precision)
+ negep : int
+ Exponent of the smallest power of `ibeta` that, substracted
+ from 1.0, gives something different from 1.0.
+ epsneg : float
+ Floating-point number ``beta**negep``.
+ iexp : int
+ Number of bits in the exponent (including its sign and bias).
+ minexp : int
+ Smallest (most negative) power of `ibeta` consistent with there
+ being no leading zeros in the mantissa.
+ xmin : float
+ Floating point number ``beta**minexp`` (the smallest [in
+ magnitude] usable floating value).
+ maxexp : int
+ Smallest (positive) power of `ibeta` that causes overflow.
+ xmax : float
+ ``(1-epsneg) * beta**maxexp`` (the largest [in magnitude]
+ usable floating value).
+ irnd : int
+ In ``range(6)``, information on what kind of rounding is done
+ in addition, and on how underflow is handled.
+ ngrd : int
+ Number of 'guard digits' used when truncating the product
+ of two mantissas to fit the representation.
- ibeta - radix in which numbers are represented
- it - number of base-ibeta digits in the floating point mantissa M
- machep - exponent of the smallest (most negative) power of ibeta that,
- added to 1.0,
- gives something different from 1.0
- eps - floating-point number beta**machep (floating point precision)
- negep - exponent of the smallest power of ibeta that, substracted
- from 1.0, gives something different from 1.0
- epsneg - floating-point number beta**negep
- iexp - number of bits in the exponent (including its sign and bias)
- minexp - smallest (most negative) power of ibeta consistent with there
- being no leading zeros in the mantissa
- xmin - floating point number beta**minexp (the smallest (in
- magnitude) usable floating value)
- maxexp - smallest (positive) power of ibeta that causes overflow
- xmax - (1-epsneg)* beta**maxexp (the largest (in magnitude)
- usable floating value)
- irnd - in range(6), information on what kind of rounding is done
- in addition, and on how underflow is handled
- ngrd - number of 'guard digits' used when truncating the product
- of two mantissas to fit the representation
+ epsilon : float
+ Same as `eps`.
+ tiny : float
+ Same as `xmin`.
+ huge : float
+ Same as `xmax`.
+ precision : float
+ ``- int(-log10(eps))``
+ resolution : float
+ `` - 10**(-precision)``
- epsilon - same as eps
- tiny - same as xmin
- huge - same as xmax
- precision - int(-log10(eps))
- resolution - 10**(-precision)
+ References
+ ----------
+ .. [1] Press, Teukolsky, Vetterling and Flannery,
+ "Numerical Recipes in C++," 2nd ed,
+ Cambridge University Press, 2002, p. 31.
- Reference:
- Numerical Recipies.
"""
def __init__(self, float_conv=float,int_conv=int,
float_to_float=float,
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py
index 8fb0337dc..bce7f0e4e 100644
--- a/numpy/lib/polynomial.py
+++ b/numpy/lib/polynomial.py
@@ -46,15 +46,49 @@ def _lstsq(X, y, rcond):
return lstsq(X, y, rcond)
def poly(seq_of_zeros):
- """ Return a sequence representing a polynomial given a sequence of roots.
+ """
+ Return polynomial coefficients given a sequence of roots.
+
+ Calculate the coefficients of a polynomial given the zeros
+ of the polynomial.
+
+ If a square matrix is given, then the coefficients for
+ characteristic equation of the matrix, defined by
+ :math:`\\mathrm{det}(\\mathbf{A} - \\lambda \\mathbf{I})`,
+ are returned.
+
+ Parameters
+ ----------
+ seq_of_zeros : ndarray
+ A sequence of polynomial roots or a square matrix.
+
+ Returns
+ -------
+ coefs : ndarray
+ A sequence of polynomial coefficients representing the polynomial
+
+ :math:`\\mathrm{coefs}[0] x^{n-1} + \\mathrm{coefs}[1] x^{n-2} +
+ ... + \\mathrm{coefs}[2] x + \\mathrm{coefs}[n]`
+
+ See Also
+ --------
+ numpy.poly1d : A one-dimensional polynomial class.
+ numpy.roots : Return the roots of the polynomial coefficients in p
+ numpy.polyfit : Least squares polynomial fit
+
+ Examples
+ --------
+ Given a sequence of polynomial zeros,
- If the input is a matrix, return the characteristic polynomial.
+ >>> b = np.roots([1, 3, 1, 5, 6])
+ >>> np.poly(b)
+ array([ 1., 3., 1., 5., 6.])
- Example:
+ Given a square matrix,
- >>> b = np.roots([1,3,1,5,6])
- >>> np.poly(b)
- array([ 1., 3., 1., 5., 6.])
+ >>> P = np.array([[19, 3], [-2, 26]])
+ >>> np.poly(P)
+ array([ 1., -45., 500.])
"""
seq_of_zeros = atleast_1d(seq_of_zeros)
@@ -86,11 +120,35 @@ def poly(seq_of_zeros):
return a
def roots(p):
- """ Return the roots of the polynomial coefficients in p.
+ """
+ Return the roots of a polynomial with coefficients given in p.
+
+ The values in the rank-1 array `p` are coefficients of a polynomial.
+ If the length of `p` is n+1 then the polynomial is described by
+ p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
+
+ Parameters
+ ----------
+ p : (N,) array_like
+ Rank-1 array of polynomial co-efficients.
+
+ Returns
+ -------
+ out : ndarray
+ An array containing the complex roots of the polynomial.
+
+ Raises
+ ------
+ ValueError:
+ When `p` cannot be converted to a rank-1 array.
+
+ Examples
+ --------
+
+ >>> coeff = [3.2, 2, 1]
+ >>> print np.roots(coeff)
+ [-0.3125+0.46351241j -0.3125-0.46351241j]
- The values in the rank-1 array p are coefficients of a polynomial.
- If the length of p is n+1 then the polynomial is
- p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
"""
# If input is scalar, this makes it an array
p = atleast_1d(p)
@@ -128,12 +186,70 @@ def roots(p):
return roots
def polyint(p, m=1, k=None):
- """Return the mth analytical integral of the polynomial p.
+ """
+ Return an antiderivative (indefinite integral) of a polynomial.
+
+ The returned order `m` antiderivative `P` of polynomial `p` satisfies
+ :math:`\\frac{d^m}{dx^m}P(x) = p(x)` and is defined up to `m - 1`
+ integration constants `k`. The constants determine the low-order
+ polynomial part
+
+ .. math:: \\frac{k_{m-1}}{0!} x^0 + \\ldots + \\frac{k_0}{(m-1)!}x^{m-1}
+
+ of `P` so that :math:`P^{(j)}(0) = k_{m-j-1}`.
+
+ Parameters
+ ----------
+ p : poly1d or sequence
+ Polynomial to differentiate.
+ A sequence is interpreted as polynomial coefficients, see `poly1d`.
+ m : int, optional
+ Order of the antiderivative. (Default: 1)
+ k : {None, list of `m` scalars, scalar}, optional
+ Integration constants. They are given in the order of integration:
+ those corresponding to highest-order terms come first.
+
+ If ``None`` (default), all constants are assumed to be zero.
+ If `m = 1`, a single scalar can be given instead of a list.
+
+ See Also
+ --------
+ polyder : derivative of a polynomial
+ poly1d.integ : equivalent method
+
+ Examples
+ --------
+ The defining property of the antiderivative:
+
+ >>> p = np.poly1d([1,1,1])
+ >>> P = np.polyint(p)
+ poly1d([ 0.33333333, 0.5 , 1. , 0. ])
+ >>> np.polyder(P) == p
+ True
+
+ The integration constants default to zero, but can be specified:
+
+ >>> P = np.polyint(p, 3)
+ >>> P(0)
+ 0.0
+ >>> np.polyder(P)(0)
+ 0.0
+ >>> np.polyder(P, 2)(0)
+ 0.0
+ >>> P = np.polyint(p, 3, k=[6,5,3])
+ >>> P
+ poly1d([ 0.01666667, 0.04166667, 0.16666667, 3., 5., 3. ])
+
+ Note that 3 = 6 / 2!, and that the constants are given in the order of
+ integrations. Constant of the highest-order polynomial term comes first:
+
+ >>> np.polyder(P, 2)(0)
+ 6.0
+ >>> np.polyder(P, 1)(0)
+ 5.0
+ >>> P(0)
+ 3.0
- If k is None, then zero-valued constants of integration are used.
- otherwise, k should be a list of length m (or a scalar if m=1) to
- represent the constants of integration to use for each integration
- (starting with k[0])
"""
m = int(m)
if m < 0:
@@ -160,7 +276,55 @@ def polyint(p, m=1, k=None):
return val
def polyder(p, m=1):
- """Return the mth derivative of the polynomial p.
+ """
+ Return the derivative of order m of a polynomial.
+
+ Parameters
+ ----------
+ p : poly1d or sequence
+ Polynomial to differentiate.
+ A sequence is interpreted as polynomial coefficients, see `poly1d`.
+ m : int, optional
+ Order of differentiation (default: 1)
+
+ Returns
+ -------
+ der : poly1d
+ A new polynomial representing the derivative.
+
+ See Also
+ --------
+ polyint : Anti-derivative of a polynomial.
+
+ Examples
+ --------
+ The derivative of the polynomial :math:`x^3 + x^2 + x^1 + 1` is:
+
+ >>> p = np.poly1d([1,1,1,1])
+ >>> p2 = np.polyder(p)
+ >>> p2
+ poly1d([3, 2, 1])
+
+ which evaluates to:
+
+ >>> p2(2.)
+ 17.0
+
+ We can verify this, approximating the derivative with
+ ``(f(x + h) - f(x))/h``:
+
+ >>> (p(2. + 0.001) - p(2.)) / 0.001
+ 17.007000999997857
+
+ The fourth-order derivative of a 3rd-order polynomial is zero:
+
+ >>> np.polyder(p, 2)
+ poly1d([6, 2])
+ >>> np.polyder(p, 3)
+ poly1d([6])
+ >>> np.polyder(p, 4)
+ poly1d([ 0.])
+
"""
m = int(m)
truepoly = isinstance(p, poly1d)
@@ -178,107 +342,134 @@ def polyder(p, m=1):
return val
def polyfit(x, y, deg, rcond=None, full=False):
- """Least squares polynomial fit.
-
- Do a best fit polynomial of degree 'deg' of 'x' to 'y'. Return value is a
- vector of polynomial coefficients [pk ... p1 p0]. Eg, for n=2
+ """
+ Least squares polynomial fit.
- p2*x0^2 + p1*x0 + p0 = y1
- p2*x1^2 + p1*x1 + p0 = y1
- p2*x2^2 + p1*x2 + p0 = y2
- .....
- p2*xk^2 + p1*xk + p0 = yk
+ Fit a polynomial ``p(x) = p[0] * x**deg + ... + p[deg]`` of degree `deg`
+ to points `(x, y)`. Returns a vector of coefficients `p` that minimises
+ the squared error.
Parameters
----------
- x : array_like
- 1D vector of sample points.
- y : array_like
- 1D vector or 2D array of values to fit. The values should run down the
- columes in the 2D case.
- deg : integer
+ x : array_like, shape (M,)
+ x-coordinates of the M sample points ``(x[i], y[i])``.
+ y : array_like, shape (M,) or (M, K)
+ y-coordinates of the sample points. Several data sets of sample
+ points sharing the same x-coordinates can be fitted at once by
+ passing in a 2D-array that contains one dataset per column.
+ deg : int
Degree of the fitting polynomial
- rcond: {None, float}, optional
+ rcond : float, optional
Relative condition number of the fit. Singular values smaller than this
- relative to the largest singular value will be ignored. The defaul value
- is len(x)*eps, where eps is the relative precision of the float type,
- about 2e-16 in most cases.
- full : {False, boolean}, optional
- Switch determining nature of return value. When it is False just the
- coefficients are returned, when True diagnostic information from the
- singular value decomposition is also returned.
+ relative to the largest singular value will be ignored. The default
+ value is len(x)*eps, where eps is the relative precision of the float
+ type, about 2e-16 in most cases.
+ full : bool, optional
+ Switch determining nature of return value. When it is
+ False (the default) just the coefficients are returned, when True
+ diagnostic information from the singular value decomposition is also
+ returned.
Returns
-------
- coefficients, [residuals, rank, singular_values, rcond] : variable
- When full=False, only the coefficients are returned, running down the
- appropriate colume when y is a 2D array. When full=True, the rank of the
- scaled Vandermonde matrix, it's effective rank in light of the rcond
- value, its singular values, and the specified value of rcond are also
- returned.
+ p : ndarray, shape (M,) or (M, K)
+ Polynomial coefficients, highest power first.
+ If `y` was 2-D, the coefficients for `k`-th data set are in ``p[:,k]``.
+
+ residuals, rank, singular_values, rcond : present only if `full` = True
+ Residuals of the least-squares fit, the effective rank of the scaled
+ Vandermonde coefficient matrix, its singular values, and the specified
+ value of `rcond`. For more details, see `linalg.lstsq`.
Warns
-----
- RankWarning : if rank is reduced and not full output
- The warnings can be turned off by:
- >>> import warnings
- >>> warnings.simplefilter('ignore',np.RankWarning)
+ RankWarning
+ The rank of the coefficient matrix in the least-squares fit is
+ deficient. The warning is only raised if `full` = False.
+ The warnings can be turned off by
+
+ >>> import warnings
+ >>> warnings.simplefilter('ignore', np.RankWarning)
See Also
--------
- polyval : computes polynomial values.
+ polyval : Computes polynomial values.
+ linalg.lstsq : Computes a least-squares fit.
+ scipy.interpolate.UnivariateSpline : Computes spline fits.
Notes
-----
- If X is a the Vandermonde Matrix computed from x (see
- http://mathworld.wolfram.com/VandermondeMatrix.html), then the
- polynomial least squares solution is given by the 'p' in
-
- X*p = y
-
- where X.shape is a matrix of dimensions (len(x), deg + 1), p is a vector of
- dimensions (deg + 1, 1), and y is a vector of dimensions (len(x), 1).
-
- This equation can be solved as
-
- p = (XT*X)^-1 * XT * y
-
- where XT is the transpose of X and -1 denotes the inverse. However, this
- method is susceptible to rounding errors and generally the singular value
- decomposition of the matrix X is preferred and that is what is done here.
- The singular value method takes a paramenter, 'rcond', which sets a limit on
- the relative size of the smallest singular value to be used in solving the
- equation. This may result in lowering the rank of the Vandermonde matrix, in
- which case a RankWarning is issued. If polyfit issues a RankWarning, try a
- fit of lower degree or replace x by x - x.mean(), both of which will
- generally improve the condition number. The routine already normalizes the
- vector x by its maximum absolute value to help in this regard. The rcond
- parameter can be set to a value smaller than its default, but the resulting
- fit may be spurious. The current default value of rcond is len(x)*eps, where
- eps is the relative precision of the floating type being used, generally
- around 1e-7 and 2e-16 for IEEE single and double precision respectively.
- This value of rcond is fairly conservative but works pretty well when x -
- x.mean() is used in place of x.
-
-
- DISCLAIMER: Power series fits are full of pitfalls for the unwary once the
- degree of the fit becomes large or the interval of sample points is badly
- centered. The problem is that the powers x**n are generally a poor basis for
- the polynomial functions on the sample interval, resulting in a Vandermonde
- matrix is ill conditioned and coefficients sensitive to rounding erros. The
- computation of the polynomial values will also sensitive to rounding errors.
- Consequently, the quality of the polynomial fit should be checked against
- the data whenever the condition number is large. The quality of polynomial
- fits *can not* be taken for granted. If all you want to do is draw a smooth
- curve through the y values and polyfit is not doing the job, try centering
- the sample range or look into scipy.interpolate, which includes some nice
- spline fitting functions that may be of use.
-
- For more info, see
- http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html,
- but note that the k's and n's in the superscripts and subscripts
- on that page. The linear algebra is correct, however.
+ The solution minimizes the squared error
+
+ .. math ::
+ E = \\sum_{j=0}^k |p(x_j) - y_j|^2
+
+ in the equations::
+
+ x[0]**n * p[n] + ... + x[0] * p[1] + p[0] = y[0]
+ x[1]**n * p[n] + ... + x[1] * p[1] + p[0] = y[1]
+ ...
+ x[k]**n * p[n] + ... + x[k] * p[1] + p[0] = y[k]
+
+ The coefficient matrix of the coefficients `p` is a Vandermonde matrix.
+
+ `polyfit` issues a `RankWarning` when the least-squares fit is badly
+ conditioned. This implies that the best fit is not well-defined due
+ to numerical error. The results may be improved by lowering the polynomial
+ degree or by replacing `x` by `x` - `x`.mean(). The `rcond` parameter
+ can also be set to a value smaller than its default, but the resulting
+ fit may be spurious: including contributions from the small singular
+ values can add numerical noise to the result.
+
+ Note that fitting polynomial coefficients is inherently badly conditioned
+ when the degree of the polynomial is large or the interval of sample points
+ is badly centered. The quality of the fit should always be checked in these
+ cases. When polynomial fits are not satisfactory, splines may be a good
+ alternative.
+
+ References
+ ----------
+ .. [1] Wikipedia, "Curve fitting",
+ http://en.wikipedia.org/wiki/Curve_fitting
+ .. [2] Wikipedia, "Polynomial interpolation",
+ http://en.wikipedia.org/wiki/Polynomial_interpolation
+
+ Examples
+ --------
+ >>> x = np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
+ >>> y = np.array([0.0, 0.8, 0.9, 0.1, -0.8, -1.0])
+ >>> z = np.polyfit(x, y, 3)
+ array([ 0.08703704, -0.81349206, 1.69312169, -0.03968254])
+
+ It is convenient to use `poly1d` objects for dealing with polynomials:
+
+ >>> p = np.poly1d(z)
+ >>> p(0.5)
+ 0.6143849206349179
+ >>> p(3.5)
+ -0.34732142857143039
+ >>> p(10)
+ 22.579365079365115
+
+ High-order polynomials may oscillate wildly:
+
+ >>> p30 = np.poly1d(np.polyfit(x, y, 30))
+ /... RankWarning: Polyfit may be poorly conditioned...
+ >>> p30(4)
+ -0.80000000000000204
+ >>> p30(5)
+ -0.99999999999999445
+ >>> p30(4.5)
+ -0.10547061179440398
+
+ Illustration:
+
+ >>> import matplotlib.pyplot as plt
+ >>> xp = np.linspace(-2, 6, 100)
+ >>> plt.plot(x, y, '.', xp, p(xp), '-', xp, p30(xp), '--')
+ >>> plt.ylim(-2,2)
+ >>> plt.show()
"""
order = int(deg) + 1
@@ -330,36 +521,48 @@ def polyfit(x, y, deg, rcond=None, full=False):
def polyval(p, x):
- """Evaluate the polynomial p at x.
+ """
+ Evaluate the polynomial p at x.
If p is of length N, this function returns the value:
p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]
- If x is a sequence then p(x) will be returned for all elements of x. If x is
- another polynomial then the composite polynomial p(x) will be returned.
+ If x is a sequence then p(x) will be returned for all elements of x.
+ If x is another polynomial then the composite polynomial p(x) will
+ be returned.
Parameters
----------
p : {array_like, poly1d}
- 1D array of polynomial coefficients from highest degree to zero or an
- instance of poly1d.
+ 1D array of polynomial coefficients from highest degree to zero or an
+ instance of poly1d.
x : {array_like, poly1d}
- A number, a 1D array of numbers, or an instance of poly1d.
+ A number, a 1D array of numbers, or an instance of poly1d.
Returns
-------
values : {array, poly1d}
- If either p or x is an instance of poly1d, then an instance of poly1d is
- returned, otherwise a 1D array is returned. In the case where x is a
- poly1d, the result is the composition of the two polynomials, i.e.,
- substitution is used.
+ If either p or x is an instance of poly1d, then an instance of poly1d
+ is returned, otherwise a 1D array is returned. In the case where x is
+ a poly1d, the result is the composition of the two polynomials, i.e.,
+ substitution is used.
+
+ See Also
+ --------
+ poly1d: A polynomial class.
Notes
-----
- Horners method is used to evaluate the polynomial. Even so, for polynomial
- if high degree the values may be inaccurate due to rounding errors. Use
- carefully.
+ Horner's method is used to evaluate the polynomial. Even so, for
+ polynomials of high degree the values may be inaccurate due to
+ rounding errors. Use carefully.
+
+
+ Examples
+ --------
+ >>> np.polyval([3,0,1], 5) # 3 * 5**2 + 0 * 5**1 + 1
+ 76
"""
p = NX.asarray(p)
@@ -473,24 +676,90 @@ def _raise_power(astr, wrap=70):
class poly1d(object):
- """A one-dimensional polynomial class.
+ """
+ A one-dimensional polynomial class.
+
+ Parameters
+ ----------
+ c_or_r : array_like
+ Polynomial coefficients, in decreasing powers. E.g.,
+ ``(1, 2, 3)`` implies :math:`x^2 + 2x + 3`. If `r` is set
+ to True, these coefficients specify the polynomial roots
+ (values where the polynomial evaluate to 0) instead.
+ r : bool, optional
+ If True, `c_or_r` gives the polynomial roots. Default is False.
+
+ Examples
+ --------
+ Construct the polynomial :math:`x^2 + 2x + 3`:
+
+ >>> p = np.poly1d([1, 2, 3])
+ >>> print np.poly1d(p)
+ 2
+ 1 x + 2 x + 3
+
+ Evaluate the polynomial:
+
+ >>> p(0.5)
+ 4.25
+
+ Find the roots:
+
+ >>> p.r
+ array([-1.+1.41421356j, -1.-1.41421356j])
+
+ Show the coefficients:
+
+ >>> p.c
+ array([1, 2, 3])
+
+ Display the order (the leading zero-coefficients are removed):
+
+ >>> p.order
+ 2
+
+ Show the coefficient of the k-th power in the polynomial
+ (which is equivalent to ``p.c[-(i+1)]``):
+
+ >>> p[1]
+ 2
+
+ Polynomials can be added, substracted, multplied and divided
+ (returns quotient and remainder):
+
+ >>> p * p
+ poly1d([ 1, 4, 10, 12, 9])
+
+ >>> (p**3 + 4) / p
+ (poly1d([ 1., 4., 10., 12., 9.]), poly1d([4]))
- p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3
+ ``asarray(p)`` gives the coefficient array, so polynomials can be
+ used in all functions that accept arrays:
- p(0.5) evaluates the polynomial at the location
- p.r is a list of roots
- p.c is the coefficient array [1,2,3]
- p.order is the polynomial order (after leading zeros in p.c are removed)
- p[k] is the coefficient on the kth power of x (backwards from
- sequencing the coefficient array.
+ >>> p**2 # square of polynomial
+ poly1d([ 1, 4, 10, 12, 9])
- polynomials can be added, substracted, multplied and divided (returns
- quotient and remainder).
- asarray(p) will also give the coefficient array, so polynomials can
- be used in all functions that accept arrays.
+ >>> np.square(p) # square of individual coefficients
+ array([1, 4, 9])
+
+ The variable used in the string representation of `p` can be modified,
+ using the `variable` parameter:
+
+ >>> p = np.poly1d([1,2,3], variable='z')
+ >>> print p
+ 2
+ 1 z + 2 z + 3
+
+ Construct a polynomial from its roots:
+
+ >>> np.poly1d([1, 2], True)
+ poly1d([ 1, -3, 2])
+
+ This is the same polynomial as obtained by:
+
+ >>> np.poly1d([1, -1]) * np.poly1d([1, -2])
+ poly1d([ 1, -3, 2])
- p = poly1d([1,2,3], variable='lambda') will use lambda in the
- string representation of p.
"""
coeffs = None
order = None
@@ -686,13 +955,28 @@ class poly1d(object):
return iter(self.coeffs)
def integ(self, m=1, k=0):
- """Return the mth analytical integral of this polynomial.
- See the documentation for polyint.
+ """
+ Return an antiderivative (indefinite integral) of this polynomial.
+
+ Refer to `polyint` for full documentation.
+
+ See Also
+ --------
+ polyint : equivalent function
+
"""
return poly1d(polyint(self.coeffs, m=m, k=k))
def deriv(self, m=1):
- """Return the mth derivative of this polynomial.
+ """
+ Return a derivative of this polynomial.
+
+ Refer to `polyder` for full documentation.
+
+ See Also
+ --------
+ polyder : equivalent function
+
"""
return poly1d(polyder(self.coeffs, m=m))
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index afdb879e4..8f6073bd5 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -9,9 +9,47 @@ from numpy.core.numeric import asarray, zeros, newaxis, outer, \
from numpy.core.fromnumeric import product, reshape
def apply_along_axis(func1d,axis,arr,*args):
- """ Execute func1d(arr[i],*args) where func1d takes 1-D arrays
- and arr is an N-d array. i varies so as to apply the function
- along the given axis for each 1-d subarray in arr.
+ """
+ Apply function to 1-D slices along the given axis.
+
+ Execute `func1d(arr[i],*args)` where `func1d` takes 1-D arrays, `arr` is
+ the input array, and `i` is an integer that varies in order to apply the
+ function along the given axis for each 1-D subarray in `arr`.
+
+ Parameters
+ ----------
+ func1d : function
+ This function should be able to take 1-D arrays. It is applied to 1-D
+ slices of `arr` along the specified axis.
+ axis : integer
+ Axis along which `func1d` is applied.
+ arr : ndarray
+ Input array.
+ args : any
+ Additional arguments to `func1d`.
+
+ Returns
+ -------
+ outarr : ndarray
+ The output array. The shape of `outarr` depends on the return
+ value of `func1d`. If it returns arrays with the same shape as the
+ input arrays it receives, `outarr` has the same shape as `arr`.
+
+ See Also
+ --------
+ apply_over_axes : Apply a function repeatedly over multiple axes.
+
+ Examples
+ --------
+ >>> def my_func(a):
+ ... \"\"\"Average first and last element of a 1-D array\"\"\"
+ ... return (a[0] + a[-1]) * 0.5
+ >>> b = np.array([[1,2,3], [4,5,6], [7,8,9]])
+ >>> np.apply_along_axis(my_func, 0, b)
+ array([4., 5., 6.])
+ >>> np.apply_along_axis(my_func, 1, b)
+ array([2., 5., 8.])
+
"""
arr = asarray(arr)
nd = arr.ndim
@@ -71,12 +109,58 @@ def apply_along_axis(func1d,axis,arr,*args):
def apply_over_axes(func, a, axes):
- """Apply a function repeatedly over multiple axes, keeping the same shape
- for the resulting array.
+ """
+ Apply a function repeatedly over multiple axes.
+
+ `func` is called as `res = func(a, axis)`, with `axis` the first element
+ of `axes`. The result `res` of the function call has to have
+ the same or one less dimension(s) as `a`. If `res` has one less dimension
+ than `a`, a dimension is then inserted before `axis`.
+ The call to `func` is then repeated for each axis in `axes`,
+ with `res` as the first argument.
+
+ Parameters
+ ----------
+ func : function
+ This function should take two arguments, `func(a, axis)`.
+ arr : ndarray
+ Input array.
+ axes : array_like
+ Axes over which `func` has to be applied, the elements should be
+ integers.
+
+ Returns
+ -------
+ val : ndarray
+ The output array. The number of dimensions is the same as `a`,
+ the shape can be different, this depends on whether `func` changes
+ the shape of its output with respect to its input.
+
+ See Also
+ --------
+ apply_along_axis :
+ Apply a function to 1-D slices of an array along the given axis.
+
+ Examples
+ --------
+ >>> a = np.arange(24).reshape(2,3,4)
+ >>> a
+ array([[[ 0, 1, 2, 3],
+ [ 4, 5, 6, 7],
+ [ 8, 9, 10, 11]],
+ <BLANKLINE>
+ [[12, 13, 14, 15],
+ [16, 17, 18, 19],
+ [20, 21, 22, 23]]])
+
+ Sum over axes 0 and 2. The result has same number of dimensions
+ as the original array:
+
+ >>> np.apply_over_axes(np.sum, a, [0,2])
+ array([[[ 60],
+ [ 92],
+ [124]]])
- func is called as res = func(a, axis). The result is assumed
- to be either the same shape as a or have one less dimension.
- This call is repeated for each axis in the axes sequence.
"""
val = asarray(a)
N = a.ndim
@@ -98,7 +182,55 @@ def apply_over_axes(func, a, axes):
return val
def expand_dims(a, axis):
- """Expand the shape of a by including newaxis before given axis.
+ """
+ Expand the shape of an array.
+
+ Insert a new axis, corresponding to a given position in the array shape.
+
+ Parameters
+ ----------
+ a : array_like
+ Input array.
+ axis : int
+ Position (amongst axes) where new axis is to be inserted.
+
+ Returns
+ -------
+ res : ndarray
+ Output array. The number of dimensions is one greater than that of
+ the input array.
+
+ See Also
+ --------
+ doc.indexing, atleast_1d, atleast_2d, atleast_3d
+
+ Examples
+ --------
+ >>> x = np.array([1,2])
+ >>> x.shape
+ (2,)
+
+ The following is equivalent to ``x[np.newaxis,:]`` or ``x[np.newaxis]``:
+
+ >>> y = np.expand_dims(x, axis=0)
+ >>> y
+ array([[1, 2]])
+ >>> y.shape
+ (1, 2)
+
+ >>> y = np.expand_dims(x, axis=1) # Equivalent to x[:,newaxis]
+ >>> y
+ array([[1],
+ [2]])
+ >>> y.shape
+ (2, 1)
+
+ Note that some examples may use ``None`` instead of ``np.newaxis``. These
+ are the same objects:
+
+ >>> np.newaxis is None
+ True
+
"""
a = asarray(a)
shape = a.shape
@@ -108,16 +240,43 @@ def expand_dims(a, axis):
def atleast_1d(*arys):
- """ Force a sequence of arrays to each be at least 1D.
+ """
+ Convert inputs to arrays with at least one dimension.
+
+ Scalar inputs are converted to 1-dimensional arrays, whilst
+ higher-dimensional inputs are preserved.
+
+ Parameters
+ ----------
+ array1, array2, ... : array_like
+ One or more input arrays.
+
+ Returns
+ -------
+ ret : ndarray
+ An array, or sequence of arrays, each with ``a.ndim >= 1``.
+ Copies are made only if necessary.
+
+ See Also
+ --------
+ atleast_2d, atleast_3d
+
+ Examples
+ --------
+ >>> np.atleast_1d(1.0)
+ array([ 1.])
+
+ >>> x = np.arange(9.0).reshape(3,3)
+ >>> np.atleast_1d(x)
+ array([[ 0., 1., 2.],
+ [ 3., 4., 5.],
+ [ 6., 7., 8.]])
+ >>> np.atleast_1d(x) is x
+ True
+
+ >>> np.atleast_1d(1, [3, 4])
+ [array([1]), array([3, 4])]
- Description:
- Force an array to be at least 1D. If an array is 0D, the
- array is converted to a single row of values. Otherwise,
- the array is unaltered.
- Arguments:
- *arys -- arrays to be converted to 1 or more dimensional array.
- Returns:
- input array converted to at least 1D array.
"""
res = []
for ary in arys:
@@ -128,16 +287,41 @@ def atleast_1d(*arys):
return res
def atleast_2d(*arys):
- """ Force a sequence of arrays to each be at least 2D.
+ """
+ View inputs as arrays with at least two dimensions.
+
+ Parameters
+ ----------
+ array1, array2, ... : array_like
+ One or more array-like sequences. Non-array inputs are converted
+ to arrays. Arrays that already have two or more dimensions are
+ preserved.
+
+ Returns
+ -------
+ res, res2, ... : ndarray
+ An array, or tuple of arrays, each with ``a.ndim >= 2``.
+ Copies are avoided where possible, and views with two or more
+ dimensions are returned.
+
+ See Also
+ --------
+ atleast_1d, atleast_3d
+
+ Examples
+ --------
+ >>> numpy.atleast_2d(3.0)
+ array([[ 3.]])
+
+ >>> x = numpy.arange(3.0)
+ >>> numpy.atleast_2d(x)
+ array([[ 0., 1., 2.]])
+ >>> numpy.atleast_2d(x).base is x
+ True
+
+ >>> np.atleast_2d(1, [1, 2], [[1, 2]])
+ [array([[1]]), array([[1, 2]]), array([[1, 2]])]
- Description:
- Force an array to each be at least 2D. If the array
- is 0D or 1D, the array is converted to a single
- row of values. Otherwise, the array is unaltered.
- Arguments:
- arys -- arrays to be converted to 2 or more dimensional array.
- Returns:
- input array converted to at least 2D array.
"""
res = []
for ary in arys:
@@ -148,19 +332,54 @@ def atleast_2d(*arys):
return res
def atleast_3d(*arys):
- """ Force a sequence of arrays to each be at least 3D.
-
- Description:
- Force an array each be at least 3D. If the array is 0D or 1D,
- the array is converted to a single 1xNx1 array of values where
- N is the orginal length of the array. If the array is 2D, the
- array is converted to a single MxNx1 array of values where MxN
- is the orginal shape of the array. Otherwise, the array is
- unaltered.
- Arguments:
- arys -- arrays to be converted to 3 or more dimensional array.
- Returns:
- input array converted to at least 3D array.
+ """
+ View inputs as arrays with at least three dimensions.
+
+ Parameters
+ ----------
+ array1, array2, ... : array_like
+ One or more array-like sequences. Non-array inputs are converted
+ to arrays. Arrays that already have three or more dimensions are
+ preserved.
+
+ Returns
+ -------
+ res1, res2, ... : ndarray
+ An array, or tuple of arrays, each with ``a.ndim >= 3``.
+ Copies are avoided where possible, and views with three or more
+ dimensions are returned. For example, a one-dimensional array of
+ shape ``N`` becomes a view of shape ``(1, N, 1)``. An ``(M, N)``
+ array becomes a view of shape ``(N, M, 1)``.
+
+ See Also
+ --------
+ numpy.atleast_1d, numpy.atleast_2d
+
+ Examples
+ --------
+ >>> numpy.atleast_3d(3.0)
+ array([[[ 3.]]])
+
+ >>> x = numpy.arange(3.0)
+ >>> numpy.atleast_3d(x).shape
+ (1, 3, 1)
+
+ >>> x = numpy.arange(12.0).reshape(4,3)
+ >>> numpy.atleast_3d(x).shape
+ (4, 3, 1)
+ >>> numpy.atleast_3d(x).base is x
+ True
+
+ >>> for arr in np.atleast_3d(1, [1, 2], [[1, 2]]): print arr, "\\n"
+ ...
+ [[[1]]]
+
+ [[[1]
+ [2]]]
+
+ [[[1]
+ [2]]]
+
"""
res = []
for ary in arys:
@@ -181,57 +400,78 @@ def atleast_3d(*arys):
def vstack(tup):
- """ Stack arrays in sequence vertically (row wise)
-
- Description:
- Take a sequence of arrays and stack them vertically
- to make a single array. All arrays in the sequence
- must have the same shape along all but the first axis.
- vstack will rebuild arrays divided by vsplit.
- Arguments:
- tup -- sequence of arrays. All arrays must have the same
- shape.
- Examples:
- >>> a = np.array((1,2,3))
- >>> b = np.array((2,3,4))
- >>> np.vstack((a,b))
- array([[1, 2, 3],
- [2, 3, 4]])
- >>> a = np.array([[1],[2],[3]])
- >>> b = np.array([[2],[3],[4]])
- >>> np.vstack((a,b))
- array([[1],
- [2],
- [3],
- [2],
- [3],
- [4]])
+ """
+ Stack arrays vertically.
+
+ `vstack` can be used to rebuild arrays divided by `vsplit`.
+
+ Parameters
+ ----------
+ tup : sequence of arrays
+ Tuple containing arrays to be stacked. The arrays must have the same
+ shape along all but the first axis.
+
+ See Also
+ --------
+ array_split : Split an array into a list of multiple sub-arrays of
+ near-equal size.
+ split : Split array into a list of multiple sub-arrays of equal size.
+ vsplit : Split array into a list of multiple sub-arrays vertically.
+ dsplit : Split array into a list of multiple sub-arrays along the 3rd axis
+ (depth).
+ concatenate : Join arrays together.
+ hstack : Stack arrays in sequence horizontally (column wise).
+ dstack : Stack arrays in sequence depth wise (along third dimension).
+
+ Examples
+ --------
+ >>> a = np.array([1, 2, 3])
+ >>> b = np.array([2, 3, 4])
+ >>> np.vstack((a,b))
+ array([[1, 2, 3],
+ [2, 3, 4]])
+ >>> a = np.array([[1], [2], [3]])
+ >>> b = np.array([[2], [3], [4]])
+ >>> np.vstack((a,b))
+ array([[1],
+ [2],
+ [3],
+ [2],
+ [3],
+ [4]])
"""
return _nx.concatenate(map(atleast_2d,tup),0)
def hstack(tup):
- """ Stack arrays in sequence horizontally (column wise)
-
- Description:
- Take a sequence of arrays and stack them horizontally
- to make a single array. All arrays in the sequence
- must have the same shape along all but the second axis.
- hstack will rebuild arrays divided by hsplit.
- Arguments:
- tup -- sequence of arrays. All arrays must have the same
- shape.
- Examples:
- >>> a = np.array((1,2,3))
- >>> b = np.array((2,3,4))
- >>> np.hstack((a,b))
- array([1, 2, 3, 2, 3, 4])
- >>> a = np.array([[1],[2],[3]])
- >>> b = np.array([[2],[3],[4]])
- >>> np.hstack((a,b))
- array([[1, 2],
- [2, 3],
- [3, 4]])
+ """
+ Stack arrays in sequence horizontally (column wise)
+
+ Take a sequence of arrays and stack them horizontally to make
+ a single array. hstack will rebuild arrays divided by hsplit.
+
+ Parameters
+ ----------
+ tup : sequence of ndarrays
+ All arrays must have the same shape along all but the second axis.
+
+ Returns
+ -------
+ stacked : ndarray
+ Ndarray formed by stacking the given arrays.
+
+ Examples
+ --------
+ >>> a = np.array((1,2,3))
+ >>> b = np.array((2,3,4))
+ >>> np.hstack((a,b))
+ array([1, 2, 3, 2, 3, 4])
+ >>> a = np.array([[1],[2],[3]])
+ >>> b = np.array([[2],[3],[4]])
+ >>> np.hstack((a,b))
+ array([[1, 2],
+ [2, 3],
+ [3, 4]])
"""
return _nx.concatenate(map(atleast_1d,tup),1)
@@ -239,25 +479,27 @@ def hstack(tup):
row_stack = vstack
def column_stack(tup):
- """ Stack 1D arrays as columns into a 2D array
-
- Description:
- Take a sequence of 1D arrays and stack them as columns
- to make a single 2D array. All arrays in the sequence
- must have the same first dimension. 2D arrays are
- stacked as-is, just like with hstack. 1D arrays are turned
- into 2D columns first.
-
- Arguments:
- tup -- sequence of 1D or 2D arrays. All arrays must have the same
- first dimension.
- Examples:
- >>> a = np.array((1,2,3))
- >>> b = np.array((2,3,4))
- >>> np.column_stack((a,b))
- array([[1, 2],
- [2, 3],
- [3, 4]])
+ """
+ Stack 1-D arrays as columns into a 2-D array
+
+ Take a sequence of 1-D arrays and stack them as columns
+ to make a single 2-D array. 2-D arrays are stacked as-is,
+ just like with hstack. 1-D arrays are turned into 2-D columns
+ first.
+
+ Parameters
+ ----------
+ tup : sequence of 1-D or 2-D arrays.
+ Arrays to stack. All of them must have the same first dimension.
+
+ Examples
+ --------
+ >>> a = np.array((1,2,3))
+ >>> b = np.array((2,3,4))
+ >>> np.column_stack((a,b))
+ array([[1, 2],
+ [2, 3],
+ [3, 4]])
"""
arrays = []
@@ -269,32 +511,35 @@ def column_stack(tup):
return _nx.concatenate(arrays,1)
def dstack(tup):
- """ Stack arrays in sequence depth wise (along third dimension)
-
- Description:
- Take a sequence of arrays and stack them along the third axis.
- All arrays in the sequence must have the same shape along all
- but the third axis. This is a simple way to stack 2D arrays
- (images) into a single 3D array for processing.
- dstack will rebuild arrays divided by dsplit.
- Arguments:
- tup -- sequence of arrays. All arrays must have the same
- shape.
- Examples:
- >>> a = np.array((1,2,3))
- >>> b = np.array((2,3,4))
- >>> np.dstack((a,b))
- array([[[1, 2],
- [2, 3],
- [3, 4]]])
- >>> a = np.array([[1],[2],[3]])
- >>> b = np.array([[2],[3],[4]])
- >>> np.dstack((a,b))
- array([[[1, 2]],
- <BLANKLINE>
- [[2, 3]],
- <BLANKLINE>
- [[3, 4]]])
+ """
+ Stack arrays in sequence depth wise (along third dimension)
+
+ Take a sequence of arrays and stack them along the third axis.
+ This is a simple way to stack 2D arrays (images) into a single
+ 3D array for processing. dstack will rebuild arrays divided by dsplit.
+
+ Parameters
+ ----------
+ tup : sequence of arrays
+ Arrays to stack. All of them must have the same shape along all
+ but the third axis.
+
+ Examples
+ --------
+ >>> a = np.array((1,2,3))
+ >>> b = np.array((2,3,4))
+ >>> np.dstack((a,b))
+ array([[[1, 2],
+ [2, 3],
+ [3, 4]]])
+ >>> a = np.array([[1],[2],[3]])
+ >>> b = np.array([[2],[3],[4]])
+ >>> np.dstack((a,b))
+ array([[[1, 2]],
+ <BLANKLINE>
+ [[2, 3]],
+ <BLANKLINE>
+ [[3, 4]]])
"""
return _nx.concatenate(map(atleast_3d,tup),2)
@@ -308,32 +553,23 @@ def _replace_zero_by_x_arrays(sub_arys):
return sub_arys
def array_split(ary,indices_or_sections,axis = 0):
- """ Divide an array into a list of sub-arrays.
-
- Description:
- Divide ary into a list of sub-arrays along the
- specified axis. If indices_or_sections is an integer,
- ary is divided into that many equally sized arrays.
- If it is impossible to make an equal split, each of the
- leading arrays in the list have one additional member. If
- indices_or_sections is a list of sorted integers, its
- entries define the indexes where ary is split.
-
- Arguments:
- ary -- N-D array.
- Array to be divided into sub-arrays.
- indices_or_sections -- integer or 1D array.
- If integer, defines the number of (close to) equal sized
- sub-arrays. If it is a 1D array of sorted indices, it
- defines the indexes at which ary is divided. Any empty
- list results in a single sub-array equal to the original
- array.
- axis -- integer. default=0.
- Specifies the axis along which to split ary.
- Caveats:
- Currently, the default for axis is 0. This
- means a 2D array is divided into multiple groups
- of rows. This seems like the appropriate default,
+ """
+ Split an array into multiple sub-arrays of equal or near-equal size.
+
+ Please refer to the `numpy.split` documentation. The only difference
+ between these functions is that `array_split` allows `indices_or_sections`
+ to be an integer that does *not* equally divide the axis.
+
+ See Also
+ --------
+ numpy.split : Split array into multiple sub-arrays.
+
+ Examples
+ --------
+ >>> x = np.arange(8.0)
+ >>> np.array_split(x, 3)
+ [array([ 0., 1., 2.]), array([ 3., 4., 5.]), array([ 6., 7.])]
+
"""
try:
Ntotal = ary.shape[axis]
@@ -367,33 +603,70 @@ def array_split(ary,indices_or_sections,axis = 0):
return sub_arys
def split(ary,indices_or_sections,axis=0):
- """ Divide an array into a list of sub-arrays.
-
- Description:
- Divide ary into a list of sub-arrays along the
- specified axis. If indices_or_sections is an integer,
- ary is divided into that many equally sized arrays.
- If it is impossible to make an equal split, an error is
- raised. This is the only way this function differs from
- the array_split() function. If indices_or_sections is a
- list of sorted integers, its entries define the indexes
- where ary is split.
-
- Arguments:
- ary -- N-D array.
- Array to be divided into sub-arrays.
- indices_or_sections -- integer or 1D array.
- If integer, defines the number of (close to) equal sized
- sub-arrays. If it is a 1D array of sorted indices, it
- defines the indexes at which ary is divided. Any empty
- list results in a single sub-array equal to the original
- array.
- axis -- integer. default=0.
- Specifies the axis along which to split ary.
- Caveats:
- Currently, the default for axis is 0. This
- means a 2D array is divided into multiple groups
- of rows. This seems like the appropriate default
+ """
+ Split an array into multiple sub-arrays of equal size.
+
+ Parameters
+ ----------
+ ary : ndarray
+ Array to be divided into sub-arrays.
+ indices_or_sections: integer or 1D array
+ If `indices_or_sections` is an integer, N, the array will be divided
+ into N equal arrays along `axis`. If such a split is not possible,
+ an error is raised.
+
+ If `indices_or_sections` is a 1D array of sorted integers, the entries
+ indicate where along `axis` the array is split. For example,
+ ``[2, 3]`` would, for ``axis = 0``, result in
+
+ - ary[:2]
+ - ary[2:3]
+ - ary[3:]
+
+ If an index exceeds the dimension of the array along `axis`,
+ an empty sub-array is returned correspondingly.
+ axis : integer, optional
+ The axis along which to split. Default is 0.
+
+ Returns
+ -------
+ sub-arrays : list
+ A list of sub-arrays.
+
+ Raises
+ ------
+ ValueError
+ If `indices_or_sections` is given as an integer, but
+ a split does not result in equal division.
+
+ See Also
+ --------
+ array_split : Split an array into multiple sub-arrays of equal or
+ near-equal size. Does not raise an exception if
+ an equal division cannot be made.
+ hsplit : Split array into multiple sub-arrays horizontally (column-wise).
+ vsplit : Split array into multiple sub-arrays vertically (row wise).
+ dsplit : Split array into multiple sub-arrays along the 3rd axis (depth).
+ concatenate : Join arrays together.
+ hstack : Stack arrays in sequence horizontally (column wise).
+ vstack : Stack arrays in sequence vertically (row wise).
+ dstack : Stack arrays in sequence depth wise (along third dimension).
+
+ Examples
+ --------
+ >>> x = np.arange(9.0)
+ >>> np.split(x, 3)
+ [array([ 0., 1., 2.]), array([ 3., 4., 5.]), array([ 6., 7., 8.])]
+
+ >>> x = np.arange(8.0)
+ >>> np.split(x, [3, 5, 6, 10])
+ <BLANKLINE>
+ [array([ 0., 1., 2.]),
+ array([ 3., 4.]),
+ array([ 5.]),
+ array([ 6., 7.]),
+ array([], dtype=float64)]
+
"""
try: len(indices_or_sections)
except TypeError:
@@ -405,38 +678,41 @@ def split(ary,indices_or_sections,axis=0):
return res
def hsplit(ary,indices_or_sections):
- """ Split ary into multiple columns of sub-arrays
-
- Description:
- Split a single array into multiple sub arrays. The array is
- divided into groups of columns. If indices_or_sections is
- an integer, ary is divided into that many equally sized sub arrays.
- If it is impossible to make the sub-arrays equally sized, the
- operation throws a ValueError exception. See array_split and
- split for other options on indices_or_sections.
- Arguments:
- ary -- N-D array.
- Array to be divided into sub-arrays.
- indices_or_sections -- integer or 1D array.
- If integer, defines the number of (close to) equal sized
- sub-arrays. If it is a 1D array of sorted indices, it
- defines the indexes at which ary is divided. Any empty
- list results in a single sub-array equal to the original
- array.
- Returns:
- sequence of sub-arrays. The returned arrays have the same
- number of dimensions as the input array.
- Related:
- hstack, split, array_split, vsplit, dsplit.
- Examples:
- >>> a= np.array((1,2,3,4))
- >>> np.hsplit(a,2)
- [array([1, 2]), array([3, 4])]
- >>> a = np.array([[1,2,3,4],[1,2,3,4]])
- >>> np.hsplit(a,2)
- [array([[1, 2],
- [1, 2]]), array([[3, 4],
- [3, 4]])]
+ """
+ Split array into multiple sub-arrays horizontally.
+
+ Please refer to the `numpy.split` documentation. `hsplit` is
+ equivalent to `numpy.split` with ``axis = 1``.
+
+ See Also
+ --------
+ split : Split array into multiple sub-arrays.
+
+ Examples
+ --------
+ >>> x = np.arange(16.0).reshape(4, 4)
+ >>> np.hsplit(x, 2)
+ <BLANKLINE>
+ [array([[ 0., 1.],
+ [ 4., 5.],
+ [ 8., 9.],
+ [ 12., 13.]]),
+ array([[ 2., 3.],
+ [ 6., 7.],
+ [ 10., 11.],
+ [ 14., 15.]])]
+
+ >>> np.hsplit(x, array([3, 6]))
+ <BLANKLINE>
+ [array([[ 0., 1., 2.],
+ [ 4., 5., 6.],
+ [ 8., 9., 10.],
+ [ 12., 13., 14.]]),
+ array([[ 3.],
+ [ 7.],
+ [ 11.],
+ [ 15.]]),
+ array([], dtype=float64)]
"""
if len(_nx.shape(ary)) == 0:
@@ -447,41 +723,15 @@ def hsplit(ary,indices_or_sections):
return split(ary,indices_or_sections,0)
def vsplit(ary,indices_or_sections):
- """ Split ary into multiple rows of sub-arrays
-
- Description:
- Split a single array into multiple sub arrays. The array is
- divided into groups of rows. If indices_or_sections is
- an integer, ary is divided into that many equally sized sub arrays.
- If it is impossible to make the sub-arrays equally sized, the
- operation throws a ValueError exception. See array_split and
- split for other options on indices_or_sections.
- Arguments:
- ary -- N-D array.
- Array to be divided into sub-arrays.
- indices_or_sections -- integer or 1D array.
- If integer, defines the number of (close to) equal sized
- sub-arrays. If it is a 1D array of sorted indices, it
- defines the indexes at which ary is divided. Any empty
- list results in a single sub-array equal to the original
- array.
- Returns:
- sequence of sub-arrays. The returned arrays have the same
- number of dimensions as the input array.
- Caveats:
- How should we handle 1D arrays here? I am currently raising
- an error when I encounter them. Any better approach?
-
- Should we reduce the returned array to their minium dimensions
- by getting rid of any dimensions that are 1?
- Related:
- vstack, split, array_split, hsplit, dsplit.
- Examples:
- import numpy
- >>> a = np.array([[1,2,3,4],
- ... [1,2,3,4]])
- >>> np.vsplit(a,2)
- [array([[1, 2, 3, 4]]), array([[1, 2, 3, 4]])]
+ """
+ Split array into multiple sub-arrays vertically.
+
+ Please refer to the `numpy.split` documentation.
+
+ See Also
+ --------
+ numpy.split : The default behaviour of this function implements
+ `vsplit`.
"""
if len(_nx.shape(ary)) < 2:
@@ -489,37 +739,79 @@ def vsplit(ary,indices_or_sections):
return split(ary,indices_or_sections,0)
def dsplit(ary,indices_or_sections):
- """ Split ary into multiple sub-arrays along the 3rd axis (depth)
-
- Description:
- Split a single array into multiple sub arrays. The array is
- divided into groups along the 3rd axis. If indices_or_sections is
- an integer, ary is divided into that many equally sized sub arrays.
- If it is impossible to make the sub-arrays equally sized, the
- operation throws a ValueError exception. See array_split and
- split for other options on indices_or_sections.
- Arguments:
- ary -- N-D array.
- Array to be divided into sub-arrays.
- indices_or_sections -- integer or 1D array.
- If integer, defines the number of (close to) equal sized
- sub-arrays. If it is a 1D array of sorted indices, it
- defines the indexes at which ary is divided. Any empty
- list results in a single sub-array equal to the original
- array.
- Returns:
- sequence of sub-arrays. The returned arrays have the same
- number of dimensions as the input array.
- Caveats:
- See vsplit caveats.
- Related:
- dstack, split, array_split, hsplit, vsplit.
- Examples:
- >>> a = np.array([[[1,2,3,4],[1,2,3,4]]])
- >>> np.dsplit(a,2)
- [array([[[1, 2],
- [1, 2]]]), array([[[3, 4],
- [3, 4]]])]
+ """
+ Split array into multiple sub-arrays along the 3rd axis (depth).
+
+ Parameters
+ ----------
+ ary : ndarray
+ An array, with at least 3 dimensions, to be divided into sub-arrays
+ depth-wise, or along the third axis.
+ indices_or_sections: integer or 1D array
+ If `indices_or_sections` is an integer, N, the array will be divided
+ into N equal arrays along `axis`. If an equal split is not possible,
+ a ValueError is raised.
+
+ if `indices_or_sections` is a 1D array of sorted integers representing
+ indices along `axis`, the array will be divided such that each index
+ marks the start of each sub-array. If an index exceeds the dimension of
+ the array along `axis`, and empty sub-array is returned for that index.
+ axis : integer, optional
+ the axis along which to split. Default is 0.
+
+ Returns
+ -------
+ sub-arrays : list
+ A list of sub-arrays.
+
+ See Also
+ --------
+ array_split : Split an array into a list of multiple sub-arrays
+ of near-equal size.
+ split : Split array into a list of multiple sub-arrays of equal size.
+ hsplit : Split array into a list of multiple sub-arrays horizontally
+ vsplit : Split array into a list of multiple sub-arrays vertically
+ concatenate : Join arrays together.
+ hstack : Stack arrays in sequence horizontally (column wise)
+ vstack : Stack arrays in sequence vertically (row wise)
+ dstack : Stack arrays in sequence depth wise (along third dimension)
+
+ Notes
+ -----
+ `dsplit` requires that sub-arrays are of equal shape, whereas
+ `array_split` allows for sub-arrays to have nearly-equal shape.
+ Equivalent to `split` with `axis` = 2.
+
+ Examples
+ --------
+ >>> x = np.arange(16.0).reshape(2, 2, 4)
+ >>> np.dsplit(x, 2)
+ <BLANKLINE>
+ [array([[[ 0., 1.],
+ [ 4., 5.]],
+ <BLANKLINE>
+ [[ 8., 9.],
+ [ 12., 13.]]]),
+ array([[[ 2., 3.],
+ [ 6., 7.]],
+ <BLANKLINE>
+ [[ 10., 11.],
+ [ 14., 15.]]])]
+ <BLANKLINE>
+ >>> x = np.arange(16.0).reshape(2, 2, 4)
+ >>> np.dsplit(x, array([3, 6]))
+ <BLANKLINE>
+ [array([[[ 0., 1., 2.],
+ [ 4., 5., 6.]],
+ <BLANKLINE>
+ [[ 8., 9., 10.],
+ [ 12., 13., 14.]]]),
+ array([[[ 3.],
+ [ 7.]],
+ <BLANKLINE>
+ [[ 11.],
+ [ 15.]]]),
+ array([], dtype=float64)]
"""
if len(_nx.shape(ary)) < 3:
@@ -540,12 +832,74 @@ def get_array_wrap(*args):
return None
def kron(a,b):
- """kronecker product of a and b
+ """
+ Kronecker product of two arrays.
+
+ Computes the Kronecker product, a composite array made of blocks of the
+ second array scaled by the first.
+
+ Parameters
+ ----------
+ a, b : array_like
+
+ Returns
+ -------
+ out : ndarray
+
+ See Also
+ --------
+
+ outer : The outer product
+
+ Notes
+ -----
+
+ The function assumes that the number of dimenensions of `a` and `b`
+ are the same, if necessary prepending the smallest with ones.
+ If `a.shape = (r0,r1,..,rN)` and `b.shape = (s0,s1,...,sN)`,
+ the Kronecker product has shape `(r0*s0, r1*s1, ..., rN*SN)`.
+ The elements are products of elements from `a` and `b`, organized
+ explicitly by::
+
+ kron(a,b)[k0,k1,...,kN] = a[i0,i1,...,iN] * b[j0,j1,...,jN]
+
+ where::
+
+ kt = it * st + jt, t = 0,...,N
+
+ In the common 2-D case (N=1), the block structure can be visualized::
+
+ [[ a[0,0]*b, a[0,1]*b, ... , a[0,-1]*b ],
+ [ ... ... ],
+ [ a[-1,0]*b, a[-1,1]*b, ... , a[-1,-1]*b ]]
+
+
+ Examples
+ --------
+ >>> np.kron([1,10,100], [5,6,7])
+ array([ 5, 6, 7, 50, 60, 70, 500, 600, 700])
+ >>> np.kron([5,6,7], [1,10,100])
+ array([ 5, 50, 500, 6, 60, 600, 7, 70, 700])
+
+ >>> np.kron(np.eye(2), np.ones((2,2)))
+ array([[ 1., 1., 0., 0.],
+ [ 1., 1., 0., 0.],
+ [ 0., 0., 1., 1.],
+ [ 0., 0., 1., 1.]])
+
+ >>> a = np.arange(100).reshape((2,5,2,5))
+ >>> b = np.arange(24).reshape((2,3,4))
+ >>> c = np.kron(a,b)
+ >>> c.shape
+ (2, 10, 6, 20)
+ >>> I = (1,3,0,2)
+ >>> J = (0,2,1)
+ >>> J1 = (0,) + J # extend to ndim=4
+ >>> S1 = (1,) + b.shape
+ >>> K = tuple(np.array(I) * np.array(S1) + np.array(J1))
+ >>> C[K] == A[I]*B[J]
+ True
- Kronecker product of two arrays is block array
- [[ a[ 0 ,0]*b, a[ 0 ,1]*b, ... , a[ 0 ,n-1]*b ],
- [ ... ... ],
- [ a[m-1,0]*b, a[m-1,1]*b, ... , a[m-1,n-1]*b ]]
"""
wrapper = get_array_wrap(a, b)
b = asanyarray(b)
@@ -576,37 +930,61 @@ def kron(a,b):
def tile(A, reps):
- """Repeat an array the number of times given in the integer tuple, reps.
-
- If reps has length d, the result will have dimension of max(d, A.ndim).
- If reps is scalar it is treated as a 1-tuple.
-
- If A.ndim < d, A is promoted to be d-dimensional by prepending new axes.
- So a shape (3,) array is promoted to (1,3) for 2-D replication,
- or shape (1,1,3) for 3-D replication.
- If this is not the desired behavior, promote A to d-dimensions manually
- before calling this function.
-
- If d < A.ndim, tup is promoted to A.ndim by pre-pending 1's to it. Thus
- for an A.shape of (2,3,4,5), a tup of (2,2) is treated as (1,1,2,2)
-
-
- Examples:
- >>> a = np.array([0,1,2])
- >>> np.tile(a,2)
+ """
+ Construct an array by repeating A the number of times given by reps.
+
+ Parameters
+ ----------
+ A : array_like
+ The input array.
+ reps : array_like
+ The number of repetitions of `A` along each axis.
+
+ Returns
+ -------
+ c : ndarray
+ The output array.
+
+ See Also
+ --------
+ repeat
+
+ Notes
+ -----
+ If `reps` has length d, the result will have dimension of max(d, `A`.ndim).
+
+ If `A`.ndim < d, `A` is promoted to be d-dimensional by prepending new
+ axes. So a shape (3,) array is promoted to (1,3) for 2-D replication,
+ or shape (1,1,3) for 3-D replication. If this is not the desired behavior,
+ promote `A` to d-dimensions manually before calling this function.
+
+ If `A`.ndim > d, `reps` is promoted to `A`.ndim by pre-pending 1's to it.
+ Thus for an `A` of shape (2,3,4,5), a `reps` of (2,2) is treated as
+ (1,1,2,2).
+
+ Examples
+ --------
+ >>> a = np.array([0, 1, 2])
+ >>> np.tile(a, 2)
array([0, 1, 2, 0, 1, 2])
- >>> np.tile(a,(1,2))
- array([[0, 1, 2, 0, 1, 2]])
- >>> np.tile(a,(2,2))
+ >>> np.tile(a, (2, 2))
array([[0, 1, 2, 0, 1, 2],
[0, 1, 2, 0, 1, 2]])
- >>> np.tile(a,(2,1,2))
+ >>> np.tile(a, (2, 1, 2))
array([[[0, 1, 2, 0, 1, 2]],
<BLANKLINE>
[[0, 1, 2, 0, 1, 2]]])
- See Also:
- repeat
+ >>> b = np.array([[1, 2], [3, 4]])
+ >>> np.tile(b, 2)
+ array([[1, 2, 1, 2],
+ [3, 4, 3, 4]])
+ >>> np.tile(b, (2, 1))
+ array([[1, 2],
+ [3, 4],
+ [1, 2],
+ [3, 4]])
+
"""
try:
tup = tuple(reps)
diff --git a/numpy/lib/stride_tricks.py b/numpy/lib/stride_tricks.py
index 25987362f..8006b25d1 100644
--- a/numpy/lib/stride_tricks.py
+++ b/numpy/lib/stride_tricks.py
@@ -23,11 +23,13 @@ def as_strided(x, shape=None, strides=None):
return np.asarray(DummyArray(interface, base=x))
def broadcast_arrays(*args):
- """ Broadcast any number of arrays against each other.
+ """
+ Broadcast any number of arrays against each other.
Parameters
----------
- *args : arrays
+ `*args` : arrays
+ The arrays to broadcast.
Returns
-------
diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py
index ab1e5fcf0..d779009e7 100644
--- a/numpy/lib/twodim_base.py
+++ b/numpy/lib/twodim_base.py
@@ -9,8 +9,49 @@ from numpy.core.numeric import asanyarray, equal, subtract, arange, \
zeros, arange, greater_equal, multiply, ones, asarray
def fliplr(m):
- """ returns an array m with the rows preserved and columns flipped
- in the left/right direction. Works on the first two dimensions of m.
+ """
+ Left-right flip.
+
+ Flip the entries in each row in the left/right direction.
+ Columns are preserved, but appear in a different order than before.
+
+ Parameters
+ ----------
+ m : array_like
+ Input array.
+
+ Returns
+ -------
+ f : ndarray
+ A view of `m` with the columns reversed. Since a view
+ is returned, this operation is :math:`\\mathcal O(1)`.
+
+ See Also
+ --------
+ flipud : Flip array in the up/down direction.
+ rot90 : Rotate array counterclockwise.
+
+ Notes
+ -----
+ Equivalent to A[::-1,...]. Does not require the array to be
+ two-dimensional.
+
+ Examples
+ --------
+ >>> A = np.diag([1.,2.,3.])
+ >>> A
+ array([[ 1., 0., 0.],
+ [ 0., 2., 0.],
+ [ 0., 0., 3.]])
+ >>> np.fliplr(A)
+ array([[ 0., 0., 1.],
+ [ 0., 2., 0.],
+ [ 3., 0., 0.]])
+
+ >>> A = np.random.randn(2,3,5)
+ >>> np.all(numpy.fliplr(A)==A[:,::-1,...])
+ True
+
"""
m = asanyarray(m)
if m.ndim < 2:
@@ -18,8 +59,47 @@ def fliplr(m):
return m[:, ::-1]
def flipud(m):
- """ returns an array with the columns preserved and rows flipped in
- the up/down direction. Works on the first dimension of m.
+ """
+ Up-down flip.
+
+ Flip the entries in each column in the up/down direction.
+ Rows are preserved, but appear in a different order than before.
+
+ Parameters
+ ----------
+ m : array_like
+ Input array.
+
+ Returns
+ -------
+ out : array_like
+ A view of `m` with the rows reversed. Since a view is
+ returned, this operation is :math:`\\mathcal O(1)`.
+
+ Notes
+ -----
+ Equivalent to ``A[::-1,...]``.
+ Does not require the array to be two-dimensional.
+
+ Examples
+ --------
+ >>> A = np.diag([1.0, 2, 3])
+ >>> A
+ array([[ 1., 0., 0.],
+ [ 0., 2., 0.],
+ [ 0., 0., 3.]])
+ >>> np.flipud(A)
+ array([[ 0., 0., 3.],
+ [ 0., 2., 0.],
+ [ 1., 0., 0.]])
+
+ >>> A = np.random.randn(2,3,5)
+ >>> np.all(np.flipud(A)==A[::-1,...])
+ True
+
+ >>> np.flipud([1,2])
+ array([2, 1])
+
"""
m = asanyarray(m)
if m.ndim < 1:
@@ -27,9 +107,42 @@ def flipud(m):
return m[::-1,...]
def rot90(m, k=1):
- """ returns the array found by rotating m by k*90
- degrees in the counterclockwise direction. Works on the first two
- dimensions of m.
+ """
+ Rotate an array by 90 degrees in the counter-clockwise direction.
+
+ The first two dimensions are rotated; therefore, the array must be at
+ least 2-D.
+
+ Parameters
+ ----------
+ m : array_like
+ Array of two or more dimensions.
+ k : integer
+ Number of times the array is rotated by 90 degrees.
+
+ Returns
+ -------
+ y : ndarray
+ Rotated array.
+
+ See Also
+ --------
+ fliplr : Flip an array horizontally.
+ flipud : Flip an array vertically.
+
+ Examples
+ --------
+ >>> m = np.array([[1,2],[3,4]], int)
+ >>> m
+ array([[1, 2],
+ [3, 4]])
+ >>> np.rot90(m)
+ array([[2, 4],
+ [1, 3]])
+ >>> np.rot90(m, 2)
+ array([[4, 3],
+ [2, 1]])
+
"""
m = asanyarray(m)
if m.ndim < 2:
@@ -41,8 +154,41 @@ def rot90(m, k=1):
else: return fliplr(m.swapaxes(0,1)) # k==3
def eye(N, M=None, k=0, dtype=float):
- """ eye returns a N-by-M 2-d array where the k-th diagonal is all ones,
- and everything else is zeros.
+ """
+ Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+ Parameters
+ ----------
+ N : int
+ Number of rows in the output.
+ M : int, optional
+ Number of columns in the output. If None, defaults to `N`.
+ k : int, optional
+ Index of the diagonal: 0 refers to the main diagonal, a positive value
+ refers to an upper diagonal and a negative value to a lower diagonal.
+ dtype : dtype, optional
+ Data-type of the returned array.
+
+ Returns
+ -------
+ I : ndarray (N,M)
+ An array where all elements are equal to zero, except for the k'th
+ diagonal, whose values are equal to one.
+
+ See Also
+ --------
+ diag : Return a diagonal 2-D array using a 1-D array specified by the user.
+
+ Examples
+ --------
+ >>> np.eye(2, dtype=int)
+ array([[1, 0],
+ [0, 1]])
+ >>> np.eye(3, k=1)
+ array([[ 0., 1., 0.],
+ [ 0., 0., 1.],
+ [ 0., 0., 0.]])
+
"""
if M is None: M = N
m = equal(subtract.outer(arange(N), arange(M)),-k)
@@ -51,9 +197,34 @@ def eye(N, M=None, k=0, dtype=float):
return m
def diag(v, k=0):
- """ returns a copy of the the k-th diagonal if v is a 2-d array
- or returns a 2-d array with v as the k-th diagonal if v is a
- 1-d array.
+ """
+ Extract a diagonal or construct a diagonal array.
+
+ Parameters
+ ----------
+ v : array_like
+ If `v` is a 2-dimensional array, return a copy of
+ its `k`-th diagonal. If `v` is a 1-dimensional array,
+ return a 2-dimensional array with `v` on the `k`-th diagonal.
+ k : int, optional
+ Diagonal in question. The defaults is 0.
+
+ Examples
+ --------
+ >>> x = np.arange(9).reshape((3,3))
+ >>> x
+ array([[0, 1, 2],
+ [3, 4, 5],
+ [6, 7, 8]])
+
+ >>> np.diag(x)
+ array([0, 4, 8])
+
+ >>> np.diag(np.diag(x))
+ array([[0, 0, 0],
+ [0, 4, 0],
+ [0, 0, 8]])
+
"""
v = asarray(v)
s = v.shape
@@ -83,21 +254,30 @@ def diag(v, k=0):
raise ValueError, "Input must be 1- or 2-d."
def diagflat(v,k=0):
- """Return a 2D array whose k'th diagonal is a flattened v and all other
- elements are zero.
+ """
+ Create a 2-dimensional array with the flattened input as a diagonal.
+
+ Parameters
+ ----------
+ v : array_like
+ Input data, which is flattened and set as the `k`-th
+ diagonal of the output.
+ k : int, optional
+ Diagonal to set. The default is 0.
Examples
--------
- >>> np.diagflat([[1,2],[3,4]])
- array([[1, 0, 0, 0],
- [0, 2, 0, 0],
- [0, 0, 3, 0],
- [0, 0, 0, 4]])
+ >>> np.diagflat([[1,2],[3,4]])
+ array([[1, 0, 0, 0],
+ [0, 2, 0, 0],
+ [0, 0, 3, 0],
+ [0, 0, 0, 4]])
+
+ >>> np.diagflat([1,2], 1)
+ array([[0, 1, 0],
+ [0, 0, 2],
+ [0, 0, 0]])
- >>> np.diagflat([1,2], 1)
- array([[0, 1, 0],
- [0, 0, 2],
- [0, 0, 0]])
"""
try:
wrap = v.__array_wrap__
@@ -119,24 +299,102 @@ def diagflat(v,k=0):
return wrap(res)
def tri(N, M=None, k=0, dtype=float):
- """ returns a N-by-M array where all the diagonals starting from
- lower left corner up to the k-th are all ones.
+ """
+ Construct an array filled with ones at and below the given diagonal.
+
+ Parameters
+ ----------
+ N : int
+ Number of rows in the array.
+ M : int, optional
+ Number of columns in the array.
+ By default, `M` is taken to equal to `N`.
+ k : int, optional
+ The sub-diagonal below which the array is filled.
+ ``k = 0`` is the main diagonal, while ``k < 0`` is below it,
+ and ``k > 0`` is above. The default is 0.
+ dtype : dtype, optional
+ Data type of the returned array. The default is `float`.
+
+ Returns
+ -------
+ T : (N,M) ndarray
+ Array with a lower triangle filled with ones, in other words
+ ``T[i,j] == 1`` for ``i <= j + k``.
+
+ Examples
+ --------
+ >>> np.tri(3, 5, 2, dtype=int)
+ array([[1, 1, 1, 0, 0],
+ [1, 1, 1, 1, 0],
+ [1, 1, 1, 1, 1]])
+
+ >>> np.tri(3, 5, -1)
+ array([[ 0., 0., 0., 0., 0.],
+ [ 1., 0., 0., 0., 0.],
+ [ 1., 1., 0., 0., 0.]])
+
"""
if M is None: M = N
m = greater_equal(subtract.outer(arange(N), arange(M)),-k)
return m.astype(dtype)
def tril(m, k=0):
- """ returns the elements on and below the k-th diagonal of m. k=0 is the
- main diagonal, k > 0 is above and k < 0 is below the main diagonal.
+ """
+ Lower triangular.
+
+ Return a copy of an array with elements above the k-th diagonal zeroed.
+
+ Parameters
+ ----------
+ m : array-like, shape (M, N)
+ Input array.
+ k : int
+ Diagonal above which to zero elements.
+ `k = 0` is the main diagonal, `k < 0` is below it and `k > 0` is above.
+
+ Returns
+ -------
+ L : ndarray, shape (M, N)
+ Lower triangle of `m`, of same shape and data-type as `m`.
+
+ See Also
+ --------
+ triu
+
+ Examples
+ --------
+ >>> np.tril([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], -1)
+ array([[ 0, 0, 0],
+ [ 4, 0, 0],
+ [ 7, 8, 0],
+ [10, 11, 12]])
+
"""
m = asanyarray(m)
out = multiply(tri(m.shape[0], m.shape[1], k=k, dtype=int),m)
return out
def triu(m, k=0):
- """ returns the elements on and above the k-th diagonal of m. k=0 is the
- main diagonal, k > 0 is above and k < 0 is below the main diagonal.
+ """
+ Upper triangular.
+
+ Construct a copy of a matrix with elements below the k-th diagonal zeroed.
+
+ Please refer to the documentation for `tril`.
+
+ See Also
+ --------
+ tril
+
+ Examples
+ --------
+ >>> np.triu([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], -1)
+ array([[ 1, 2, 3],
+ [ 4, 5, 6],
+ [ 0, 8, 9],
+ [ 0, 0, 12]])
+
"""
m = asanyarray(m)
out = multiply((1-tri(m.shape[0], m.shape[1], k-1, int)),m)
@@ -145,10 +403,40 @@ def triu(m, k=0):
# borrowed from John Hunter and matplotlib
def vander(x, N=None):
"""
- Generate the Vandermonde matrix of vector x.
+ Generate a Van der Monde matrix.
- The i-th column of X is the the (N-i)-1-th power of x. N is the
- maximum power to compute; if N is None it defaults to len(x).
+ The columns of the output matrix are decreasing powers of the input
+ vector. Specifically, the i-th output column is the input vector to
+ the power of ``N - i - 1``.
+
+ Parameters
+ ----------
+ x : array_like
+ Input array.
+ N : int, optional
+ Order of (number of columns in) the output.
+
+ Returns
+ -------
+ out : ndarray
+ Van der Monde matrix of order `N`. The first column is ``x^(N-1)``,
+ the second ``x^(N-2)`` and so forth.
+
+ Examples
+ --------
+ >>> x = np.array([1, 2, 3, 5])
+ >>> N = 3
+ >>> np.vander(x, N)
+ array([[ 1, 1, 1],
+ [ 4, 2, 1],
+ [ 9, 3, 1],
+ [25, 5, 1]])
+
+ >>> np.column_stack([x**(N-1-i) for i in range(N)])
+ array([[ 1, 1, 1],
+ [ 4, 2, 1],
+ [ 9, 3, 1],
+ [25, 5, 1]])
"""
x = asarray(x)
@@ -160,30 +448,77 @@ def vander(x, N=None):
def histogram2d(x,y, bins=10, range=None, normed=False, weights=None):
- """histogram2d(x,y, bins=10, range=None, normed=False) -> H, xedges, yedges
-
- Compute the 2D histogram from samples x,y.
-
- :Parameters:
- - `x,y` : Sample arrays (1D).
- - `bins` : Number of bins -or- [nbin x, nbin y] -or-
- [bin edges] -or- [x bin edges, y bin edges].
- - `range` : A sequence of lower and upper bin edges (default: [min, max]).
- - `normed` : Boolean, if False, return the number of samples in each bin,
- if True, returns the density.
- - `weights` : An array of weights. The weights are normed only if normed
- is True. Should weights.sum() not equal N, the total bin count \
- will not be equal to the number of samples.
-
- :Return:
- - `hist` : Histogram array.
- - `xedges, yedges` : Arrays defining the bin edges.
-
- Example:
- >>> x = np.random.randn(100,2)
- >>> hist2d, xedges, yedges = np.lib.histogram2d(x, bins = (6, 7))
-
- :SeeAlso: histogramdd
+ """
+ Compute the bidimensional histogram of two data samples.
+
+ Parameters
+ ----------
+ x : array-like (N,)
+ A sequence of values to be histogrammed along the first dimension.
+ y : array-like (N,)
+ A sequence of values to be histogrammed along the second dimension.
+ bins : int or [int, int] or array-like or [array, array], optional
+ The bin specification:
+
+ * the number of bins for the two dimensions (nx=ny=bins),
+ * the number of bins in each dimension (nx, ny = bins),
+ * the bin edges for the two dimensions (x_edges=y_edges=bins),
+ * the bin edges in each dimension (x_edges, y_edges = bins).
+
+ range : array-like, (2,2), optional
+ The leftmost and rightmost edges of the bins along each dimension
+ (if not specified explicitly in the `bins` parameters):
+ [[xmin, xmax], [ymin, ymax]]. All values outside of this range will be
+ considered outliers and not tallied in the histogram.
+ normed : boolean, optional
+ If False, returns the number of samples in each bin. If True, returns
+ the bin density, ie, the bin count divided by the bin area.
+ weights : array-like (N,), optional
+ An array of values `w_i` weighing each sample `(x_i, y_i)`. Weights are
+ normalized to 1 if normed is True. If normed is False, the values of the
+ returned histogram are equal to the sum of the weights belonging to the
+ samples falling into each bin.
+
+ Returns
+ -------
+ H : array (nx, ny)
+ The bidimensional histogram of samples x and y. Values in x are
+ histogrammed along the first dimension and values in y are histogrammed
+ along the second dimension.
+ xedges : array (nx,)
+ The bin edges along the first dimension.
+ yedges : array (ny,)
+ The bin edges along the second dimension.
+
+ See Also
+ --------
+ histogram: 1D histogram
+ histogramdd: Multidimensional histogram
+
+ Notes
+ -----
+ When normed is True, then the returned histogram is the sample density,
+ defined such that:
+
+ .. math::
+ \\sum_{i=0}^{nx-1} \\sum_{j=0}^{ny-1} H_{i,j} \\Delta x_i \\Delta y_j = 1
+
+ where :math:`H` is the histogram array and :math:`\\Delta x_i \\Delta y_i`
+ the area of bin :math:`{i,j}`.
+
+ Please note that the histogram does not follow the cartesian convention
+ where `x` values are on the abcissa and `y` values on the ordinate axis.
+ Rather, `x` is histogrammed along the first dimension of the array
+ (vertical), and `y` along the second dimension of the array (horizontal).
+ This ensures compatibility with `histogrammdd`.
+
+ Examples
+ --------
+ >>> x,y = np.random.randn(2,100)
+ >>> H, xedges, yedges = np.histogram2d(x, y, bins = (5, 8))
+ >>> H.shape, xedges.shape, yedges.shape
+ ((5,8), (6,), (9,))
+
"""
from numpy import histogramdd
diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py
index 20817ab01..0a78986ac 100644
--- a/numpy/lib/type_check.py
+++ b/numpy/lib/type_check.py
@@ -49,16 +49,53 @@ def asfarray(a, dtype=_nx.float_):
return asarray(a,dtype=dtype)
def real(val):
- """Return the real part of val.
+ """
+ Return the real part of the elements of the array.
+
+ Parameters
+ ----------
+ val : {array_like, scalar}
+ Input array.
+
+ Returns
+ -------
+ out : ndarray
+ If `val` is real, the type of `val` is used for the output. If `val`
+ has complex elements, the returned type is float.
+
+ See Also
+ --------
+ real_if_close, imag, angle
+
+ Examples
+ --------
+ >>> a = np.array([1+2j,3+4j,5+6j])
+ >>> a.real
+ array([ 1., 3., 5.])
+ >>> a.real = 9
+ >>> a
+ array([ 9.+2.j, 9.+4.j, 9.+6.j])
+ >>> a.real = np.array([9,8,7])
+ >>> a
+ array([ 9.+2.j, 8.+4.j, 7.+6.j])
- Useful if val maybe a scalar or an array.
"""
return asanyarray(val).real
def imag(val):
- """Return the imaginary part of val.
+ """
+ Return the imaginary part of array.
+
+ Parameters
+ ----------
+ val : array_like
+ Input array.
+
+ Returns
+ -------
+ out : ndarray, real or int
+ Real part of each element, same shape as `val`.
- Useful if val maybe a scalar or an array.
"""
return asanyarray(val).imag
@@ -75,10 +112,26 @@ def iscomplex(x):
return +res # convet to array-scalar if needed
def isreal(x):
- """Return a boolean array where elements are True if that element
- is real (has zero imaginary part)
+ """
+ Returns a bool array where True if the corresponding input element is real.
+
+ True if complex part is zero.
+
+ Parameters
+ ----------
+ x : array_like
+ Input array.
+
+ Returns
+ -------
+ out : ndarray, bool
+ Boolean array of same shape as `x`.
+
+ Examples
+ --------
+ >>> np.isreal([1+1j, 1+0j, 4.5, 3, 2, 2j])
+ >>> array([False, True, True, True, True, False], dtype=bool)
- For scalars, return a boolean.
"""
return imag(x) == 0
@@ -105,12 +158,27 @@ def _getmaxmin(t):
def nan_to_num(x):
"""
- Returns a copy of replacing NaN's with 0 and Infs with large numbers
+ Replace nan with zero and inf with large numbers.
+
+ Parameters
+ ----------
+ x : array_like
+ Input data.
+
+ Returns
+ -------
+ out : ndarray
+ Array with the same shape and dtype as `x`. Nan is replaced
+ by zero, and inf (-inf) is replaced by the largest (smallest)
+ floating point value that fits in the output dtype.
+
+ Examples
+ --------
+ >>> x = np.array([np.inf, -np.inf, np.nan, -128, 128])
+ >>> np.nan_to_num(x)
+ array([ 1.79769313e+308, -1.79769313e+308, 0.00000000e+000,
+ -1.28000000e+002, 1.28000000e+002])
- The following mappings are applied:
- NaN -> 0
- Inf -> limits.double_max
- -Inf -> limits.double_min
"""
try:
t = x.dtype.type
@@ -143,10 +211,36 @@ def nan_to_num(x):
#-----------------------------------------------------------------------------
def real_if_close(a,tol=100):
- """If a is a complex array, return it as a real array if the imaginary
- part is close enough to zero.
+ """
+ If complex input returns a real array if complex parts are close to zero.
+
+ "Close to zero" is defined as `tol` * (machine epsilon of the type for
+ `a`).
+
+ Parameters
+ ----------
+ a : {array_like, scalar}
+ Input array.
+ tol : scalar
+ Tolerance for the complex part of the elements in the array.
+
+ Returns
+ -------
+ out : ndarray
+ If `a` is real, the type of `a` is used for the output. If `a`
+ has complex elements, the returned type is float.
+
+ See Also
+ --------
+ real, imag, angle
+
+ Notes
+ -----
+ Machine epsilon varies from machine to machine and between data types
+ but Python floats on most platforms have a machine epsilon equal to
+ 2.2204460492503131e-16. You can use 'np.finfo(np.float).eps' to print
+ out the machine epsilon for floats.
- "Close enough" is defined as tol*(machine epsilon of a's element type).
"""
a = asanyarray(a)
if not issubclass(a.dtype.type, _nx.complexfloating):
@@ -192,7 +286,24 @@ _namefromtype = {'S1' : 'character',
}
def typename(char):
- """Return an english description for the given data type character.
+ """
+ Return a description for the given data type code.
+
+ Parameters
+ ----------
+ char : str
+ Data type code.
+
+ Returns
+ -------
+ out : str
+ Description of the input data type code.
+
+ See Also
+ --------
+ typecodes
+ dtype
+
"""
return _namefromtype[char]
@@ -208,11 +319,22 @@ array_precision = {_nx.single : 0,
_nx.cdouble : 1,
_nx.clongdouble : 2}
def common_type(*arrays):
- """Given a sequence of arrays as arguments, return the best inexact
- scalar type which is "most" common amongst them.
+ """
+ Return the inexact scalar type which is most common in a list of arrays.
The return type will always be a inexact scalar type, even if all
- the arrays are integer arrays.
+ the arrays are integer arrays
+
+ Parameters
+ ----------
+ arrays: sequence of array_like
+ Input sequence of arrays.
+
+ Returns
+ -------
+ out: data type code
+ Data type code.
+
"""
is_complex = False
precision = 0
diff --git a/numpy/lib/ufunclike.py b/numpy/lib/ufunclike.py
index a8c2c1e25..37c38e94e 100644
--- a/numpy/lib/ufunclike.py
+++ b/numpy/lib/ufunclike.py
@@ -24,9 +24,30 @@ def fix(x, y=None):
return y
def isposinf(x, y=None):
- """Return a boolean array y with y[i] True for x[i] = +Inf.
+ """
+ Return True where x is +infinity, and False otherwise.
+
+ Parameters
+ ----------
+ x : array_like
+ The input array.
+ y : array_like
+ A boolean array with the same shape as `x` to store the result.
+
+ Returns
+ -------
+ y : ndarray
+ A boolean array where y[i] = True only if x[i] = +Inf.
+
+ See Also
+ --------
+ isneginf, isfinite
+
+ Examples
+ --------
+ >>> np.isposinf([-np.inf, 0., np.inf])
+ array([ False, False, True], dtype=bool)
- If y is an array, the result replaces the contents of y.
"""
if y is None:
x = asarray(x)
@@ -35,9 +56,30 @@ def isposinf(x, y=None):
return y
def isneginf(x, y=None):
- """Return a boolean array y with y[i] True for x[i] = -Inf.
+ """
+ Return True where x is -infinity, and False otherwise.
+
+ Parameters
+ ----------
+ x : array_like
+ The input array.
+ y : array_like
+ A boolean array with the same shape as `x` to store the result.
+
+ Returns
+ -------
+ y : ndarray
+ A boolean array where y[i] = True only if x[i] = -Inf.
+
+ See Also
+ --------
+ isposinf, isfinite
+
+ Examples
+ --------
+ >>> np.isneginf([-np.inf, 0., np.inf])
+ array([ True, False, False], dtype=bool)
- If y is an array, the result replaces the contents of y.
"""
if y is None:
x = asarray(x)
@@ -47,9 +89,32 @@ def isneginf(x, y=None):
_log2 = umath.log(2)
def log2(x, y=None):
- """Returns the base 2 logarithm of x
+ """
+ Return the base 2 logarithm.
+
+ Parameters
+ ----------
+ x : array_like
+ Input array.
+ y : array_like
+ Optional output array with the same shape as `x`.
+
+ Returns
+ -------
+ y : {ndarray, scalar}
+ The logarithm to the base 2 of `x` elementwise.
+ NaNs are returned where `x` is negative.
+
+
+ See Also
+ --------
+ log, log1p, log10
+
+ Examples
+ --------
+ >>> np.log2([-1,2,4])
+ array([ NaN, 1., 2.])
- If y is an array, the result replaces the contents of y.
"""
x = asanyarray(x)
if y is None:
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index 9d37dc1b5..bb162bfd3 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -24,6 +24,29 @@ def issubsctype(arg1, arg2):
return issubclass(obj2sctype(arg1), obj2sctype(arg2))
def issubdtype(arg1, arg2):
+ """
+ Returns True if first argument is a typecode lower/equal in type hierarchy.
+
+ Parameters
+ ----------
+ arg1 : dtype_like
+ dtype or string representing a typecode.
+ arg2 : dtype_like
+ dtype or string representing a typecode.
+
+
+ See Also
+ --------
+ numpy.core.numerictypes : Overview of numpy type hierarchy.
+
+ Examples
+ --------
+ >>> np.issubdtype('S1', str)
+ True
+ >>> np.issubdtype(np.float64, np.float32)
+ False
+
+ """
if issubclass_(arg2, generic):
return issubclass(_dtype(arg1).type, arg2)
mro = _dtype(arg2).type.mro()
@@ -34,15 +57,23 @@ def issubdtype(arg1, arg2):
return issubclass(_dtype(arg1).type, val)
def get_include():
- """Return the directory in the package that contains the numpy/*.h header
- files.
+ """
+ Return the directory that contains the numpy \\*.h header files.
Extension modules that need to compile against numpy should use this
- function to locate the appropriate include directory. Using distutils:
+ function to locate the appropriate include directory.
+
+ Notes
+ -----
+ When using ``distutils``, for example in ``setup.py``.
+ ::
+
+ import numpy as np
+ ...
+ Extension('extension_name', ...
+ include_dirs=[np.get_include()])
+ ...
- import numpy
- Extension('extension_name', ...
- include_dirs=[numpy.get_include()])
"""
import numpy
if numpy.show_config is None:
@@ -109,6 +140,10 @@ def deprecate(func, oldname=None, newname=None):
depdoc = '%s is DEPRECATED!! -- use %s instead' % (oldname, newname,)
def newfunc(*args,**kwds):
+ """
+ Use get_include, get_numpy_include is DEPRECATED.
+
+ """
warnings.warn(str1, DeprecationWarning)
return func(*args, **kwds)
@@ -204,7 +239,40 @@ def may_share_memory(a, b):
def who(vardict=None):
- """Print the Numpy arrays in the given dictionary (or globals() if None).
+ """
+ Print the Numpy arrays in the given dictionary.
+
+ If there is no dictionary passed in or `vardict` is None then returns
+ Numpy arrays in the globals() dictionary (all Numpy arrays in the
+ namespace).
+
+ Parameters
+ ----------
+ vardict : dict, optional
+ A dictionary possibly containing ndarrays. Default is globals().
+
+ Returns
+ -------
+ out : None
+ Returns 'None'.
+
+ Notes
+ -----
+ Prints out the name, shape, bytes and type of all of the ndarrays present
+ in `vardict`.
+
+ Examples
+ --------
+ >>> d = {'x': arange(2.0), 'y': arange(3.0), 'txt': 'Some str', 'idx': 5}
+ >>> np.whos(d)
+ Name Shape Bytes Type
+ ===========================================================
+ <BLANKLINE>
+ y 3 24 float64
+ x 2 16 float64
+ <BLANKLINE>
+ Upper bound on total bytes = 40
+
"""
if vardict is None:
frame = sys._getframe().f_back
@@ -464,7 +532,18 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'):
def source(object, output=sys.stdout):
- """Write source for this object to output.
+ """
+ Print or write to a file the source code for a Numpy object.
+
+ Parameters
+ ----------
+ object : numpy object
+ Input object.
+ output : file object, optional
+ If `output` not supplied then source code is printed to screen
+ (sys.stdout). File object must be created with either write 'w' or
+ append 'a' modes.
+
"""
# Local import to speed up numpy's import time.
import inspect
@@ -485,21 +564,31 @@ _function_signature_re = re.compile(r"[a-z_]+\(.*[,=].*\)", re.I)
def lookfor(what, module=None, import_modules=True, regenerate=False):
"""
- Search for objects whose documentation contains all given words.
- Shows a summary of matching objects, sorted roughly by relevance.
+ Do a keyword search on docstrings.
+
+ A list of of objects that matched the search is displayed,
+ sorted by relevance.
Parameters
----------
what : str
String containing words to look for.
-
module : str, module
Module whose docstrings to go through.
import_modules : bool
Whether to import sub-modules in packages.
- Will import only modules in __all__
- regenerate: bool
- Re-generate the docstring cache
+ Will import only modules in ``__all__``.
+ regenerate : bool
+ Whether to re-generate the docstring cache.
+
+ Examples
+ --------
+
+ >>> np.lookfor('binary representation')
+ Search results for 'binary representation'
+ ------------------------------------------
+ numpy.binary_repr
+ Return the binary representation of the input number as a string.
"""
import pydoc
@@ -718,7 +807,10 @@ class SafeEval(object):
raise SyntaxError("Unknown name: %s" % node.name)
def safe_eval(source):
- """ Evaluate a string containing a Python literal expression without
+ """
+ Protected string evaluation.
+
+ Evaluate a string containing a Python literal expression without
allowing the execution of arbitrary non-literal code.
Parameters
@@ -731,8 +823,9 @@ def safe_eval(source):
Raises
------
- SyntaxError if the code is invalid Python expression syntax or if it
- contains non-literal code.
+ SyntaxError
+ If the code has invalid Python syntax, or if it contains non-literal
+ code.
Examples
--------
@@ -755,6 +848,7 @@ def safe_eval(source):
Traceback (most recent call last):
...
SyntaxError: Unknown name: dict
+
"""
# Local import to speed up numpy's import time.
import compiler
diff --git a/numpy/linalg/__init__.py b/numpy/linalg/__init__.py
index 835fb74a6..58b012f00 100644
--- a/numpy/linalg/__init__.py
+++ b/numpy/linalg/__init__.py
@@ -1,3 +1,46 @@
+"""
+Core Linear Algebra Tools
+=========================
+
+=============== ==========================================================
+Linear algebra basics
+==========================================================================
+norm Vector or matrix norm
+inv Inverse of a square matrix
+solve Solve a linear system of equations
+det Determinant of a square matrix
+lstsq Solve linear least-squares problem
+pinv Pseudo-inverse (Moore-Penrose) calculated using a singular
+ value decomposition
+matrix_power Integer power of a square matrix
+=============== ==========================================================
+
+=============== ==========================================================
+Eigenvalues and decompositions
+==========================================================================
+eig Eigenvalues and vectors of a square matrix
+eigh Eigenvalues and eigenvectors of a Hermitian matrix
+eigvals Eigenvalues of a square matrix
+eigvalsh Eigenvalues of a Hermitian matrix
+qr QR decomposition of a matrix
+svd Singular value decomposition of a matrix
+cholesky Cholesky decomposition of a matrix
+=============== ==========================================================
+
+=============== ==========================================================
+Tensor operations
+==========================================================================
+tensorsolve Solve a linear tensor equation
+tensorinv Calculate an inverse of a tensor
+=============== ==========================================================
+
+=============== ==========================================================
+Exceptions
+==========================================================================
+LinAlgError Indicates a failed linear algebra operation
+=============== ==========================================================
+
+"""
# To get sub-modules
from info import __doc__
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
index 913a99499..f9af033f0 100644
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -133,7 +133,8 @@ def _assertNonEmpty(*arrays):
# Linear equations
def tensorsolve(a, b, axes=None):
- """Solve the tensor equation a x = b for x
+ """
+ Solve the tensor equation a x = b for x
It is assumed that all indices of x are summed over in the product,
together with the rightmost indices of a, similarly as in
@@ -141,10 +142,10 @@ def tensorsolve(a, b, axes=None):
Parameters
----------
- a : array-like, shape b.shape+Q
+ a : array_like, shape b.shape+Q
Coefficient tensor. Shape Q of the rightmost indices of a must
be such that a is 'square', ie., prod(Q) == prod(b.shape).
- b : array-like, any shape
+ b : array_like, any shape
Right-hand tensor.
axes : tuple of integers
Axes in a to reorder to the right, before inversion.
@@ -189,18 +190,39 @@ def tensorsolve(a, b, axes=None):
return res
def solve(a, b):
- """Solve the equation a x = b
+ """
+ Solve the equation ``a x = b`` for ``x``.
Parameters
----------
- a : array-like, shape (M, M)
- b : array-like, shape (M,)
+ a : array_like, shape (M, M)
+ Input equation coefficients.
+ b : array_like, shape (M,)
+ Equation target values.
Returns
-------
x : array, shape (M,)
- Raises LinAlgError if a is singular or not square
+ Raises
+ ------
+ LinAlgError
+ If `a` is singular or not square.
+
+ Examples
+ --------
+ Solve the system of equations ``3 * x0 + x1 = 9`` and ``x0 + 2 * x1 = 8``:
+
+ >>> a = np.array([[3,1], [1,2]])
+ >>> b = np.array([9,8])
+ >>> x = np.linalg.solve(a, b)
+ >>> x
+ array([ 2., 3.])
+
+ Check that the solution is correct:
+
+ >>> (np.dot(a, x) == b).all()
+ True
"""
a, _ = _makearray(a)
@@ -232,7 +254,8 @@ def solve(a, b):
def tensorinv(a, ind=2):
- """Find the 'inverse' of a N-d array
+ """
+ Find the 'inverse' of a N-d array
The result is an inverse corresponding to the operation
tensordot(a, b, ind), ie.,
@@ -244,7 +267,7 @@ def tensorinv(a, ind=2):
Parameters
----------
- a : array-like
+ a : array_like
Tensor to 'invert'. Its shape must 'square', ie.,
prod(a.shape[:ind]) == prod(a.shape[ind:])
ind : integer > 0
@@ -275,6 +298,7 @@ def tensorinv(a, ind=2):
>>> b = np.random.randn(24)
>>> np.allclose(np.tensordot(ainv, b, 1), np.linalg.tensorsolve(a, b))
True
+
"""
a = asarray(a)
oldshape = a.shape
@@ -293,19 +317,23 @@ def tensorinv(a, ind=2):
# Matrix inversion
def inv(a):
- """Compute the inverse of a matrix.
+ """
+ Compute the inverse of a matrix.
Parameters
----------
- a : array-like, shape (M, M)
+ a : array_like, shape (M, M)
Matrix to be inverted
Returns
-------
- ainv : array-like, shape (M, M)
- Inverse of the matrix a
+ ainv : ndarray, shape (M, M)
+ Inverse of the matrix `a`
- Raises LinAlgError if a is singular or not square
+ Raises
+ ------
+ LinAlgError
+ If `a` is singular or not square.
Examples
--------
@@ -326,22 +354,40 @@ def inv(a):
def cholesky(a):
"""
- Compute the Cholesky decomposition of a matrix.
+ Cholesky decomposition.
- Returns the Cholesky decomposition, :math:`A = L L^*` of a Hermitian
+ Return the Cholesky decomposition, :math:`A = L L^*` of a Hermitian
positive-definite matrix :math:`A`.
Parameters
----------
- a : array-like, shape (M, M)
- Matrix to be decomposed
+ a : array_like, shape (M, M)
+ Hermitian (symmetric, if it is real) and positive definite
+ input matrix.
Returns
-------
- L : array-like, shape (M, M)
- Lower-triangular Cholesky factor of A
+ L : array_like, shape (M, M)
+ Lower-triangular Cholesky factor of A.
- Raises LinAlgError if decomposition fails
+ Raises
+ ------
+ LinAlgError
+ If the decomposition fails.
+
+ Notes
+ -----
+ The Cholesky decomposition is often used as a fast way of solving
+
+ .. math:: A \\mathbf{x} = \\mathbf{b}.
+
+ First, we solve for :math:`\\mathbf{y}` in
+
+ .. math:: L \\mathbf{y} = \\mathbf{b},
+
+ and then for :math:`\\mathbf{x}` in
+
+ .. math:: L^* \\mathbf{x} = \\mathbf{y}.
Examples
--------
@@ -378,14 +424,15 @@ def cholesky(a):
# QR decompostion
def qr(a, mode='full'):
- """Compute QR decomposition of a matrix.
+ """
+ Compute QR decomposition of a matrix.
Calculate the decomposition :math:`A = Q R` where Q is orthonormal
and R upper triangular.
Parameters
----------
- a : array-like, shape (M, N)
+ a : array_like, shape (M, N)
Matrix to be decomposed
mode : {'full', 'r', 'economic'}
Determines what information is to be returned. 'full' is the default.
@@ -505,24 +552,26 @@ def qr(a, mode='full'):
def eigvals(a):
- """Compute the eigenvalues of a general matrix.
+ """
+ Compute the eigenvalues of a general matrix.
Parameters
----------
- a : array-like, shape (M, M)
+ a : array_like, shape (M, M)
A complex or real matrix whose eigenvalues and eigenvectors
will be computed.
Returns
-------
- w : double or complex array, shape (M,)
+ w : ndarray, shape (M,)
The eigenvalues, each repeated according to its multiplicity.
They are not necessarily ordered, nor are they necessarily
real for real matrices.
- If a is a matrix, so is w.
-
- Raises LinAlgError if eigenvalue computation does not converge
+ Raises
+ ------
+ LinAlgError
+ If the eigenvalue computation does not converge.
See Also
--------
@@ -587,25 +636,29 @@ def eigvals(a):
def eigvalsh(a, UPLO='L'):
- """Compute the eigenvalues of a Hermitean or real symmetric matrix.
+ """
+ Compute the eigenvalues of a Hermitean or real symmetric matrix.
Parameters
----------
- a : array-like, shape (M, M)
+ a : array_like, shape (M, M)
A complex or real matrix whose eigenvalues and eigenvectors
will be computed.
- UPLO : {'L', 'U'}
- Specifies whether the pertinent array data is taken from the upper
- or lower triangular part of a. Possible values are 'L', and 'U' for
- upper and lower respectively. Default is 'L'.
+ UPLO : {'L', 'U'}, optional
+ Specifies whether the calculation is done with data from the
+ lower triangular part of `a` ('L', default) or the upper triangular
+ part ('U').
Returns
-------
- w : double array, shape (M,)
+ w : ndarray, shape (M,)
The eigenvalues, each repeated according to its multiplicity.
They are not necessarily ordered.
- Raises LinAlgError if eigenvalue computation does not converge
+ Raises
+ ------
+ LinAlgError
+ If the eigenvalue computation does not converge.
See Also
--------
@@ -674,27 +727,28 @@ def _convertarray(a):
def eig(a):
- """Compute eigenvalues and right eigenvectors of a general matrix.
+ """
+ Compute eigenvalues and right eigenvectors of an array.
Parameters
----------
- a : array-like, shape (M, M)
- A complex or real 2-d array whose eigenvalues and eigenvectors
- will be computed.
+ a : array_like, shape (M, M)
+ A complex or real 2-D array.
Returns
-------
- w : double or complex array, shape (M,)
+ w : ndarray, shape (M,)
The eigenvalues, each repeated according to its multiplicity.
The eigenvalues are not necessarily ordered, nor are they
necessarily real for real matrices.
- v : double or complex array, shape (M, M)
- The normalized eigenvector corresponding to the eigenvalue w[i] is
- the column v[:,i].
-
- If a is a matrix, so are all the return values.
+ v : ndarray, shape (M, M)
+ The normalized eigenvector corresponding to the eigenvalue ``w[i]`` is
+ the column ``v[:,i]``.
- Raises LinAlgError if eigenvalue computation does not converge
+ Raises
+ ------
+ LinAlgError
+ If the eigenvalue computation does not converge.
See Also
--------
@@ -708,17 +762,17 @@ def eig(a):
that compute the eigenvalues and eigenvectors of general real and
complex arrays respectively.
- The number w is an eigenvalue of a if there exists a vector v
- satisfying the equation dot(a,v) = w*v. Alternately, if w is a root of
- the characteristic equation det(a - w[i]*I) = 0, where det is the
- determinant and I is the identity matrix. The arrays a, w, and v
- satisfy the equation dot(a,v[i]) = w[i]*v[:,i].
+ The number `w` is an eigenvalue of a if there exists a vector `v`
+ satisfying the equation ``dot(a,v) = w*v``. Alternately, if `w` is a root of
+ the characteristic equation ``det(a - w[i]*I) = 0``, where `det` is the
+ determinant and `I` is the identity matrix. The arrays `a`, `w`, and `v`
+ satisfy the equation ``dot(a,v[i]) = w[i]*v[:,i]``.
- The array v of eigenvectors may not be of maximum rank, that is, some
+ The array `v` of eigenvectors may not be of maximum rank, that is, some
of the columns may be dependent, although roundoff error may obscure
that fact. If the eigenvalues are all different, then theoretically the
eigenvectors are independent. Likewise, the matrix of eigenvectors is
- unitary if the matrix a is normal, i.e., if dot(a, a.H) = dot(a.H, a).
+ unitary if the matrix `a` is normal, i.e., if ``dot(a, a.H) = dot(a.H, a)``.
The left and right eigenvectors are not necessarily the (Hermitian)
transposes of each other.
@@ -779,29 +833,30 @@ def eig(a):
def eigh(a, UPLO='L'):
- """Compute eigenvalues for a Hermitian or real symmetric matrix.
+ """
+ Eigenvalues and eigenvectors of a Hermitian or real symmetric matrix.
Parameters
----------
- a : array-like, shape (M, M)
- A complex Hermitian or symmetric real matrix whose eigenvalues
- and eigenvectors will be computed.
- UPLO : {'L', 'U'}
- Specifies whether the pertinent array date is taken from the upper
- or lower triangular part of a. Possible values are 'L', and 'U'.
- Default is 'L'.
+ a : array_like, shape (M, M)
+ A complex Hermitian or symmetric real matrix.
+ UPLO : {'L', 'U'}, optional
+ Specifies whether the calculation is done with data from the
+ lower triangular part of `a` ('L', default) or the upper triangular
+ part ('U').
Returns
-------
- w : double array, shape (M,)
+ w : ndarray, shape (M,)
The eigenvalues. The eigenvalues are not necessarily ordered.
- v : double or complex double array, shape (M, M)
+ v : ndarray, shape (M, M)
The normalized eigenvector corresponding to the eigenvalue w[i] is
the column v[:,i].
- If a is a matrix, then so are the return values.
-
- Raises LinAlgError if eigenvalue computation does not converge
+ Raises
+ ------
+ LinAlgError
+ If the eigenvalue computation does not converge.
See Also
--------
@@ -822,6 +877,7 @@ def eigh(a, UPLO='L'):
symmetric or complex Hermitean matrices are always real. The array v
of eigenvectors is unitary and a, w, and v satisfy the equation
dot(a,v[i]) = w[i]*v[:,i].
+
"""
a, wrap = _makearray(a)
_assertRank2(a)
@@ -867,34 +923,44 @@ def eigh(a, UPLO='L'):
# Singular value decomposition
def svd(a, full_matrices=1, compute_uv=1):
- """Singular Value Decomposition.
+ """
+ Singular Value Decomposition.
- Factorizes the matrix a into two unitary matrices U and Vh and
- an 1d-array s of singular values (real, non-negative) such that
- a == U S Vh if S is an suitably shaped matrix of zeros whose
- main diagonal is s.
+ Factorizes the matrix `a` into two unitary matrices, ``U`` and ``Vh``,
+ and a 1-dimensional array of singular values, ``s`` (real, non-negative),
+ such that ``a == U S Vh``, where ``S`` is the diagonal
+ matrix ``np.diag(s)``.
Parameters
----------
- a : array-like, shape (M, N)
+ a : array_like, shape (M, N)
Matrix to decompose
- full_matrices : boolean
- If true, U, Vh are shaped (M,M), (N,N)
- If false, the shapes are (M,K), (K,N) where K = min(M,N)
+ full_matrices : boolean, optional
+ If True (default), ``U`` and ``Vh`` are shaped
+ ``(M,M)`` and ``(N,N)``. Otherwise, the shapes are
+ ``(M,K)`` and ``(K,N)``, where ``K = min(M,N)``.
compute_uv : boolean
- Whether to compute U and Vh in addition to s
+ Whether to compute ``U`` and ``Vh`` in addition to ``s``.
+ True by default.
Returns
-------
- U: array, shape (M,M) or (M,K) depending on full_matrices
- s: array, shape (K,)
- The singular values, sorted so that s[i] >= s[i+1]
- K = min(M, N)
- Vh: array, shape (N,N) or (K,N) depending on full_matrices
+ U : ndarray, shape (M, M) or (M, K) depending on `full_matrices`
+ Unitary matrix.
+ s : ndarray, shape (K,) where ``K = min(M, N)``
+ The singular values, sorted so that ``s[i] >= s[i+1]``.
+ Vh : ndarray, shape (N,N) or (K,N) depending on `full_matrices`
+ Unitary matrix.
+
+ Raises
+ ------
+ LinAlgError
+ If SVD computation does not converge.
- If a is a matrix, so are all the return values.
-
- Raises LinAlgError if SVD computation does not converge
+ Notes
+ -----
+ If `a` is a matrix (in contrast to an ndarray), then so are all
+ the return values.
Examples
--------
@@ -913,6 +979,7 @@ def svd(a, full_matrices=1, compute_uv=1):
>>> s2 = np.linalg.svd(a, compute_uv=False)
>>> np.allclose(s, s2)
True
+
"""
a, wrap = _makearray(a)
_assertRank2(a)
@@ -973,19 +1040,21 @@ def svd(a, full_matrices=1, compute_uv=1):
return s
def cond(x, p=None):
- """Compute the condition number of a matrix.
+ """
+ Compute the condition number of a matrix.
- The condition number of x is the norm of x times the norm
- of the inverse of x. The norm can be the usual L2
+ The condition number of `x` is the norm of `x` times the norm
+ of the inverse of `x`. The norm can be the usual L2
(root-of-sum-of-squares) norm or a number of other matrix norms.
Parameters
----------
- x : array-like, shape (M, N)
+ x : array_like, shape (M, N)
The matrix whose condition number is sought.
p : {None, 1, -1, 2, -2, inf, -inf, 'fro'}
Order of the norm:
+ ===== ============================
p norm for matrices
===== ============================
None 2-norm, computed directly using the SVD
@@ -1002,6 +1071,7 @@ def cond(x, p=None):
-------
c : float
The condition number of the matrix. May be infinite.
+
"""
x = asarray(x) # in case we have a matrix
if p is None:
@@ -1013,27 +1083,33 @@ def cond(x, p=None):
# Generalized inverse
def pinv(a, rcond=1e-15 ):
- """Compute the (Moore-Penrose) pseudo-inverse of a matrix.
+ """
+ Compute the (Moore-Penrose) pseudo-inverse of a matrix.
- Calculate a generalized inverse of a matrix using its
- singular-value decomposition and including all 'large' singular
- values.
+ Calculate the generalized inverse of a matrix using its
+ singular-value decomposition (SVD) and including all
+ `large` singular values.
Parameters
----------
- a : array-like, shape (M, N)
- Matrix to be pseudo-inverted
+ a : array_like (M, N)
+ Matrix to be pseudo-inverted.
rcond : float
- Cutoff for 'small' singular values.
- Singular values smaller than rcond*largest_singular_value are
- considered zero.
+ Cutoff for `small` singular values.
+ Singular values smaller than rcond*largest_singular_value are
+ considered zero.
Returns
-------
- B : array, shape (N, M)
- If a is a matrix, then so is B.
+ B : ndarray (N, M)
+ The pseudo-inverse of `a`. If `a` is an np.matrix instance, then so
+ is `B`.
+
- Raises LinAlgError if SVD computation does not converge
+ Raises
+ ------
+ LinAlgError
+ In case SVD computation does not converge.
Examples
--------
@@ -1063,20 +1139,32 @@ def pinv(a, rcond=1e-15 ):
# Determinant
def det(a):
- """Compute the determinant of a matrix
+ """
+ Compute the determinant of an array.
Parameters
----------
a : array-like, shape (M, M)
+ Input array.
Returns
-------
- det : float or complex
- Determinant of a
+ det : ndarray
+ Determinant of `a`.
Notes
-----
- The determinant is computed via LU factorization, LAPACK routine z/dgetrf.
+ The determinant is computed via LU factorization using the LAPACK
+ routine z/dgetrf.
+
+ Examples
+ --------
+ The determinant of a 2-D array [[a, b], [c, d]] is ad - bc:
+
+ >>> a = np.array([[1, 2], [3, 4]])
+ >>> np.linalg.det(a)
+ -2.0
+
"""
a = asarray(a)
_assertRank2(a)
@@ -1102,37 +1190,82 @@ def det(a):
# Linear Least Squares
def lstsq(a, b, rcond=-1):
- """Compute least-squares solution to equation :math:`a x = b`
+ """
+ Return the least-squares solution to an equation.
- Compute a vector x such that the 2-norm :math:`|b - a x|` is minimised.
+ Solves the equation `a x = b` by computing a vector `x` that minimizes
+ the norm `|| b - a x ||`.
Parameters
----------
- a : array-like, shape (M, N)
- b : array-like, shape (M,) or (M, K)
- rcond : float
- Cutoff for 'small' singular values.
- Singular values smaller than rcond*largest_singular_value are
- considered zero.
-
- Raises LinAlgError if computation does not converge
+ a : array_like, shape (M, N)
+ Input equation coefficients.
+ b : array_like, shape (M,) or (M, K)
+ Equation target values. If `b` is two-dimensional, the least
+ squares solution is calculated for each of the `K` target sets.
+ rcond : float, optional
+ Cutoff for ``small`` singular values of `a`.
+ Singular values smaller than `rcond` times the largest singular
+ value are considered zero.
Returns
-------
- x : array, shape (N,) or (N, K) depending on shape of b
- Least-squares solution
- residues : array, shape () or (1,) or (K,)
- Sums of residues, squared 2-norm for each column in :math:`b - a x`
- If rank of matrix a is < N or > M this is an empty array.
- If b was 1-d, this is an (1,) shape array, otherwise the shape is (K,)
+ x : ndarray, shape(N,) or (N, K)
+ Least squares solution. The shape of `x` depends on the shape of
+ `b`.
+ residues : ndarray, shape(), (1,), or (K,)
+ Sums of residues; squared Euclidian norm for each column in
+ `b - a x`.
+ If the rank of `a` is < N or > M, this is an empty array.
+ If `b` is 1-dimensional, this is a (1,) shape array.
+ Otherwise the shape is (K,).
rank : integer
- Rank of matrix a
- s : array, shape (min(M,N),)
- Singular values of a
+ Rank of matrix `a`.
+ s : ndarray, shape(min(M,N),)
+ Singular values of `a`.
+
+ Raises
+ ------
+ LinAlgError
+ If computation does not converge.
- If b is a matrix, then all results except the rank are also returned as
+ Notes
+ -----
+ If `b` is a matrix, then all array results returned as
matrices.
+ Examples
+ --------
+ Fit a line, ``y = mx + c``, through some noisy data-points:
+
+ >>> x = np.array([0, 1, 2, 3])
+ >>> y = np.array([-1, 0.2, 0.9, 2.1])
+
+ By examining the coefficients, we see that the line should have a
+ gradient of roughly 1 and cuts the y-axis at more-or-less -1.
+
+ We can rewrite the line equation as ``y = Ap``, where ``A = [[x 1]]``
+ and ``p = [[m], [c]]``. Now use `lstsq` to solve for `p`:
+
+ >>> A = np.vstack([x, np.ones(len(x))]).T
+ >>> A
+ array([[ 0., 1.],
+ [ 1., 1.],
+ [ 2., 1.],
+ [ 3., 1.]])
+
+ >>> m, c = np.linalg.lstsq(A, y)[0]
+ >>> print m, c
+ 1.0 -0.95
+
+ Plot the data along with the fitted line:
+
+ >>> import matplotlib.pyplot as plt
+ >>> plt.plot(x, y, 'o', label='Original data', markersize=10)
+ >>> plt.plot(x, m*x + c, 'r', label='Fitted line')
+ >>> plt.legend()
+ >>> plt.show()
+
"""
import math
a, _ = _makearray(a)
@@ -1199,26 +1332,15 @@ def lstsq(a, b, rcond=-1):
return wrap(x), wrap(resids), results['rank'], st
def norm(x, ord=None):
- """Matrix or vector norm.
+ """
+ Matrix or vector norm.
Parameters
----------
- x : array-like, shape (M,) or (M, N)
- ord : number, or {None, 1, -1, 2, -2, inf, -inf, 'fro'}
- Order of the norm:
-
- ord norm for matrices norm for vectors
- ===== ============================ ==========================
- None Frobenius norm 2-norm
- 'fro' Frobenius norm -
- inf max(sum(abs(x), axis=1)) max(abs(x))
- -inf min(sum(abs(x), axis=1)) min(abs(x))
- 1 max(sum(abs(x), axis=0)) as below
- -1 min(sum(abs(x), axis=0)) as below
- 2 2-norm (largest sing. value) as below
- -2 smallest singular value as below
- other - sum(abs(x)**ord)**(1./ord)
- ===== ============================ ==========================
+ x : array_like, shape (M,) or (M, N)
+ Input array.
+ ord : {int, 1, -1, 2, -2, inf, -inf, 'fro'}
+ Order of the norm (see table under ``Notes``).
Returns
-------
@@ -1231,6 +1353,22 @@ def norm(x, ord=None):
mathematical 'norm', but it may still be useful for numerical
purposes.
+ The following norms can be calculated:
+
+ ===== ============================ ==========================
+ ord norm for matrices norm for vectors
+ ===== ============================ ==========================
+ None Frobenius norm 2-norm
+ 'fro' Frobenius norm --
+ inf max(sum(abs(x), axis=1)) max(abs(x))
+ -inf min(sum(abs(x), axis=1)) min(abs(x))
+ 1 max(sum(abs(x), axis=0)) as below
+ -1 min(sum(abs(x), axis=0)) as below
+ 2 2-norm (largest sing. value) as below
+ -2 smallest singular value as below
+ other -- sum(abs(x)**ord)**(1./ord)
+ ===== ============================ ==========================
+
"""
x = asarray(x)
nd = len(x.shape)
diff --git a/numpy/ma/__init__.py b/numpy/ma/__init__.py
index 46aee2082..c09f73980 100644
--- a/numpy/ma/__init__.py
+++ b/numpy/ma/__init__.py
@@ -1,10 +1,40 @@
-"""Masked arrays add-ons.
+"""
+=============
+Masked Arrays
+=============
+
+Arrays sometimes contain invalid or missing data. When doing operations
+on such arrays, we wish to suppress invalid values, which is the purpose masked
+arrays fulfill (an example of typical use is given below).
+
+For example, examine the following array:
+
+>>> x = np.array([2, 1, 3, np.nan, 5, 2, 3, np.nan])
+
+When we try to calculate the mean of the data, the result is undetermined:
+
+>>> np.mean(x)
+nan
+
+The mean is calculated using roughly ``np.sum(x)/len(x)``, but since
+any number added to ``NaN`` [*]_ produces ``NaN``, this doesn't work. Enter
+masked arrays:
+
+>>> m = np.ma.masked_array(x, np.isnan(x))
+>>> m
+masked_array(data = [2.0 1.0 3.0 -- 5.0 2.0 3.0 --],
+ mask = [False False False True False False False True],
+ fill_value=1e+20)
+
+Here, we construct a masked array that suppress all ``NaN`` values. We
+may now proceed to calculate the mean of the other values:
+
+>>> np.mean(m)
+2.6666666666666665
-A collection of utilities for maskedarray
+.. [*] Not-a-Number, a floating point value that is the result of an
+ invalid operation.
-:author: Pierre GF Gerard-Marchant
-:contact: pierregm_at_uga_dot_edu
-:version: $Id: __init__.py 3473 2007-10-29 15:18:13Z jarrod.millman $
"""
__author__ = "Pierre GF Gerard-Marchant ($Author: jarrod.millman $)"
__version__ = '1.0'
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py
index c4259ecee..41b64339d 100644
--- a/numpy/ma/extras.py
+++ b/numpy/ma/extras.py
@@ -839,11 +839,115 @@ def vander(x, n=None):
def polyfit(x, y, deg, rcond=None, full=False):
- """%s
+ """
+ Least squares polynomial fit.
+
+ Do a best fit polynomial of degree 'deg' of 'x' to 'y'. Return value is a
+ vector of polynomial coefficients [pk ... p1 p0]. Eg, for ``deg = 2``::
+
+ p2*x0^2 + p1*x0 + p0 = y1
+ p2*x1^2 + p1*x1 + p0 = y1
+ p2*x2^2 + p1*x2 + p0 = y2
+ .....
+ p2*xk^2 + p1*xk + p0 = yk
+
+ Parameters
+ ----------
+ x : array_like
+ 1D vector of sample points.
+ y : array_like
+ 1D vector or 2D array of values to fit. The values should run down the
+ columns in the 2D case.
+ deg : integer
+ Degree of the fitting polynomial
+ rcond: {None, float}, optional
+ Relative condition number of the fit. Singular values smaller than this
+ relative to the largest singular value will be ignored. The defaul value
+ is len(x)*eps, where eps is the relative precision of the float type,
+ about 2e-16 in most cases.
+ full : {False, boolean}, optional
+ Switch determining nature of return value. When it is False just the
+ coefficients are returned, when True diagnostic information from the
+ singular value decomposition is also returned.
+
+ Returns
+ -------
+ coefficients, [residuals, rank, singular_values, rcond] : variable
+ When full=False, only the coefficients are returned, running down the
+ appropriate colume when y is a 2D array. When full=True, the rank of the
+ scaled Vandermonde matrix, its effective rank in light of the rcond
+ value, its singular values, and the specified value of rcond are also
+ returned.
+
+ Warns
+ -----
+ RankWarning : if rank is reduced and not full output
+ The warnings can be turned off by:
+ >>> import warnings
+ >>> warnings.simplefilter('ignore',np.RankWarning)
+
+
+ See Also
+ --------
+ polyval : computes polynomial values.
+
+ Notes
+ -----
+ If X is a the Vandermonde Matrix computed from x (see
+ http://mathworld.wolfram.com/VandermondeMatrix.html), then the
+ polynomial least squares solution is given by the 'p' in
+
+ X*p = y
+
+ where X.shape is a matrix of dimensions (len(x), deg + 1), p is a vector of
+ dimensions (deg + 1, 1), and y is a vector of dimensions (len(x), 1).
+
+ This equation can be solved as
+
+ p = (XT*X)^-1 * XT * y
+
+ where XT is the transpose of X and -1 denotes the inverse. However, this
+ method is susceptible to rounding errors and generally the singular value
+ decomposition of the matrix X is preferred and that is what is done here.
+ The singular value method takes a paramenter, 'rcond', which sets a limit on
+ the relative size of the smallest singular value to be used in solving the
+ equation. This may result in lowering the rank of the Vandermonde matrix, in
+ which case a RankWarning is issued. If polyfit issues a RankWarning, try a
+ fit of lower degree or replace x by x - x.mean(), both of which will
+ generally improve the condition number. The routine already normalizes the
+ vector x by its maximum absolute value to help in this regard. The rcond
+ parameter can be set to a value smaller than its default, but the resulting
+ fit may be spurious. The current default value of rcond is len(x)*eps, where
+ eps is the relative precision of the floating type being used, generally
+ around 1e-7 and 2e-16 for IEEE single and double precision respectively.
+ This value of rcond is fairly conservative but works pretty well when x -
+ x.mean() is used in place of x.
+
+
+ DISCLAIMER: Power series fits are full of pitfalls for the unwary once the
+ degree of the fit becomes large or the interval of sample points is badly
+ centered. The problem is that the powers x**n are generally a poor basis for
+ the polynomial functions on the sample interval, resulting in a Vandermonde
+ matrix is ill conditioned and coefficients sensitive to rounding erros. The
+ computation of the polynomial values will also sensitive to rounding errors.
+ Consequently, the quality of the polynomial fit should be checked against
+ the data whenever the condition number is large. The quality of polynomial
+ fits *can not* be taken for granted. If all you want to do is draw a smooth
+ curve through the y values and polyfit is not doing the job, try centering
+ the sample range or look into scipy.interpolate, which includes some nice
+ spline fitting functions that may be of use.
+
+ For more info, see
+ http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html,
+ but note that the k's and n's in the superscripts and subscripts
+ on that page. The linear algebra is correct, however.
+
+
Notes
-----
Any masked values in x is propagated in y, and vice-versa.
+
"""
order = int(deg) + 1
x = asarray(x)
@@ -886,11 +990,4 @@ def polyfit(x, y, deg, rcond=None, full=False):
else :
return c
-_g = globals()
-for nfunc in ('vander', 'polyfit'):
- _g[nfunc].func_doc = _g[nfunc].func_doc % getattr(np,nfunc).__doc__
-
-
-
-
################################################################################
diff --git a/numpy/random/__init__.py b/numpy/random/__init__.py
index a60b57ccc..8c3a33368 100644
--- a/numpy/random/__init__.py
+++ b/numpy/random/__init__.py
@@ -1,3 +1,87 @@
+"""
+========================
+Random Number Generation
+========================
+
+==================== =========================================================
+Utility functions
+==============================================================================
+random Uniformly distributed values of a given shape.
+bytes Uniformly distributed random bytes.
+random_integers Uniformly distributed integers in a given range.
+random_sample Uniformly distributed floats in a given range.
+permutation Randomly permute a sequence / generate a random sequence.
+shuffle Randomly permute a sequence in place.
+seed Seed the random number generator.
+==================== =========================================================
+
+==================== =========================================================
+Compatibility functions
+==============================================================================
+rand Uniformly distributed values.
+randn Normally distributed values.
+ranf Uniformly distributed floating point numbers.
+randint Uniformly distributed integers in a given range.
+==================== =========================================================
+
+==================== =========================================================
+Univariate distributions
+==============================================================================
+beta Beta distribution over ``[0, 1]``.
+binomial Binomial distribution.
+chisquare :math:`\\chi^2` distribution.
+exponential Exponential distribution.
+f F (Fisher-Snedecor) distribution.
+gamma Gamma distribution.
+geometric Geometric distribution.
+gumbel Gumbel distribution.
+hypergeometric Hypergeometric distribution.
+laplace Laplace distribution.
+logistic Logistic distribution.
+lognormal Log-normal distribution.
+logseries Logarithmic series distribution.
+negative_binomial Negative binomial distribution.
+noncentral_chisquare Non-central chi-square distribution.
+noncentral_f Non-central F distribution.
+normal Normal / Gaussian distribution.
+pareto Pareto distribution.
+poisson Poisson distribution.
+power Power distribution.
+rayleigh Rayleigh distribution.
+triangular Triangular distribution.
+uniform Uniform distribution.
+vonmises Von Mises circular distribution.
+wald Wald (inverse Gaussian) distribution.
+weibull Weibull distribution.
+zipf Zipf's distribution over ranked data.
+==================== =========================================================
+
+==================== =========================================================
+Multivariate distributions
+==============================================================================
+dirichlet Multivariate generalization of Beta distribution.
+multinomial Multivariate generalization of the binomial distribution.
+multivariate_normal Multivariate generalization of the normal distribution.
+==================== =========================================================
+
+==================== =========================================================
+Standard distributions
+==============================================================================
+standard_cauchy Standard Cauchy-Lorentz distribution.
+standard_exponential Standard exponential distribution.
+standard_gamma Standard Gamma distribution.
+standard_normal Standard normal distribution.
+standard_t Standard Student's t-distribution.
+==================== =========================================================
+
+==================== =========================================================
+Internal functions
+==============================================================================
+get_state Get tuple representing internal state of generator.
+set_state Set state of generator.
+==================== =========================================================
+
+"""
# To get sub-modules
from info import __doc__, __all__
from mtrand import *
diff --git a/numpy/random/mtrand/mtrand.c b/numpy/random/mtrand/mtrand.c
index 4579e6e22..4b300babf 100644
--- a/numpy/random/mtrand/mtrand.c
+++ b/numpy/random/mtrand/mtrand.c
@@ -1,4 +1,4 @@
-/* Generated by Pyrex 0.9.8.4 on Fri Jul 25 12:42:18 2008 */
+/* Generated by Pyrex 0.9.8.2 on Tue Aug 5 11:02:12 2008 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -35,7 +35,8 @@
#include "initarray.h"
-typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
+typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
+typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
static PyObject *__pyx_m;
static PyObject *__pyx_b;
@@ -43,6 +44,10 @@ static int __pyx_lineno;
static char *__pyx_filename;
static char **__pyx_f;
+static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
+
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
@@ -54,14 +59,12 @@ static int __Pyx_EndUnpack(PyObject *); /*proto*/
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
-static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/
-
static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
-
static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v); /*proto*/
+static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
+
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/
@@ -72,9 +75,6 @@ static void __Pyx_AddTraceback(char *funcname); /*proto*/
/* Declarations from mtrand */
-
-/* Declarations from implementation of mtrand */
-
typedef double (*__pyx_t_6mtrand_rk_cont0)(rk_state *);
typedef double (*__pyx_t_6mtrand_rk_cont1)(rk_state *,double);
@@ -102,6 +102,65 @@ static PyTypeObject *__pyx_ptype_6mtrand_ndarray = 0;
static PyTypeObject *__pyx_ptype_6mtrand_flatiter = 0;
static PyTypeObject *__pyx_ptype_6mtrand_broadcast = 0;
static PyTypeObject *__pyx_ptype_6mtrand_RandomState = 0;
+static PyObject *__pyx_k2;
+static PyObject *__pyx_k3;
+static PyObject *__pyx_k4;
+static PyObject *__pyx_k5;
+static PyObject *__pyx_k6;
+static PyObject *__pyx_k7;
+static PyObject *__pyx_k8;
+static PyObject *__pyx_k9;
+static PyObject *__pyx_k10;
+static PyObject *__pyx_k11;
+static PyObject *__pyx_k12;
+static PyObject *__pyx_k13;
+static PyObject *__pyx_k14;
+static PyObject *__pyx_k15;
+static PyObject *__pyx_k16;
+static PyObject *__pyx_k17;
+static PyObject *__pyx_k18;
+static PyObject *__pyx_k19;
+static PyObject *__pyx_k20;
+static PyObject *__pyx_k21;
+static PyObject *__pyx_k22;
+static PyObject *__pyx_k23;
+static PyObject *__pyx_k24;
+static PyObject *__pyx_k25;
+static PyObject *__pyx_k26;
+static PyObject *__pyx_k27;
+static PyObject *__pyx_k28;
+static PyObject *__pyx_k29;
+static PyObject *__pyx_k30;
+static PyObject *__pyx_k31;
+static PyObject *__pyx_k32;
+static PyObject *__pyx_k33;
+static PyObject *__pyx_k34;
+static PyObject *__pyx_k35;
+static PyObject *__pyx_k36;
+static PyObject *__pyx_k37;
+static PyObject *__pyx_k38;
+static PyObject *__pyx_k39;
+static PyObject *__pyx_k40;
+static PyObject *__pyx_k41;
+static PyObject *__pyx_k42;
+static PyObject *__pyx_k43;
+static PyObject *__pyx_k44;
+static PyObject *__pyx_k45;
+static PyObject *__pyx_k46;
+static PyObject *__pyx_k47;
+static PyObject *__pyx_k48;
+static PyObject *__pyx_k49;
+static PyObject *__pyx_k50;
+static PyObject *__pyx_k51;
+static PyObject *__pyx_k52;
+static PyObject *__pyx_k53;
+static PyObject *__pyx_k54;
+static PyObject *__pyx_k55;
+static PyObject *__pyx_k56;
+static PyObject *__pyx_k57;
+static PyObject *__pyx_k58;
+static PyObject *__pyx_k59;
+static PyObject *__pyx_k60;
static PyObject *__pyx_f_6mtrand_cont0_array(rk_state *,__pyx_t_6mtrand_rk_cont0,PyObject *); /*proto*/
static PyObject *__pyx_f_6mtrand_cont1_array_sc(rk_state *,__pyx_t_6mtrand_rk_cont1,PyObject *,double); /*proto*/
static PyObject *__pyx_f_6mtrand_cont1_array(rk_state *,__pyx_t_6mtrand_rk_cont1,PyObject *,PyArrayObject *); /*proto*/
@@ -118,426 +177,62 @@ static PyObject *__pyx_f_6mtrand_discd_array_sc(rk_state *,__pyx_t_6mtrand_rk_di
static PyObject *__pyx_f_6mtrand_discd_array(rk_state *,__pyx_t_6mtrand_rk_discd,PyObject *,PyArrayObject *); /*proto*/
static double __pyx_f_6mtrand_kahan_sum(double *,long); /*proto*/
-static char __pyx_k1[] = "np";
-static char __pyx_k2[] = "empty";
-static char __pyx_k3[] = "float64";
-static char __pyx_k4[] = "size is not compatible with inputs";
-static char __pyx_k5[] = "seed";
-static char __pyx_k6[] = "integer";
-static char __pyx_k7[] = "uint";
-static char __pyx_k8[] = "asarray";
-static char __pyx_k9[] = "uint32";
-static char __pyx_k10[] = "MT19937";
-static char __pyx_k11[] = "algorithm must be 'MT19937'";
-static char __pyx_k12[] = "state must be 624 longs";
-static char __pyx_k13[] = "get_state";
-static char __pyx_k14[] = "set_state";
-static char __pyx_k15[] = "random";
-static char __pyx_k16[] = "__RandomState_ctor";
-static char __pyx_k17[] = "low >= high";
-static char __pyx_k18[] = "subtract";
-static char __pyx_k19[] = "random_sample";
-static char __pyx_k20[] = "size";
-static char __pyx_k21[] = "standard_normal";
-static char __pyx_k22[] = "randint";
-static char __pyx_k23[] = "scale <= 0";
-static char __pyx_k24[] = "any";
-static char __pyx_k25[] = "less_equal";
-static char __pyx_k26[] = "a <= 0";
-static char __pyx_k27[] = "b <= 0";
-static char __pyx_k28[] = "shape <= 0";
-static char __pyx_k29[] = "dfnum <= 0";
-static char __pyx_k30[] = "dfden <= 0";
-static char __pyx_k31[] = "dfnum <= 1";
-static char __pyx_k32[] = "nonc < 0";
-static char __pyx_k33[] = "less";
-static char __pyx_k34[] = "df <= 0";
-static char __pyx_k35[] = "nonc <= 0";
-static char __pyx_k36[] = "df <= 1";
-static char __pyx_k37[] = "kappa < 0";
-static char __pyx_k38[] = "sigma <= 0";
-static char __pyx_k39[] = "sigma <= 0.0";
-static char __pyx_k40[] = "scale <= 0.0";
-static char __pyx_k41[] = "mean <= 0";
-static char __pyx_k42[] = "mean <= 0.0";
-static char __pyx_k43[] = "left > mode";
-static char __pyx_k44[] = "mode > right";
-static char __pyx_k45[] = "left == right";
-static char __pyx_k46[] = "greater";
-static char __pyx_k47[] = "equal";
-static char __pyx_k48[] = "n <= 0";
-static char __pyx_k49[] = "p < 0";
-static char __pyx_k50[] = "p > 1";
-static char __pyx_k51[] = "lam < 0";
-static char __pyx_k52[] = "a <= 1.0";
-static char __pyx_k53[] = "p < 0.0";
-static char __pyx_k54[] = "p > 1.0";
-static char __pyx_k55[] = "ngood < 1";
-static char __pyx_k56[] = "nbad < 1";
-static char __pyx_k57[] = "nsample < 1";
-static char __pyx_k58[] = "ngood + nbad < nsample";
-static char __pyx_k59[] = "add";
-static char __pyx_k60[] = "array";
-static char __pyx_k61[] = "shape";
-static char __pyx_k62[] = "mean must be 1 dimensional";
-static char __pyx_k63[] = "cov must be 2 dimensional and square";
-static char __pyx_k64[] = "mean and cov must have same length";
-static char __pyx_k65[] = "append";
-static char __pyx_k66[] = "multiply";
-static char __pyx_k67[] = "reduce";
-static char __pyx_k68[] = "numpy.dual";
-static char __pyx_k69[] = "svd";
-static char __pyx_k70[] = "dot";
-static char __pyx_k71[] = "sqrt";
-static char __pyx_k72[] = "sum(pvals[:-1]) > 1.0";
-static char __pyx_k73[] = "zeros";
-static char __pyx_k74[] = "copy";
-static char __pyx_k75[] = "arange";
-static char __pyx_k76[] = "shuffle";
-static char __pyx_k77[] = "numpy";
-static char __pyx_k78[] = "_rand";
-static char __pyx_k79[] = "bytes";
-static char __pyx_k80[] = "uniform";
-static char __pyx_k81[] = "rand";
-static char __pyx_k82[] = "randn";
-static char __pyx_k83[] = "random_integers";
-static char __pyx_k84[] = "normal";
-static char __pyx_k85[] = "beta";
-static char __pyx_k86[] = "exponential";
-static char __pyx_k87[] = "standard_exponential";
-static char __pyx_k88[] = "standard_gamma";
-static char __pyx_k89[] = "gamma";
-static char __pyx_k90[] = "f";
-static char __pyx_k91[] = "noncentral_f";
-static char __pyx_k92[] = "chisquare";
-static char __pyx_k93[] = "noncentral_chisquare";
-static char __pyx_k94[] = "standard_cauchy";
-static char __pyx_k95[] = "standard_t";
-static char __pyx_k96[] = "vonmises";
-static char __pyx_k97[] = "pareto";
-static char __pyx_k98[] = "weibull";
-static char __pyx_k99[] = "power";
-static char __pyx_k100[] = "laplace";
-static char __pyx_k101[] = "gumbel";
-static char __pyx_k102[] = "logistic";
-static char __pyx_k103[] = "lognormal";
-static char __pyx_k104[] = "rayleigh";
-static char __pyx_k105[] = "wald";
-static char __pyx_k106[] = "triangular";
-static char __pyx_k107[] = "binomial";
-static char __pyx_k108[] = "negative_binomial";
-static char __pyx_k109[] = "poisson";
-static char __pyx_k110[] = "zipf";
-static char __pyx_k111[] = "geometric";
-static char __pyx_k112[] = "hypergeometric";
-static char __pyx_k113[] = "logseries";
-static char __pyx_k114[] = "multivariate_normal";
-static char __pyx_k115[] = "multinomial";
-static char __pyx_k116[] = "dirichlet";
-static char __pyx_k117[] = "permutation";
-static PyObject *__pyx_n_MT19937;
-static PyObject *__pyx_n___RandomState_ctor;
+/* Implementation of mtrand */
+
+
+static PyObject *__pyx_n_numpy;
+static PyObject *__pyx_n_np;
static PyObject *__pyx_n__rand;
-static PyObject *__pyx_n_add;
-static PyObject *__pyx_n_any;
-static PyObject *__pyx_n_append;
-static PyObject *__pyx_n_arange;
-static PyObject *__pyx_n_array;
-static PyObject *__pyx_n_asarray;
-static PyObject *__pyx_n_beta;
-static PyObject *__pyx_n_binomial;
-static PyObject *__pyx_n_bytes;
-static PyObject *__pyx_n_chisquare;
-static PyObject *__pyx_n_copy;
-static PyObject *__pyx_n_dirichlet;
-static PyObject *__pyx_n_dot;
-static PyObject *__pyx_n_empty;
-static PyObject *__pyx_n_equal;
-static PyObject *__pyx_n_exponential;
-static PyObject *__pyx_n_f;
-static PyObject *__pyx_n_float64;
-static PyObject *__pyx_n_gamma;
-static PyObject *__pyx_n_geometric;
+static PyObject *__pyx_n_seed;
static PyObject *__pyx_n_get_state;
-static PyObject *__pyx_n_greater;
-static PyObject *__pyx_n_gumbel;
-static PyObject *__pyx_n_hypergeometric;
-static PyObject *__pyx_n_integer;
-static PyObject *__pyx_n_laplace;
-static PyObject *__pyx_n_less;
-static PyObject *__pyx_n_less_equal;
-static PyObject *__pyx_n_logistic;
-static PyObject *__pyx_n_lognormal;
-static PyObject *__pyx_n_logseries;
-static PyObject *__pyx_n_multinomial;
-static PyObject *__pyx_n_multiply;
-static PyObject *__pyx_n_multivariate_normal;
-static PyObject *__pyx_n_negative_binomial;
-static PyObject *__pyx_n_noncentral_chisquare;
-static PyObject *__pyx_n_noncentral_f;
-static PyObject *__pyx_n_normal;
-static PyObject *__pyx_n_np;
-static PyObject *__pyx_n_numpy;
-static PyObject *__pyx_n_pareto;
-static PyObject *__pyx_n_permutation;
-static PyObject *__pyx_n_poisson;
-static PyObject *__pyx_n_power;
-static PyObject *__pyx_n_rand;
+static PyObject *__pyx_n_set_state;
+static PyObject *__pyx_n_random_sample;
static PyObject *__pyx_n_randint;
+static PyObject *__pyx_n_bytes;
+static PyObject *__pyx_n_uniform;
+static PyObject *__pyx_n_rand;
static PyObject *__pyx_n_randn;
-static PyObject *__pyx_n_random;
static PyObject *__pyx_n_random_integers;
-static PyObject *__pyx_n_random_sample;
-static PyObject *__pyx_n_rayleigh;
-static PyObject *__pyx_n_reduce;
-static PyObject *__pyx_n_seed;
-static PyObject *__pyx_n_set_state;
-static PyObject *__pyx_n_shape;
-static PyObject *__pyx_n_shuffle;
-static PyObject *__pyx_n_size;
-static PyObject *__pyx_n_sqrt;
-static PyObject *__pyx_n_standard_cauchy;
+static PyObject *__pyx_n_standard_normal;
+static PyObject *__pyx_n_normal;
+static PyObject *__pyx_n_beta;
+static PyObject *__pyx_n_exponential;
static PyObject *__pyx_n_standard_exponential;
static PyObject *__pyx_n_standard_gamma;
-static PyObject *__pyx_n_standard_normal;
+static PyObject *__pyx_n_gamma;
+static PyObject *__pyx_n_f;
+static PyObject *__pyx_n_noncentral_f;
+static PyObject *__pyx_n_chisquare;
+static PyObject *__pyx_n_noncentral_chisquare;
+static PyObject *__pyx_n_standard_cauchy;
static PyObject *__pyx_n_standard_t;
-static PyObject *__pyx_n_subtract;
-static PyObject *__pyx_n_svd;
-static PyObject *__pyx_n_triangular;
-static PyObject *__pyx_n_uint;
-static PyObject *__pyx_n_uint32;
-static PyObject *__pyx_n_uniform;
static PyObject *__pyx_n_vonmises;
-static PyObject *__pyx_n_wald;
+static PyObject *__pyx_n_pareto;
static PyObject *__pyx_n_weibull;
-static PyObject *__pyx_n_zeros;
+static PyObject *__pyx_n_power;
+static PyObject *__pyx_n_laplace;
+static PyObject *__pyx_n_gumbel;
+static PyObject *__pyx_n_logistic;
+static PyObject *__pyx_n_lognormal;
+static PyObject *__pyx_n_rayleigh;
+static PyObject *__pyx_n_wald;
+static PyObject *__pyx_n_triangular;
+static PyObject *__pyx_n_binomial;
+static PyObject *__pyx_n_negative_binomial;
+static PyObject *__pyx_n_poisson;
static PyObject *__pyx_n_zipf;
+static PyObject *__pyx_n_geometric;
+static PyObject *__pyx_n_hypergeometric;
+static PyObject *__pyx_n_logseries;
+static PyObject *__pyx_n_multivariate_normal;
+static PyObject *__pyx_n_multinomial;
+static PyObject *__pyx_n_dirichlet;
+static PyObject *__pyx_n_shuffle;
+static PyObject *__pyx_n_permutation;
-static PyObject *__pyx_k4p;
-static PyObject *__pyx_k11p;
-static PyObject *__pyx_k12p;
-static PyObject *__pyx_k17p;
-static PyObject *__pyx_k23p;
-static PyObject *__pyx_k26p;
-static PyObject *__pyx_k27p;
-static PyObject *__pyx_k28p;
-static PyObject *__pyx_k29p;
-static PyObject *__pyx_k30p;
-static PyObject *__pyx_k31p;
-static PyObject *__pyx_k32p;
-static PyObject *__pyx_k34p;
-static PyObject *__pyx_k35p;
-static PyObject *__pyx_k36p;
-static PyObject *__pyx_k37p;
-static PyObject *__pyx_k38p;
-static PyObject *__pyx_k39p;
-static PyObject *__pyx_k40p;
-static PyObject *__pyx_k41p;
-static PyObject *__pyx_k42p;
-static PyObject *__pyx_k43p;
-static PyObject *__pyx_k44p;
-static PyObject *__pyx_k45p;
-static PyObject *__pyx_k48p;
-static PyObject *__pyx_k49p;
-static PyObject *__pyx_k50p;
-static PyObject *__pyx_k51p;
-static PyObject *__pyx_k52p;
-static PyObject *__pyx_k53p;
-static PyObject *__pyx_k54p;
-static PyObject *__pyx_k55p;
-static PyObject *__pyx_k56p;
-static PyObject *__pyx_k57p;
-static PyObject *__pyx_k58p;
-static PyObject *__pyx_k62p;
-static PyObject *__pyx_k63p;
-static PyObject *__pyx_k64p;
-static PyObject *__pyx_k68p;
-static PyObject *__pyx_k72p;
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_MT19937, 1, __pyx_k10, sizeof(__pyx_k10)},
- {&__pyx_n___RandomState_ctor, 1, __pyx_k16, sizeof(__pyx_k16)},
- {&__pyx_n__rand, 1, __pyx_k78, sizeof(__pyx_k78)},
- {&__pyx_n_add, 1, __pyx_k59, sizeof(__pyx_k59)},
- {&__pyx_n_any, 1, __pyx_k24, sizeof(__pyx_k24)},
- {&__pyx_n_append, 1, __pyx_k65, sizeof(__pyx_k65)},
- {&__pyx_n_arange, 1, __pyx_k75, sizeof(__pyx_k75)},
- {&__pyx_n_array, 1, __pyx_k60, sizeof(__pyx_k60)},
- {&__pyx_n_asarray, 1, __pyx_k8, sizeof(__pyx_k8)},
- {&__pyx_n_beta, 1, __pyx_k85, sizeof(__pyx_k85)},
- {&__pyx_n_binomial, 1, __pyx_k107, sizeof(__pyx_k107)},
- {&__pyx_n_bytes, 1, __pyx_k79, sizeof(__pyx_k79)},
- {&__pyx_n_chisquare, 1, __pyx_k92, sizeof(__pyx_k92)},
- {&__pyx_n_copy, 1, __pyx_k74, sizeof(__pyx_k74)},
- {&__pyx_n_dirichlet, 1, __pyx_k116, sizeof(__pyx_k116)},
- {&__pyx_n_dot, 1, __pyx_k70, sizeof(__pyx_k70)},
- {&__pyx_n_empty, 1, __pyx_k2, sizeof(__pyx_k2)},
- {&__pyx_n_equal, 1, __pyx_k47, sizeof(__pyx_k47)},
- {&__pyx_n_exponential, 1, __pyx_k86, sizeof(__pyx_k86)},
- {&__pyx_n_f, 1, __pyx_k90, sizeof(__pyx_k90)},
- {&__pyx_n_float64, 1, __pyx_k3, sizeof(__pyx_k3)},
- {&__pyx_n_gamma, 1, __pyx_k89, sizeof(__pyx_k89)},
- {&__pyx_n_geometric, 1, __pyx_k111, sizeof(__pyx_k111)},
- {&__pyx_n_get_state, 1, __pyx_k13, sizeof(__pyx_k13)},
- {&__pyx_n_greater, 1, __pyx_k46, sizeof(__pyx_k46)},
- {&__pyx_n_gumbel, 1, __pyx_k101, sizeof(__pyx_k101)},
- {&__pyx_n_hypergeometric, 1, __pyx_k112, sizeof(__pyx_k112)},
- {&__pyx_n_integer, 1, __pyx_k6, sizeof(__pyx_k6)},
- {&__pyx_n_laplace, 1, __pyx_k100, sizeof(__pyx_k100)},
- {&__pyx_n_less, 1, __pyx_k33, sizeof(__pyx_k33)},
- {&__pyx_n_less_equal, 1, __pyx_k25, sizeof(__pyx_k25)},
- {&__pyx_n_logistic, 1, __pyx_k102, sizeof(__pyx_k102)},
- {&__pyx_n_lognormal, 1, __pyx_k103, sizeof(__pyx_k103)},
- {&__pyx_n_logseries, 1, __pyx_k113, sizeof(__pyx_k113)},
- {&__pyx_n_multinomial, 1, __pyx_k115, sizeof(__pyx_k115)},
- {&__pyx_n_multiply, 1, __pyx_k66, sizeof(__pyx_k66)},
- {&__pyx_n_multivariate_normal, 1, __pyx_k114, sizeof(__pyx_k114)},
- {&__pyx_n_negative_binomial, 1, __pyx_k108, sizeof(__pyx_k108)},
- {&__pyx_n_noncentral_chisquare, 1, __pyx_k93, sizeof(__pyx_k93)},
- {&__pyx_n_noncentral_f, 1, __pyx_k91, sizeof(__pyx_k91)},
- {&__pyx_n_normal, 1, __pyx_k84, sizeof(__pyx_k84)},
- {&__pyx_n_np, 1, __pyx_k1, sizeof(__pyx_k1)},
- {&__pyx_n_numpy, 1, __pyx_k77, sizeof(__pyx_k77)},
- {&__pyx_n_pareto, 1, __pyx_k97, sizeof(__pyx_k97)},
- {&__pyx_n_permutation, 1, __pyx_k117, sizeof(__pyx_k117)},
- {&__pyx_n_poisson, 1, __pyx_k109, sizeof(__pyx_k109)},
- {&__pyx_n_power, 1, __pyx_k99, sizeof(__pyx_k99)},
- {&__pyx_n_rand, 1, __pyx_k81, sizeof(__pyx_k81)},
- {&__pyx_n_randint, 1, __pyx_k22, sizeof(__pyx_k22)},
- {&__pyx_n_randn, 1, __pyx_k82, sizeof(__pyx_k82)},
- {&__pyx_n_random, 1, __pyx_k15, sizeof(__pyx_k15)},
- {&__pyx_n_random_integers, 1, __pyx_k83, sizeof(__pyx_k83)},
- {&__pyx_n_random_sample, 1, __pyx_k19, sizeof(__pyx_k19)},
- {&__pyx_n_rayleigh, 1, __pyx_k104, sizeof(__pyx_k104)},
- {&__pyx_n_reduce, 1, __pyx_k67, sizeof(__pyx_k67)},
- {&__pyx_n_seed, 1, __pyx_k5, sizeof(__pyx_k5)},
- {&__pyx_n_set_state, 1, __pyx_k14, sizeof(__pyx_k14)},
- {&__pyx_n_shape, 1, __pyx_k61, sizeof(__pyx_k61)},
- {&__pyx_n_shuffle, 1, __pyx_k76, sizeof(__pyx_k76)},
- {&__pyx_n_size, 1, __pyx_k20, sizeof(__pyx_k20)},
- {&__pyx_n_sqrt, 1, __pyx_k71, sizeof(__pyx_k71)},
- {&__pyx_n_standard_cauchy, 1, __pyx_k94, sizeof(__pyx_k94)},
- {&__pyx_n_standard_exponential, 1, __pyx_k87, sizeof(__pyx_k87)},
- {&__pyx_n_standard_gamma, 1, __pyx_k88, sizeof(__pyx_k88)},
- {&__pyx_n_standard_normal, 1, __pyx_k21, sizeof(__pyx_k21)},
- {&__pyx_n_standard_t, 1, __pyx_k95, sizeof(__pyx_k95)},
- {&__pyx_n_subtract, 1, __pyx_k18, sizeof(__pyx_k18)},
- {&__pyx_n_svd, 1, __pyx_k69, sizeof(__pyx_k69)},
- {&__pyx_n_triangular, 1, __pyx_k106, sizeof(__pyx_k106)},
- {&__pyx_n_uint, 1, __pyx_k7, sizeof(__pyx_k7)},
- {&__pyx_n_uint32, 1, __pyx_k9, sizeof(__pyx_k9)},
- {&__pyx_n_uniform, 1, __pyx_k80, sizeof(__pyx_k80)},
- {&__pyx_n_vonmises, 1, __pyx_k96, sizeof(__pyx_k96)},
- {&__pyx_n_wald, 1, __pyx_k105, sizeof(__pyx_k105)},
- {&__pyx_n_weibull, 1, __pyx_k98, sizeof(__pyx_k98)},
- {&__pyx_n_zeros, 1, __pyx_k73, sizeof(__pyx_k73)},
- {&__pyx_n_zipf, 1, __pyx_k110, sizeof(__pyx_k110)},
- {&__pyx_k4p, 0, __pyx_k4, sizeof(__pyx_k4)},
- {&__pyx_k11p, 0, __pyx_k11, sizeof(__pyx_k11)},
- {&__pyx_k12p, 0, __pyx_k12, sizeof(__pyx_k12)},
- {&__pyx_k17p, 0, __pyx_k17, sizeof(__pyx_k17)},
- {&__pyx_k23p, 0, __pyx_k23, sizeof(__pyx_k23)},
- {&__pyx_k26p, 0, __pyx_k26, sizeof(__pyx_k26)},
- {&__pyx_k27p, 0, __pyx_k27, sizeof(__pyx_k27)},
- {&__pyx_k28p, 0, __pyx_k28, sizeof(__pyx_k28)},
- {&__pyx_k29p, 0, __pyx_k29, sizeof(__pyx_k29)},
- {&__pyx_k30p, 0, __pyx_k30, sizeof(__pyx_k30)},
- {&__pyx_k31p, 0, __pyx_k31, sizeof(__pyx_k31)},
- {&__pyx_k32p, 0, __pyx_k32, sizeof(__pyx_k32)},
- {&__pyx_k34p, 0, __pyx_k34, sizeof(__pyx_k34)},
- {&__pyx_k35p, 0, __pyx_k35, sizeof(__pyx_k35)},
- {&__pyx_k36p, 0, __pyx_k36, sizeof(__pyx_k36)},
- {&__pyx_k37p, 0, __pyx_k37, sizeof(__pyx_k37)},
- {&__pyx_k38p, 0, __pyx_k38, sizeof(__pyx_k38)},
- {&__pyx_k39p, 0, __pyx_k39, sizeof(__pyx_k39)},
- {&__pyx_k40p, 0, __pyx_k40, sizeof(__pyx_k40)},
- {&__pyx_k41p, 0, __pyx_k41, sizeof(__pyx_k41)},
- {&__pyx_k42p, 0, __pyx_k42, sizeof(__pyx_k42)},
- {&__pyx_k43p, 0, __pyx_k43, sizeof(__pyx_k43)},
- {&__pyx_k44p, 0, __pyx_k44, sizeof(__pyx_k44)},
- {&__pyx_k45p, 0, __pyx_k45, sizeof(__pyx_k45)},
- {&__pyx_k48p, 0, __pyx_k48, sizeof(__pyx_k48)},
- {&__pyx_k49p, 0, __pyx_k49, sizeof(__pyx_k49)},
- {&__pyx_k50p, 0, __pyx_k50, sizeof(__pyx_k50)},
- {&__pyx_k51p, 0, __pyx_k51, sizeof(__pyx_k51)},
- {&__pyx_k52p, 0, __pyx_k52, sizeof(__pyx_k52)},
- {&__pyx_k53p, 0, __pyx_k53, sizeof(__pyx_k53)},
- {&__pyx_k54p, 0, __pyx_k54, sizeof(__pyx_k54)},
- {&__pyx_k55p, 0, __pyx_k55, sizeof(__pyx_k55)},
- {&__pyx_k56p, 0, __pyx_k56, sizeof(__pyx_k56)},
- {&__pyx_k57p, 0, __pyx_k57, sizeof(__pyx_k57)},
- {&__pyx_k58p, 0, __pyx_k58, sizeof(__pyx_k58)},
- {&__pyx_k62p, 0, __pyx_k62, sizeof(__pyx_k62)},
- {&__pyx_k63p, 0, __pyx_k63, sizeof(__pyx_k63)},
- {&__pyx_k64p, 0, __pyx_k64, sizeof(__pyx_k64)},
- {&__pyx_k68p, 0, __pyx_k68, sizeof(__pyx_k68)},
- {&__pyx_k72p, 0, __pyx_k72, sizeof(__pyx_k72)},
- {0, 0, 0, 0}
-};
-
-static PyObject *__pyx_d1;
-static PyObject *__pyx_d2;
-static PyObject *__pyx_d3;
-static PyObject *__pyx_d4;
-static PyObject *__pyx_d5;
-static PyObject *__pyx_d6;
-static PyObject *__pyx_d7;
-static PyObject *__pyx_d8;
-static PyObject *__pyx_d9;
-static PyObject *__pyx_d10;
-static PyObject *__pyx_d11;
-static PyObject *__pyx_d12;
-static PyObject *__pyx_d13;
-static PyObject *__pyx_d14;
-static PyObject *__pyx_d15;
-static PyObject *__pyx_d16;
-static PyObject *__pyx_d17;
-static PyObject *__pyx_d18;
-static PyObject *__pyx_d19;
-static PyObject *__pyx_d20;
-static PyObject *__pyx_d21;
-static PyObject *__pyx_d22;
-static PyObject *__pyx_d23;
-static PyObject *__pyx_d24;
-static PyObject *__pyx_d25;
-static PyObject *__pyx_d26;
-static PyObject *__pyx_d27;
-static PyObject *__pyx_d28;
-static PyObject *__pyx_d29;
-static PyObject *__pyx_d30;
-static PyObject *__pyx_d31;
-static PyObject *__pyx_d32;
-static PyObject *__pyx_d33;
-static PyObject *__pyx_d34;
-static PyObject *__pyx_d35;
-static PyObject *__pyx_d36;
-static PyObject *__pyx_d37;
-static PyObject *__pyx_d38;
-static PyObject *__pyx_d39;
-static PyObject *__pyx_d40;
-static PyObject *__pyx_d41;
-static PyObject *__pyx_d42;
-static PyObject *__pyx_d43;
-static PyObject *__pyx_d44;
-static PyObject *__pyx_d45;
-static PyObject *__pyx_d46;
-static PyObject *__pyx_d47;
-static PyObject *__pyx_d48;
-static PyObject *__pyx_d49;
-static PyObject *__pyx_d50;
-static PyObject *__pyx_d51;
-static PyObject *__pyx_d52;
-static PyObject *__pyx_d53;
-static PyObject *__pyx_d54;
-static PyObject *__pyx_d55;
-static PyObject *__pyx_d56;
-static PyObject *__pyx_d57;
-static PyObject *__pyx_d58;
-static PyObject *__pyx_d59;
-
-
-/* Implementation of mtrand */
+static PyObject *__pyx_n_empty;
+static PyObject *__pyx_n_float64;
static PyObject *__pyx_f_6mtrand_cont0_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_cont0 __pyx_v_func,PyObject *__pyx_v_size) {
double *__pyx_v_array_data;
@@ -552,7 +247,7 @@ static PyObject *__pyx_f_6mtrand_cont0_array(rk_state *__pyx_v_state,__pyx_t_6mt
Py_INCREF(__pyx_v_size);
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":130 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":130 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
__pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}
@@ -563,7 +258,7 @@ static PyObject *__pyx_f_6mtrand_cont0_array(rk_state *__pyx_v_state,__pyx_t_6mt
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":133 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":133 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -578,23 +273,23 @@ static PyObject *__pyx_f_6mtrand_cont0_array(rk_state *__pyx_v_state,__pyx_t_6mt
__pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":134 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":134 */
__pyx_v_length = PyArray_SIZE(arrayObject);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":135 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":135 */
__pyx_v_array_data = ((double *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":136 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":136 */
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":138 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":138 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -628,7 +323,7 @@ static PyObject *__pyx_f_6mtrand_cont1_array_sc(rk_state *__pyx_v_state,__pyx_t_
Py_INCREF(__pyx_v_size);
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":147 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":147 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
__pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; goto __pyx_L1;}
@@ -639,7 +334,7 @@ static PyObject *__pyx_f_6mtrand_cont1_array_sc(rk_state *__pyx_v_state,__pyx_t_
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":150 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":150 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -654,23 +349,23 @@ static PyObject *__pyx_f_6mtrand_cont1_array_sc(rk_state *__pyx_v_state,__pyx_t_
__pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":151 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":151 */
__pyx_v_length = PyArray_SIZE(arrayObject);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":152 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":152 */
__pyx_v_array_data = ((double *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":153 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":153 */
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":155 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":155 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -691,6 +386,10 @@ static PyObject *__pyx_f_6mtrand_cont1_array_sc(rk_state *__pyx_v_state,__pyx_t_
return __pyx_r;
}
+static PyObject *__pyx_k61p;
+
+static char __pyx_k61[] = "size is not compatible with inputs";
+
static PyObject *__pyx_f_6mtrand_cont1_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_cont1 __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_oa) {
double *__pyx_v_array_data;
double *__pyx_v_oa_data;
@@ -711,44 +410,44 @@ static PyObject *__pyx_f_6mtrand_cont1_array(rk_state *__pyx_v_state,__pyx_t_6mt
__pyx_v_itera = ((PyArrayIterObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":166 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":166 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":167 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":167 */
__pyx_2 = PyArray_SimpleNew(__pyx_v_oa->nd,__pyx_v_oa->dimensions,NPY_DOUBLE); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":168 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":168 */
__pyx_v_length = PyArray_SIZE(arrayObject);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":169 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":169 */
__pyx_v_array_data = ((double *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":170 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":170 */
__pyx_2 = PyArray_IterNew(((PyObject *)__pyx_v_oa)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayIterObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_itera));
__pyx_v_itera = ((PyArrayIterObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":171 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":171 */
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":172 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":172 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(((double *)__pyx_v_itera->dataptr)[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":173 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":173 */
PyArray_ITER_NEXT(__pyx_v_itera);
}
goto __pyx_L2;
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":175 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":175 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -763,27 +462,27 @@ static PyObject *__pyx_f_6mtrand_cont1_array(rk_state *__pyx_v_state,__pyx_t_6mt
__pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":176 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":176 */
__pyx_v_array_data = ((double *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":177 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":177 */
__pyx_3 = PyArray_MultiIterNew(2,((void *)arrayObject),((void *)__pyx_v_oa)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_multi));
__pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":179 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":179 */
__pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject));
if (__pyx_1) {
__pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}
- Py_INCREF(__pyx_k4p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p);
+ Py_INCREF(__pyx_k61p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k61p);
__pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_4, 0, 0);
@@ -793,23 +492,23 @@ static PyObject *__pyx_f_6mtrand_cont1_array(rk_state *__pyx_v_state,__pyx_t_6mt
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":181 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":181 */
__pyx_5 = __pyx_v_multi->size;
for (__pyx_v_i = 0; __pyx_v_i < __pyx_5; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":182 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":182 */
__pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":183 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":183 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":184 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":184 */
PyArray_MultiIter_NEXTi(__pyx_v_multi,1);
}
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":185 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":185 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -844,7 +543,7 @@ static PyObject *__pyx_f_6mtrand_cont2_array_sc(rk_state *__pyx_v_state,__pyx_t_
Py_INCREF(__pyx_v_size);
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":194 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":194 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
__pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;}
@@ -855,7 +554,7 @@ static PyObject *__pyx_f_6mtrand_cont2_array_sc(rk_state *__pyx_v_state,__pyx_t_
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":197 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":197 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -870,23 +569,23 @@ static PyObject *__pyx_f_6mtrand_cont2_array_sc(rk_state *__pyx_v_state,__pyx_t_
__pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":198 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":198 */
__pyx_v_length = PyArray_SIZE(arrayObject);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":199 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":199 */
__pyx_v_array_data = ((double *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":200 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":200 */
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b);
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":202 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":202 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -907,6 +606,10 @@ static PyObject *__pyx_f_6mtrand_cont2_array_sc(rk_state *__pyx_v_state,__pyx_t_
return __pyx_r;
}
+static PyObject *__pyx_k62p;
+
+static char __pyx_k62[] = "size is not compatible with inputs";
+
static PyObject *__pyx_f_6mtrand_cont2_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_cont2 __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_oa,PyArrayObject *__pyx_v_ob) {
double *__pyx_v_array_data;
double *__pyx_v_oa_data;
@@ -926,48 +629,48 @@ static PyObject *__pyx_f_6mtrand_cont2_array(rk_state *__pyx_v_state,__pyx_t_6mt
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":215 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":215 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":216 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":216 */
__pyx_2 = PyArray_MultiIterNew(2,((void *)__pyx_v_oa),((void *)__pyx_v_ob)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_multi));
__pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":217 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":217 */
__pyx_2 = PyArray_SimpleNew(__pyx_v_multi->nd,__pyx_v_multi->dimensions,NPY_DOUBLE); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":218 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":218 */
__pyx_v_array_data = ((double *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":219 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":219 */
__pyx_3 = __pyx_v_multi->size;
for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":220 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":220 */
__pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,0));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":221 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":221 */
__pyx_v_ob_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":222 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":222 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0]),(__pyx_v_ob_data[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":223 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":223 */
PyArray_MultiIter_NEXT(__pyx_v_multi);
}
goto __pyx_L2;
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":225 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":225 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;}
__pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -982,27 +685,27 @@ static PyObject *__pyx_f_6mtrand_cont2_array(rk_state *__pyx_v_state,__pyx_t_6mt
__pyx_5 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_5);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_5)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_5);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":226 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":226 */
__pyx_v_array_data = ((double *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":227 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":227 */
__pyx_4 = PyArray_MultiIterNew(3,((void *)arrayObject),((void *)__pyx_v_oa),((void *)__pyx_v_ob)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;}
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_4)));
Py_DECREF(((PyObject *)__pyx_v_multi));
__pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":228 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":228 */
__pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject));
if (__pyx_1) {
__pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;}
- Py_INCREF(__pyx_k4p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p);
+ Py_INCREF(__pyx_k62p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k62p);
__pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
@@ -1012,29 +715,29 @@ static PyObject *__pyx_f_6mtrand_cont2_array(rk_state *__pyx_v_state,__pyx_t_6mt
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":230 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":230 */
__pyx_3 = __pyx_v_multi->size;
for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":231 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":231 */
__pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":232 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":232 */
__pyx_v_ob_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,2));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":233 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":233 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0]),(__pyx_v_ob_data[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":234 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":234 */
PyArray_MultiIter_NEXTi(__pyx_v_multi,1);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":235 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":235 */
PyArray_MultiIter_NEXTi(__pyx_v_multi,2);
}
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":236 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":236 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -1069,7 +772,7 @@ static PyObject *__pyx_f_6mtrand_cont3_array_sc(rk_state *__pyx_v_state,__pyx_t_
Py_INCREF(__pyx_v_size);
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":246 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":246 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
__pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}
@@ -1080,7 +783,7 @@ static PyObject *__pyx_f_6mtrand_cont3_array_sc(rk_state *__pyx_v_state,__pyx_t_
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":249 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":249 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -1095,23 +798,23 @@ static PyObject *__pyx_f_6mtrand_cont3_array_sc(rk_state *__pyx_v_state,__pyx_t_
__pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":250 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":250 */
__pyx_v_length = PyArray_SIZE(arrayObject);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":251 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":251 */
__pyx_v_array_data = ((double *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":252 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":252 */
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c);
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":254 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":254 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -1132,6 +835,10 @@ static PyObject *__pyx_f_6mtrand_cont3_array_sc(rk_state *__pyx_v_state,__pyx_t_
return __pyx_r;
}
+static PyObject *__pyx_k63p;
+
+static char __pyx_k63[] = "size is not compatible with inputs";
+
static PyObject *__pyx_f_6mtrand_cont3_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_cont3 __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_oa,PyArrayObject *__pyx_v_ob,PyArrayObject *__pyx_v_oc) {
double *__pyx_v_array_data;
double *__pyx_v_oa_data;
@@ -1153,51 +860,51 @@ static PyObject *__pyx_f_6mtrand_cont3_array(rk_state *__pyx_v_state,__pyx_t_6mt
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":268 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":268 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":269 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":269 */
__pyx_2 = PyArray_MultiIterNew(3,((void *)__pyx_v_oa),((void *)__pyx_v_ob),((void *)__pyx_v_oc)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_multi));
__pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":270 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":270 */
__pyx_2 = PyArray_SimpleNew(__pyx_v_multi->nd,__pyx_v_multi->dimensions,NPY_DOUBLE); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":271 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":271 */
__pyx_v_array_data = ((double *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":272 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":272 */
__pyx_3 = __pyx_v_multi->size;
for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":273 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":273 */
__pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,0));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":274 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":274 */
__pyx_v_ob_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":275 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":275 */
__pyx_v_oc_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,2));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":276 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":276 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0]),(__pyx_v_ob_data[0]),(__pyx_v_oc_data[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":277 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":277 */
PyArray_MultiIter_NEXT(__pyx_v_multi);
}
goto __pyx_L2;
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":279 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":279 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;}
__pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -1212,27 +919,27 @@ static PyObject *__pyx_f_6mtrand_cont3_array(rk_state *__pyx_v_state,__pyx_t_6mt
__pyx_5 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_5);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_5)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_5);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":280 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":280 */
__pyx_v_array_data = ((double *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":281 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":281 */
__pyx_4 = PyArray_MultiIterNew(4,((void *)arrayObject),((void *)__pyx_v_oa),((void *)__pyx_v_ob),((void *)__pyx_v_oc)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; goto __pyx_L1;}
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_4)));
Py_DECREF(((PyObject *)__pyx_v_multi));
__pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":283 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":283 */
__pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject));
if (__pyx_1) {
__pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}
- Py_INCREF(__pyx_k4p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p);
+ Py_INCREF(__pyx_k63p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k63p);
__pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
@@ -1242,29 +949,29 @@ static PyObject *__pyx_f_6mtrand_cont3_array(rk_state *__pyx_v_state,__pyx_t_6mt
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":285 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":285 */
__pyx_3 = __pyx_v_multi->size;
for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":286 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":286 */
__pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":287 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":287 */
__pyx_v_ob_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,2));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":288 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":288 */
__pyx_v_oc_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,3));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":289 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":289 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0]),(__pyx_v_ob_data[0]),(__pyx_v_oc_data[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":290 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":290 */
PyArray_MultiIter_NEXT(__pyx_v_multi);
}
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":291 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":291 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -1300,7 +1007,7 @@ static PyObject *__pyx_f_6mtrand_disc0_array(rk_state *__pyx_v_state,__pyx_t_6mt
Py_INCREF(__pyx_v_size);
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":299 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":299 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
__pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; goto __pyx_L1;}
@@ -1311,7 +1018,7 @@ static PyObject *__pyx_f_6mtrand_disc0_array(rk_state *__pyx_v_state,__pyx_t_6mt
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":302 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":302 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -1323,23 +1030,23 @@ static PyObject *__pyx_f_6mtrand_disc0_array(rk_state *__pyx_v_state,__pyx_t_6mt
__pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":303 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":303 */
__pyx_v_length = PyArray_SIZE(arrayObject);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":304 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":304 */
__pyx_v_array_data = ((long *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":305 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":305 */
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":307 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":307 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -1373,7 +1080,7 @@ static PyObject *__pyx_f_6mtrand_discnp_array_sc(rk_state *__pyx_v_state,__pyx_t
Py_INCREF(__pyx_v_size);
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":315 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":315 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
__pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}
@@ -1384,7 +1091,7 @@ static PyObject *__pyx_f_6mtrand_discnp_array_sc(rk_state *__pyx_v_state,__pyx_t
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":318 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":318 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -1396,23 +1103,23 @@ static PyObject *__pyx_f_6mtrand_discnp_array_sc(rk_state *__pyx_v_state,__pyx_t
__pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":319 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":319 */
__pyx_v_length = PyArray_SIZE(arrayObject);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":320 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":320 */
__pyx_v_array_data = ((long *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":321 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":321 */
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p);
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":323 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":323 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -1433,6 +1140,10 @@ static PyObject *__pyx_f_6mtrand_discnp_array_sc(rk_state *__pyx_v_state,__pyx_t
return __pyx_r;
}
+static PyObject *__pyx_k64p;
+
+static char __pyx_k64[] = "size is not compatible with inputs";
+
static PyObject *__pyx_f_6mtrand_discnp_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_discnp __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_on,PyArrayObject *__pyx_v_op) {
long *__pyx_v_array_data;
PyArrayObject *arrayObject;
@@ -1452,48 +1163,48 @@ static PyObject *__pyx_f_6mtrand_discnp_array(rk_state *__pyx_v_state,__pyx_t_6m
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":334 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":334 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":335 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":335 */
__pyx_2 = PyArray_MultiIterNew(2,((void *)__pyx_v_on),((void *)__pyx_v_op)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_multi));
__pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":336 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":336 */
__pyx_2 = PyArray_SimpleNew(__pyx_v_multi->nd,__pyx_v_multi->dimensions,NPY_LONG); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":337 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":337 */
__pyx_v_array_data = ((long *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":338 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":338 */
__pyx_3 = __pyx_v_multi->size;
for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":339 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":339 */
__pyx_v_on_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,0));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":340 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":340 */
__pyx_v_op_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":341 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":341 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_on_data[0]),(__pyx_v_op_data[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":342 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":342 */
PyArray_MultiIter_NEXT(__pyx_v_multi);
}
goto __pyx_L2;
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":344 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":344 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;}
__pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -1505,27 +1216,27 @@ static PyObject *__pyx_f_6mtrand_discnp_array(rk_state *__pyx_v_state,__pyx_t_6m
__pyx_5 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_5);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_5)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_5);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":345 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":345 */
__pyx_v_array_data = ((long *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":346 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":346 */
__pyx_4 = PyArray_MultiIterNew(3,((void *)arrayObject),((void *)__pyx_v_on),((void *)__pyx_v_op)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_4)));
Py_DECREF(((PyObject *)__pyx_v_multi));
__pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":347 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":347 */
__pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject));
if (__pyx_1) {
__pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}
- Py_INCREF(__pyx_k4p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p);
+ Py_INCREF(__pyx_k64p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k64p);
__pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
@@ -1535,29 +1246,29 @@ static PyObject *__pyx_f_6mtrand_discnp_array(rk_state *__pyx_v_state,__pyx_t_6m
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":349 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":349 */
__pyx_3 = __pyx_v_multi->size;
for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":350 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":350 */
__pyx_v_on_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,1));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":351 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":351 */
__pyx_v_op_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,2));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":352 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":352 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_on_data[0]),(__pyx_v_op_data[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":353 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":353 */
PyArray_MultiIter_NEXTi(__pyx_v_multi,1);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":354 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":354 */
PyArray_MultiIter_NEXTi(__pyx_v_multi,2);
}
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":356 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":356 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -1592,7 +1303,7 @@ static PyObject *__pyx_f_6mtrand_discnmN_array_sc(rk_state *__pyx_v_state,__pyx_
Py_INCREF(__pyx_v_size);
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":365 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":365 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
__pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;}
@@ -1603,7 +1314,7 @@ static PyObject *__pyx_f_6mtrand_discnmN_array_sc(rk_state *__pyx_v_state,__pyx_
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":368 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":368 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -1615,23 +1326,23 @@ static PyObject *__pyx_f_6mtrand_discnmN_array_sc(rk_state *__pyx_v_state,__pyx_
__pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":369 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":369 */
__pyx_v_length = PyArray_SIZE(arrayObject);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":370 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":370 */
__pyx_v_array_data = ((long *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":371 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":371 */
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N);
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":373 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":373 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -1652,6 +1363,10 @@ static PyObject *__pyx_f_6mtrand_discnmN_array_sc(rk_state *__pyx_v_state,__pyx_
return __pyx_r;
}
+static PyObject *__pyx_k65p;
+
+static char __pyx_k65[] = "size is not compatible with inputs";
+
static PyObject *__pyx_f_6mtrand_discnmN_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_discnmN __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_on,PyArrayObject *__pyx_v_om,PyArrayObject *__pyx_v_oN) {
long *__pyx_v_array_data;
long *__pyx_v_on_data;
@@ -1673,51 +1388,51 @@ static PyObject *__pyx_f_6mtrand_discnmN_array(rk_state *__pyx_v_state,__pyx_t_6
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":386 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":386 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":387 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":387 */
__pyx_2 = PyArray_MultiIterNew(3,((void *)__pyx_v_on),((void *)__pyx_v_om),((void *)__pyx_v_oN)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_multi));
__pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":388 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":388 */
__pyx_2 = PyArray_SimpleNew(__pyx_v_multi->nd,__pyx_v_multi->dimensions,NPY_LONG); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":389 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":389 */
__pyx_v_array_data = ((long *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":390 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":390 */
__pyx_3 = __pyx_v_multi->size;
for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":391 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":391 */
__pyx_v_on_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,0));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":392 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":392 */
__pyx_v_om_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,1));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":393 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":393 */
__pyx_v_oN_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,2));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":394 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":394 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_on_data[0]),(__pyx_v_om_data[0]),(__pyx_v_oN_data[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":395 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":395 */
PyArray_MultiIter_NEXT(__pyx_v_multi);
}
goto __pyx_L2;
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":397 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":397 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
__pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -1729,27 +1444,27 @@ static PyObject *__pyx_f_6mtrand_discnmN_array(rk_state *__pyx_v_state,__pyx_t_6
__pyx_5 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_5);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_5)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_5);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":398 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":398 */
__pyx_v_array_data = ((long *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":399 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":399 */
__pyx_4 = PyArray_MultiIterNew(4,((void *)arrayObject),((void *)__pyx_v_on),((void *)__pyx_v_om),((void *)__pyx_v_oN)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_4)));
Py_DECREF(((PyObject *)__pyx_v_multi));
__pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":401 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":401 */
__pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject));
if (__pyx_1) {
__pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; goto __pyx_L1;}
- Py_INCREF(__pyx_k4p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p);
+ Py_INCREF(__pyx_k65p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k65p);
__pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
@@ -1759,29 +1474,29 @@ static PyObject *__pyx_f_6mtrand_discnmN_array(rk_state *__pyx_v_state,__pyx_t_6
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":403 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":403 */
__pyx_3 = __pyx_v_multi->size;
for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":404 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":404 */
__pyx_v_on_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,1));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":405 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":405 */
__pyx_v_om_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,2));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":406 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":406 */
__pyx_v_oN_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,3));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":407 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":407 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_on_data[0]),(__pyx_v_om_data[0]),(__pyx_v_oN_data[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":408 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":408 */
PyArray_MultiIter_NEXT(__pyx_v_multi);
}
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":410 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":410 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -1817,7 +1532,7 @@ static PyObject *__pyx_f_6mtrand_discd_array_sc(rk_state *__pyx_v_state,__pyx_t_
Py_INCREF(__pyx_v_size);
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":418 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":418 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
__pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; goto __pyx_L1;}
@@ -1828,7 +1543,7 @@ static PyObject *__pyx_f_6mtrand_discd_array_sc(rk_state *__pyx_v_state,__pyx_t_
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":421 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":421 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -1840,23 +1555,23 @@ static PyObject *__pyx_f_6mtrand_discd_array_sc(rk_state *__pyx_v_state,__pyx_t_
__pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":422 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":422 */
__pyx_v_length = PyArray_SIZE(arrayObject);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":423 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":423 */
__pyx_v_array_data = ((long *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":424 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":424 */
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":426 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":426 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -1877,6 +1592,10 @@ static PyObject *__pyx_f_6mtrand_discd_array_sc(rk_state *__pyx_v_state,__pyx_t_
return __pyx_r;
}
+static PyObject *__pyx_k66p;
+
+static char __pyx_k66[] = "size is not compatible with inputs";
+
static PyObject *__pyx_f_6mtrand_discd_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_discd __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_oa) {
long *__pyx_v_array_data;
double *__pyx_v_oa_data;
@@ -1897,44 +1616,44 @@ static PyObject *__pyx_f_6mtrand_discd_array(rk_state *__pyx_v_state,__pyx_t_6mt
__pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_itera = ((PyArrayIterObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":437 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":437 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":438 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":438 */
__pyx_2 = PyArray_SimpleNew(__pyx_v_oa->nd,__pyx_v_oa->dimensions,NPY_LONG); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":439 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":439 */
__pyx_v_length = PyArray_SIZE(arrayObject);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":440 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":440 */
__pyx_v_array_data = ((long *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":441 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":441 */
__pyx_2 = PyArray_IterNew(((PyObject *)__pyx_v_oa)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ Py_INCREF(((PyObject *)((PyArrayIterObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_itera));
__pyx_v_itera = ((PyArrayIterObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":442 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":442 */
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":443 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":443 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(((double *)__pyx_v_itera->dataptr)[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":444 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":444 */
PyArray_ITER_NEXT(__pyx_v_itera);
}
goto __pyx_L2;
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":446 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":446 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;}
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
@@ -1946,27 +1665,27 @@ static PyObject *__pyx_f_6mtrand_discd_array(rk_state *__pyx_v_state,__pyx_t_6mt
__pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- Py_INCREF(__pyx_4);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_4);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":447 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":447 */
__pyx_v_array_data = ((long *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":448 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":448 */
__pyx_3 = PyArray_MultiIterNew(2,((void *)arrayObject),((void *)__pyx_v_oa)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_multi));
__pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":449 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":449 */
__pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject));
if (__pyx_1) {
__pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;}
- Py_INCREF(__pyx_k4p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p);
+ Py_INCREF(__pyx_k66p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k66p);
__pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_4, 0, 0);
@@ -1976,23 +1695,23 @@ static PyObject *__pyx_f_6mtrand_discd_array(rk_state *__pyx_v_state,__pyx_t_6mt
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":451 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":451 */
__pyx_5 = __pyx_v_multi->size;
for (__pyx_v_i = 0; __pyx_v_i < __pyx_5; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":452 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":452 */
__pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":453 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":453 */
(__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":454 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":454 */
PyArray_MultiIter_NEXTi(__pyx_v_multi,1);
}
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":455 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":455 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -2022,29 +1741,29 @@ static double __pyx_f_6mtrand_kahan_sum(double *__pyx_v_darr,long __pyx_v_n) {
long __pyx_v_i;
double __pyx_r;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":460 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":460 */
__pyx_v_sum = (__pyx_v_darr[0]);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":461 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":461 */
__pyx_v_c = 0.0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":462 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":462 */
for (__pyx_v_i = 1; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":463 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":463 */
__pyx_v_y = ((__pyx_v_darr[__pyx_v_i]) - __pyx_v_c);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":464 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":464 */
__pyx_v_t = (__pyx_v_sum + __pyx_v_y);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":465 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":465 */
__pyx_v_c = ((__pyx_v_t - __pyx_v_sum) - __pyx_v_y);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":466 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":466 */
__pyx_v_sum = __pyx_v_t;
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":467 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":467 */
__pyx_r = __pyx_v_sum;
goto __pyx_L0;
@@ -2061,20 +1780,20 @@ static int __pyx_f_6mtrand_11RandomState___init__(PyObject *__pyx_v_self, PyObje
PyObject *__pyx_2 = 0;
PyObject *__pyx_3 = 0;
static char *__pyx_argnames[] = {"seed",0};
- __pyx_v_seed = __pyx_d1;
+ __pyx_v_seed = __pyx_k2;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_seed)) return -1;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_seed);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":490 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":497 */
((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state = ((rk_state *)PyMem_Malloc((sizeof(rk_state))));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":492 */
- __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":499 */
+ __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; goto __pyx_L1;}
Py_INCREF(__pyx_v_seed);
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_seed);
- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
@@ -2100,10 +1819,10 @@ static void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self) {
__pyx_1 = (((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state != NULL);
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":496 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":503 */
PyMem_Free(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":497 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":504 */
((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state = NULL;
goto __pyx_L2;
}
@@ -2112,8 +1831,10 @@ static void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self) {
Py_DECREF(__pyx_v_self);
}
+static PyObject *__pyx_n_integer;
+
static PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_seed[] = "Seed the generator.\n\n seed(seed=None)\n\n seed can be an integer, an array (or other sequence) of integers of any\n length, or None. If seed is None, then RandomState will try to read data\n from /dev/urandom (or the Windows analogue) if available or seed from\n the clock otherwise.\n ";
+static char __pyx_doc_6mtrand_11RandomState_seed[] = "\n seed(seed=None)\n\n Seed the generator.\n\n seed can be an integer, an array (or other sequence) of integers of any\n length, or None. If seed is None, then RandomState will try to read data\n from /dev/urandom (or the Windows analogue) if available or seed from\n the clock otherwise.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_seed = 0;
rk_error __pyx_v_errcode;
@@ -2125,63 +1846,63 @@ static PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyOb
PyObject *__pyx_3 = 0;
unsigned long __pyx_4;
static char *__pyx_argnames[] = {"seed",0};
- __pyx_v_seed = __pyx_d2;
+ __pyx_v_seed = __pyx_k3;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_seed)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_seed);
arrayObject_obj = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_iseed = Py_None; Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":511 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":520 */
__pyx_1 = __pyx_v_seed == Py_None;
if (__pyx_1) {
__pyx_v_errcode = rk_randomseed(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);
goto __pyx_L2;
}
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; goto __pyx_L1;}
Py_INCREF(__pyx_v_seed);
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_seed);
- __pyx_3 = PyObject_CallObject(((PyObject *)(&PyType_Type)), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(((PyObject *)(&PyType_Type)), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_1 = __pyx_3 == ((PyObject *)(&PyInt_Type));
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_4 = PyInt_AsUnsignedLongMask(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;}
+ __pyx_4 = PyInt_AsUnsignedLongMask(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;}
rk_seed(__pyx_4,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);
goto __pyx_L2;
}
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_integer); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_integer); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyObject_IsInstance(__pyx_v_seed,__pyx_3); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsInstance(__pyx_v_seed,__pyx_3); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":516 */
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":525 */
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}
Py_INCREF(__pyx_v_seed);
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_seed);
- __pyx_3 = PyObject_CallObject(((PyObject *)(&PyInt_Type)), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(((PyObject *)(&PyInt_Type)), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_v_iseed);
__pyx_v_iseed = __pyx_3;
__pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":517 */
- __pyx_4 = PyInt_AsUnsignedLongMask(__pyx_v_iseed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":526 */
+ __pyx_4 = PyInt_AsUnsignedLongMask(__pyx_v_iseed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; goto __pyx_L1;}
rk_seed(__pyx_4,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);
goto __pyx_L2;
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":519 */
- __pyx_2 = PyArray_ContiguousFromObject(__pyx_v_seed,NPY_LONG,1,1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":528 */
+ __pyx_2 = PyArray_ContiguousFromObject(__pyx_v_seed,NPY_LONG,1,1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)arrayObject_obj));
arrayObject_obj = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":520 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":529 */
init_by_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,((unsigned long *)arrayObject_obj->data),(arrayObject_obj->dimensions[0]));
}
__pyx_L2:;
@@ -2201,8 +1922,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyOb
return __pyx_r;
}
+static PyObject *__pyx_n_uint;
+static PyObject *__pyx_n_asarray;
+static PyObject *__pyx_n_uint32;
+static PyObject *__pyx_n_MT19937;
+
+
static PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_get_state[] = "Return a tuple representing the internal state of the generator.\n\n get_state() -> (\'MT19937\', int key[624], int pos, int has_gauss, float cached_gaussian)\n ";
+static char __pyx_doc_6mtrand_11RandomState_get_state[] = "\n get_state()\n\n Return a tuple representing the internal state of the generator::\n\n (\'MT19937\', int key[624], int pos, int has_gauss, float cached_gaussian)\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyArrayObject *arrayObject_state;
PyObject *__pyx_r;
@@ -2215,55 +1942,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self,
Py_INCREF(__pyx_v_self);
arrayObject_state = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":529 */
- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":542 */
+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_1 = PyInt_FromLong(624); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;}
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_uint); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;}
+ __pyx_1 = PyInt_FromLong(624); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_uint); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
__pyx_1 = 0;
__pyx_4 = 0;
- __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;}
+ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- Py_INCREF(__pyx_1);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1)));
Py_DECREF(((PyObject *)arrayObject_state));
arrayObject_state = ((PyArrayObject *)__pyx_1);
Py_DECREF(__pyx_1); __pyx_1 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":530 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":543 */
memcpy(arrayObject_state->data,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,(624 * (sizeof(long))));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":531 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_asarray); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":544 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_asarray); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}
- __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_uint32); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; goto __pyx_L1;}
+ __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_uint32); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; goto __pyx_L1;}
Py_INCREF(((PyObject *)arrayObject_state));
PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)arrayObject_state));
PyTuple_SET_ITEM(__pyx_4, 1, __pyx_1);
__pyx_1 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- Py_INCREF(__pyx_3);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)arrayObject_state));
arrayObject_state = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":532 */
- __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; goto __pyx_L1;}
- __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->has_gauss); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; goto __pyx_L1;}
- __pyx_4 = PyFloat_FromDouble(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->gauss); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":545 */
+ __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; goto __pyx_L1;}
+ __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->has_gauss); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; goto __pyx_L1;}
+ __pyx_4 = PyFloat_FromDouble(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->gauss); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; goto __pyx_L1;}
Py_INCREF(__pyx_n_MT19937);
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_MT19937);
Py_INCREF(((PyObject *)arrayObject_state));
@@ -2293,8 +2020,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self,
return __pyx_r;
}
+static PyObject *__pyx_k69p;
+static PyObject *__pyx_k70p;
+
+static char __pyx_k69[] = "algorithm must be 'MT19937'";
+static char __pyx_k70[] = "state must be 624 longs";
+
static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_set_state[] = "Set the state from a tuple.\n\n state = (\'MT19937\', int key[624], int pos, int has_gauss, float cached_gaussian)\n\n For backwards compatibility, the following form is also accepted\n although it is missing some information about the cached Gaussian value.\n\n state = (\'MT19937\', int key[624], int pos)\n\n set_state(state)\n ";
+static char __pyx_doc_6mtrand_11RandomState_set_state[] = "\n set_state(state)\n\n Set the state from a tuple.\n\n state = (\'MT19937\', int key[624], int pos, int has_gauss, float cached_gaussian)\n\n For backwards compatibility, the following form is also accepted\n although it is missing some information about the cached Gaussian value.\n\n state = (\'MT19937\', int key[624], int pos)\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_state = 0;
PyArrayObject *arrayObject_obj;
@@ -2321,82 +2054,82 @@ static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self,
__pyx_v_has_gauss = Py_None; Py_INCREF(Py_None);
__pyx_v_cached_gaussian = Py_None; Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":549 */
- __pyx_1 = __Pyx_GetItemInt(__pyx_v_state, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":564 */
+ __pyx_1 = __Pyx_GetItemInt(__pyx_v_state, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}
Py_DECREF(__pyx_v_algorithm_name);
__pyx_v_algorithm_name = __pyx_1;
__pyx_1 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":550 */
- if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":565 */
+ if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; goto __pyx_L1;}
__pyx_2 = __pyx_2 != 0;
if (__pyx_2) {
- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; goto __pyx_L1;}
- Py_INCREF(__pyx_k11p);
- PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k11p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; goto __pyx_L1;}
+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}
+ Py_INCREF(__pyx_k69p);
+ PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k69p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":552 */
- __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;}
- __pyx_3 = PyObject_GetIter(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":567 */
+ __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetIter(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_1 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;}
+ __pyx_1 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;}
Py_DECREF(__pyx_v_key);
__pyx_v_key = __pyx_1;
__pyx_1 = 0;
- __pyx_1 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;}
- __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;}
+ __pyx_1 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;}
+ __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
__pyx_v_pos = __pyx_2;
- if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;}
+ if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":553 */
- __pyx_4 = PyObject_Length(__pyx_v_state); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":568 */
+ __pyx_4 = PyObject_Length(__pyx_v_state); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; goto __pyx_L1;}
__pyx_2 = (__pyx_4 == 3);
if (__pyx_2) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":554 */
- __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":569 */
+ __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; goto __pyx_L1;}
Py_DECREF(__pyx_v_has_gauss);
__pyx_v_has_gauss = __pyx_1;
__pyx_1 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":555 */
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":570 */
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; goto __pyx_L1;}
Py_DECREF(__pyx_v_cached_gaussian);
__pyx_v_cached_gaussian = __pyx_3;
__pyx_3 = 0;
goto __pyx_L3;
}
/*else*/ {
- __pyx_1 = PySequence_GetSlice(__pyx_v_state, 3, 5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}
- __pyx_3 = PyObject_GetIter(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}
+ __pyx_1 = PySequence_GetSlice(__pyx_v_state, 3, 5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetIter(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_1 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}
+ __pyx_1 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; goto __pyx_L1;}
Py_DECREF(__pyx_v_has_gauss);
__pyx_v_has_gauss = __pyx_1;
__pyx_1 = 0;
- __pyx_1 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}
+ __pyx_1 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; goto __pyx_L1;}
Py_DECREF(__pyx_v_cached_gaussian);
__pyx_v_cached_gaussian = __pyx_1;
__pyx_1 = 0;
- if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;}
+ if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":558 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":573 */
/*try:*/ {
- __pyx_1 = PyArray_ContiguousFromObject(__pyx_v_key,NPY_ULONG,1,1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L4;}
- Py_INCREF(__pyx_1);
+ __pyx_1 = PyArray_ContiguousFromObject(__pyx_v_key,NPY_ULONG,1,1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; goto __pyx_L4;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1)));
Py_DECREF(((PyObject *)arrayObject_obj));
arrayObject_obj = ((PyArrayObject *)__pyx_1);
Py_DECREF(__pyx_1); __pyx_1 = 0;
@@ -2406,13 +2139,13 @@ static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self,
Py_XDECREF(__pyx_3); __pyx_3 = 0;
Py_XDECREF(__pyx_1); __pyx_1 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":560 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":575 */
__pyx_2 = PyErr_ExceptionMatches(PyExc_TypeError);
if (__pyx_2) {
__Pyx_AddTraceback("mtrand.set_state");
- if (__Pyx_GetException(&__pyx_3, &__pyx_1, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; goto __pyx_L1;}
- __pyx_6 = PyArray_ContiguousFromObject(__pyx_v_key,NPY_LONG,1,1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;}
- Py_INCREF(__pyx_6);
+ if (__Pyx_GetException(&__pyx_3, &__pyx_1, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}
+ __pyx_6 = PyArray_ContiguousFromObject(__pyx_v_key,NPY_LONG,1,1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_6)));
Py_DECREF(((PyObject *)arrayObject_obj));
arrayObject_obj = ((PyArrayObject *)__pyx_6);
Py_DECREF(__pyx_6); __pyx_6 = 0;
@@ -2424,33 +2157,33 @@ static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self,
goto __pyx_L1;
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":563 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":578 */
__pyx_2 = ((arrayObject_obj->dimensions[0]) != 624);
if (__pyx_2) {
- __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}
- Py_INCREF(__pyx_k12p);
- PyTuple_SET_ITEM(__pyx_6, 0, __pyx_k12p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}
+ __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; goto __pyx_L1;}
+ Py_INCREF(__pyx_k70p);
+ PyTuple_SET_ITEM(__pyx_6, 0, __pyx_k70p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; goto __pyx_L1;}
Py_DECREF(__pyx_6); __pyx_6 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":565 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":580 */
memcpy(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,arrayObject_obj->data,(624 * (sizeof(long))));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":566 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":581 */
((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos = __pyx_v_pos;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":567 */
- __pyx_2 = PyInt_AsLong(__pyx_v_has_gauss); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":582 */
+ __pyx_2 = PyInt_AsLong(__pyx_v_has_gauss); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; goto __pyx_L1;}
((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->has_gauss = __pyx_2;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":568 */
- __pyx_7 = PyFloat_AsDouble(__pyx_v_cached_gaussian); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":583 */
+ __pyx_7 = PyFloat_AsDouble(__pyx_v_cached_gaussian); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; goto __pyx_L1;}
((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->gauss = __pyx_7;
__pyx_r = Py_None; Py_INCREF(Py_None);
@@ -2481,8 +2214,8 @@ static PyObject *__pyx_f_6mtrand_11RandomState___getstate__(PyObject *__pyx_v_se
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
Py_INCREF(__pyx_v_self);
- __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; goto __pyx_L1;}
- __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; goto __pyx_L1;}
+ __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
__pyx_r = __pyx_2;
__pyx_2 = 0;
@@ -2511,11 +2244,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_se
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_state)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_state);
- __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}
+ __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; goto __pyx_L1;}
Py_INCREF(__pyx_v_state);
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_state);
- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
@@ -2534,6 +2267,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_se
return __pyx_r;
}
+static PyObject *__pyx_n_random;
+static PyObject *__pyx_n___RandomState_ctor;
+
static PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_r;
@@ -2544,16 +2280,16 @@ static PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self
static char *__pyx_argnames[] = {0};
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
Py_INCREF(__pyx_v_self);
- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;}
+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n___RandomState_ctor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;}
+ __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n___RandomState_ctor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;}
- __pyx_4 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
PyTuple_SET_ITEM(__pyx_3, 2, __pyx_4);
@@ -2579,17 +2315,17 @@ static PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self
}
static PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_random_sample[] = "Return random floats in the half-open interval [0.0, 1.0).\n\n random_sample(size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_random_sample[] = "\n random_sample(size=None)\n\n Return random floats in the half-open interval [0.0, 1.0).\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_size = 0;
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
static char *__pyx_argnames[] = {"size",0};
- __pyx_v_size = __pyx_d3;
+ __pyx_v_size = __pyx_k4;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_size);
- __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_double,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; goto __pyx_L1;}
+ __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_double,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
@@ -2607,17 +2343,17 @@ static PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_s
}
static PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_tomaxint[] = "Returns random integers x such that 0 <= x <= sys.maxint.\n\n tomaxint(size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_tomaxint[] = "\n tomaxint(size=None)\n\n Uniformly sample discrete random integers `x` such that\n ``0 <= x <= sys.maxint``.\n\n Parameters\n ----------\n size : tuple of ints, int, optional\n Shape of output. If the given size is, for example, (m,n,k),\n m*n*k samples are generated. If no shape is specified, a single sample\n is returned.\n\n Returns\n -------\n out : ndarray\n Drawn samples, with shape `size`.\n\n See Also\n --------\n randint : Uniform sampling over a given half-open interval of integers.\n random_integers : Uniform sampling over a given closed interval of\n integers.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_size = 0;
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
static char *__pyx_argnames[] = {"size",0};
- __pyx_v_size = __pyx_d4;
+ __pyx_v_size = __pyx_k5;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_size);
- __pyx_1 = __pyx_f_6mtrand_disc0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_long,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;}
+ __pyx_1 = __pyx_f_6mtrand_disc0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_long,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
@@ -2634,8 +2370,12 @@ static PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self,
return __pyx_r;
}
+static PyObject *__pyx_k71p;
+
+static char __pyx_k71[] = "low >= high";
+
static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_randint[] = "Return random integers x such that low <= x < high.\n\n randint(low, high=None, size=None) -> random values\n\n If high is None, then 0 <= x < low.\n ";
+static char __pyx_doc_6mtrand_11RandomState_randint[] = "\n randint(low, high=None, size=None)\n\n Return random integers x such that low <= x < high.\n\n If high is None, then 0 <= x < low.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_low = 0;
PyObject *__pyx_v_high = 0;
@@ -2654,8 +2394,8 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, P
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"low","high","size",0};
- __pyx_v_high = __pyx_d5;
- __pyx_v_size = __pyx_d6;
+ __pyx_v_high = __pyx_k6;
+ __pyx_v_size = __pyx_k7;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|OO", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_low);
@@ -2663,52 +2403,52 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, P
Py_INCREF(__pyx_v_size);
arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":608 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":648 */
__pyx_1 = __pyx_v_high == Py_None;
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":609 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":649 */
__pyx_v_lo = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":610 */
- __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":650 */
+ __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;}
__pyx_v_hi = __pyx_2;
goto __pyx_L2;
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":612 */
- __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":652 */
+ __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}
__pyx_v_lo = __pyx_2;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":613 */
- __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":653 */
+ __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; goto __pyx_L1;}
__pyx_v_hi = __pyx_2;
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":615 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":655 */
__pyx_v_diff = ((__pyx_v_hi - __pyx_v_lo) - 1);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":616 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":656 */
__pyx_1 = (__pyx_v_diff < 0);
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; goto __pyx_L1;}
- Py_INCREF(__pyx_k17p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k17p);
- __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; goto __pyx_L1;}
+ Py_INCREF(__pyx_k71p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k71p);
+ __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_4, 0, 0);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":619 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":659 */
__pyx_1 = __pyx_v_size == Py_None;
if (__pyx_1) {
- __pyx_3 = PyInt_FromLong((((long)rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)) + __pyx_v_lo)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; goto __pyx_L1;}
+ __pyx_3 = PyInt_FromLong((((long)rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)) + __pyx_v_lo)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;}
__pyx_r = __pyx_3;
__pyx_3 = 0;
goto __pyx_L0;
@@ -2716,35 +2456,35 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, P
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":622 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":662 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; goto __pyx_L1;}
Py_INCREF(__pyx_v_size);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_size);
Py_INCREF(((PyObject *)(&PyInt_Type)));
PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)(&PyInt_Type)));
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- Py_INCREF(__pyx_5);
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_5)));
Py_DECREF(((PyObject *)arrayObject));
arrayObject = ((PyArrayObject *)__pyx_5);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":623 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":663 */
__pyx_v_length = PyArray_SIZE(arrayObject);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":624 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":664 */
__pyx_v_array_data = ((long *)arrayObject->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":625 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":665 */
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {
(__pyx_v_array_data[__pyx_v_i]) = (__pyx_v_lo + ((long)rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)));
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":627 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":667 */
Py_INCREF(((PyObject *)arrayObject));
__pyx_r = ((PyObject *)arrayObject);
goto __pyx_L0;
@@ -2769,7 +2509,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, P
}
static PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_bytes[] = "Return random bytes.\n\n bytes(length) -> str\n ";
+static char __pyx_doc_6mtrand_11RandomState_bytes[] = "\n bytes(length)\n\n Return random bytes.\n\n Parameters\n ----------\n length : int\n Number of random bytes.\n\n Returns\n -------\n out : str\n String of length `N`.\n\n Examples\n --------\n >>> np.random.bytes(10)\n \' eh\x085\x0022SZ\x0bf\x0a4\' #random\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
unsigned int __pyx_v_length;
void *__pyx_v_bytes;
@@ -2781,19 +2521,19 @@ static PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyO
Py_INCREF(__pyx_v_self);
__pyx_v_bytestring = Py_None; Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":635 */
- __pyx_1 = PyString_FromStringAndSize(NULL,__pyx_v_length); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":692 */
+ __pyx_1 = PyString_FromStringAndSize(NULL,__pyx_v_length); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; goto __pyx_L1;}
Py_DECREF(__pyx_v_bytestring);
__pyx_v_bytestring = __pyx_1;
__pyx_1 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":636 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":693 */
__pyx_v_bytes = PyString_AS_STRING(__pyx_v_bytestring);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":637 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":694 */
rk_fill(__pyx_v_bytes,__pyx_v_length,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":638 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":695 */
Py_INCREF(__pyx_v_bytestring);
__pyx_r = __pyx_v_bytestring;
goto __pyx_L0;
@@ -2810,8 +2550,10 @@ static PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyO
return __pyx_r;
}
+static PyObject *__pyx_n_subtract;
+
static PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_uniform[] = "Uniform distribution over [low, high).\n\n uniform(low=0.0, high=1.0, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_uniform[] = "\n uniform(low=0.0, high=1.0, size=1)\n\n Draw samples from a uniform distribution.\n\n Samples are uniformly distributed over the half-open interval\n ``[low, high)`` (includes low, but excludes high). In other words,\n any value within the given interval is equally likely to be drawn\n by `uniform`.\n\n Parameters\n ----------\n low : float, optional\n Lower boundary of the output interval. All values generated will be\n greater than or equal to low. The default value is 0.\n high : float\n Upper boundary of the output interval. All values generated will be\n less than high. The default value is 1.0.\n size : tuple of ints, int, optional\n Shape of output. If the given size is, for example, (m,n,k),\n m*n*k samples are generated. If no shape is specified, a single sample\n is returned.\n\n Returns\n -------\n out : ndarray\n Drawn samples, with shape `size`.\n\n See Also\n --------\n randint : Discrete uniform distribution, yielding integers.\n random_integers : Discrete uniform distribution over the closed interval\n ``[low, high]``.\n random_sample : Floats uniformly distributed over ``[0, 1)``.\n random : Alias for `random_sample`.\n rand : Convenience function that accepts dimensions as input, e.g.,\n ``rand(2,2)`` would generate a 2-by-2 array of floats, uniformly\n distributed over ``[0, 1)``.\n\n Notes\n -----\n The probability density function of the uniform distribution is\n\n .. math:: p(x) = \\frac{1}{b - a}\n\n anywhere within the interval ``[a, b)``, and zero elsewhere.\n\n Examples\n --------\n Draw samples from the distribution:\n\n >>> s = np.random.uniform(-1,0,1000)\n\n All values are within the given interval:\n\n >>> np.all(s >= -1)\n True\n\n >>> np.all(s < 0)\n True\n\n Display the histogram of the samples, along with the\n probability density function:\n\n >>> import matplotlib.pyplot as plt\n >>> count, bins, ignored = plt.hist(s, 15, normed=True)\n >>> plt.plot(bins, np.ones_like(bins), linewidth=2, color=\'r\')\n >>> plt.show()\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_low = 0;
PyObject *__pyx_v_high = 0;
@@ -2828,9 +2570,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, P
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
static char *__pyx_argnames[] = {"low","high","size",0};
- __pyx_v_low = __pyx_d7;
- __pyx_v_high = __pyx_d8;
- __pyx_v_size = __pyx_d9;
+ __pyx_v_low = __pyx_k8;
+ __pyx_v_high = __pyx_k9;
+ __pyx_v_size = __pyx_k10;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_low);
@@ -2841,16 +2583,16 @@ static PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, P
__pyx_v_odiff = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_temp = Py_None; Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":649 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":772 */
__pyx_v_flow = PyFloat_AsDouble(__pyx_v_low);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":650 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":773 */
__pyx_v_fhigh = PyFloat_AsDouble(__pyx_v_high);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":651 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":774 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_flow,(__pyx_v_fhigh - __pyx_v_flow)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;}
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_flow,(__pyx_v_fhigh - __pyx_v_flow)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -2858,51 +2600,51 @@ static PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, P
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":653 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":776 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":654 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_low,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":777 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_low,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_olow));
__pyx_v_olow = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":655 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_high,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":778 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_high,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_ohigh));
__pyx_v_ohigh = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":656 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_subtract); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":779 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_subtract); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_ohigh));
PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_ohigh));
Py_INCREF(((PyObject *)__pyx_v_olow));
PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_olow));
- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_v_temp);
__pyx_v_temp = __pyx_4;
__pyx_4 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":657 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":780 */
Py_INCREF(__pyx_v_temp);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":659 */
- __pyx_3 = PyArray_EnsureArray(__pyx_v_temp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":782 */
+ __pyx_3 = PyArray_EnsureArray(__pyx_v_temp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_odiff));
__pyx_v_odiff = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":660 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_olow,__pyx_v_odiff); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":783 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_olow,__pyx_v_odiff); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -2927,8 +2669,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, P
return __pyx_r;
}
+static PyObject *__pyx_n_size;
+
+
static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_rand[] = "Return an array of the given dimensions which is initialized to\n random numbers from a uniform distribution in the range [0,1).\n\n rand(d0, d1, ..., dn) -> random values\n\n Note: This is a convenience function. If you want an\n interface that takes a tuple as the first argument\n use numpy.random.random_sample(shape_tuple).\n\n ";
+static char __pyx_doc_6mtrand_11RandomState_rand[] = "\n rand(d0, d1, ..., dn)\n\n Random values in a given shape.\n\n Create an array of the given shape and propagate it with\n random samples from a uniform distribution\n over ``[0, 1)``.\n\n Parameters\n ----------\n d0, d1, ..., dn : int\n Shape of the output.\n\n Returns\n -------\n out : ndarray, shape ``(d0, d1, ..., dn)``\n Random values.\n\n See Also\n --------\n random\n\n Notes\n -----\n This is a convenience function. If you want an interface that\n takes a shape-tuple as the first argument, refer to\n `random`.\n\n Examples\n --------\n >>> np.random.rand(3,2)\n array([[ 0.14022471, 0.96360618], #random\n [ 0.37601032, 0.25528411], #random\n [ 0.49313049, 0.94909878]]) #random\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_args = 0;
PyObject *__pyx_r;
@@ -2947,11 +2692,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyOb
return 0;
}
Py_INCREF(__pyx_v_self);
- __pyx_1 = PyObject_Length(__pyx_v_args); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; goto __pyx_L1;}
+ __pyx_1 = PyObject_Length(__pyx_v_args); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;}
__pyx_2 = (__pyx_1 == 0);
if (__pyx_2) {
- __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}
- __pyx_4 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__pyx_r = __pyx_4;
__pyx_4 = 0;
@@ -2959,11 +2704,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyOb
goto __pyx_L2;
}
/*else*/ {
- __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}
- __pyx_5 = PyDict_New(); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}
- if (PyDict_SetItem(__pyx_5, __pyx_n_size, __pyx_v_args) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}
- __pyx_6 = PyEval_CallObjectWithKeywords(__pyx_3, __pyx_4, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}
+ __pyx_5 = PyDict_New(); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}
+ if (PyDict_SetItem(__pyx_5, __pyx_n_size, __pyx_v_args) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}
+ __pyx_6 = PyEval_CallObjectWithKeywords(__pyx_3, __pyx_4, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
@@ -2991,7 +2736,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyOb
}
static PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_randn[] = "Returns zero-mean, unit-variance Gaussian random numbers in an\n array of shape (d0, d1, ..., dn).\n\n randn(d0, d1, ..., dn) -> random values\n\n Note: This is a convenience function. If you want an\n interface that takes a tuple as the first argument\n use numpy.random.standard_normal(shape_tuple).\n ";
+static char __pyx_doc_6mtrand_11RandomState_randn[] = "\n randn(d0, d1, ..., dn)\n\n Returns zero-mean, unit-variance Gaussian random numbers in an\n array of shape (d0, d1, ..., dn).\n\n Note: This is a convenience function. If you want an\n interface that takes a tuple as the first argument\n use numpy.random.standard_normal(shape_tuple).\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_args = 0;
PyObject *__pyx_r;
@@ -3009,11 +2754,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyO
return 0;
}
Py_INCREF(__pyx_v_self);
- __pyx_1 = PyObject_Length(__pyx_v_args); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; goto __pyx_L1;}
+ __pyx_1 = PyObject_Length(__pyx_v_args); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; goto __pyx_L1;}
__pyx_2 = (__pyx_1 == 0);
if (__pyx_2) {
- __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}
- __pyx_4 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__pyx_r = __pyx_4;
__pyx_4 = 0;
@@ -3021,11 +2766,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyO
goto __pyx_L2;
}
/*else*/ {
- __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}
Py_INCREF(__pyx_v_args);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_args);
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
__pyx_r = __pyx_5;
@@ -3051,7 +2796,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyO
}
static PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_random_integers[] = "Return random integers x such that low <= x <= high.\n\n random_integers(low, high=None, size=None) -> random values.\n\n If high is None, then 1 <= x <= low.\n ";
+static char __pyx_doc_6mtrand_11RandomState_random_integers[] = "\n random_integers(low, high=None, size=None)\n\n Return random integers x such that low <= x <= high.\n\n If high is None, then 1 <= x <= low.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_low = 0;
PyObject *__pyx_v_high = 0;
@@ -3062,25 +2807,25 @@ static PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
static char *__pyx_argnames[] = {"low","high","size",0};
- __pyx_v_high = __pyx_d10;
- __pyx_v_size = __pyx_d11;
+ __pyx_v_high = __pyx_k11;
+ __pyx_v_size = __pyx_k12;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|OO", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_low);
Py_INCREF(__pyx_v_high);
Py_INCREF(__pyx_v_size);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":700 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":854 */
__pyx_1 = __pyx_v_high == Py_None;
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":701 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":855 */
Py_INCREF(__pyx_v_low);
Py_DECREF(__pyx_v_high);
__pyx_v_high = __pyx_v_low;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":702 */
- __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":856 */
+ __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;}
Py_DECREF(__pyx_v_low);
__pyx_v_low = __pyx_2;
__pyx_2 = 0;
@@ -3088,19 +2833,19 @@ static PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":703 */
- __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}
- __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}
- __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":857 */
+ __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}
+ __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}
+ __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}
Py_INCREF(__pyx_v_low);
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_low);
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
Py_INCREF(__pyx_v_size);
PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_size);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
__pyx_r = __pyx_4;
@@ -3124,17 +2869,17 @@ static PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v
}
static PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_standard_normal[] = "Standard Normal distribution (mean=0, stdev=1).\n\n standard_normal(size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_standard_normal[] = "\n standard_normal(size=None)\n\n Standard Normal distribution (mean=0, stdev=1).\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_size = 0;
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
static char *__pyx_argnames[] = {"size",0};
- __pyx_v_size = __pyx_d12;
+ __pyx_v_size = __pyx_k13;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_size);
- __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gauss,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; goto __pyx_L1;}
+ __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gauss,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
@@ -3151,8 +2896,17 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v
return __pyx_r;
}
+static PyObject *__pyx_n_any;
+static PyObject *__pyx_n_less_equal;
+
+static PyObject *__pyx_k73p;
+static PyObject *__pyx_k74p;
+
+static char __pyx_k73[] = "scale <= 0";
+static char __pyx_k74[] = "scale <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_normal[] = "Normal distribution (mean=loc, stdev=scale).\n\n normal(loc=0.0, scale=1.0, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_normal[] = "\n normal(loc=0.0, scale=1.0, size=None)\n\n Draw random samples from a normal (Gaussian) distribution.\n\n The probability density function of the normal distribution, first\n derived by De Moivre and 200 years later by both Gauss and Laplace\n independently [2]_, is often called the bell curve because of\n its characteristic shape (see the example below).\n\n The normal distributions occurs often in nature. For example, it\n describes the commonly occurring distribution of samples influenced\n by a large number of tiny, random disturbances, each with its own\n unique distribution [2]_.\n\n Parameters\n ----------\n loc : float\n Mean (\"centre\") of the distribution.\n scale : float\n Standard deviation (spread or \"width\") of the distribution.\n size : tuple of ints\n Output shape. If the given shape is, e.g., ``(m, n, k)``, then\n ``m * n * k`` samples are drawn.\n\n See Also\n --------\n scipy.stats.distributions.norm : probability density function,\n distribution or cumulative density function, etc.\n\n Notes\n -----\n The probability density for the Gaussian distribution is\n\n .. math:: p(x) = \\frac{1}{\\sqrt{ 2 \\pi \\sigma^2 }}\n e^{ - \\frac{ (x - \\mu)^2 } {2 \\sigma^2} },\n\n where :math:`\\mu` is the mean and :math:`\\sigma` the standard deviation.\n The square of the standard deviation, :math:`\\sigma^2`, is called the\n variance.\n\n The function has its peak at the mean, and its \"spread\" increases with\n the standard deviation (the function reaches 0.607 times its maximum at\n :math:`x + \\sigma` and :math:`x - \\sigma` [2]_). This implies that\n `numpy.random.normal` is more likely to return samples lying close to the\n mean, rather than those far away.\n\n References\n ----------\n .. [1] Wikipedia, \"Normal distribution\",\n http://en.wikipedia.org/wiki/Normal_distribution\n .. [2] P. R. Peebles Jr., \"Central Limit Theorem\" in \"Probability, Random\n Variables and Random Signal Principles\", 4th ed., 2001,\n pp. 51, 51, 125.\n\n Examples\n --------\n Draw samples from the distribution:\n\n >>> mu, sigma = 0, 0.1 # mean and standard deviation\n >>> s = np.random.normal(mu, sigma, 1000)\n\n Verify the mean and the variance:\n\n >>> abs(mu - np.mean(s)) < 0.01\n True\n\n >>> abs(sigma - np.std(s, ddof=1)) < 0.01\n True\n\n Display the histogram of the samples, along with\n the probability density function:\n\n >>> import matplotlib.pyplot as plt\n >>> count, bins, ignored = plt.hist(s, 30, normed=True)\n >>> plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) * ... np.exp( - (bins - mu)**2 / (2 * sigma**2) ),\n ... linewidth=2, color=\'r\')\n >>> plt.show()\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_loc = 0;
PyObject *__pyx_v_scale = 0;
@@ -3168,9 +2922,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, Py
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"loc","scale","size",0};
- __pyx_v_loc = __pyx_d13;
- __pyx_v_scale = __pyx_d14;
- __pyx_v_size = __pyx_d15;
+ __pyx_v_loc = __pyx_k14;
+ __pyx_v_scale = __pyx_k15;
+ __pyx_v_size = __pyx_k16;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_loc);
@@ -3179,33 +2933,33 @@ static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, Py
__pyx_v_oloc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":721 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":954 */
__pyx_v_floc = PyFloat_AsDouble(__pyx_v_loc);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":722 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":955 */
__pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":723 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":956 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":724 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":957 */
__pyx_1 = (__pyx_v_fscale <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}
+ Py_INCREF(__pyx_k73p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k73p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":726 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":959 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -3213,62 +2967,62 @@ static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, Py
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":728 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":961 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":730 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":963 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oloc));
__pyx_v_oloc = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":731 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":964 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_oscale));
__pyx_v_oscale = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":732 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":965 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}
+ __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k23p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}
+ Py_INCREF(__pyx_k74p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k74p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":734 */
- __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":967 */
+ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -3292,8 +3046,18 @@ static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, Py
return __pyx_r;
}
+static PyObject *__pyx_k75p;
+static PyObject *__pyx_k76p;
+static PyObject *__pyx_k77p;
+static PyObject *__pyx_k78p;
+
+static char __pyx_k75[] = "a <= 0";
+static char __pyx_k76[] = "b <= 0";
+static char __pyx_k77[] = "a <= 0";
+static char __pyx_k78[] = "b <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_beta[] = "Beta distribution over [0, 1].\n\n beta(a, b, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_beta[] = "\n beta(a, b, size=None)\n\n The Beta distribution over ``[0, 1]``.\n\n The Beta distribution is a special case of the Dirichlet distribution,\n and is related to the Gamma distribution. It has the probability\n distribution function\n\n .. math:: f(x; a,b) = \\frac{1}{B(\\alpha, \\beta)} x^{\\alpha - 1}\n (1 - x)^{\\beta - 1},\n\n where the normalisation, B, is the beta function,\n\n .. math:: B(\\alpha, \\beta) = \\int_0^1 t^{\\alpha - 1}\n (1 - t)^{\\beta - 1} dt.\n\n It is often seen in Bayesian inference and order statistics.\n\n Parameters\n ----------\n a : float\n Alpha, non-negative.\n b : float\n Beta, non-negative.\n size : tuple of ints, optional\n The number of samples to draw. The ouput is packed according to\n the size given.\n\n Returns\n -------\n out : ndarray\n Array of the given shape, containing values drawn from a\n Beta distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_a = 0;
PyObject *__pyx_v_b = 0;
@@ -3309,7 +3073,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyOb
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"a","b","size",0};
- __pyx_v_size = __pyx_d16;
+ __pyx_v_size = __pyx_k17;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_a, &__pyx_v_b, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_a);
@@ -3318,48 +3082,48 @@ static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyOb
__pyx_v_oa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_ob = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":744 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1009 */
__pyx_v_fa = PyFloat_AsDouble(__pyx_v_a);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":745 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1010 */
__pyx_v_fb = PyFloat_AsDouble(__pyx_v_b);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":746 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1011 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":747 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1012 */
__pyx_1 = (__pyx_v_fa <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; goto __pyx_L1;}
- Py_INCREF(__pyx_k26p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; goto __pyx_L1;}
+ Py_INCREF(__pyx_k75p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k75p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":749 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1014 */
__pyx_1 = (__pyx_v_fb <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}
- Py_INCREF(__pyx_k27p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k27p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; goto __pyx_L1;}
+ Py_INCREF(__pyx_k76p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k76p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":751 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_fa,__pyx_v_fb); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1016 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_fa,__pyx_v_fb); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -3367,99 +3131,99 @@ static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyOb
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":753 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1018 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":755 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1020 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oa));
__pyx_v_oa = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":756 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_b,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1021 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_b,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_ob));
__pyx_v_ob = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":757 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1022 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}
+ __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oa));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oa));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}
- Py_INCREF(__pyx_k26p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k26p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1023; goto __pyx_L1;}
+ Py_INCREF(__pyx_k77p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k77p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1023; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1023; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":759 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1024 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}
+ __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_ob));
PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_ob));
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
__pyx_4 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}
- Py_INCREF(__pyx_k27p);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k27p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; goto __pyx_L1;}
+ Py_INCREF(__pyx_k78p);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k78p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":761 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_oa,__pyx_v_ob); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1026 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_oa,__pyx_v_ob); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -3483,8 +3247,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyOb
return __pyx_r;
}
+static PyObject *__pyx_k79p;
+static PyObject *__pyx_k80p;
+
+static char __pyx_k79[] = "scale <= 0";
+static char __pyx_k80[] = "scale <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_exponential[] = "Exponential distribution.\n\n exponential(scale=1.0, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_exponential[] = "\n exponential(scale=1.0, size=None)\n\n Exponential distribution.\n\n Its probability density function is\n\n .. math:: f(x; \\lambda) = \\lambda \\exp(-\\lambda x),\n\n for ``x > 0`` and 0 elsewhere. :math:`lambda` is\n known as the rate parameter.\n\n The exponential distribution is a continuous analogue of the\n geometric distribution. It describes many common situations, such as\n the size of raindrops measured over many rainstorms [1]_, or the time\n between page requests to Wikipedia [2]_.\n\n Parameters\n ----------\n scale : float\n The rate parameter, :math:`\\lambda`.\n size : tuple of ints\n Number of samples to draw. The output is shaped\n according to `size`.\n\n References\n ----------\n .. [1] Peyton Z. Peebles Jr., \"Probability, Random Variables and\n Random Signal Principles\", 4th ed, 2001, p. 57.\n .. [2] \"Poisson Process\", Wikipedia,\n http://en.wikipedia.org/wiki/Poisson_process\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_scale = 0;
PyObject *__pyx_v_size = 0;
@@ -3497,38 +3267,38 @@ static PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_sel
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"scale","size",0};
- __pyx_v_scale = __pyx_d17;
- __pyx_v_size = __pyx_d18;
+ __pyx_v_scale = __pyx_k18;
+ __pyx_v_size = __pyx_k19;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OO", __pyx_argnames, &__pyx_v_scale, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_scale);
Py_INCREF(__pyx_v_size);
__pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":771 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1065 */
__pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":772 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1066 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":773 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1067 */
__pyx_1 = (__pyx_v_fscale <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; goto __pyx_L1;}
+ Py_INCREF(__pyx_k79p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k79p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":775 */
- __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1069 */
+ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -3536,55 +3306,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_sel
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":777 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1071 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":779 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1073 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oscale));
__pyx_v_oscale = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":780 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1074 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; goto __pyx_L1;}
+ Py_INCREF(__pyx_k80p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k80p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":782 */
- __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1076 */
+ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -3607,17 +3377,17 @@ static PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_sel
}
static PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_standard_exponential[] = "Standard exponential distribution (scale=1).\n\n standard_exponential(size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_standard_exponential[] = "\n standard_exponential(size=None)\n\n Standard exponential distribution (scale=1).\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_size = 0;
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
static char *__pyx_argnames[] = {"size",0};
- __pyx_v_size = __pyx_d19;
+ __pyx_v_size = __pyx_k20;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_size);
- __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_exponential,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; goto __pyx_L1;}
+ __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_exponential,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
@@ -3634,8 +3404,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__
return __pyx_r;
}
+static PyObject *__pyx_k81p;
+static PyObject *__pyx_k82p;
+
+static char __pyx_k81[] = "shape <= 0";
+static char __pyx_k82[] = "shape <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_standard_gamma[] = "Standard Gamma distribution.\n\n standard_gamma(shape, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_standard_gamma[] = "\n standard_gamma(shape, size=None)\n\n Standard Gamma distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_shape = 0;
PyObject *__pyx_v_size = 0;
@@ -3648,37 +3424,37 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"shape","size",0};
- __pyx_v_size = __pyx_d20;
+ __pyx_v_size = __pyx_k21;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_shape, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_shape);
Py_INCREF(__pyx_v_size);
__pyx_v_oshape = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":799 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1097 */
__pyx_v_fshape = PyFloat_AsDouble(__pyx_v_shape);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":800 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1098 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":801 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1099 */
__pyx_1 = (__pyx_v_fshape <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;}
- Py_INCREF(__pyx_k28p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k28p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1100; goto __pyx_L1;}
+ Py_INCREF(__pyx_k81p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k81p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1100; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1100; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":803 */
- __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_fshape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1101 */
+ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_fshape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -3686,55 +3462,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":805 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1103 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":806 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_shape,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1104 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_shape,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oshape));
__pyx_v_oshape = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":807 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1105 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oshape));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oshape));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;}
- Py_INCREF(__pyx_k28p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k28p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; goto __pyx_L1;}
+ Py_INCREF(__pyx_k82p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k82p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":809 */
- __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_oshape); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1107 */
+ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_oshape); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -3756,8 +3532,18 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_
return __pyx_r;
}
+static PyObject *__pyx_k83p;
+static PyObject *__pyx_k84p;
+static PyObject *__pyx_k85p;
+static PyObject *__pyx_k86p;
+
+static char __pyx_k83[] = "shape <= 0";
+static char __pyx_k84[] = "scale <= 0";
+static char __pyx_k85[] = "shape <= 0";
+static char __pyx_k86[] = "scale <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_gamma[] = "Gamma distribution.\n\n gamma(shape, scale=1.0, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_gamma[] = "\n gamma(shape, scale=1.0, size=None)\n\n Gamma distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_shape = 0;
PyObject *__pyx_v_scale = 0;
@@ -3773,8 +3559,8 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyO
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"shape","scale","size",0};
- __pyx_v_scale = __pyx_d21;
- __pyx_v_size = __pyx_d22;
+ __pyx_v_scale = __pyx_k22;
+ __pyx_v_size = __pyx_k23;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|OO", __pyx_argnames, &__pyx_v_shape, &__pyx_v_scale, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_shape);
@@ -3783,48 +3569,48 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyO
__pyx_v_oshape = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":819 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1119 */
__pyx_v_fshape = PyFloat_AsDouble(__pyx_v_shape);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":820 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1120 */
__pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":821 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1121 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":822 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1122 */
__pyx_1 = (__pyx_v_fshape <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;}
- Py_INCREF(__pyx_k28p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k28p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; goto __pyx_L1;}
+ Py_INCREF(__pyx_k83p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k83p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":824 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1124 */
__pyx_1 = (__pyx_v_fscale <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; goto __pyx_L1;}
+ Py_INCREF(__pyx_k84p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k84p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":826 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_fshape,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1126 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_fshape,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -3832,99 +3618,99 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyO
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":828 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1128 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":829 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_shape,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1129 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_shape,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1129; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oshape));
__pyx_v_oshape = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":830 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1130 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_oscale));
__pyx_v_oscale = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":831 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1131 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;}
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oshape));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oshape));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;}
- Py_INCREF(__pyx_k28p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k28p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1132; goto __pyx_L1;}
+ Py_INCREF(__pyx_k85p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k85p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1132; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1132; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":833 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1133 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;}
+ __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
__pyx_4 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k23p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; goto __pyx_L1;}
+ Py_INCREF(__pyx_k86p);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k86p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":835 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_oshape,__pyx_v_oscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1135 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_oshape,__pyx_v_oscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -3948,8 +3734,18 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyO
return __pyx_r;
}
+static PyObject *__pyx_k87p;
+static PyObject *__pyx_k88p;
+static PyObject *__pyx_k89p;
+static PyObject *__pyx_k90p;
+
+static char __pyx_k87[] = "shape <= 0";
+static char __pyx_k88[] = "scale <= 0";
+static char __pyx_k89[] = "dfnum <= 0";
+static char __pyx_k90[] = "dfden <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_f[] = "F distribution.\n\n f(dfnum, dfden, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_f[] = "\n f(dfnum, dfden, size=None)\n\n F distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_dfnum = 0;
PyObject *__pyx_v_dfden = 0;
@@ -3965,7 +3761,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObjec
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"dfnum","dfden","size",0};
- __pyx_v_size = __pyx_d23;
+ __pyx_v_size = __pyx_k24;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_dfnum);
@@ -3974,48 +3770,48 @@ static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObjec
__pyx_v_odfnum = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_odfden = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":845 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1147 */
__pyx_v_fdfnum = PyFloat_AsDouble(__pyx_v_dfnum);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":846 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1148 */
__pyx_v_fdfden = PyFloat_AsDouble(__pyx_v_dfden);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":847 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1149 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":848 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1150 */
__pyx_1 = (__pyx_v_fdfnum <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;}
- Py_INCREF(__pyx_k28p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k28p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; goto __pyx_L1;}
+ Py_INCREF(__pyx_k87p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k87p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":850 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1152 */
__pyx_1 = (__pyx_v_fdfden <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; goto __pyx_L1;}
+ Py_INCREF(__pyx_k88p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k88p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":852 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_fdfnum,__pyx_v_fdfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1154 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_fdfnum,__pyx_v_fdfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -4023,99 +3819,99 @@ static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObjec
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":854 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1156 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":856 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_dfnum,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1158 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_dfnum,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_odfnum));
__pyx_v_odfnum = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":857 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_dfden,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1159 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_dfden,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_odfden));
__pyx_v_odfden = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":858 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1160 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;}
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_odfnum));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_odfnum));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}
- Py_INCREF(__pyx_k29p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k29p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; goto __pyx_L1;}
+ Py_INCREF(__pyx_k89p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k89p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":860 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1162 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;}
+ __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_odfden));
PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_odfden));
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
__pyx_4 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; goto __pyx_L1;}
- Py_INCREF(__pyx_k30p);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k30p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1163; goto __pyx_L1;}
+ Py_INCREF(__pyx_k90p);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k90p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1163; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1163; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":862 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_odfnum,__pyx_v_odfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1164 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_odfnum,__pyx_v_odfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -4139,8 +3935,24 @@ static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObjec
return __pyx_r;
}
+static PyObject *__pyx_n_less;
+
+static PyObject *__pyx_k91p;
+static PyObject *__pyx_k92p;
+static PyObject *__pyx_k93p;
+static PyObject *__pyx_k94p;
+static PyObject *__pyx_k95p;
+static PyObject *__pyx_k96p;
+
+static char __pyx_k91[] = "dfnum <= 1";
+static char __pyx_k92[] = "dfden <= 0";
+static char __pyx_k93[] = "nonc < 0";
+static char __pyx_k94[] = "dfnum <= 1";
+static char __pyx_k95[] = "dfden <= 0";
+static char __pyx_k96[] = "nonc < 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_noncentral_f[] = "Noncentral F distribution.\n\n noncentral_f(dfnum, dfden, nonc, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_noncentral_f[] = "\n noncentral_f(dfnum, dfden, nonc, size=None)\n\n Noncentral F distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_dfnum = 0;
PyObject *__pyx_v_dfden = 0;
@@ -4159,7 +3971,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_se
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"dfnum","dfden","nonc","size",0};
- __pyx_v_size = __pyx_d24;
+ __pyx_v_size = __pyx_k25;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO|O", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_nonc, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_dfnum);
@@ -4170,66 +3982,66 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_se
__pyx_v_odfden = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_ononc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":872 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1176 */
__pyx_v_fdfnum = PyFloat_AsDouble(__pyx_v_dfnum);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":873 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1177 */
__pyx_v_fdfden = PyFloat_AsDouble(__pyx_v_dfden);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":874 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1178 */
__pyx_v_fnonc = PyFloat_AsDouble(__pyx_v_nonc);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":875 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1179 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":876 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1180 */
__pyx_1 = (__pyx_v_fdfnum <= 1);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; goto __pyx_L1;}
- Py_INCREF(__pyx_k31p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k31p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; goto __pyx_L1;}
+ Py_INCREF(__pyx_k91p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k91p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":878 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1182 */
__pyx_1 = (__pyx_v_fdfden <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; goto __pyx_L1;}
- Py_INCREF(__pyx_k30p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k30p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1183; goto __pyx_L1;}
+ Py_INCREF(__pyx_k92p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k92p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1183; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1183; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":880 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1184 */
__pyx_1 = (__pyx_v_fnonc < 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; goto __pyx_L1;}
- Py_INCREF(__pyx_k32p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k32p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; goto __pyx_L1;}
+ Py_INCREF(__pyx_k93p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k93p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":882 */
- __pyx_2 = __pyx_f_6mtrand_cont3_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_fdfnum,__pyx_v_fdfden,__pyx_v_fnonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1186 */
+ __pyx_2 = __pyx_f_6mtrand_cont3_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_fdfnum,__pyx_v_fdfden,__pyx_v_fnonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1186; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -4237,143 +4049,143 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_se
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":885 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1189 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":887 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_dfnum,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1191 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_dfnum,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_odfnum));
__pyx_v_odfnum = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":888 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_dfden,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1192 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_dfden,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1192; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_odfden));
__pyx_v_odfden = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":889 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_nonc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1193 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_nonc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_ononc));
__pyx_v_ononc = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":891 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1195 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_odfnum));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_odfnum));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;}
- Py_INCREF(__pyx_k31p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k31p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; goto __pyx_L1;}
+ Py_INCREF(__pyx_k94p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k94p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":893 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1197 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;}
- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;}
+ __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_odfden));
PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_odfden));
PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
__pyx_4 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
if (__pyx_1) {
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;}
- Py_INCREF(__pyx_k30p);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k30p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1198; goto __pyx_L1;}
+ Py_INCREF(__pyx_k95p);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k95p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1198; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1198; goto __pyx_L1;}
goto __pyx_L7;
}
__pyx_L7:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":895 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1199 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_less); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;}
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_less); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;}
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_ononc));
PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_ononc));
PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; goto __pyx_L1;}
- Py_INCREF(__pyx_k32p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k32p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1200; goto __pyx_L1;}
+ Py_INCREF(__pyx_k96p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k96p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1200; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1200; goto __pyx_L1;}
goto __pyx_L8;
}
__pyx_L8:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":897 */
- __pyx_5 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_odfnum,__pyx_v_odfden,__pyx_v_ononc); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1201 */
+ __pyx_5 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_odfnum,__pyx_v_odfden,__pyx_v_ononc); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;}
__pyx_r = __pyx_5;
__pyx_5 = 0;
goto __pyx_L0;
@@ -4399,8 +4211,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_se
return __pyx_r;
}
+static PyObject *__pyx_k97p;
+static PyObject *__pyx_k98p;
+
+static char __pyx_k97[] = "df <= 0";
+static char __pyx_k98[] = "df <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_chisquare[] = "Chi^2 distribution.\n\n chisquare(df, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_chisquare[] = "\n chisquare(df, size=None)\n\n Draw samples from a chi-square distribution.\n\n When `df` independent random variables, each with standard\n normal distributions (mean 0, variance 1), are squared and summed,\n the resulting distribution is chi-square (see Notes). This\n distribution is often used in hypothesis testing.\n\n Parameters\n ----------\n df : int\n Number of degrees of freedom.\n size : tuple of ints, int, optional\n Size of the returned array. By default, a scalar is\n returned.\n\n Returns\n -------\n output : ndarray\n Samples drawn from the distribution, packed in a `size`-shaped\n array.\n\n Raises\n ------\n ValueError\n When `df` <= 0 or when an inappropriate `size` (e.g. ``size=-1``)\n is given.\n\n Notes\n -----\n The variable obtained by summing the squares of `df` independent,\n standard normally distributed random variables:\n\n .. math:: Q = \\sum_{i=0}^{\\mathtt{df}} X^2_i\n\n is chi-square distributed, denoted\n\n .. math:: Q \\sim \\chi^2_k.\n\n The probability density function of the chi-squared distribution is\n\n .. math:: p(x) = \\frac{(1/2)^{k/2}}{\\Gamma(k/2)}\n x^{k/2 - 1} e^{-x/2},\n\n where :math:`\\Gamma` is the gamma function,\n\n .. math:: \\Gamma(x) = \\int_0^{-\\infty} t^{x - 1} e^{-t} dt.\n\n References\n ----------\n .. [1] NIST/SEMATECH e-Handbook of Statistical Methods,\n http://www.itl.nist.gov/div898/handbook/eda/section3/eda3666.htm\n .. [2] Wikipedia, \"Chi-square distribution\",\n http://en.wikipedia.org/wiki/Chi-square_distribution\n\n Examples\n --------\n >>> np.random.chisquare(2,4)\n array([ 1.89920014, 9.00867716, 3.13710533, 5.62318272])\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_df = 0;
PyObject *__pyx_v_size = 0;
@@ -4413,37 +4231,37 @@ static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self,
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"df","size",0};
- __pyx_v_size = __pyx_d25;
+ __pyx_v_size = __pyx_k26;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_df);
Py_INCREF(__pyx_v_size);
__pyx_v_odf = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":908 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1271 */
__pyx_v_fdf = PyFloat_AsDouble(__pyx_v_df);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":909 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1272 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":910 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1273 */
__pyx_1 = (__pyx_v_fdf <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}
- Py_INCREF(__pyx_k34p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k34p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
+ Py_INCREF(__pyx_k97p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k97p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":912 */
- __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_fdf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1275 */
+ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_fdf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -4451,55 +4269,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self,
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":914 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1277 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":916 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_df,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1279 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_df,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1279; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_odf));
__pyx_v_odf = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":917 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1280 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_odf));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_odf));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}
- Py_INCREF(__pyx_k34p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k34p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; goto __pyx_L1;}
+ Py_INCREF(__pyx_k98p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k98p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":919 */
- __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_odf); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1282 */
+ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_odf); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1282; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -4521,8 +4339,18 @@ static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self,
return __pyx_r;
}
+static PyObject *__pyx_k99p;
+static PyObject *__pyx_k100p;
+static PyObject *__pyx_k101p;
+static PyObject *__pyx_k102p;
+
+static char __pyx_k99[] = "df <= 0";
+static char __pyx_k100[] = "nonc <= 0";
+static char __pyx_k101[] = "df <= 1";
+static char __pyx_k102[] = "nonc < 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_noncentral_chisquare[] = "Noncentral Chi^2 distribution.\n\n noncentral_chisquare(df, nonc, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_noncentral_chisquare[] = "\n noncentral_chisquare(df, nonc, size=None)\n\n Draw samples from a noncentral chi-square distribution.\n\n The noncentral :math:`\\chi^2` distribution is a generalisation of\n the :math:`\\chi^2` distribution.\n\n Parameters\n ----------\n df : int\n Degrees of freedom.\n nonc : float\n Non-centrality.\n size : tuple of ints\n Shape of the output.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_df = 0;
PyObject *__pyx_v_nonc = 0;
@@ -4538,7 +4366,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"df","nonc","size",0};
- __pyx_v_size = __pyx_d26;
+ __pyx_v_size = __pyx_k27;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_df, &__pyx_v_nonc, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_df);
@@ -4547,48 +4375,48 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__
__pyx_v_odf = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_ononc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":928 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1305 */
__pyx_v_fdf = PyFloat_AsDouble(__pyx_v_df);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":929 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1306 */
__pyx_v_fnonc = PyFloat_AsDouble(__pyx_v_nonc);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":930 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1307 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":931 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1308 */
__pyx_1 = (__pyx_v_fdf <= 1);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}
- Py_INCREF(__pyx_k34p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k34p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; goto __pyx_L1;}
+ Py_INCREF(__pyx_k99p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k99p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":933 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1310 */
__pyx_1 = (__pyx_v_fnonc <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}
- Py_INCREF(__pyx_k35p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k35p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1311; goto __pyx_L1;}
+ Py_INCREF(__pyx_k100p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k100p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1311; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1311; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":935 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_fdf,__pyx_v_fnonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1312 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_fdf,__pyx_v_fnonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -4596,99 +4424,99 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":938 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1315 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":940 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_df,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1317 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_df,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_odf));
__pyx_v_odf = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":941 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_nonc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1318 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_nonc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_ononc));
__pyx_v_ononc = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":942 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1319 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_odf));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_odf));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}
- Py_INCREF(__pyx_k36p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k36p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; goto __pyx_L1;}
+ Py_INCREF(__pyx_k101p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k101p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":944 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1321 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}
+ __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_ononc));
PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_ononc));
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
__pyx_4 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}
- Py_INCREF(__pyx_k32p);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k32p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; goto __pyx_L1;}
+ Py_INCREF(__pyx_k102p);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k102p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":946 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_odf,__pyx_v_ononc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1323 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_odf,__pyx_v_ononc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -4713,17 +4541,17 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__
}
static PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_standard_cauchy[] = "Standard Cauchy with mode=0.\n\n standard_cauchy(size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_standard_cauchy[] = "\n standard_cauchy(size=None)\n\n Standard Cauchy with mode=0.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_size = 0;
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
static char *__pyx_argnames[] = {"size",0};
- __pyx_v_size = __pyx_d27;
+ __pyx_v_size = __pyx_k28;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_size);
- __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_cauchy,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; goto __pyx_L1;}
+ __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_cauchy,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1333; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
@@ -4740,8 +4568,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v
return __pyx_r;
}
+static PyObject *__pyx_k103p;
+static PyObject *__pyx_k104p;
+
+static char __pyx_k103[] = "df <= 0";
+static char __pyx_k104[] = "df <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_standard_t[] = "Standard Student\'s t distribution with df degrees of freedom.\n\n standard_t(df, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_standard_t[] = "\n standard_t(df, size=None)\n\n Standard Student\'s t distribution with df degrees of freedom.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_df = 0;
PyObject *__pyx_v_size = 0;
@@ -4754,37 +4588,37 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"df","size",0};
- __pyx_v_size = __pyx_d28;
+ __pyx_v_size = __pyx_k29;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_df);
Py_INCREF(__pyx_v_size);
__pyx_v_odf = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":964 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1345 */
__pyx_v_fdf = PyFloat_AsDouble(__pyx_v_df);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":965 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1346 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":966 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1347 */
__pyx_1 = (__pyx_v_fdf <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; goto __pyx_L1;}
- Py_INCREF(__pyx_k34p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k34p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1348; goto __pyx_L1;}
+ Py_INCREF(__pyx_k103p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k103p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1348; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1348; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":968 */
- __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_fdf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1349 */
+ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_fdf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1349; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -4792,55 +4626,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":970 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1351 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":972 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_df,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1353 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_df,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_odf));
__pyx_v_odf = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":973 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1354 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_odf));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_odf));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; goto __pyx_L1;}
- Py_INCREF(__pyx_k34p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k34p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1355; goto __pyx_L1;}
+ Py_INCREF(__pyx_k104p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k104p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1355; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1355; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":975 */
- __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_odf); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1356 */
+ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_odf); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1356; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -4862,8 +4696,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self
return __pyx_r;
}
+static PyObject *__pyx_k105p;
+static PyObject *__pyx_k106p;
+
+static char __pyx_k105[] = "kappa < 0";
+static char __pyx_k106[] = "kappa < 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_vonmises[] = "von Mises circular distribution with mode mu and dispersion parameter\n kappa on [-pi, pi].\n\n vonmises(mu, kappa, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_vonmises[] = "\n vonmises(mu=0.0, kappa=1.0, size=None)\n\n Draw samples from a von Mises distribution.\n\n Samples are drawn from a von Mises distribution with specified mode (mu)\n and dispersion (kappa), on the interval [-pi, pi].\n\n The von Mises distribution (also known as the circular normal\n distribution) is a continuous probability distribution on the circle. It\n may be thought of as the circular analogue of the normal distribution.\n\n Parameters\n ----------\n mu : float\n Mode (\"center\") of the distribution.\n kappa : float, >= 0.\n Dispersion of the distribution.\n size : {tuple, int}\n Output shape. If the given shape is, e.g., ``(m, n, k)``, then\n ``m * n * k`` samples are drawn.\n\n Returns\n -------\n samples : {ndarray, scalar}\n The returned samples live on the unit circle [-\\pi, \\pi].\n\n See Also\n --------\n scipy.stats.distributions.vonmises : probability density function,\n distribution or cumulative density function, etc.\n\n Notes\n -----\n The probability density for the von Mises distribution is\n\n .. math:: p(x) = \\frac{e^{\\kappa cos(x-\\mu)}}{2\\pi I_0(\\kappa)},\n\n where :math:`\\mu` is the mode and :math:`\\kappa` the dispersion,\n and :math:`I_0(\\kappa)` is the modified Bessel function of order 0.\n\n The von Mises, named for Richard Edler von Mises, born in\n Austria-Hungary, in what is now the Ukraine. He fled to the United\n States in 1939 and became a professor at Harvard. He worked in\n probability theory, aerodynamics, fluid mechanics, and philosophy of\n science.\n\n References\n ----------\n .. [1] Abramowitz, M. and Stegun, I. A. (ed.), Handbook of Mathematical\n Functions, National Bureau of Standards, 1964; reprinted Dover\n Publications, 1965.\n .. [2] von Mises, Richard, 1964, Mathematical Theory of Probability\n and Statistics (New York: Academic Press).\n .. [3] Wikipedia, \"Von Mises distribution\",\n http://en.wikipedia.org/wiki/Von_Mises_distribution\n\n Examples\n --------\n Draw samples from the distribution:\n\n >>> mu, kappa = 0.0, 4.0 # mean and dispersion\n >>> s = np.random.vonmises(mu, kappa, 1000)\n\n Display the histogram of the samples, along with\n the probability density function:\n\n >>> import matplotlib.pyplot as plt\n >>> import scipy.special as sps\n >>> count, bins, ignored = plt.hist(s, 50, normed=True)\n >>> x = arange(-pi, pi, 2*pi/50.)\n >>> y = -np.exp(kappa*np.cos(x-mu))/(2*pi*sps.jn(0,kappa))\n >>> plt.plot(x, y/max(y), linewidth=2, color=\'r\')\n >>> plt.show()\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_mu = 0;
PyObject *__pyx_v_kappa = 0;
@@ -4879,7 +4719,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self,
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"mu","kappa","size",0};
- __pyx_v_size = __pyx_d29;
+ __pyx_v_size = __pyx_k30;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_mu, &__pyx_v_kappa, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_mu);
@@ -4888,33 +4728,33 @@ static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self,
__pyx_v_omu = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_okappa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":986 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1438 */
__pyx_v_fmu = PyFloat_AsDouble(__pyx_v_mu);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":987 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1439 */
__pyx_v_fkappa = PyFloat_AsDouble(__pyx_v_kappa);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":988 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1440 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":989 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1441 */
__pyx_1 = (__pyx_v_fkappa < 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; goto __pyx_L1;}
- Py_INCREF(__pyx_k37p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k37p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; goto __pyx_L1;}
+ Py_INCREF(__pyx_k105p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k105p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":991 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_fmu,__pyx_v_fkappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1443 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_fmu,__pyx_v_fkappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1443; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -4922,62 +4762,62 @@ static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self,
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":993 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1445 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":995 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_mu,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1447 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_mu,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_omu));
__pyx_v_omu = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":996 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_kappa,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1448 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_kappa,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_okappa));
__pyx_v_okappa = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":997 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1449 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;}
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_okappa));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_okappa));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 998; goto __pyx_L1;}
- Py_INCREF(__pyx_k37p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k37p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 998; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1450; goto __pyx_L1;}
+ Py_INCREF(__pyx_k106p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k106p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1450; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 998; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1450; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":999 */
- __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_omu,__pyx_v_okappa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1451 */
+ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_omu,__pyx_v_okappa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1451; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -5001,8 +4841,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self,
return __pyx_r;
}
+static PyObject *__pyx_k107p;
+static PyObject *__pyx_k108p;
+
+static char __pyx_k107[] = "a <= 0";
+static char __pyx_k108[] = "a <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_pareto[] = "Pareto distribution.\n\n pareto(a, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_pareto[] = "\n pareto(a, size=None)\n\n Draw samples from a Pareto distribution with specified shape.\n\n This is a simplified version of the Generalized Pareto distribution\n (available in SciPy), with the scale set to one and the location set to\n zero. Most authors default the location to one.\n\n The Pareto distribution must be greater than zero, and is unbounded above.\n It is also known as the \"80-20 rule\". In this distribution, 80 percent of\n the weights are in the lowest 20 percent of the range, while the other 20\n percent fill the remaining 80 percent of the range.\n\n Parameters\n ----------\n shape : float, > 0.\n Shape of the distribution.\n size : tuple of ints\n Output shape. If the given shape is, e.g., ``(m, n, k)``, then\n ``m * n * k`` samples are drawn.\n\n See Also\n --------\n scipy.stats.distributions.genpareto.pdf : probability density function,\n distribution or cumulative density function, etc.\n\n Notes\n -----\n The probability density for the Pareto distribution is\n\n .. math:: p(x) = \\frac{am^a}{x^{a+1}}\n\n where :math:`a` is the shape and :math:`m` the location\n\n The Pareto distribution, named after the Italian economist Vilfredo Pareto,\n is a power law probability distribution useful in many real world problems.\n Outside the field of economics it is generally referred to as the Bradford\n distribution. Pareto developed the distribution to describe the\n distribution of wealth in an economy. It has also found use in insurance,\n web page access statistics, oil field sizes, and many other problems,\n including the download frequency for projects in Sourceforge [1]. It is\n one of the so-called \"fat-tailed\" distributions.\n\n\n References\n ----------\n .. [1] Francis Hunt and Paul Johnson, On the Pareto Distribution of\n Sourceforge projects.\n .. [2] Pareto, V. (1896). Course of Political Economy. Lausanne.\n .. [3] Reiss, R.D., Thomas, M.(2001), Statistical Analysis of Extreme\n Values, Birkhauser Verlag, Basel, pp 23-30.\n .. [4] Wikipedia, \"Pareto distribution\",\n http://en.wikipedia.org/wiki/Pareto_distribution\n\n Examples\n --------\n Draw samples from the distribution:\n\n >>> a, m = 3., 1. # shape and mode\n >>> s = np.random.pareto(a, 1000) + m\n\n Display the histogram of the samples, along with\n the probability density function:\n\n >>> import matplotlib.pyplot as plt\n >>> count, bins, ignored = plt.hist(s, 100, normed=True, align=\'center\')\n >>> fit = a*m**a/bins**(a+1)\n >>> plt.plot(bins, max(count)*fit/max(fit),linewidth=2, color=\'r\')\n >>> plt.show()\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_a = 0;
PyObject *__pyx_v_size = 0;
@@ -5015,37 +4861,37 @@ static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, Py
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"a","size",0};
- __pyx_v_size = __pyx_d30;
+ __pyx_v_size = __pyx_k31;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_a);
Py_INCREF(__pyx_v_size);
__pyx_v_oa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1009 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1529 */
__pyx_v_fa = PyFloat_AsDouble(__pyx_v_a);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1010 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1530 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1011 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1531 */
__pyx_1 = (__pyx_v_fa <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; goto __pyx_L1;}
- Py_INCREF(__pyx_k26p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1532; goto __pyx_L1;}
+ Py_INCREF(__pyx_k107p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k107p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1532; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1532; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1013 */
- __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1533 */
+ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1533; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -5053,55 +4899,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, Py
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1015 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1535 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1017 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1537 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1537; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oa));
__pyx_v_oa = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1018 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1538 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oa));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oa));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; goto __pyx_L1;}
- Py_INCREF(__pyx_k26p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; goto __pyx_L1;}
+ Py_INCREF(__pyx_k108p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k108p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1020 */
- __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1540 */
+ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -5123,8 +4969,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, Py
return __pyx_r;
}
+static PyObject *__pyx_k109p;
+static PyObject *__pyx_k110p;
+
+static char __pyx_k109[] = "a <= 0";
+static char __pyx_k110[] = "a <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_weibull[] = "Weibull distribution.\n\n weibull(a, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_weibull[] = "\n weibull(a, size=None)\n\n Weibull distribution.\n\n Draw samples from a 1-parameter Weibull distribution with the given\n shape parameter.\n\n .. math:: X = (-ln(U))^{1/a}\n\n Here, U is drawn from the uniform distribution over (0,1].\n\n The more common 2-parameter Weibull, including a scale parameter\n :math:`\\lambda` is just :math:`X = \\lambda(-ln(U))^{1/a}`.\n\n The Weibull (or Type III asymptotic extreme value distribution for smallest\n values, SEV Type III, or Rosin-Rammler distribution) is one of a class of\n Generalized Extreme Value (GEV) distributions used in modeling extreme\n value problems. This class includes the Gumbel and Frechet distributions.\n\n Parameters\n ----------\n a : float\n Shape of the distribution.\n size : tuple of ints\n Output shape. If the given shape is, e.g., ``(m, n, k)``, then\n ``m * n * k`` samples are drawn.\n\n See Also\n --------\n scipy.stats.distributions.weibull : probability density function,\n distribution or cumulative density function, etc.\n\n gumbel, scipy.stats.distributions.genextreme\n\n Notes\n -----\n The probability density for the Weibull distribution is\n\n .. math:: p(x) = \\frac{a}\n {\\lambda}(\\frac{x}{\\lambda})^{a-1}e^{-(x/\\lambda)^a},\n\n where :math:`a` is the shape and :math:`\\lambda` the scale.\n\n The function has its peak (the mode) at\n :math:`\\lambda(\\frac{a-1}{a})^{1/a}`.\n\n When ``a = 1``, the Weibull distribution reduces to the exponential\n distribution.\n\n References\n ----------\n .. [1] Waloddi Weibull, Professor, Royal Technical University, Stockholm,\n 1939 \"A Statistical Theory Of The Strength Of Materials\",\n Ingeniorsvetenskapsakademiens Handlingar Nr 151, 1939,\n Generalstabens Litografiska Anstalts Forlag, Stockholm.\n .. [2] Waloddi Weibull, 1951 \"A Statistical Distribution Function of Wide\n Applicability\", Journal Of Applied Mechanics ASME Paper.\n .. [3] Wikipedia, \"Weibull distribution\",\n http://en.wikipedia.org/wiki/Weibull_distribution\n\n Examples\n --------\n Draw samples from the distribution:\n\n >>> a = 5. # shape\n >>> s = np.random.weibull(a, 1000)\n\n Display the histogram of the samples, along with\n the probability density function:\n\n >>> import matplotlib.pyplot as plt\n >>> def weib(x,n,a):\n ... return (a/n)*(x/n)**(a-1)*exp(-(x/n)**a)\n\n >>> count, bins, ignored = plt.hist(numpy.random.weibull(5.,1000))\n >>> scale = count.max()/weib(x, 1., 5.).max()\n >>> x = arange(1,100.)/50.\n >>> plt.plot(x, weib(x, 1., 5.)*scale)\n >>> plt.show()\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_a = 0;
PyObject *__pyx_v_size = 0;
@@ -5137,37 +4989,37 @@ static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, P
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"a","size",0};
- __pyx_v_size = __pyx_d31;
+ __pyx_v_size = __pyx_k32;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_a);
Py_INCREF(__pyx_v_size);
__pyx_v_oa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1030 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1628 */
__pyx_v_fa = PyFloat_AsDouble(__pyx_v_a);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1031 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1629 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1032 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1630 */
__pyx_1 = (__pyx_v_fa <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; goto __pyx_L1;}
- Py_INCREF(__pyx_k26p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1631; goto __pyx_L1;}
+ Py_INCREF(__pyx_k109p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k109p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1631; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1631; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1034 */
- __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1632 */
+ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -5175,55 +5027,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, P
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1036 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1634 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1038 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1636 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oa));
__pyx_v_oa = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1039 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1637 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oa));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oa));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1637; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; goto __pyx_L1;}
- Py_INCREF(__pyx_k26p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1638; goto __pyx_L1;}
+ Py_INCREF(__pyx_k110p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k110p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1638; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1638; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1041 */
- __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1639 */
+ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1639; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -5245,8 +5097,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, P
return __pyx_r;
}
+static PyObject *__pyx_k111p;
+static PyObject *__pyx_k112p;
+
+static char __pyx_k111[] = "a <= 0";
+static char __pyx_k112[] = "a <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_power[] = "Power distribution.\n\n power(a, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_power[] = "\n power(a, size=None)\n\n Power distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_a = 0;
PyObject *__pyx_v_size = 0;
@@ -5259,37 +5117,37 @@ static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyO
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"a","size",0};
- __pyx_v_size = __pyx_d32;
+ __pyx_v_size = __pyx_k33;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_a);
Py_INCREF(__pyx_v_size);
__pyx_v_oa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1051 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1651 */
__pyx_v_fa = PyFloat_AsDouble(__pyx_v_a);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1052 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1652 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1053 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1653 */
__pyx_1 = (__pyx_v_fa <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; goto __pyx_L1;}
- Py_INCREF(__pyx_k26p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; goto __pyx_L1;}
+ Py_INCREF(__pyx_k111p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k111p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1055 */
- __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1655 */
+ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1655; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -5297,55 +5155,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyO
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1057 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1657 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1059 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1659 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oa));
__pyx_v_oa = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1060 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1660 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oa));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oa));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; goto __pyx_L1;}
- Py_INCREF(__pyx_k26p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; goto __pyx_L1;}
+ Py_INCREF(__pyx_k112p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k112p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1062 */
- __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1662 */
+ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -5367,8 +5225,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyO
return __pyx_r;
}
+static PyObject *__pyx_k113p;
+static PyObject *__pyx_k114p;
+
+static char __pyx_k113[] = "scale <= 0";
+static char __pyx_k114[] = "scale <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_laplace[] = "Laplace distribution.\n\n laplace(loc=0.0, scale=1.0, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_laplace[] = "\n laplace(loc=0.0, scale=1.0, size=None)\n\n Laplace or double exponential distribution.\n\n It has the probability density function\n\n .. math:: f(x; \\mu, \\lambda) = \\frac{1}{2\\lambda}\n \\exp\\left(-\\frac{|x - \\mu|}{\\lambda}\\right).\n\n The Laplace distribution is similar to the Gaussian/normal distribution,\n but is sharper at the peak and has fatter tails.\n\n Parameters\n ----------\n loc : float\n The position, :math:`\\mu`, of the distribution peak.\n scale : float\n :math:`\\lambda`, the exponential decay.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_loc = 0;
PyObject *__pyx_v_scale = 0;
@@ -5384,9 +5248,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, P
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"loc","scale","size",0};
- __pyx_v_loc = __pyx_d33;
- __pyx_v_scale = __pyx_d34;
- __pyx_v_size = __pyx_d35;
+ __pyx_v_loc = __pyx_k34;
+ __pyx_v_scale = __pyx_k35;
+ __pyx_v_size = __pyx_k36;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_loc);
@@ -5395,33 +5259,33 @@ static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, P
__pyx_v_oloc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1072 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1689 */
__pyx_v_floc = PyFloat_AsDouble(__pyx_v_loc);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1073 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1690 */
__pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1074 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1691 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1075 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1692 */
__pyx_1 = (__pyx_v_fscale <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; goto __pyx_L1;}
+ Py_INCREF(__pyx_k113p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k113p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1077 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1077; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1694 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -5429,62 +5293,62 @@ static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, P
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1079 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1696 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1080 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1080; goto __pyx_L1;}
- if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1080; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1697 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; goto __pyx_L1;}
+ if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_v_oloc));
__pyx_v_oloc = ((PyArrayObject *)__pyx_3);
__pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1081 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; goto __pyx_L1;}
- if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1698 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1698; goto __pyx_L1;}
+ if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1698; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_v_oscale));
__pyx_v_oscale = ((PyArrayObject *)__pyx_2);
__pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1082 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1699 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;}
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k23p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; goto __pyx_L1;}
+ Py_INCREF(__pyx_k114p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k114p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1084 */
- __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1701 */
+ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -5508,8 +5372,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, P
return __pyx_r;
}
+static PyObject *__pyx_k115p;
+static PyObject *__pyx_k116p;
+
+static char __pyx_k115[] = "scale <= 0";
+static char __pyx_k116[] = "scale <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_gumbel[] = "Gumbel distribution.\n\n gumbel(loc=0.0, scale=1.0, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_gumbel[] = "\n gumbel(loc=0.0, scale=1.0, size=None)\n\n Gumbel distribution.\n\n Draw samples from a Gumbel distribution with specified location (or mean)\n and scale (or standard deviation).\n\n The Gumbel (or Smallest Extreme Value (SEV) or the Smallest Extreme Value\n Type I) distribution is one of a class of Generalized Extreme Value (GEV)\n distributions used in modeling extreme value problems. The Gumbel is a\n special case of the Extreme Value Type I distribution for maximums from\n distributions with \"exponential-like\" tails, it may be derived by\n considering a Gaussian process of measurements, and generating the pdf for\n the maximum values from that set of measurements (see examples).\n\n Parameters\n ----------\n loc : float\n The location of the mode of the distribution.\n scale : float\n The scale parameter of the distribution.\n size : tuple of ints\n Output shape. If the given shape is, e.g., ``(m, n, k)``, then\n ``m * n * k`` samples are drawn.\n\n See Also\n --------\n scipy.stats.gumbel : probability density function,\n distribution or cumulative density function, etc.\n weibull, scipy.stats.genextreme\n\n Notes\n -----\n The probability density for the Gumbel distribution is\n\n .. math:: p(x) = \\frac{e^{-(x - \\mu)/ \\beta}}{\\beta} e^{ -e^{-(x - \\mu)/\n \\beta}},\n\n where :math:`\\mu` is the mode, a location parameter, and :math:`\\beta`\n is the scale parameter.\n\n The Gumbel (named for German mathematician Emil Julius Gumbel) was used\n very early in the hydrology literature, for modeling the occurrence of\n flood events. It is also used for modeling maximum wind speed and rainfall\n rates. It is a \"fat-tailed\" distribution - the probability of an event in\n the tail of the distribution is larger than if one used a Gaussian, hence\n the surprisingly frequent occurrence of 100-year floods. Floods were\n initially modeled as a Gaussian process, which underestimated the frequency\n of extreme events.\n\n It is one of a class of extreme value distributions, the Generalized\n Extreme Value (GEV) distributions, which also includes the Weibull and\n Frechet.\n\n The function has a mean of :math:`\\mu + 0.57721\\beta` and a variance of\n :math:`\\frac{\\pi^2}{6}\\beta^2`.\n\n References\n ----------\n .. [1] Gumbel, E.J. (1958). Statistics of Extremes. Columbia University\n Press.\n .. [2] Reiss, R.-D. and Thomas M. (2001), Statistical Analysis of Extreme\n Values, from Insurance, Finance, Hydrology and Other Fields,\n Birkhauser Verlag, Basel: Boston : Berlin.\n .. [3] Wikipedia, \"Gumbel distribution\",\n http://en.wikipedia.org/wiki/Gumbel_distribution\n\n Examples\n --------\n Draw samples from the distribution:\n\n >>> mu, beta = 0, 0.1 # location and scale\n >>> s = np.random.gumbel(mu, beta, 1000)\n\n Display the histogram of the samples, along with\n the probability density function:\n\n >>> import matplotlib.pyplot as plt\n >>> count, bins, ignored = plt.hist(s, 30, normed=True)\n >>> plt.plot(bins, (1/beta)*np.exp(-(bins - mu)/beta)* ... np.exp( -np.exp( -(bins - mu) /beta) ),\n ... linewidth=2, color=\'r\')\n >>> plt.show()\n\n Show how an extreme value distribution can arise from a Gaussian process\n and compare to a Gaussian:\n\n >>> means = []\n >>> maxima = []\n >>> for i in range(0,1000) :\n ... a = np.random.normal(mu, beta, 1000)\n ... means.append(a.mean())\n ... maxima.append(a.max())\n >>> count, bins, ignored = plt.hist(maxima, 30, normed=True)\n >>> beta = np.std(maxima)*np.pi/np.sqrt(6)\n >>> mu = np.mean(maxima) - 0.57721*beta\n >>> plt.plot(bins, (1/beta)*np.exp(-(bins - mu)/beta)* ... np.exp( -np.exp( -(bins - mu) /beta) ),\n ... linewidth=2, color=\'r\')\n >>> plt.plot(bins, 1/(beta * np.sqrt(2 * np.pi)) * ... np.exp( - (bins - mu)**2 / (2 * beta**2) ),\n ... linewidth=2, color=\'g\')\n >>> plt.show()\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_loc = 0;
PyObject *__pyx_v_scale = 0;
@@ -5525,9 +5395,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, Py
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"loc","scale","size",0};
- __pyx_v_loc = __pyx_d36;
- __pyx_v_scale = __pyx_d37;
- __pyx_v_size = __pyx_d38;
+ __pyx_v_loc = __pyx_k37;
+ __pyx_v_scale = __pyx_k38;
+ __pyx_v_size = __pyx_k39;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_loc);
@@ -5536,33 +5406,33 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, Py
__pyx_v_oloc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1094 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1813 */
__pyx_v_floc = PyFloat_AsDouble(__pyx_v_loc);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1095 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1814 */
__pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1096 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1815 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1097 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1816 */
__pyx_1 = (__pyx_v_fscale <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; goto __pyx_L1;}
+ Py_INCREF(__pyx_k115p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k115p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1099 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1818 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1818; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -5570,62 +5440,62 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, Py
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1101 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1820 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1102 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1102; goto __pyx_L1;}
- if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1102; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1821 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; goto __pyx_L1;}
+ if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_v_oloc));
__pyx_v_oloc = ((PyArrayObject *)__pyx_3);
__pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1103 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; goto __pyx_L1;}
- if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1822 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; goto __pyx_L1;}
+ if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_v_oscale));
__pyx_v_oscale = ((PyArrayObject *)__pyx_2);
__pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1104 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1823 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;}
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k23p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; goto __pyx_L1;}
+ Py_INCREF(__pyx_k116p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k116p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1106 */
- __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1825 */
+ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1825; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -5649,8 +5519,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, Py
return __pyx_r;
}
+static PyObject *__pyx_k117p;
+static PyObject *__pyx_k118p;
+
+static char __pyx_k117[] = "scale <= 0";
+static char __pyx_k118[] = "scale <= 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_logistic[] = "Logistic distribution.\n\n logistic(loc=0.0, scale=1.0, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_logistic[] = "\n logistic(loc=0.0, scale=1.0, size=None)\n\n Logistic distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_loc = 0;
PyObject *__pyx_v_scale = 0;
@@ -5666,9 +5542,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self,
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"loc","scale","size",0};
- __pyx_v_loc = __pyx_d39;
- __pyx_v_scale = __pyx_d40;
- __pyx_v_size = __pyx_d41;
+ __pyx_v_loc = __pyx_k40;
+ __pyx_v_scale = __pyx_k41;
+ __pyx_v_size = __pyx_k42;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_loc);
@@ -5677,33 +5553,33 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self,
__pyx_v_oloc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1116 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1837 */
__pyx_v_floc = PyFloat_AsDouble(__pyx_v_loc);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1117 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1838 */
__pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1118 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1839 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1119 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1840 */
__pyx_1 = (__pyx_v_fscale <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1841; goto __pyx_L1;}
+ Py_INCREF(__pyx_k117p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k117p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1841; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1841; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1121 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1121; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1842 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1842; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -5711,62 +5587,62 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self,
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1123 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1844 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1124 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; goto __pyx_L1;}
- if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1845 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; goto __pyx_L1;}
+ if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_v_oloc));
__pyx_v_oloc = ((PyArrayObject *)__pyx_3);
__pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1125 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; goto __pyx_L1;}
- if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1846 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; goto __pyx_L1;}
+ if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_v_oscale));
__pyx_v_oscale = ((PyArrayObject *)__pyx_2);
__pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1126 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1847 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;}
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k23p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1848; goto __pyx_L1;}
+ Py_INCREF(__pyx_k118p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k118p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1848; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1848; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1128 */
- __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1849 */
+ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1849; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -5790,8 +5666,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self,
return __pyx_r;
}
+static PyObject *__pyx_k119p;
+static PyObject *__pyx_k120p;
+
+static char __pyx_k119[] = "sigma <= 0";
+static char __pyx_k120[] = "sigma <= 0.0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_lognormal[] = "Log-normal distribution.\n\n Note that the mean parameter is not the mean of this distribution, but\n the underlying normal distribution.\n\n lognormal(mean, sigma) <=> exp(normal(mean, sigma))\n\n lognormal(mean=0.0, sigma=1.0, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_lognormal[] = "\n lognormal(mean=0.0, sigma=1.0, size=None)\n\n Log-normal distribution.\n\n Draw samples from a log-normal distribution with specified mean, standard\n deviation, and shape. Note that the mean and standard deviation are not the\n values for the distribution itself, but of the underlying normal\n distribution it is derived from.\n\n\n Parameters\n ----------\n mean : float\n Mean value of the underlying normal distribution\n sigma : float, >0.\n Standard deviation of the underlying normal distribution\n size : tuple of ints\n Output shape. If the given shape is, e.g., ``(m, n, k)``, then\n ``m * n * k`` samples are drawn.\n\n See Also\n --------\n scipy.stats.lognorm : probability density function, distribution,\n cumulative density function, etc.\n\n Notes\n -----\n A variable `x` has a log-normal distribution if `log(x)` is normally\n distributed.\n\n The probability density function for the log-normal distribution is\n\n .. math:: p(x) = \\frac{1}{\\sigma x \\sqrt{2\\pi}}\n e^{(-\\frac{(ln(x)-\\mu)^2}{2\\sigma^2})}\n\n where :math:`\\mu` is the mean and :math:`\\sigma` is the standard deviation\n of the normally distributed logarithm of the variable.\n\n A log normal distribution results if a random variable is the *product* of\n a large number of independent, identically-distributed variables in the\n same way that a normal distribution results if the variable is the *sum*\n of a large number of independent, identically-distributed variables\n (see the last example). It is one of the so-called \"fat-tailed\"\n distributions.\n\n The log-normal distribution is commonly used to model the lifespan of units\n with fatigue-stress failure modes. Since this includes\n most mechanical systems, the lognormal distribution has widespread\n application.\n\n It is also commonly used to model oil field sizes, species abundance, and\n latent periods of infectious diseases.\n\n References\n ----------\n .. [1] Eckhard Limpert, Werner A. Stahel, and Markus Abbt, \"Log-normal\n Distributions across the Sciences: Keys and Clues\", May 2001\n Vol. 51 No. 5 BioScience\n http://stat.ethz.ch/~stahel/lognormal/bioscience.pdf\n .. [2] Reiss, R.D., Thomas, M.(2001), Statistical Analysis of Extreme\n Values, Birkhauser Verlag, Basel, pp 31-32.\n .. [3] Wikipedia, \"Lognormal distribution\",\n http://en.wikipedia.org/wiki/Lognormal_distribution\n\n Examples\n --------\n Draw samples from the distribution:\n\n >>> mu, sigma = 3., 1. # mean and standard deviation\n >>> s = np.random.lognormal(mu, sigma, 1000)\n\n Display the histogram of the samples, along with\n the probability density function:\n\n >>> import matplotlib.pyplot as plt\n >>> count, bins, ignored = plt.hist(s, 100, normed=True, align=\'center\')\n\n >>> x = np.linspace(min(bins), max(bins), 10000)\n >>> pdf = np.exp(-(np.log(x) - mu)**2 / (2 * sigma**2)) ... / (x * sigma * np.sqrt(2 * np.pi))\n\n >>> plt.plot(x, pdf, linewidth=2, color=\'r\')\n >>> plt.axis(\'tight\')\n >>> plt.show()\n\n Demonstrate that taking the products of random samples from a uniform\n distribution can be fit well by a log-normal pdf.\n\n >>> # Generate a thousand samples: each is the product of 100 random\n >>> # values, drawn from a normal distribution.\n >>> b = []\n >>> for i in range(1000):\n ... a = 10. + np.random.random(100)\n ... b.append(np.product(a))\n\n >>> b = np.array(b) / np.min(b) # scale values to be positive\n\n >>> count, bins, ignored = plt.hist(b, 100, normed=True, align=\'center\')\n\n >>> sigma = np.std(np.log(b))\n >>> mu = np.mean(np.log(b))\n\n >>> x = np.linspace(min(bins), max(bins), 10000)\n >>> pdf = np.exp(-(np.log(x) - mu)**2 / (2 * sigma**2)) ... / (x * sigma * np.sqrt(2 * np.pi))\n\n >>> plt.plot(x, pdf, color=\'r\', linewidth=2)\n >>> plt.show()\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_mean = 0;
PyObject *__pyx_v_sigma = 0;
@@ -5807,9 +5689,9 @@ static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self,
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"mean","sigma","size",0};
- __pyx_v_mean = __pyx_d42;
- __pyx_v_sigma = __pyx_d43;
- __pyx_v_size = __pyx_d44;
+ __pyx_v_mean = __pyx_k43;
+ __pyx_v_sigma = __pyx_k44;
+ __pyx_v_size = __pyx_k45;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_mean, &__pyx_v_sigma, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_mean);
@@ -5818,33 +5700,33 @@ static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self,
__pyx_v_omean = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_osigma = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1143 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1966 */
__pyx_v_fmean = PyFloat_AsDouble(__pyx_v_mean);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1144 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1967 */
__pyx_v_fsigma = PyFloat_AsDouble(__pyx_v_sigma);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1146 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1969 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1147 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1970 */
__pyx_1 = (__pyx_v_fsigma <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; goto __pyx_L1;}
- Py_INCREF(__pyx_k38p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k38p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; goto __pyx_L1;}
+ Py_INCREF(__pyx_k119p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k119p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1149 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_fmean,__pyx_v_fsigma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1149; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1972 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_fmean,__pyx_v_fsigma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -5852,62 +5734,62 @@ static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self,
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1151 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1974 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1153 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_mean,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; goto __pyx_L1;}
- if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1976 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_mean,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1976; goto __pyx_L1;}
+ if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1976; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_v_omean));
__pyx_v_omean = ((PyArrayObject *)__pyx_3);
__pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1154 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_sigma,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; goto __pyx_L1;}
- if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1977 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_sigma,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; goto __pyx_L1;}
+ if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_v_osigma));
__pyx_v_osigma = ((PyArrayObject *)__pyx_2);
__pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1155 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1978 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;}
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_osigma));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_osigma));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1156; goto __pyx_L1;}
- Py_INCREF(__pyx_k39p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k39p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1156; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; goto __pyx_L1;}
+ Py_INCREF(__pyx_k120p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k120p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1156; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1157 */
- __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_omean,__pyx_v_osigma); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1157; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1980 */
+ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_omean,__pyx_v_osigma); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1980; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -5931,8 +5813,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self,
return __pyx_r;
}
+static PyObject *__pyx_k121p;
+static PyObject *__pyx_k122p;
+
+static char __pyx_k121[] = "scale <= 0";
+static char __pyx_k122[] = "scale <= 0.0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_rayleigh[] = "Rayleigh distribution.\n\n rayleigh(scale=1.0, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_rayleigh[] = "\n rayleigh(scale=1.0, size=None)\n\n Rayleigh distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_scale = 0;
PyObject *__pyx_v_size = 0;
@@ -5945,38 +5833,38 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self,
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"scale","size",0};
- __pyx_v_scale = __pyx_d45;
- __pyx_v_size = __pyx_d46;
+ __pyx_v_scale = __pyx_k46;
+ __pyx_v_size = __pyx_k47;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OO", __pyx_argnames, &__pyx_v_scale, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_scale);
Py_INCREF(__pyx_v_size);
__pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1167 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1992 */
__pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1169 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1994 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1170 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1995 */
__pyx_1 = (__pyx_v_fscale <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; goto __pyx_L1;}
+ Py_INCREF(__pyx_k121p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k121p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1172 */
- __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1997 */
+ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -5984,55 +5872,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self,
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1174 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1999 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1176 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2001 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2001; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oscale));
__pyx_v_oscale = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1177 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2002 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1178; goto __pyx_L1;}
- Py_INCREF(__pyx_k40p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k40p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1178; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; goto __pyx_L1;}
+ Py_INCREF(__pyx_k122p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k122p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1178; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1179 */
- __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2004 */
+ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2004; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -6054,8 +5942,18 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self,
return __pyx_r;
}
+static PyObject *__pyx_k123p;
+static PyObject *__pyx_k124p;
+static PyObject *__pyx_k125p;
+static PyObject *__pyx_k126p;
+
+static char __pyx_k123[] = "mean <= 0";
+static char __pyx_k124[] = "scale <= 0";
+static char __pyx_k125[] = "mean <= 0.0";
+static char __pyx_k126[] = "scale <= 0.0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_wald[] = "Wald (inverse Gaussian) distribution.\n\n wald(mean, scale, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_wald[] = "\n wald(mean, scale, size=None)\n\n Wald (inverse Gaussian) distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_mean = 0;
PyObject *__pyx_v_scale = 0;
@@ -6071,7 +5969,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyOb
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"mean","scale","size",0};
- __pyx_v_size = __pyx_d47;
+ __pyx_v_size = __pyx_k48;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_mean, &__pyx_v_scale, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_mean);
@@ -6080,48 +5978,48 @@ static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyOb
__pyx_v_omean = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1189 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2016 */
__pyx_v_fmean = PyFloat_AsDouble(__pyx_v_mean);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1190 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2017 */
__pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1191 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2018 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1192 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2019 */
__pyx_1 = (__pyx_v_fmean <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; goto __pyx_L1;}
- Py_INCREF(__pyx_k41p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k41p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2020; goto __pyx_L1;}
+ Py_INCREF(__pyx_k123p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k123p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2020; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2020; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1194 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2021 */
__pyx_1 = (__pyx_v_fscale <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
- Py_INCREF(__pyx_k23p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2022; goto __pyx_L1;}
+ Py_INCREF(__pyx_k124p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k124p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2022; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2022; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1196 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_fmean,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2023 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_fmean,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2023; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -6129,96 +6027,96 @@ static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyOb
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1198 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2025 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1199 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_mean,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
- if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2026 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_mean,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2026; goto __pyx_L1;}
+ if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2026; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_v_omean));
__pyx_v_omean = ((PyArrayObject *)__pyx_3);
__pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1200 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1200; goto __pyx_L1;}
- if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1200; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2027 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2027; goto __pyx_L1;}
+ if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2027; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_v_oscale));
__pyx_v_oscale = ((PyArrayObject *)__pyx_2);
__pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1201 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2028 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;}
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_omean));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_omean));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; goto __pyx_L1;}
- Py_INCREF(__pyx_k42p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k42p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; goto __pyx_L1;}
+ Py_INCREF(__pyx_k125p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k125p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; goto __pyx_L1;}
goto __pyx_L5;
}
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;}
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2030; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2030; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2030; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2030; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;}
+ __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2030; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2030; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_oscale));
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2030; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2030; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
__pyx_4 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2030; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2030; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; goto __pyx_L1;}
- Py_INCREF(__pyx_k40p);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k40p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2031; goto __pyx_L1;}
+ Py_INCREF(__pyx_k126p);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k126p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2031; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2031; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1205 */
- __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_omean,__pyx_v_oscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2032 */
+ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_omean,__pyx_v_oscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -6242,8 +6140,25 @@ static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyOb
return __pyx_r;
}
+static PyObject *__pyx_n_greater;
+static PyObject *__pyx_n_equal;
+
+static PyObject *__pyx_k127p;
+static PyObject *__pyx_k128p;
+static PyObject *__pyx_k129p;
+static PyObject *__pyx_k130p;
+static PyObject *__pyx_k131p;
+static PyObject *__pyx_k132p;
+
+static char __pyx_k127[] = "left > mode";
+static char __pyx_k128[] = "mode > right";
+static char __pyx_k129[] = "left == right";
+static char __pyx_k130[] = "left > mode";
+static char __pyx_k131[] = "mode > right";
+static char __pyx_k132[] = "left == right";
+
static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_triangular[] = "Triangular distribution starting at left, peaking at mode, and\n ending at right (left <= mode <= right).\n\n triangular(left, mode, right, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_triangular[] = "\n triangular(left, mode, right, size=None)\n\n Triangular distribution starting at left, peaking at mode, and\n ending at right (left <= mode <= right).\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_left = 0;
PyObject *__pyx_v_mode = 0;
@@ -6262,7 +6177,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"left","mode","right","size",0};
- __pyx_v_size = __pyx_d48;
+ __pyx_v_size = __pyx_k49;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO|O", __pyx_argnames, &__pyx_v_left, &__pyx_v_mode, &__pyx_v_right, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_left);
@@ -6273,66 +6188,66 @@ static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self
__pyx_v_omode = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_oright = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1218 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2047 */
__pyx_v_fleft = PyFloat_AsDouble(__pyx_v_left);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1219 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2048 */
__pyx_v_fright = PyFloat_AsDouble(__pyx_v_right);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1220 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2049 */
__pyx_v_fmode = PyFloat_AsDouble(__pyx_v_mode);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1221 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2050 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1222 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2051 */
__pyx_1 = (__pyx_v_fleft > __pyx_v_fmode);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; goto __pyx_L1;}
- Py_INCREF(__pyx_k43p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k43p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; goto __pyx_L1;}
+ Py_INCREF(__pyx_k127p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k127p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1224 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2053 */
__pyx_1 = (__pyx_v_fmode > __pyx_v_fright);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; goto __pyx_L1;}
- Py_INCREF(__pyx_k44p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k44p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; goto __pyx_L1;}
+ Py_INCREF(__pyx_k128p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k128p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1226 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2055 */
__pyx_1 = (__pyx_v_fleft == __pyx_v_fright);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1227; goto __pyx_L1;}
- Py_INCREF(__pyx_k45p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k45p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1227; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; goto __pyx_L1;}
+ Py_INCREF(__pyx_k129p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k129p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1227; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1228 */
- __pyx_2 = __pyx_f_6mtrand_cont3_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_fleft,__pyx_v_fmode,__pyx_v_fright); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2057 */
+ __pyx_2 = __pyx_f_6mtrand_cont3_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_fleft,__pyx_v_fmode,__pyx_v_fright); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -6340,140 +6255,140 @@ static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1231 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2060 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1232 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_left,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1232; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2061 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_left,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oleft));
__pyx_v_oleft = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1233 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_mode,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2062 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_mode,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_omode));
__pyx_v_omode = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1234 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_right,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2063 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_right,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oright));
__pyx_v_oright = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1236 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2065 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2065; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2065; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_greater); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2065; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_greater); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2065; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2065; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oleft));
PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_oleft));
Py_INCREF(((PyObject *)__pyx_v_omode));
PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_omode));
- __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2065; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2065; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
__pyx_5 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2065; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2065; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
if (__pyx_1) {
- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; goto __pyx_L1;}
- Py_INCREF(__pyx_k43p);
- PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k43p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; goto __pyx_L1;}
+ Py_INCREF(__pyx_k130p);
+ PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k130p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1238 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2067 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_greater); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;}
+ __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_greater); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_omode));
PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_omode));
Py_INCREF(((PyObject *)__pyx_v_oright));
PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)__pyx_v_oright));
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
__pyx_5 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
if (__pyx_1) {
- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; goto __pyx_L1;}
- Py_INCREF(__pyx_k44p);
- PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k44p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; goto __pyx_L1;}
+ Py_INCREF(__pyx_k131p);
+ PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k131p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; goto __pyx_L1;}
goto __pyx_L7;
}
__pyx_L7:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1240 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2069 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;}
+ __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oleft));
PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_oleft));
Py_INCREF(((PyObject *)__pyx_v_oright));
PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_oright));
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_5);
__pyx_5 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; goto __pyx_L1;}
- Py_INCREF(__pyx_k45p);
- PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k45p);
- __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; goto __pyx_L1;}
+ Py_INCREF(__pyx_k132p);
+ PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k132p);
+ __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
__Pyx_Raise(__pyx_4, 0, 0);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; goto __pyx_L1;}
goto __pyx_L8;
}
__pyx_L8:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1242 */
- __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_oleft,__pyx_v_omode,__pyx_v_oright); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1242; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2071 */
+ __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_oleft,__pyx_v_omode,__pyx_v_oright); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -6499,8 +6414,22 @@ static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self
return __pyx_r;
}
+static PyObject *__pyx_k133p;
+static PyObject *__pyx_k134p;
+static PyObject *__pyx_k135p;
+static PyObject *__pyx_k136p;
+static PyObject *__pyx_k137p;
+static PyObject *__pyx_k138p;
+
+static char __pyx_k133[] = "n <= 0";
+static char __pyx_k134[] = "p < 0";
+static char __pyx_k135[] = "p > 1";
+static char __pyx_k136[] = "n <= 0";
+static char __pyx_k137[] = "p < 0";
+static char __pyx_k138[] = "p > 1";
+
static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_binomial[] = "Binomial distribution of n trials and p probability of success.\n\n binomial(n, p, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_binomial[] = "\n binomial(n, p, size=None)\n\n Binomial distribution of n trials and p probability of success.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_n = 0;
PyObject *__pyx_v_p = 0;
@@ -6516,7 +6445,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self,
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"n","p","size",0};
- __pyx_v_size = __pyx_d49;
+ __pyx_v_size = __pyx_k50;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_n);
@@ -6525,60 +6454,60 @@ static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self,
__pyx_v_on = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_op = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1255 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2086 */
__pyx_v_fp = PyFloat_AsDouble(__pyx_v_p);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1256 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2087 */
__pyx_v_ln = PyInt_AsLong(__pyx_v_n);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1257 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2088 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1258 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2089 */
__pyx_1 = (__pyx_v_ln <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1259; goto __pyx_L1;}
- Py_INCREF(__pyx_k48p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k48p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1259; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2090; goto __pyx_L1;}
+ Py_INCREF(__pyx_k133p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k133p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2090; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1259; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2090; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1260 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2091 */
__pyx_1 = (__pyx_v_fp < 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1261; goto __pyx_L1;}
- Py_INCREF(__pyx_k49p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k49p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1261; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; goto __pyx_L1;}
+ Py_INCREF(__pyx_k134p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k134p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1261; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_1 = (__pyx_v_fp > 1);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; goto __pyx_L1;}
- Py_INCREF(__pyx_k50p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k50p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; goto __pyx_L1;}
+ Py_INCREF(__pyx_k135p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k135p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1264 */
- __pyx_2 = __pyx_f_6mtrand_discnp_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_ln,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2095 */
+ __pyx_2 = __pyx_f_6mtrand_discnp_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_ln,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -6586,136 +6515,136 @@ static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self,
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1266 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2097 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1268 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_n,NPY_LONG,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2099 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_n,NPY_LONG,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_on));
__pyx_v_on = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1269 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1269; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2100 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2100; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_op));
__pyx_v_op = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1270 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2101 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;}
+ __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; goto __pyx_L1;}
Py_INCREF(__pyx_v_n);
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_n);
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1271; goto __pyx_L1;}
- Py_INCREF(__pyx_k48p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k48p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1271; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2102; goto __pyx_L1;}
+ Py_INCREF(__pyx_k136p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k136p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2102; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1271; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2102; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1272 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2103 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;}
+ __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; goto __pyx_L1;}
Py_INCREF(__pyx_v_p);
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_p);
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
__pyx_4 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; goto __pyx_L1;}
- Py_INCREF(__pyx_k49p);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k49p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2104; goto __pyx_L1;}
+ Py_INCREF(__pyx_k137p);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k137p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2104; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2104; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1274 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2105 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_greater); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_greater); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
+ __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; goto __pyx_L1;}
Py_INCREF(__pyx_v_p);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_p);
PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; goto __pyx_L1;}
- Py_INCREF(__pyx_k50p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k50p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; goto __pyx_L1;}
+ Py_INCREF(__pyx_k138p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k138p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; goto __pyx_L1;}
goto __pyx_L7;
}
__pyx_L7:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1276 */
- __pyx_5 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_on,__pyx_v_op); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1276; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2107 */
+ __pyx_5 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_on,__pyx_v_op); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; goto __pyx_L1;}
__pyx_r = __pyx_5;
__pyx_5 = 0;
goto __pyx_L0;
@@ -6739,8 +6668,22 @@ static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self,
return __pyx_r;
}
+static PyObject *__pyx_k139p;
+static PyObject *__pyx_k140p;
+static PyObject *__pyx_k141p;
+static PyObject *__pyx_k142p;
+static PyObject *__pyx_k143p;
+static PyObject *__pyx_k144p;
+
+static char __pyx_k139[] = "n <= 0";
+static char __pyx_k140[] = "p < 0";
+static char __pyx_k141[] = "p > 1";
+static char __pyx_k142[] = "n <= 0";
+static char __pyx_k143[] = "p < 0";
+static char __pyx_k144[] = "p > 1";
+
static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_negative_binomial[] = "Negative Binomial distribution.\n\n negative_binomial(n, p, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_negative_binomial[] = "\n negative_binomial(n, p, size=None)\n\n Negative Binomial distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_n = 0;
PyObject *__pyx_v_p = 0;
@@ -6756,7 +6699,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"n","p","size",0};
- __pyx_v_size = __pyx_d50;
+ __pyx_v_size = __pyx_k51;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_n);
@@ -6765,60 +6708,60 @@ static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx
__pyx_v_on = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_op = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1288 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2121 */
__pyx_v_fp = PyFloat_AsDouble(__pyx_v_p);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1289 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2122 */
__pyx_v_ln = PyInt_AsLong(__pyx_v_n);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1290 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2123 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1291 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2124 */
__pyx_1 = (__pyx_v_ln <= 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; goto __pyx_L1;}
- Py_INCREF(__pyx_k48p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k48p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2125; goto __pyx_L1;}
+ Py_INCREF(__pyx_k139p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k139p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2125; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2125; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1293 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2126 */
__pyx_1 = (__pyx_v_fp < 0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; goto __pyx_L1;}
- Py_INCREF(__pyx_k49p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k49p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; goto __pyx_L1;}
+ Py_INCREF(__pyx_k140p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k140p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_1 = (__pyx_v_fp > 1);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; goto __pyx_L1;}
- Py_INCREF(__pyx_k50p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k50p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; goto __pyx_L1;}
+ Py_INCREF(__pyx_k141p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k141p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1297 */
- __pyx_2 = __pyx_f_6mtrand_discnp_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_ln,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1297; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2130 */
+ __pyx_2 = __pyx_f_6mtrand_discnp_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_ln,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -6826,136 +6769,136 @@ static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1300 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2133 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1302 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_n,NPY_LONG,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1302; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2135 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_n,NPY_LONG,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2135; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_on));
__pyx_v_on = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1303 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1303; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2136 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2136; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_op));
__pyx_v_op = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1304 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2137 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;}
+ __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; goto __pyx_L1;}
Py_INCREF(__pyx_v_n);
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_n);
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; goto __pyx_L1;}
- Py_INCREF(__pyx_k48p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k48p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; goto __pyx_L1;}
+ Py_INCREF(__pyx_k142p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k142p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1306 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2139 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;}
+ __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; goto __pyx_L1;}
Py_INCREF(__pyx_v_p);
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_p);
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
__pyx_4 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; goto __pyx_L1;}
- Py_INCREF(__pyx_k49p);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k49p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; goto __pyx_L1;}
+ Py_INCREF(__pyx_k143p);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k143p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1308 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2141 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_greater); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;}
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_greater); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;}
+ __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; goto __pyx_L1;}
Py_INCREF(__pyx_v_p);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_p);
PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; goto __pyx_L1;}
- Py_INCREF(__pyx_k50p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k50p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; goto __pyx_L1;}
+ Py_INCREF(__pyx_k144p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k144p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; goto __pyx_L1;}
goto __pyx_L7;
}
__pyx_L7:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1310 */
- __pyx_5 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_on,__pyx_v_op); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2143 */
+ __pyx_5 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_on,__pyx_v_op); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; goto __pyx_L1;}
__pyx_r = __pyx_5;
__pyx_5 = 0;
goto __pyx_L0;
@@ -6979,8 +6922,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx
return __pyx_r;
}
+static PyObject *__pyx_k145p;
+static PyObject *__pyx_k146p;
+
+static char __pyx_k145[] = "lam < 0";
+static char __pyx_k146[] = "lam < 0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_poisson[] = "Poisson distribution.\n\n poisson(lam=1.0, size=None) -> random values\n ";
+static char __pyx_doc_6mtrand_11RandomState_poisson[] = "\n poisson(lam=1.0, size=None)\n\n Poisson distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_lam = 0;
PyObject *__pyx_v_size = 0;
@@ -6993,41 +6942,41 @@ static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, P
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"lam","size",0};
- __pyx_v_lam = __pyx_d51;
- __pyx_v_size = __pyx_d52;
+ __pyx_v_lam = __pyx_k52;
+ __pyx_v_size = __pyx_k53;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OO", __pyx_argnames, &__pyx_v_lam, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_lam);
Py_INCREF(__pyx_v_size);
__pyx_v_olam = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1320 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2155 */
__pyx_v_flam = PyFloat_AsDouble(__pyx_v_lam);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1321 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2156 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1322 */
- __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; goto __pyx_L1;}
- if (PyObject_Cmp(__pyx_v_lam, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2157 */
+ __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2157; goto __pyx_L1;}
+ if (PyObject_Cmp(__pyx_v_lam, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2157; goto __pyx_L1;}
__pyx_1 = __pyx_1 < 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; goto __pyx_L1;}
- Py_INCREF(__pyx_k51p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k51p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; goto __pyx_L1;}
+ Py_INCREF(__pyx_k145p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k145p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1324 */
- __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_flam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2159 */
+ __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_flam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2159; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -7035,55 +6984,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, P
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1326 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2161 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1328 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_lam,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1328; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2163 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_lam,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2163; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_olam));
__pyx_v_olam = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1329 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2164 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;}
+ __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_olam));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_olam));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1330; goto __pyx_L1;}
- Py_INCREF(__pyx_k51p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k51p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1330; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; goto __pyx_L1;}
+ Py_INCREF(__pyx_k146p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k146p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1330; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1331 */
- __pyx_4 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_olam); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2166 */
+ __pyx_4 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_olam); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2166; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -7105,8 +7054,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, P
return __pyx_r;
}
+static PyObject *__pyx_k147p;
+static PyObject *__pyx_k148p;
+
+static char __pyx_k147[] = "a <= 1.0";
+static char __pyx_k148[] = "a <= 1.0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_zipf[] = "Zipf distribution.\n\n zipf(a, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_zipf[] = "\n zipf(a, size=None)\n\n Draw samples from a Zipf distribution.\n\n Samples are drawn from a Zipf distribution with specified parameter (a),\n where a > 1.\n\n The zipf distribution (also known as the zeta\n distribution) is a continuous probability distribution that satisfies\n Zipf\'s law, where the frequency of an item is inversely proportional to\n its rank in a frequency table.\n\n Parameters\n ----------\n a : float\n parameter, > 1.\n size : {tuple, int}\n Output shape. If the given shape is, e.g., ``(m, n, k)``, then\n ``m * n * k`` samples are drawn.\n\n Returns\n -------\n samples : {ndarray, scalar}\n The returned samples are greater than or equal to one.\n\n See Also\n --------\n scipy.stats.distributions.zipf : probability density function,\n distribution or cumulative density function, etc.\n\n Notes\n -----\n The probability density for the Zipf distribution is\n\n .. math:: p(x) = \\frac{x^{-a}}{\\zeta(a)},\n\n where :math:`\\zeta` is the Riemann Zeta function.\n\n Named after the American linguist George Kingsley Zipf, who noted that\n the frequency of any word in a sample of a language is inversely\n proportional to its rank in the frequency table.\n\n\n References\n ----------\n .. [1] Weisstein, Eric W. \"Zipf Distribution.\" From MathWorld--A Wolfram\n Web Resource. http://mathworld.wolfram.com/ZipfDistribution.html\n .. [2] Wikipedia, \"Zeta distribution\",\n http://en.wikipedia.org/wiki/Zeta_distribution\n .. [3] Wikipedia, \"Zipf\'s Law\",\n http://en.wikipedia.org/wiki/Zipf%27s_law\n .. [4] Zipf, George Kingsley (1932): Selected Studies of the Principle\n of Relative Frequency in Language. Cambridge (Mass.).\n\n Examples\n --------\n Draw samples from the distribution:\n\n >>> a = 2. # parameter\n >>> s = np.random.zipf(a, 1000)\n\n Display the histogram of the samples, along with\n the probability density function:\n\n >>> import matplotlib.pyplot as plt\n >>> import scipy.special as sps\n Truncate s values at 50 so plot is interesting\n >>> count, bins, ignored = plt.hist(s[s<50], 50, normed=True)\n >>> x = arange(1., 50.)\n >>> y = x**(-a)/sps.zetac(a)\n >>> plt.plot(x, y/max(y), linewidth=2, color=\'r\')\n >>> plt.show()\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_a = 0;
PyObject *__pyx_v_size = 0;
@@ -7119,37 +7074,37 @@ static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyOb
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"a","size",0};
- __pyx_v_size = __pyx_d53;
+ __pyx_v_size = __pyx_k54;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_a);
Py_INCREF(__pyx_v_size);
__pyx_v_oa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1341 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2247 */
__pyx_v_fa = PyFloat_AsDouble(__pyx_v_a);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1342 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2248 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1343 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2249 */
__pyx_1 = (__pyx_v_fa <= 1.0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; goto __pyx_L1;}
- Py_INCREF(__pyx_k52p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k52p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2250; goto __pyx_L1;}
+ Py_INCREF(__pyx_k147p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k147p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2250; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2250; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1345 */
- __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2251 */
+ __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -7157,55 +7112,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyOb
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1347 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2253 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1349 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1349; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2255 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_oa));
__pyx_v_oa = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1350 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2256 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_oa));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_oa));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; goto __pyx_L1;}
- Py_INCREF(__pyx_k52p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k52p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2257; goto __pyx_L1;}
+ Py_INCREF(__pyx_k148p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k148p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2257; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2257; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1352 */
- __pyx_4 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1352; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2258 */
+ __pyx_4 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2258; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -7227,8 +7182,18 @@ static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyOb
return __pyx_r;
}
+static PyObject *__pyx_k149p;
+static PyObject *__pyx_k150p;
+static PyObject *__pyx_k151p;
+static PyObject *__pyx_k152p;
+
+static char __pyx_k149[] = "p < 0.0";
+static char __pyx_k150[] = "p > 1.0";
+static char __pyx_k151[] = "p < 0.0";
+static char __pyx_k152[] = "p > 1.0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_geometric[] = "Geometric distribution with p being the probability of \"success\" on\n an individual trial.\n\n geometric(p, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_geometric[] = "\n geometric(p, size=None)\n\n Draw samples from the geometric distribution.\n\n Bernoulli trials are experiments with one of two outcomes:\n success or failure (an example of such an experiment is flipping\n a coin). The geometric distribution models the number of trials\n that must be run in order to achieve success. It is therefore\n supported on the positive integers, ``k = 1, 2, ...``.\n\n The probability mass function of the geometric distribution is\n\n .. math:: f(k) = (1 - p)^{k - 1} p\n\n where `p` is the probability of success of an individual trial.\n\n Parameters\n ----------\n p : float\n The probability of success of an individual trial.\n size : tuple of ints\n Number of values to draw from the distribution. The output\n is shaped according to `size`.\n\n Returns\n -------\n out : ndarray\n Samples from the geometric distribution, shaped according to\n `size`.\n\n Examples\n --------\n Draw ten thousand values from the geometric distribution,\n with the probability of an individual success equal to 0.35:\n\n >>> z = np.random.geometric(p=0.35, size=10000)\n\n How many trials succeeded after a single run?\n\n >>> (z == 1).sum() / 10000.\n 0.34889999999999999 #random\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_p = 0;
PyObject *__pyx_v_size = 0;
@@ -7241,52 +7206,52 @@ static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self,
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"p","size",0};
- __pyx_v_size = __pyx_d54;
+ __pyx_v_size = __pyx_k55;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_p, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_p);
Py_INCREF(__pyx_v_size);
__pyx_v_op = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1363 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2308 */
__pyx_v_fp = PyFloat_AsDouble(__pyx_v_p);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1364 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2309 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1365 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2310 */
__pyx_1 = (__pyx_v_fp < 0.0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; goto __pyx_L1;}
- Py_INCREF(__pyx_k53p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k53p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2311; goto __pyx_L1;}
+ Py_INCREF(__pyx_k149p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k149p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2311; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2311; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1367 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2312 */
__pyx_1 = (__pyx_v_fp > 1.0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; goto __pyx_L1;}
- Py_INCREF(__pyx_k54p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k54p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; goto __pyx_L1;}
+ Py_INCREF(__pyx_k150p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k150p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1369 */
- __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2314 */
+ __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -7294,92 +7259,92 @@ static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self,
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1371 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2316 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1374 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1374; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2319 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2319; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_op));
__pyx_v_op = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1375 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2320 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_op));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_op));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; goto __pyx_L1;}
- Py_INCREF(__pyx_k53p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k53p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2321; goto __pyx_L1;}
+ Py_INCREF(__pyx_k151p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k151p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2321; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2321; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1377 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2322 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_greater); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_greater); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;}
- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;}
+ __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_op));
PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_op));
PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
__pyx_4 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
if (__pyx_1) {
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; goto __pyx_L1;}
- Py_INCREF(__pyx_k54p);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k54p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2323; goto __pyx_L1;}
+ Py_INCREF(__pyx_k152p);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k152p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2323; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2323; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1379 */
- __pyx_3 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_op); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1379; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2324 */
+ __pyx_3 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_op); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2324; goto __pyx_L1;}
__pyx_r = __pyx_3;
__pyx_3 = 0;
goto __pyx_L0;
@@ -7401,8 +7366,28 @@ static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self,
return __pyx_r;
}
+static PyObject *__pyx_n_add;
+
+static PyObject *__pyx_k153p;
+static PyObject *__pyx_k154p;
+static PyObject *__pyx_k155p;
+static PyObject *__pyx_k156p;
+static PyObject *__pyx_k157p;
+static PyObject *__pyx_k158p;
+static PyObject *__pyx_k159p;
+static PyObject *__pyx_k160p;
+
+static char __pyx_k153[] = "ngood < 1";
+static char __pyx_k154[] = "nbad < 1";
+static char __pyx_k155[] = "nsample < 1";
+static char __pyx_k156[] = "ngood + nbad < nsample";
+static char __pyx_k157[] = "ngood < 1";
+static char __pyx_k158[] = "nbad < 1";
+static char __pyx_k159[] = "nsample < 1";
+static char __pyx_k160[] = "ngood + nbad < nsample";
+
static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_hypergeometric[] = "Hypergeometric distribution.\n\n Consider an urn with ngood \"good\" balls and nbad \"bad\" balls. If one\n were to draw nsample balls from the urn without replacement, then\n the hypergeometric distribution describes the distribution of \"good\"\n balls in the sample.\n\n hypergeometric(ngood, nbad, nsample, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_hypergeometric[] = "\n hypergeometric(ngood, nbad, nsample, size=None)\n\n Hypergeometric distribution.\n\n Consider an urn with ngood \"good\" balls and nbad \"bad\" balls. If one\n were to draw nsample balls from the urn without replacement, then\n the hypergeometric distribution describes the distribution of \"good\"\n balls in the sample.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_ngood = 0;
PyObject *__pyx_v_nbad = 0;
@@ -7422,7 +7407,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_
PyObject *__pyx_5 = 0;
PyObject *__pyx_6 = 0;
static char *__pyx_argnames[] = {"ngood","nbad","nsample","size",0};
- __pyx_v_size = __pyx_d55;
+ __pyx_v_size = __pyx_k56;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO|O", __pyx_argnames, &__pyx_v_ngood, &__pyx_v_nbad, &__pyx_v_nsample, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_ngood);
@@ -7433,93 +7418,93 @@ static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_
__pyx_v_onbad = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
__pyx_v_onsample = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1394 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2341 */
__pyx_v_lngood = PyInt_AsLong(__pyx_v_ngood);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1395 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2342 */
__pyx_v_lnbad = PyInt_AsLong(__pyx_v_nbad);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1396 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2343 */
__pyx_v_lnsample = PyInt_AsLong(__pyx_v_nsample);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1397 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2344 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1398 */
- __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; goto __pyx_L1;}
- if (PyObject_Cmp(__pyx_v_ngood, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2345 */
+ __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; goto __pyx_L1;}
+ if (PyObject_Cmp(__pyx_v_ngood, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; goto __pyx_L1;}
__pyx_1 = __pyx_1 < 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1399; goto __pyx_L1;}
- Py_INCREF(__pyx_k55p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k55p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1399; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; goto __pyx_L1;}
+ Py_INCREF(__pyx_k153p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k153p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1399; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1400 */
- __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; goto __pyx_L1;}
- if (PyObject_Cmp(__pyx_v_nbad, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2347 */
+ __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; goto __pyx_L1;}
+ if (PyObject_Cmp(__pyx_v_nbad, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; goto __pyx_L1;}
__pyx_1 = __pyx_1 < 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; goto __pyx_L1;}
- Py_INCREF(__pyx_k56p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k56p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; goto __pyx_L1;}
+ Py_INCREF(__pyx_k154p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k154p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1402 */
- __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; goto __pyx_L1;}
- if (PyObject_Cmp(__pyx_v_nsample, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2349 */
+ __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2349; goto __pyx_L1;}
+ if (PyObject_Cmp(__pyx_v_nsample, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2349; goto __pyx_L1;}
__pyx_1 = __pyx_1 < 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; goto __pyx_L1;}
- Py_INCREF(__pyx_k57p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k57p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2350; goto __pyx_L1;}
+ Py_INCREF(__pyx_k155p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k155p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2350; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2350; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1404 */
- __pyx_2 = PyNumber_Add(__pyx_v_ngood, __pyx_v_nbad); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1404; goto __pyx_L1;}
- if (PyObject_Cmp(__pyx_2, __pyx_v_nsample, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1404; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2351 */
+ __pyx_2 = PyNumber_Add(__pyx_v_ngood, __pyx_v_nbad); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; goto __pyx_L1;}
+ if (PyObject_Cmp(__pyx_2, __pyx_v_nsample, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; goto __pyx_L1;}
__pyx_1 = __pyx_1 < 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1405; goto __pyx_L1;}
- Py_INCREF(__pyx_k58p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k58p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1405; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; goto __pyx_L1;}
+ Py_INCREF(__pyx_k156p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k156p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1405; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1406 */
- __pyx_3 = __pyx_f_6mtrand_discnmN_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_lngood,__pyx_v_lnbad,__pyx_v_lnsample); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1406; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2353 */
+ __pyx_3 = __pyx_f_6mtrand_discnmN_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_lngood,__pyx_v_lnbad,__pyx_v_lnsample); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2353; goto __pyx_L1;}
__pyx_r = __pyx_3;
__pyx_3 = 0;
goto __pyx_L0;
@@ -7527,190 +7512,190 @@ static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1410 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2357 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1412 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_ngood,NPY_LONG,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1412; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2359 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_ngood,NPY_LONG,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2359; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_ongood));
__pyx_v_ongood = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1413 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_nbad,NPY_LONG,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1413; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2360 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_nbad,NPY_LONG,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2360; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_onbad));
__pyx_v_onbad = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1414 */
- __pyx_2 = PyArray_FROM_OTF(__pyx_v_nsample,NPY_LONG,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2361 */
+ __pyx_2 = PyArray_FROM_OTF(__pyx_v_nsample,NPY_LONG,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2361; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_onsample));
__pyx_v_onsample = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1415 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2362 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;}
+ __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_ongood));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_ongood));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; goto __pyx_L1;}
- Py_INCREF(__pyx_k55p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k55p);
- __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2363; goto __pyx_L1;}
+ Py_INCREF(__pyx_k157p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k157p);
+ __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2363; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_2, 0, 0);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2363; goto __pyx_L1;}
goto __pyx_L7;
}
__pyx_L7:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1417 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2364 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2364; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2364; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2364; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2364; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;}
+ __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2364; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2364; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_onbad));
PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_onbad));
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2364; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2364; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
__pyx_4 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2364; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2364; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; goto __pyx_L1;}
- Py_INCREF(__pyx_k56p);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k56p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2365; goto __pyx_L1;}
+ Py_INCREF(__pyx_k158p);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k158p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2365; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2365; goto __pyx_L1;}
goto __pyx_L8;
}
__pyx_L8:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1419 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2366 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_less); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;}
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_less); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;}
+ __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_onsample));
PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_onsample));
PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; goto __pyx_L1;}
- Py_INCREF(__pyx_k57p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k57p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2367; goto __pyx_L1;}
+ Py_INCREF(__pyx_k159p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k159p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2367; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2367; goto __pyx_L1;}
goto __pyx_L9;
}
__pyx_L9:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1421 */
- __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_5, __pyx_n_any); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2368 */
+ __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_5, __pyx_n_any); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_add); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
+ __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_add); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_ongood));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_ongood));
Py_INCREF(((PyObject *)__pyx_v_onbad));
PyTuple_SET_ITEM(__pyx_5, 1, ((PyObject *)__pyx_v_onbad));
- __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
+ __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_6);
Py_INCREF(((PyObject *)__pyx_v_onsample));
PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_onsample));
__pyx_6 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
+ __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5);
__pyx_5 = 0;
- __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_6); __pyx_6 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; goto __pyx_L1;}
- Py_INCREF(__pyx_k58p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k58p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; goto __pyx_L1;}
+ Py_INCREF(__pyx_k160p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k160p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; goto __pyx_L1;}
goto __pyx_L10;
}
__pyx_L10:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1423 */
- __pyx_4 = __pyx_f_6mtrand_discnmN_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_ongood,__pyx_v_onbad,__pyx_v_onsample); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2370 */
+ __pyx_4 = __pyx_f_6mtrand_discnmN_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_ongood,__pyx_v_onbad,__pyx_v_onsample); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2370; goto __pyx_L1;}
__pyx_r = __pyx_4;
__pyx_4 = 0;
goto __pyx_L0;
@@ -7737,8 +7722,18 @@ static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_
return __pyx_r;
}
+static PyObject *__pyx_k161p;
+static PyObject *__pyx_k162p;
+static PyObject *__pyx_k163p;
+static PyObject *__pyx_k164p;
+
+static char __pyx_k161[] = "p < 0.0";
+static char __pyx_k162[] = "p > 1.0";
+static char __pyx_k163[] = "p < 0.0";
+static char __pyx_k164[] = "p > 1.0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_logseries[] = "Logarithmic series distribution.\n\n logseries(p, size=None)\n ";
+static char __pyx_doc_6mtrand_11RandomState_logseries[] = "\n logseries(p, size=None)\n\n Logarithmic series distribution.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_p = 0;
PyObject *__pyx_v_size = 0;
@@ -7751,52 +7746,52 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self,
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"p","size",0};
- __pyx_v_size = __pyx_d56;
+ __pyx_v_size = __pyx_k57;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_p, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_p);
Py_INCREF(__pyx_v_size);
__pyx_v_op = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1434 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2383 */
__pyx_v_fp = PyFloat_AsDouble(__pyx_v_p);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1435 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2384 */
__pyx_1 = (!PyErr_Occurred());
if (__pyx_1) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1436 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2385 */
__pyx_1 = (__pyx_v_fp < 0.0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; goto __pyx_L1;}
- Py_INCREF(__pyx_k53p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k53p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2386; goto __pyx_L1;}
+ Py_INCREF(__pyx_k161p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k161p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2386; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2386; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1438 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2387 */
__pyx_1 = (__pyx_v_fp > 1.0);
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; goto __pyx_L1;}
- Py_INCREF(__pyx_k54p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k54p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2388; goto __pyx_L1;}
+ Py_INCREF(__pyx_k162p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k162p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2388; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2388; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1440 */
- __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logseries,__pyx_v_size,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2389 */
+ __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logseries,__pyx_v_size,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2389; goto __pyx_L1;}
__pyx_r = __pyx_2;
__pyx_2 = 0;
goto __pyx_L0;
@@ -7804,92 +7799,92 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self,
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1442 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2391 */
PyErr_Clear();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1444 */
- __pyx_3 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; goto __pyx_L1;}
- Py_INCREF(__pyx_3);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2393 */
+ __pyx_3 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2393; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3)));
Py_DECREF(((PyObject *)__pyx_v_op));
__pyx_v_op = ((PyArrayObject *)__pyx_3);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1445 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2394 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2394; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2394; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;}
- __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2394; goto __pyx_L1;}
+ __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2394; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;}
- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;}
+ __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2394; goto __pyx_L1;}
+ __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2394; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_op));
PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_op));
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2394; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2394; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2394; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2394; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
if (__pyx_1) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1446; goto __pyx_L1;}
- Py_INCREF(__pyx_k53p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k53p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1446; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2395; goto __pyx_L1;}
+ Py_INCREF(__pyx_k163p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k163p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2395; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1446; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2395; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1447 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2396 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_greater); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_greater); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;}
- __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;}
+ __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; goto __pyx_L1;}
Py_INCREF(((PyObject *)__pyx_v_op));
PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_op));
PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);
__pyx_4 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
__pyx_4 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;}
+ __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
if (__pyx_1) {
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; goto __pyx_L1;}
- Py_INCREF(__pyx_k54p);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k54p);
- __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; goto __pyx_L1;}
+ Py_INCREF(__pyx_k164p);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k164p);
+ __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__Pyx_Raise(__pyx_5, 0, 0);
Py_DECREF(__pyx_5); __pyx_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; goto __pyx_L1;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1449 */
- __pyx_3 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logseries,__pyx_v_size,__pyx_v_op); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2398 */
+ __pyx_3 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logseries,__pyx_v_size,__pyx_v_op); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; goto __pyx_L1;}
__pyx_r = __pyx_3;
__pyx_3 = 0;
goto __pyx_L0;
@@ -7911,8 +7906,27 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self,
return __pyx_r;
}
+static PyObject *__pyx_n_array;
+static PyObject *__pyx_n_shape;
+static PyObject *__pyx_n_append;
+static PyObject *__pyx_n_multiply;
+static PyObject *__pyx_n_reduce;
+static PyObject *__pyx_n_svd;
+static PyObject *__pyx_n_dot;
+static PyObject *__pyx_n_sqrt;
+
+static PyObject *__pyx_k165p;
+static PyObject *__pyx_k166p;
+static PyObject *__pyx_k167p;
+static PyObject *__pyx_k168p;
+
+static char __pyx_k165[] = "mean must be 1 dimensional";
+static char __pyx_k166[] = "cov must be 2 dimensional and square";
+static char __pyx_k167[] = "mean and cov must have same length";
+static char __pyx_k168[] = "numpy.dual";
+
static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_multivariate_normal[] = "Return an array containing multivariate normally distributed random numbers\n with specified mean and covariance.\n\n multivariate_normal(mean, cov) -> random values\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\n\n mean must be a 1 dimensional array. cov must be a square two dimensional\n array with the same number of rows and columns as mean has elements.\n\n The first form returns a single 1-D array containing a multivariate\n normal.\n\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\n normal.\n ";
+static char __pyx_doc_6mtrand_11RandomState_multivariate_normal[] = "\n multivariate_normal(mean, cov[, size])\n\n Draw random samples from a multivariate normal distribution.\n\n The multivariate normal, multinormal or Gaussian distribution is a\n generalisation of the one-dimensional normal distribution to higher\n dimensions.\n\n Such a distribution is specified by its mean and covariance matrix,\n which are analogous to the mean (average or \"centre\") and variance\n (standard deviation squared or \"width\") of the one-dimensional normal\n distribution.\n\n Parameters\n ----------\n mean : (N,) ndarray\n Mean of the N-dimensional distribution.\n cov : (N,N) ndarray\n Covariance matrix of the distribution.\n size : tuple of ints, optional\n Given a shape of, for example, (m,n,k), m*n*k samples are\n generated, and packed in an m-by-n-by-k arrangement. Because each\n sample is N-dimensional, the output shape is (m,n,k,N). If no\n shape is specified, a single sample is returned.\n\n Returns\n -------\n out : ndarray\n The drawn samples, arranged according to `size`. If the\n shape given is (m,n,...), then the shape of `out` is is\n (m,n,...,N).\n\n In other words, each entry ``out[i,j,...,:]`` is an N-dimensional\n value drawn from the distribution.\n\n Notes\n -----\n The mean is a coordinate in N-dimensional space, which represents the\n location where samples are most likely to be generated. This is\n analogous to the peak of the bell curve for the one-dimensional or\n univariate normal distribution.\n\n Covariance indicates the level to which two variables vary together.\n From the multivariate normal distribution, we draw N-dimensional\n samples, :math:`X = [x_1, x_2, ... x_N]`. The covariance matrix\n element :math:`C_{ij}` is the covariance of :math:`x_i` and :math:`x_j`.\n The element :math:`C_{ii}` is the variance of :math:`x_i` (i.e. its\n \"spread\").\n\n Instead of specifying the full covariance matrix, popular\n approximations include:\n\n - Spherical covariance (`cov` is a multiple of the identity matrix)\n - Diagonal covariance (`cov` has non-negative elements, and only on\n the diagonal)\n\n This geometrical property can be seen in two dimensions by plotting\n generated data-points:\n\n >>> mean = [0,0]\n >>> cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or y-axis\n\n >>> import matplotlib.pyplot as plt\n >>> x,y = np.random.multivariate_normal(mean,cov,5000).T\n >>> plt.plot(x,y,\'x\'); plt.axis(\'equal\'); plt.show()\n\n Note that the covariance matrix must be non-negative definite.\n\n References\n ----------\n .. [1] A. Papoulis, \"Probability, Random Variables, and Stochastic\n Processes,\" 3rd ed., McGraw-Hill Companies, 1991\n .. [2] R.O. Duda, P.E. Hart, and D.G. Stork, \"Pattern Classification,\"\n 2nd ed., Wiley, 2001.\n\n Examples\n --------\n >>> mean = (1,2)\n >>> cov = [[1,0],[1,0]]\n >>> x = np.random.multivariate_normal(mean,cov,(3,3))\n >>> x.shape\n (3, 3, 2)\n\n The following is probably true, given that 0.6 is roughly twice the\n standard deviation:\n\n >>> print list( (x[0,0,:] - mean) < 0.6 )\n [True, True]\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_mean = 0;
PyObject *__pyx_v_cov = 0;
@@ -7932,7 +7946,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p
Py_ssize_t __pyx_5;
PyObject *__pyx_6 = 0;
static char *__pyx_argnames[] = {"mean","cov","size",0};
- __pyx_v_size = __pyx_d57;
+ __pyx_v_size = __pyx_k58;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_mean, &__pyx_v_cov, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_mean);
@@ -7946,38 +7960,38 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p
__pyx_v_s = Py_None; Py_INCREF(Py_None);
__pyx_v_v = Py_None; Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1470 */
- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2494 */
+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; goto __pyx_L1;}
+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; goto __pyx_L1;}
Py_INCREF(__pyx_v_mean);
PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_mean);
- __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; goto __pyx_L1;}
+ __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_v_mean);
__pyx_v_mean = __pyx_3;
__pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1471 */
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; goto __pyx_L1;}
- __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2495 */
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2495; goto __pyx_L1;}
+ __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2495; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2495; goto __pyx_L1;}
Py_INCREF(__pyx_v_cov);
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_cov);
- __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2495; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_v_cov);
__pyx_v_cov = __pyx_2;
__pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1472 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2496 */
__pyx_4 = __pyx_v_size == Py_None;
if (__pyx_4) {
- __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1473; goto __pyx_L1;}
+ __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2497; goto __pyx_L1;}
Py_DECREF(__pyx_v_shape);
__pyx_v_shape = __pyx_1;
__pyx_1 = 0;
@@ -7990,82 +8004,82 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1476 */
- __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1476; goto __pyx_L1;}
- __pyx_5 = PyObject_Length(__pyx_3); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1476; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2500 */
+ __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2500; goto __pyx_L1;}
+ __pyx_5 = PyObject_Length(__pyx_3); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2500; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__pyx_4 = (__pyx_5 != 1);
if (__pyx_4) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1477; goto __pyx_L1;}
- Py_INCREF(__pyx_k62p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k62p);
- __pyx_1 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1477; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2501; goto __pyx_L1;}
+ Py_INCREF(__pyx_k165p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k165p);
+ __pyx_1 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2501; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_1, 0, 0);
Py_DECREF(__pyx_1); __pyx_1 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1477; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2501; goto __pyx_L1;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1478 */
- __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; goto __pyx_L1;}
- __pyx_5 = PyObject_Length(__pyx_3); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2502 */
+ __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2502; goto __pyx_L1;}
+ __pyx_5 = PyObject_Length(__pyx_3); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2502; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__pyx_4 = (__pyx_5 != 2);
if (!__pyx_4) {
- __pyx_2 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; goto __pyx_L1;}
- __pyx_1 = __Pyx_GetItemInt(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2502; goto __pyx_L1;}
+ __pyx_1 = __Pyx_GetItemInt(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2502; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; goto __pyx_L1;}
- __pyx_2 = __Pyx_GetItemInt(__pyx_3, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2502; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetItemInt(__pyx_3, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2502; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- if (PyObject_Cmp(__pyx_1, __pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; goto __pyx_L1;}
+ if (PyObject_Cmp(__pyx_1, __pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2502; goto __pyx_L1;}
__pyx_4 = __pyx_4 != 0;
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
}
if (__pyx_4) {
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; goto __pyx_L1;}
- Py_INCREF(__pyx_k63p);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k63p);
- __pyx_1 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; goto __pyx_L1;}
+ Py_INCREF(__pyx_k166p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k166p);
+ __pyx_1 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
__Pyx_Raise(__pyx_1, 0, 0);
Py_DECREF(__pyx_1); __pyx_1 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; goto __pyx_L1;}
goto __pyx_L4;
}
__pyx_L4:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1480 */
- __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; goto __pyx_L1;}
- __pyx_3 = __Pyx_GetItemInt(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2504 */
+ __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetItemInt(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; goto __pyx_L1;}
- __pyx_2 = __Pyx_GetItemInt(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; goto __pyx_L1;}
+ __pyx_1 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetItemInt(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- if (PyObject_Cmp(__pyx_3, __pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; goto __pyx_L1;}
+ if (PyObject_Cmp(__pyx_3, __pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; goto __pyx_L1;}
__pyx_4 = __pyx_4 != 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
if (__pyx_4) {
- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; goto __pyx_L1;}
- Py_INCREF(__pyx_k64p);
- PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k64p);
- __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; goto __pyx_L1;}
+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; goto __pyx_L1;}
+ Py_INCREF(__pyx_k167p);
+ PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k167p);
+ __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; goto __pyx_L1;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1483 */
- __pyx_4 = PyObject_IsInstance(__pyx_v_shape,((PyObject *)(&PyInt_Type))); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2507 */
+ __pyx_4 = PyObject_IsInstance(__pyx_v_shape,((PyObject *)(&PyInt_Type))); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2507; goto __pyx_L1;}
if (__pyx_4) {
- __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; goto __pyx_L1;}
+ __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2508; goto __pyx_L1;}
Py_INCREF(__pyx_v_shape);
PyList_SET_ITEM(__pyx_2, 0, __pyx_v_shape);
Py_DECREF(__pyx_v_shape);
@@ -8075,166 +8089,166 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p
}
__pyx_L6:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1485 */
- __pyx_1 = PySequence_GetSlice(__pyx_v_shape, 0, PY_SSIZE_T_MAX); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1485; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1485; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2509 */
+ __pyx_1 = PySequence_GetSlice(__pyx_v_shape, 0, PY_SSIZE_T_MAX); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
__pyx_1 = 0;
- __pyx_2 = PyObject_CallObject(((PyObject *)(&PyList_Type)), __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1485; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(((PyObject *)(&PyList_Type)), __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_v_final_shape);
__pyx_v_final_shape = __pyx_2;
__pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1486 */
- __pyx_1 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; goto __pyx_L1;}
- __pyx_2 = __Pyx_GetItemInt(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2510 */
+ __pyx_1 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetItemInt(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1490 */
- __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;}
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2514 */
+ __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_reduce); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_reduce); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; goto __pyx_L1;}
Py_INCREF(__pyx_v_final_shape);
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_final_shape);
- __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;}
+ __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_6);
__pyx_6 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_v_x);
__pyx_v_x = __pyx_2;
__pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1491 */
- __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;}
- __pyx_1 = PyObject_GetAttr(__pyx_6, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2515 */
+ __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2515; goto __pyx_L1;}
+ __pyx_1 = PyObject_GetAttr(__pyx_6, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2515; goto __pyx_L1;}
Py_DECREF(__pyx_6); __pyx_6 = 0;
- __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_reduce); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_reduce); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2515; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_5 = PyObject_Length(__pyx_v_final_shape); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;}
- __pyx_2 = PySequence_GetSlice(__pyx_v_final_shape, 0, (__pyx_5 - 1)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;}
- __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;}
+ __pyx_5 = PyObject_Length(__pyx_v_final_shape); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2515; goto __pyx_L1;}
+ __pyx_2 = PySequence_GetSlice(__pyx_v_final_shape, 0, (__pyx_5 - 1)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2515; goto __pyx_L1;}
+ __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2515; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_6, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;}
+ __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2515; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_6); __pyx_6 = 0;
- __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; goto __pyx_L1;}
- __pyx_3 = __Pyx_GetItemInt(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2516; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetItemInt(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2516; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;}
+ __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2515; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_6, 0, __pyx_1);
PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
__pyx_1 = 0;
__pyx_3 = 0;
- if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2515; goto __pyx_L1;}
Py_DECREF(__pyx_6); __pyx_6 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1500 */
- __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1500; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2524 */
+ __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2524; goto __pyx_L1;}
Py_INCREF(__pyx_n_svd);
PyList_SET_ITEM(__pyx_2, 0, __pyx_n_svd);
- __pyx_1 = __Pyx_Import(__pyx_k68p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1500; goto __pyx_L1;}
+ __pyx_1 = __Pyx_Import(__pyx_k168p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2524; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_svd); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1500; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_svd); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2524; goto __pyx_L1;}
Py_DECREF(__pyx_v_svd);
__pyx_v_svd = __pyx_3;
__pyx_3 = 0;
Py_DECREF(__pyx_1); __pyx_1 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1502 */
- __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2526 */
+ __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2526; goto __pyx_L1;}
Py_INCREF(__pyx_v_cov);
PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_cov);
- __pyx_2 = PyObject_CallObject(__pyx_v_svd, __pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_v_svd, __pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2526; goto __pyx_L1;}
Py_DECREF(__pyx_6); __pyx_6 = 0;
- __pyx_1 = PyObject_GetIter(__pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; goto __pyx_L1;}
+ __pyx_1 = PyObject_GetIter(__pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2526; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_3 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; goto __pyx_L1;}
+ __pyx_3 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2526; goto __pyx_L1;}
Py_DECREF(__pyx_v_u);
__pyx_v_u = __pyx_3;
__pyx_3 = 0;
- __pyx_6 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; goto __pyx_L1;}
+ __pyx_6 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2526; goto __pyx_L1;}
Py_DECREF(__pyx_v_s);
__pyx_v_s = __pyx_6;
__pyx_6 = 0;
- __pyx_2 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; goto __pyx_L1;}
+ __pyx_2 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2526; goto __pyx_L1;}
Py_DECREF(__pyx_v_v);
__pyx_v_v = __pyx_2;
__pyx_2 = 0;
- if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; goto __pyx_L1;}
+ if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2526; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1503 */
- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;}
- __pyx_6 = PyObject_GetAttr(__pyx_3, __pyx_n_dot); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2527 */
+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; goto __pyx_L1;}
+ __pyx_6 = PyObject_GetAttr(__pyx_3, __pyx_n_dot); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;}
- __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_sqrt); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; goto __pyx_L1;}
+ __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_sqrt); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; goto __pyx_L1;}
Py_INCREF(__pyx_v_s);
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);
- __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_1 = PyNumber_Multiply(__pyx_v_x, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;}
+ __pyx_1 = PyNumber_Multiply(__pyx_v_x, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
Py_INCREF(__pyx_v_v);
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_v);
__pyx_1 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_6, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_6, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; goto __pyx_L1;}
Py_DECREF(__pyx_6); __pyx_6 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_v_x);
__pyx_v_x = __pyx_2;
__pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1506 */
- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; goto __pyx_L1;}
- __pyx_6 = PyObject_GetAttr(__pyx_1, __pyx_n_add); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2530 */
+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2530; goto __pyx_L1;}
+ __pyx_6 = PyObject_GetAttr(__pyx_1, __pyx_n_add); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2530; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2530; goto __pyx_L1;}
Py_INCREF(__pyx_v_mean);
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_mean);
Py_INCREF(__pyx_v_x);
PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_x);
Py_INCREF(__pyx_v_x);
PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_x);
- __pyx_2 = PyObject_CallObject(__pyx_6, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_6, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2530; goto __pyx_L1;}
Py_DECREF(__pyx_6); __pyx_6 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1507 */
- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2531 */
+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2531; goto __pyx_L1;}
Py_INCREF(__pyx_v_final_shape);
PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_final_shape);
- __pyx_6 = PyObject_CallObject(((PyObject *)(&PyTuple_Type)), __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; goto __pyx_L1;}
+ __pyx_6 = PyObject_CallObject(((PyObject *)(&PyTuple_Type)), __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2531; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2531; goto __pyx_L1;}
Py_DECREF(__pyx_6); __pyx_6 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1508 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2532 */
Py_INCREF(__pyx_v_x);
__pyx_r = __pyx_v_x;
goto __pyx_L0;
@@ -8263,8 +8277,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p
return __pyx_r;
}
+static PyObject *__pyx_n_zeros;
+
+static PyObject *__pyx_k170p;
+
+static char __pyx_k170[] = "sum(pvals[:-1]) > 1.0";
+
static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_multinomial[] = "Multinomial distribution.\n\n multinomial(n, pvals, size=None) -> random values\n\n pvals is a sequence of probabilities that should sum to 1 (however, the\n last element is always assumed to account for the remaining probability\n as long as sum(pvals[:-1]) <= 1).\n ";
+static char __pyx_doc_6mtrand_11RandomState_multinomial[] = "\n multinomial(n, pvals, size=None)\n\n Draw samples from a multinomial distribution.\n\n The multinomial distribution is a multivariate generalisation of the\n binomial distribution. Take an experiment with one of ``p``\n possible outcomes. An example of such an experiment is throwing a dice,\n where the outcome can be 1 through 6. Each sample drawn from the\n distribution represents `n` such experiments. Its values,\n ``X_i = [X_0, X_1, ..., X_p]``, represent the number of times the outcome\n was ``i``.\n\n Parameters\n ----------\n n : int\n Number of experiments.\n pvals : sequence of floats, length p\n Probabilities of each of the ``p`` different outcomes. These\n should sum to 1 (however, the last element is always assumed to\n account for the remaining probability, as long as\n ``sum(pvals[:-1]) <= 1)``.\n size : tuple of ints\n Given a `size` of ``(M, N, K)``, then ``M*N*K`` samples are drawn,\n and the output shape becomes ``(M, N, K, p)``, since each sample\n has shape ``(p,)``.\n\n Examples\n --------\n Throw a dice 20 times:\n\n >>> np.random.multinomial(20, [1/6.]*6, size=1)\n array([[4, 1, 7, 5, 2, 1]])\n\n It landed 4 times on 1, once on 2, etc.\n\n Now, throw the dice 20 times, and 20 times again:\n\n >>> np.random.multinomial(20, [1/6.]*6, size=2)\n array([[3, 4, 3, 3, 4, 3],\n [2, 4, 3, 4, 0, 7]])\n\n For the first run, we threw 3 times 1, 4 times 2, etc. For the second,\n we threw 2 times 1, 4 times 2, etc.\n\n A loaded dice is more likely to land on number 6:\n\n >>> np.random.multinomial(100, [1/7.]*5)\n array([13, 16, 13, 16, 42])\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
long __pyx_v_n;
PyObject *__pyx_v_pvals = 0;
@@ -8288,7 +8308,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel
PyObject *__pyx_5 = 0;
long __pyx_6;
static char *__pyx_argnames[] = {"n","pvals","size",0};
- __pyx_v_size = __pyx_d58;
+ __pyx_v_size = __pyx_k59;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "lO|O", __pyx_argnames, &__pyx_v_n, &__pyx_v_pvals, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_pvals);
@@ -8298,40 +8318,40 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel
__pyx_v_shape = Py_None; Py_INCREF(Py_None);
__pyx_v_multin = Py_None; Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1526 */
- __pyx_1 = PyObject_Length(__pyx_v_pvals); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1526; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2593 */
+ __pyx_1 = PyObject_Length(__pyx_v_pvals); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; goto __pyx_L1;}
__pyx_v_d = __pyx_1;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1527 */
- __pyx_2 = PyArray_ContiguousFromObject(__pyx_v_pvals,NPY_DOUBLE,1,1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1527; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2594 */
+ __pyx_2 = PyArray_ContiguousFromObject(__pyx_v_pvals,NPY_DOUBLE,1,1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)arrayObject_parr));
arrayObject_parr = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1528 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2595 */
__pyx_v_pix = ((double *)arrayObject_parr->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1530 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2597 */
__pyx_3 = (__pyx_f_6mtrand_kahan_sum(__pyx_v_pix,(__pyx_v_d - 1)) > (1.0 + 1e-12));
if (__pyx_3) {
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1531; goto __pyx_L1;}
- Py_INCREF(__pyx_k72p);
- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k72p);
- __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1531; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; goto __pyx_L1;}
+ Py_INCREF(__pyx_k170p);
+ PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k170p);
+ __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__Pyx_Raise(__pyx_4, 0, 0);
Py_DECREF(__pyx_4); __pyx_4 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1531; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; goto __pyx_L1;}
goto __pyx_L2;
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1533 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2600 */
__pyx_3 = __pyx_v_size == Py_None;
if (__pyx_3) {
- __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1534; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1534; goto __pyx_L1;}
+ __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2601; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2601; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
Py_DECREF(__pyx_v_shape);
@@ -8339,16 +8359,16 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel
__pyx_4 = 0;
goto __pyx_L3;
}
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1535; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; goto __pyx_L1;}
Py_INCREF(__pyx_v_size);
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);
- __pyx_4 = PyObject_CallObject(((PyObject *)(&PyType_Type)), __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1535; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(((PyObject *)(&PyType_Type)), __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_3 = __pyx_4 == ((PyObject *)(&PyInt_Type));
Py_DECREF(__pyx_4); __pyx_4 = 0;
if (__pyx_3) {
- __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1536; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1536; goto __pyx_L1;}
+ __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2603; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2603; goto __pyx_L1;}
Py_INCREF(__pyx_v_size);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_size);
PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
@@ -8359,11 +8379,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel
goto __pyx_L3;
}
/*else*/ {
- __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
+ __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2605; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2605; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyNumber_Add(__pyx_v_size, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; goto __pyx_L1;}
+ __pyx_2 = PyNumber_Add(__pyx_v_size, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2605; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_v_shape);
__pyx_v_shape = __pyx_2;
@@ -8371,55 +8391,55 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1540 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2607 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2607; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2607; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2607; goto __pyx_L1;}
Py_INCREF(__pyx_v_shape);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_shape);
Py_INCREF(((PyObject *)(&PyInt_Type)));
PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)(&PyInt_Type)));
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2607; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_v_multin);
__pyx_v_multin = __pyx_5;
__pyx_5 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1541 */
- Py_INCREF(__pyx_v_multin);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2608 */
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_multin)));
Py_DECREF(((PyObject *)arrayObject_mnarr));
arrayObject_mnarr = ((PyArrayObject *)__pyx_v_multin);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1542 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2609 */
__pyx_v_mnix = ((long *)arrayObject_mnarr->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1543 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2610 */
__pyx_v_i = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1544 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2611 */
while (1) {
__pyx_3 = (__pyx_v_i < PyArray_SIZE(arrayObject_mnarr));
if (!__pyx_3) break;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1545 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2612 */
__pyx_v_Sum = 1.0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1546 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2613 */
__pyx_v_dn = __pyx_v_n;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1547 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2614 */
__pyx_6 = (__pyx_v_d - 1);
for (__pyx_v_j = 0; __pyx_v_j < __pyx_6; ++__pyx_v_j) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1548 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2615 */
(__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]) = rk_binomial(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,__pyx_v_dn,((__pyx_v_pix[__pyx_v_j]) / __pyx_v_Sum));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1549 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2616 */
__pyx_v_dn = (__pyx_v_dn - (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1550 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2617 */
__pyx_3 = (__pyx_v_dn <= 0);
if (__pyx_3) {
goto __pyx_L7;
@@ -8427,12 +8447,12 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel
}
__pyx_L8:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1552 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2619 */
__pyx_v_Sum = (__pyx_v_Sum - (__pyx_v_pix[__pyx_v_j]));
}
__pyx_L7:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1553 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2620 */
__pyx_3 = (__pyx_v_dn > 0);
if (__pyx_3) {
(__pyx_v_mnix[((__pyx_v_i + __pyx_v_d) - 1)]) = __pyx_v_dn;
@@ -8440,11 +8460,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel
}
__pyx_L9:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1556 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2623 */
__pyx_v_i = (__pyx_v_i + __pyx_v_d);
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1558 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2625 */
Py_INCREF(__pyx_v_multin);
__pyx_r = __pyx_v_multin;
goto __pyx_L0;
@@ -8469,7 +8489,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel
}
static PyObject *__pyx_f_6mtrand_11RandomState_dirichlet(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_dirichlet[] = "dirichlet(alpha, size=None)\n\n Draw `size` samples of dimension k from a Dirichlet distribution. A\n Dirichlet-distributed random variable can be seen as a multivariate\n generalization of a Beta distribution. Dirichlet pdf is the conjugate\n prior of a multinomial in Bayesian inference.\n\n Parameters\n ----------\n alpha : array\n Parameter of the distribution (k dimension for sample of\n dimension k).\n size : array\n Number of samples to draw.\n\n Notes\n -----\n .. math:: X \\approx \\prod_{i=1}^{k}{x^{\\alpha_i-1}_i}\n\n Uses the following property for computation: for each dimension,\n draw a random sample y_i from a standard gamma generator of shape\n `alpha_i`, then\n :math:`X = \\frac{1}{\\sum_{i=1}^k{y_i}} (y_1, \\ldot, y_n)` is\n Dirichlet distributed.\n\n References\n ----------\n .. [1] David McKay, \"Information Theory, Inference and Learning\n Algorithms,\" chapter 23,\n http://www.inference.phy.cam.ac.uk/mackay/\n\n ";
+static char __pyx_doc_6mtrand_11RandomState_dirichlet[] = "\n dirichlet(alpha, size=None)\n\n Draw samples from the Dirichlet distribution.\n\n Draw `size` samples of dimension k from a Dirichlet distribution. A\n Dirichlet-distributed random variable can be seen as a multivariate\n generalization of a Beta distribution. Dirichlet pdf is the conjugate\n prior of a multinomial in Bayesian inference.\n\n Parameters\n ----------\n alpha : array\n Parameter of the distribution (k dimension for sample of\n dimension k).\n size : array\n Number of samples to draw.\n\n Notes\n -----\n .. math:: X \approx \\prod_{i=1}^{k}{x^{\alpha_i-1}_i}\n\n Uses the following property for computation: for each dimension,\n draw a random sample y_i from a standard gamma generator of shape\n `alpha_i`, then\n :math:`X = \frac{1}{\\sum_{i=1}^k{y_i}} (y_1, \\ldots, y_n)` is\n Dirichlet distributed.\n\n References\n ----------\n .. [1] David McKay, \"Information Theory, Inference and Learning\n Algorithms,\" chapter 23,\n http://www.inference.phy.cam.ac.uk/mackay/\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_dirichlet(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_alpha = 0;
PyObject *__pyx_v_size = 0;
@@ -8492,7 +8512,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_dirichlet(PyObject *__pyx_v_self,
PyObject *__pyx_4 = 0;
PyObject *__pyx_5 = 0;
static char *__pyx_argnames[] = {"alpha","size",0};
- __pyx_v_size = __pyx_d59;
+ __pyx_v_size = __pyx_k60;
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_alpha, &__pyx_v_size)) return 0;
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_alpha);
@@ -8502,25 +8522,25 @@ static PyObject *__pyx_f_6mtrand_11RandomState_dirichlet(PyObject *__pyx_v_self,
__pyx_v_shape = Py_None; Py_INCREF(Py_None);
__pyx_v_diric = Py_None; Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1621 */
- __pyx_1 = PyObject_Length(__pyx_v_alpha); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2691 */
+ __pyx_1 = PyObject_Length(__pyx_v_alpha); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2691; goto __pyx_L1;}
__pyx_v_k = __pyx_1;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1622 */
- __pyx_2 = PyArray_ContiguousFromObject(__pyx_v_alpha,NPY_DOUBLE,1,1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; goto __pyx_L1;}
- Py_INCREF(__pyx_2);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2692 */
+ __pyx_2 = PyArray_ContiguousFromObject(__pyx_v_alpha,NPY_DOUBLE,1,1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2692; goto __pyx_L1;}
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2)));
Py_DECREF(((PyObject *)__pyx_v_alpha_arr));
__pyx_v_alpha_arr = ((PyArrayObject *)__pyx_2);
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1623 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2693 */
__pyx_v_alpha_data = ((double *)__pyx_v_alpha_arr->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1625 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2695 */
__pyx_3 = __pyx_v_size == Py_None;
if (__pyx_3) {
- __pyx_2 = PyInt_FromLong(__pyx_v_k); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1626; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1626; goto __pyx_L1;}
+ __pyx_2 = PyInt_FromLong(__pyx_v_k); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2696; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2696; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
Py_DECREF(__pyx_v_shape);
@@ -8528,16 +8548,16 @@ static PyObject *__pyx_f_6mtrand_11RandomState_dirichlet(PyObject *__pyx_v_self,
__pyx_4 = 0;
goto __pyx_L2;
}
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1627; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; goto __pyx_L1;}
Py_INCREF(__pyx_v_size);
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);
- __pyx_4 = PyObject_CallObject(((PyObject *)(&PyType_Type)), __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1627; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(((PyObject *)(&PyType_Type)), __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_3 = __pyx_4 == ((PyObject *)(&PyInt_Type));
Py_DECREF(__pyx_4); __pyx_4 = 0;
if (__pyx_3) {
- __pyx_2 = PyInt_FromLong(__pyx_v_k); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; goto __pyx_L1;}
+ __pyx_2 = PyInt_FromLong(__pyx_v_k); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2698; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2698; goto __pyx_L1;}
Py_INCREF(__pyx_v_size);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_size);
PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
@@ -8548,11 +8568,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_dirichlet(PyObject *__pyx_v_self,
goto __pyx_L2;
}
/*else*/ {
- __pyx_2 = PyInt_FromLong(__pyx_v_k); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1630; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1630; goto __pyx_L1;}
+ __pyx_2 = PyInt_FromLong(__pyx_v_k); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2700; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2700; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
__pyx_2 = 0;
- __pyx_2 = PyNumber_Add(__pyx_v_size, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1630; goto __pyx_L1;}
+ __pyx_2 = PyNumber_Add(__pyx_v_size, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2700; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_v_shape);
__pyx_v_shape = __pyx_2;
@@ -8560,70 +8580,70 @@ static PyObject *__pyx_f_6mtrand_11RandomState_dirichlet(PyObject *__pyx_v_self,
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1632 */
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2702 */
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;}
- __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_float64); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;}
+ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; goto __pyx_L1;}
+ __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_float64); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; goto __pyx_L1;}
Py_INCREF(__pyx_v_shape);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_shape);
PyTuple_SET_ITEM(__pyx_4, 1, __pyx_5);
__pyx_5 = 0;
- __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;}
+ __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_v_diric);
__pyx_v_diric = __pyx_5;
__pyx_5 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1633 */
- Py_INCREF(__pyx_v_diric);
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2703 */
+ Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_diric)));
Py_DECREF(((PyObject *)__pyx_v_val_arr));
__pyx_v_val_arr = ((PyArrayObject *)__pyx_v_diric);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1634 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2704 */
__pyx_v_val_data = ((double *)__pyx_v_val_arr->data);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1636 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2706 */
__pyx_v_i = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1637 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2707 */
__pyx_v_totsize = PyArray_SIZE(__pyx_v_val_arr);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1638 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2708 */
while (1) {
__pyx_3 = (__pyx_v_i < __pyx_v_totsize);
if (!__pyx_3) break;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1639 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2709 */
__pyx_v_acc = 0.0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1640 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2710 */
for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_k; ++__pyx_v_j) {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1641 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2711 */
(__pyx_v_val_data[(__pyx_v_i + __pyx_v_j)]) = rk_standard_gamma(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,(__pyx_v_alpha_data[__pyx_v_j]));
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1642 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2712 */
__pyx_v_acc = (__pyx_v_acc + (__pyx_v_val_data[(__pyx_v_i + __pyx_v_j)]));
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1643 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2713 */
__pyx_v_invacc = (1 / __pyx_v_acc);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1644 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2714 */
for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_k; ++__pyx_v_j) {
(__pyx_v_val_data[(__pyx_v_i + __pyx_v_j)]) = ((__pyx_v_val_data[(__pyx_v_i + __pyx_v_j)]) * __pyx_v_invacc);
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1646 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2716 */
__pyx_v_i = (__pyx_v_i + __pyx_v_k);
}
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1648 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2718 */
Py_INCREF(__pyx_v_diric);
__pyx_r = __pyx_v_diric;
goto __pyx_L0;
@@ -8647,8 +8667,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_dirichlet(PyObject *__pyx_v_self,
return __pyx_r;
}
+static PyObject *__pyx_n_copy;
+
+
static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_shuffle[] = "Modify a sequence in-place by shuffling its contents.\n\n shuffle(x)\n ";
+static char __pyx_doc_6mtrand_11RandomState_shuffle[] = "\n shuffle(x)\n\n Modify a sequence in-place by shuffling its contents.\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_x = 0;
long __pyx_v_i;
@@ -8665,14 +8688,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, P
Py_INCREF(__pyx_v_self);
Py_INCREF(__pyx_v_x);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1659 */
- __pyx_1 = PyObject_Length(__pyx_v_x); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2731 */
+ __pyx_1 = PyObject_Length(__pyx_v_x); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; goto __pyx_L1;}
__pyx_v_i = (__pyx_1 - 1);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1660 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2732 */
/*try:*/ {
- __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; goto __pyx_L2;}
- __pyx_1 = PyObject_Length(__pyx_2); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; goto __pyx_L2;}
+ __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2733; goto __pyx_L2;}
+ __pyx_1 = PyObject_Length(__pyx_2); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2733; goto __pyx_L2;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
__pyx_v_j = __pyx_1;
}
@@ -8680,10 +8703,10 @@ static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, P
__pyx_L2:;
Py_XDECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1662 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2734 */
/*except:*/ {
__Pyx_AddTraceback("mtrand.shuffle");
- if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; goto __pyx_L1;}
+ if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2734; goto __pyx_L1;}
__pyx_v_j = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_3); __pyx_3 = 0;
@@ -8692,64 +8715,64 @@ static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, P
}
__pyx_L3:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1665 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2737 */
__pyx_5 = (__pyx_v_j == 0);
if (__pyx_5) {
while (1) {
__pyx_5 = (__pyx_v_i > 0);
if (!__pyx_5) break;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1668 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2740 */
__pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1669 */
- __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; goto __pyx_L1;}
- __pyx_3 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; goto __pyx_L1;}
- if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_i, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2741 */
+ __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; goto __pyx_L1;}
+ __pyx_3 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; goto __pyx_L1;}
+ if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_i, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_j, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; goto __pyx_L1;}
+ if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_j, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1670 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2742 */
__pyx_v_i = (__pyx_v_i - 1);
}
goto __pyx_L4;
}
/*else*/ {
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1673 */
- __pyx_4 = __Pyx_GetItemInt(__pyx_v_x, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; goto __pyx_L1;}
- __pyx_5 = PyObject_HasAttr(__pyx_4,__pyx_n_copy); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2745 */
+ __pyx_4 = __Pyx_GetItemInt(__pyx_v_x, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2745; goto __pyx_L1;}
+ __pyx_5 = PyObject_HasAttr(__pyx_4,__pyx_n_copy); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2745; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
__pyx_v_copy = __pyx_5;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1674 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2746 */
__pyx_5 = __pyx_v_copy;
if (__pyx_5) {
while (1) {
__pyx_5 = (__pyx_v_i > 0);
if (!__pyx_5) break;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1676 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2748 */
__pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1677 */
- __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_copy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2749 */
+ __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_copy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_4 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; goto __pyx_L1;}
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_copy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_copy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; goto __pyx_L1;}
+ __pyx_2 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_i, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; goto __pyx_L1;}
+ if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_i, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_j, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; goto __pyx_L1;}
+ if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_j, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1678 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2750 */
__pyx_v_i = (__pyx_v_i - 1);
}
goto __pyx_L7;
@@ -8759,22 +8782,22 @@ static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, P
__pyx_5 = (__pyx_v_i > 0);
if (!__pyx_5) break;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1681 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2753 */
__pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1682 */
- __pyx_3 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; goto __pyx_L1;}
- __pyx_4 = PySequence_GetSlice(__pyx_3, 0, PY_SSIZE_T_MAX); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2754 */
+ __pyx_3 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2754; goto __pyx_L1;}
+ __pyx_4 = PySequence_GetSlice(__pyx_3, 0, PY_SSIZE_T_MAX); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2754; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; goto __pyx_L1;}
- __pyx_3 = PySequence_GetSlice(__pyx_2, 0, PY_SSIZE_T_MAX); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2754; goto __pyx_L1;}
+ __pyx_3 = PySequence_GetSlice(__pyx_2, 0, PY_SSIZE_T_MAX); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2754; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_i, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; goto __pyx_L1;}
+ if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_i, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2754; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
- if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_j, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; goto __pyx_L1;}
+ if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_j, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2754; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1683 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2755 */
__pyx_v_i = (__pyx_v_i - 1);
}
}
@@ -8796,8 +8819,10 @@ static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, P
return __pyx_r;
}
+static PyObject *__pyx_n_arange;
+
static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6mtrand_11RandomState_permutation[] = "Given an integer, return a shuffled sequence of integers >= 0 and\n < x; given a sequence, return a shuffled array copy.\n\n permutation(x)\n ";
+static char __pyx_doc_6mtrand_11RandomState_permutation[] = "\n permutation(x)\n\n Randomly permute a sequence, or return a permuted range.\n\n Parameters\n ----------\n x : int or array_like\n If `x` is an integer, randomly permute ``np.arange(x)``.\n If `x` is an array, make a copy and shuffle the elements\n randomly.\n\n Returns\n -------\n out : ndarray\n Permuted sequence or array range.\n\n Examples\n --------\n >>> np.random.permutation(10)\n array([1, 7, 4, 3, 0, 9, 2, 5, 8, 6])\n\n >>> np.random.permutation([1, 4, 9, 12, 15])\n array([15, 1, 9, 4, 12])\n\n ";
static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_x = 0;
PyObject *__pyx_v_arr;
@@ -8812,25 +8837,25 @@ static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_sel
Py_INCREF(__pyx_v_x);
__pyx_v_arr = Py_None; Py_INCREF(Py_None);
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1691 */
- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_integer); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2784 */
+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2784; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_integer); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2784; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; goto __pyx_L1;}
+ __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2784; goto __pyx_L1;}
Py_INCREF(((PyObject *)(&PyInt_Type)));
PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)(&PyInt_Type)));
PyTuple_SET_ITEM(__pyx_1, 1, __pyx_2);
__pyx_2 = 0;
- __pyx_3 = PyObject_IsInstance(__pyx_v_x,__pyx_1); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; goto __pyx_L1;}
+ __pyx_3 = PyObject_IsInstance(__pyx_v_x,__pyx_1); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2784; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
if (__pyx_3) {
- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; goto __pyx_L1;}
- __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_arange); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; goto __pyx_L1;}
+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2785; goto __pyx_L1;}
+ __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_arange); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2785; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2785; goto __pyx_L1;}
Py_INCREF(__pyx_v_x);
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);
- __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; goto __pyx_L1;}
+ __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2785; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_v_arr);
@@ -8839,13 +8864,13 @@ static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_sel
goto __pyx_L2;
}
/*else*/ {
- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; goto __pyx_L1;}
+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2787; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2787; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2787; goto __pyx_L1;}
Py_INCREF(__pyx_v_x);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_x);
- __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; goto __pyx_L1;}
+ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2787; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_v_arr);
@@ -8854,17 +8879,17 @@ static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_sel
}
__pyx_L2:;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1695 */
- __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1695; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1695; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2788 */
+ __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2788; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2788; goto __pyx_L1;}
Py_INCREF(__pyx_v_arr);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_arr);
- __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1695; goto __pyx_L1;}
+ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2788; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
Py_DECREF(__pyx_1); __pyx_1 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1696 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2789 */
Py_INCREF(__pyx_v_arr);
__pyx_r = __pyx_v_arr;
goto __pyx_L0;
@@ -8884,6 +8909,197 @@ static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_sel
return __pyx_r;
}
+static __Pyx_InternTabEntry __pyx_intern_tab[] = {
+ {&__pyx_n_MT19937, "MT19937"},
+ {&__pyx_n___RandomState_ctor, "__RandomState_ctor"},
+ {&__pyx_n__rand, "_rand"},
+ {&__pyx_n_add, "add"},
+ {&__pyx_n_any, "any"},
+ {&__pyx_n_append, "append"},
+ {&__pyx_n_arange, "arange"},
+ {&__pyx_n_array, "array"},
+ {&__pyx_n_asarray, "asarray"},
+ {&__pyx_n_beta, "beta"},
+ {&__pyx_n_binomial, "binomial"},
+ {&__pyx_n_bytes, "bytes"},
+ {&__pyx_n_chisquare, "chisquare"},
+ {&__pyx_n_copy, "copy"},
+ {&__pyx_n_dirichlet, "dirichlet"},
+ {&__pyx_n_dot, "dot"},
+ {&__pyx_n_empty, "empty"},
+ {&__pyx_n_equal, "equal"},
+ {&__pyx_n_exponential, "exponential"},
+ {&__pyx_n_f, "f"},
+ {&__pyx_n_float64, "float64"},
+ {&__pyx_n_gamma, "gamma"},
+ {&__pyx_n_geometric, "geometric"},
+ {&__pyx_n_get_state, "get_state"},
+ {&__pyx_n_greater, "greater"},
+ {&__pyx_n_gumbel, "gumbel"},
+ {&__pyx_n_hypergeometric, "hypergeometric"},
+ {&__pyx_n_integer, "integer"},
+ {&__pyx_n_laplace, "laplace"},
+ {&__pyx_n_less, "less"},
+ {&__pyx_n_less_equal, "less_equal"},
+ {&__pyx_n_logistic, "logistic"},
+ {&__pyx_n_lognormal, "lognormal"},
+ {&__pyx_n_logseries, "logseries"},
+ {&__pyx_n_multinomial, "multinomial"},
+ {&__pyx_n_multiply, "multiply"},
+ {&__pyx_n_multivariate_normal, "multivariate_normal"},
+ {&__pyx_n_negative_binomial, "negative_binomial"},
+ {&__pyx_n_noncentral_chisquare, "noncentral_chisquare"},
+ {&__pyx_n_noncentral_f, "noncentral_f"},
+ {&__pyx_n_normal, "normal"},
+ {&__pyx_n_np, "np"},
+ {&__pyx_n_numpy, "numpy"},
+ {&__pyx_n_pareto, "pareto"},
+ {&__pyx_n_permutation, "permutation"},
+ {&__pyx_n_poisson, "poisson"},
+ {&__pyx_n_power, "power"},
+ {&__pyx_n_rand, "rand"},
+ {&__pyx_n_randint, "randint"},
+ {&__pyx_n_randn, "randn"},
+ {&__pyx_n_random, "random"},
+ {&__pyx_n_random_integers, "random_integers"},
+ {&__pyx_n_random_sample, "random_sample"},
+ {&__pyx_n_rayleigh, "rayleigh"},
+ {&__pyx_n_reduce, "reduce"},
+ {&__pyx_n_seed, "seed"},
+ {&__pyx_n_set_state, "set_state"},
+ {&__pyx_n_shape, "shape"},
+ {&__pyx_n_shuffle, "shuffle"},
+ {&__pyx_n_size, "size"},
+ {&__pyx_n_sqrt, "sqrt"},
+ {&__pyx_n_standard_cauchy, "standard_cauchy"},
+ {&__pyx_n_standard_exponential, "standard_exponential"},
+ {&__pyx_n_standard_gamma, "standard_gamma"},
+ {&__pyx_n_standard_normal, "standard_normal"},
+ {&__pyx_n_standard_t, "standard_t"},
+ {&__pyx_n_subtract, "subtract"},
+ {&__pyx_n_svd, "svd"},
+ {&__pyx_n_triangular, "triangular"},
+ {&__pyx_n_uint, "uint"},
+ {&__pyx_n_uint32, "uint32"},
+ {&__pyx_n_uniform, "uniform"},
+ {&__pyx_n_vonmises, "vonmises"},
+ {&__pyx_n_wald, "wald"},
+ {&__pyx_n_weibull, "weibull"},
+ {&__pyx_n_zeros, "zeros"},
+ {&__pyx_n_zipf, "zipf"},
+ {0, 0}
+};
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+ {&__pyx_k61p, __pyx_k61, sizeof(__pyx_k61)},
+ {&__pyx_k62p, __pyx_k62, sizeof(__pyx_k62)},
+ {&__pyx_k63p, __pyx_k63, sizeof(__pyx_k63)},
+ {&__pyx_k64p, __pyx_k64, sizeof(__pyx_k64)},
+ {&__pyx_k65p, __pyx_k65, sizeof(__pyx_k65)},
+ {&__pyx_k66p, __pyx_k66, sizeof(__pyx_k66)},
+ {&__pyx_k69p, __pyx_k69, sizeof(__pyx_k69)},
+ {&__pyx_k70p, __pyx_k70, sizeof(__pyx_k70)},
+ {&__pyx_k71p, __pyx_k71, sizeof(__pyx_k71)},
+ {&__pyx_k73p, __pyx_k73, sizeof(__pyx_k73)},
+ {&__pyx_k74p, __pyx_k74, sizeof(__pyx_k74)},
+ {&__pyx_k75p, __pyx_k75, sizeof(__pyx_k75)},
+ {&__pyx_k76p, __pyx_k76, sizeof(__pyx_k76)},
+ {&__pyx_k77p, __pyx_k77, sizeof(__pyx_k77)},
+ {&__pyx_k78p, __pyx_k78, sizeof(__pyx_k78)},
+ {&__pyx_k79p, __pyx_k79, sizeof(__pyx_k79)},
+ {&__pyx_k80p, __pyx_k80, sizeof(__pyx_k80)},
+ {&__pyx_k81p, __pyx_k81, sizeof(__pyx_k81)},
+ {&__pyx_k82p, __pyx_k82, sizeof(__pyx_k82)},
+ {&__pyx_k83p, __pyx_k83, sizeof(__pyx_k83)},
+ {&__pyx_k84p, __pyx_k84, sizeof(__pyx_k84)},
+ {&__pyx_k85p, __pyx_k85, sizeof(__pyx_k85)},
+ {&__pyx_k86p, __pyx_k86, sizeof(__pyx_k86)},
+ {&__pyx_k87p, __pyx_k87, sizeof(__pyx_k87)},
+ {&__pyx_k88p, __pyx_k88, sizeof(__pyx_k88)},
+ {&__pyx_k89p, __pyx_k89, sizeof(__pyx_k89)},
+ {&__pyx_k90p, __pyx_k90, sizeof(__pyx_k90)},
+ {&__pyx_k91p, __pyx_k91, sizeof(__pyx_k91)},
+ {&__pyx_k92p, __pyx_k92, sizeof(__pyx_k92)},
+ {&__pyx_k93p, __pyx_k93, sizeof(__pyx_k93)},
+ {&__pyx_k94p, __pyx_k94, sizeof(__pyx_k94)},
+ {&__pyx_k95p, __pyx_k95, sizeof(__pyx_k95)},
+ {&__pyx_k96p, __pyx_k96, sizeof(__pyx_k96)},
+ {&__pyx_k97p, __pyx_k97, sizeof(__pyx_k97)},
+ {&__pyx_k98p, __pyx_k98, sizeof(__pyx_k98)},
+ {&__pyx_k99p, __pyx_k99, sizeof(__pyx_k99)},
+ {&__pyx_k100p, __pyx_k100, sizeof(__pyx_k100)},
+ {&__pyx_k101p, __pyx_k101, sizeof(__pyx_k101)},
+ {&__pyx_k102p, __pyx_k102, sizeof(__pyx_k102)},
+ {&__pyx_k103p, __pyx_k103, sizeof(__pyx_k103)},
+ {&__pyx_k104p, __pyx_k104, sizeof(__pyx_k104)},
+ {&__pyx_k105p, __pyx_k105, sizeof(__pyx_k105)},
+ {&__pyx_k106p, __pyx_k106, sizeof(__pyx_k106)},
+ {&__pyx_k107p, __pyx_k107, sizeof(__pyx_k107)},
+ {&__pyx_k108p, __pyx_k108, sizeof(__pyx_k108)},
+ {&__pyx_k109p, __pyx_k109, sizeof(__pyx_k109)},
+ {&__pyx_k110p, __pyx_k110, sizeof(__pyx_k110)},
+ {&__pyx_k111p, __pyx_k111, sizeof(__pyx_k111)},
+ {&__pyx_k112p, __pyx_k112, sizeof(__pyx_k112)},
+ {&__pyx_k113p, __pyx_k113, sizeof(__pyx_k113)},
+ {&__pyx_k114p, __pyx_k114, sizeof(__pyx_k114)},
+ {&__pyx_k115p, __pyx_k115, sizeof(__pyx_k115)},
+ {&__pyx_k116p, __pyx_k116, sizeof(__pyx_k116)},
+ {&__pyx_k117p, __pyx_k117, sizeof(__pyx_k117)},
+ {&__pyx_k118p, __pyx_k118, sizeof(__pyx_k118)},
+ {&__pyx_k119p, __pyx_k119, sizeof(__pyx_k119)},
+ {&__pyx_k120p, __pyx_k120, sizeof(__pyx_k120)},
+ {&__pyx_k121p, __pyx_k121, sizeof(__pyx_k121)},
+ {&__pyx_k122p, __pyx_k122, sizeof(__pyx_k122)},
+ {&__pyx_k123p, __pyx_k123, sizeof(__pyx_k123)},
+ {&__pyx_k124p, __pyx_k124, sizeof(__pyx_k124)},
+ {&__pyx_k125p, __pyx_k125, sizeof(__pyx_k125)},
+ {&__pyx_k126p, __pyx_k126, sizeof(__pyx_k126)},
+ {&__pyx_k127p, __pyx_k127, sizeof(__pyx_k127)},
+ {&__pyx_k128p, __pyx_k128, sizeof(__pyx_k128)},
+ {&__pyx_k129p, __pyx_k129, sizeof(__pyx_k129)},
+ {&__pyx_k130p, __pyx_k130, sizeof(__pyx_k130)},
+ {&__pyx_k131p, __pyx_k131, sizeof(__pyx_k131)},
+ {&__pyx_k132p, __pyx_k132, sizeof(__pyx_k132)},
+ {&__pyx_k133p, __pyx_k133, sizeof(__pyx_k133)},
+ {&__pyx_k134p, __pyx_k134, sizeof(__pyx_k134)},
+ {&__pyx_k135p, __pyx_k135, sizeof(__pyx_k135)},
+ {&__pyx_k136p, __pyx_k136, sizeof(__pyx_k136)},
+ {&__pyx_k137p, __pyx_k137, sizeof(__pyx_k137)},
+ {&__pyx_k138p, __pyx_k138, sizeof(__pyx_k138)},
+ {&__pyx_k139p, __pyx_k139, sizeof(__pyx_k139)},
+ {&__pyx_k140p, __pyx_k140, sizeof(__pyx_k140)},
+ {&__pyx_k141p, __pyx_k141, sizeof(__pyx_k141)},
+ {&__pyx_k142p, __pyx_k142, sizeof(__pyx_k142)},
+ {&__pyx_k143p, __pyx_k143, sizeof(__pyx_k143)},
+ {&__pyx_k144p, __pyx_k144, sizeof(__pyx_k144)},
+ {&__pyx_k145p, __pyx_k145, sizeof(__pyx_k145)},
+ {&__pyx_k146p, __pyx_k146, sizeof(__pyx_k146)},
+ {&__pyx_k147p, __pyx_k147, sizeof(__pyx_k147)},
+ {&__pyx_k148p, __pyx_k148, sizeof(__pyx_k148)},
+ {&__pyx_k149p, __pyx_k149, sizeof(__pyx_k149)},
+ {&__pyx_k150p, __pyx_k150, sizeof(__pyx_k150)},
+ {&__pyx_k151p, __pyx_k151, sizeof(__pyx_k151)},
+ {&__pyx_k152p, __pyx_k152, sizeof(__pyx_k152)},
+ {&__pyx_k153p, __pyx_k153, sizeof(__pyx_k153)},
+ {&__pyx_k154p, __pyx_k154, sizeof(__pyx_k154)},
+ {&__pyx_k155p, __pyx_k155, sizeof(__pyx_k155)},
+ {&__pyx_k156p, __pyx_k156, sizeof(__pyx_k156)},
+ {&__pyx_k157p, __pyx_k157, sizeof(__pyx_k157)},
+ {&__pyx_k158p, __pyx_k158, sizeof(__pyx_k158)},
+ {&__pyx_k159p, __pyx_k159, sizeof(__pyx_k159)},
+ {&__pyx_k160p, __pyx_k160, sizeof(__pyx_k160)},
+ {&__pyx_k161p, __pyx_k161, sizeof(__pyx_k161)},
+ {&__pyx_k162p, __pyx_k162, sizeof(__pyx_k162)},
+ {&__pyx_k163p, __pyx_k163, sizeof(__pyx_k163)},
+ {&__pyx_k164p, __pyx_k164, sizeof(__pyx_k164)},
+ {&__pyx_k165p, __pyx_k165, sizeof(__pyx_k165)},
+ {&__pyx_k166p, __pyx_k166, sizeof(__pyx_k166)},
+ {&__pyx_k167p, __pyx_k167, sizeof(__pyx_k167)},
+ {&__pyx_k168p, __pyx_k168, sizeof(__pyx_k168)},
+ {&__pyx_k170p, __pyx_k170, sizeof(__pyx_k170)},
+ {0, 0, 0}
+};
+
static PyObject *__pyx_tp_new_6mtrand_RandomState(PyTypeObject *t, PyObject *a, PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -9049,7 +9265,7 @@ PyTypeObject __pyx_type_6mtrand_RandomState = {
0, /*tp_setattro*/
&__pyx_tp_as_buffer_RandomState, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "Container for the Mersenne Twister PRNG.\n\n Constructor\n -----------\n RandomState(seed=None): initializes the PRNG with the given seed. See the\n seed() method for details.\n\n Distribution Methods\n -----------------\n RandomState exposes a number of methods for generating random numbers drawn\n from a variety of probability distributions. In addition to the\n distribution-specific arguments, each method takes a keyword argument\n size=None. If size is None, then a single value is generated and returned.\n If size is an integer, then a 1-D numpy array filled with generated values\n is returned. If size is a tuple, then a numpy array with that shape is\n filled and returned.\n ", /*tp_doc*/
+ "\n RandomState(seed=None)\n\n Container for the Mersenne Twister PRNG.\n\n `RandomState` exposes a number of methods for generating random numbers\n drawn from a variety of probability distributions. In addition to the\n distribution-specific arguments, each method takes a keyword argument\n `size` that defaults to ``None``. If `size` is ``None``, then a single\n value is generated and returned. If `size` is an integer, then a 1-D\n numpy array filled with generated values is returned. If size is a tuple,\n then a numpy array with that shape is filled and returned.\n\n Parameters\n ----------\n seed : {None, int, array-like}\n Random seed initializing the PRNG.\n Can be an integer, an array (or other sequence) of integers of\n any length, or ``None``.\n If `seed` is ``None``, then `RandomState` will try to read data from\n ``/dev/urandom`` (or the Windows analogue) if available or seed from\n the clock otherwise.\n\n ", /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
@@ -9109,6 +9325,7 @@ PyMODINIT_FUNC initmtrand(void) {
__pyx_b = PyImport_AddModule("__builtin__");
if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};
+ if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};
if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};
__pyx_ptype_6mtrand_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_6mtrand_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 74; goto __pyx_L1;}
__pyx_ptype_6mtrand_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_6mtrand_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 79; goto __pyx_L1;}
@@ -9118,555 +9335,555 @@ PyMODINIT_FUNC initmtrand(void) {
if (PyObject_SetAttrString(__pyx_m, "RandomState", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; goto __pyx_L1;}
__pyx_ptype_6mtrand_RandomState = &__pyx_type_6mtrand_RandomState;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":120 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":120 */
import_array();
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":122 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":122 */
__pyx_1 = __Pyx_Import(__pyx_n_numpy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;}
if (PyObject_SetAttr(__pyx_m, __pyx_n_np, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":489 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":496 */
Py_INCREF(Py_None);
- __pyx_d1 = Py_None;
+ __pyx_k2 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":499 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":506 */
Py_INCREF(Py_None);
- __pyx_d2 = Py_None;
+ __pyx_k3 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":581 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":596 */
Py_INCREF(Py_None);
- __pyx_d3 = Py_None;
+ __pyx_k4 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":588 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":605 */
Py_INCREF(Py_None);
- __pyx_d4 = Py_None;
+ __pyx_k5 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":595 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":633 */
Py_INCREF(Py_None);
- __pyx_d5 = Py_None;
+ __pyx_k6 = Py_None;
Py_INCREF(Py_None);
- __pyx_d6 = Py_None;
+ __pyx_k7 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":640 */
- __pyx_1 = PyFloat_FromDouble(0.0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}
- __pyx_d7 = __pyx_1;
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":697 */
+ __pyx_1 = PyFloat_FromDouble(0.0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; goto __pyx_L1;}
+ __pyx_k8 = __pyx_1;
__pyx_1 = 0;
- __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;}
- __pyx_d8 = __pyx_2;
+ __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; goto __pyx_L1;}
+ __pyx_k9 = __pyx_2;
__pyx_2 = 0;
Py_INCREF(Py_None);
- __pyx_d9 = Py_None;
+ __pyx_k10 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":693 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":845 */
Py_INCREF(Py_None);
- __pyx_d10 = Py_None;
+ __pyx_k11 = Py_None;
Py_INCREF(Py_None);
- __pyx_d11 = Py_None;
+ __pyx_k12 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":706 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":860 */
Py_INCREF(Py_None);
- __pyx_d12 = Py_None;
+ __pyx_k13 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":713 */
- __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; goto __pyx_L1;}
- __pyx_d13 = __pyx_3;
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":869 */
+ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; goto __pyx_L1;}
+ __pyx_k14 = __pyx_3;
__pyx_3 = 0;
- __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; goto __pyx_L1;}
- __pyx_d14 = __pyx_4;
+ __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; goto __pyx_L1;}
+ __pyx_k15 = __pyx_4;
__pyx_4 = 0;
Py_INCREF(Py_None);
- __pyx_d15 = Py_None;
+ __pyx_k16 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":736 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":969 */
Py_INCREF(Py_None);
- __pyx_d16 = Py_None;
+ __pyx_k17 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":763 */
- __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;}
- __pyx_d17 = __pyx_5;
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1028 */
+ __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; goto __pyx_L1;}
+ __pyx_k18 = __pyx_5;
__pyx_5 = 0;
Py_INCREF(Py_None);
- __pyx_d18 = Py_None;
+ __pyx_k19 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":784 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1078 */
Py_INCREF(Py_None);
- __pyx_d19 = Py_None;
+ __pyx_k20 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":791 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1087 */
Py_INCREF(Py_None);
- __pyx_d20 = Py_None;
+ __pyx_k21 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":811 */
- __pyx_6 = PyFloat_FromDouble(1.0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;}
- __pyx_d21 = __pyx_6;
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1109 */
+ __pyx_6 = PyFloat_FromDouble(1.0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; goto __pyx_L1;}
+ __pyx_k22 = __pyx_6;
__pyx_6 = 0;
Py_INCREF(Py_None);
- __pyx_d22 = Py_None;
+ __pyx_k23 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":837 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1137 */
Py_INCREF(Py_None);
- __pyx_d23 = Py_None;
+ __pyx_k24 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":864 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1166 */
Py_INCREF(Py_None);
- __pyx_d24 = Py_None;
+ __pyx_k25 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":900 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1204 */
Py_INCREF(Py_None);
- __pyx_d25 = Py_None;
+ __pyx_k26 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":921 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1284 */
Py_INCREF(Py_None);
- __pyx_d26 = Py_None;
+ __pyx_k27 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":949 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1326 */
Py_INCREF(Py_None);
- __pyx_d27 = Py_None;
+ __pyx_k28 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":956 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1335 */
Py_INCREF(Py_None);
- __pyx_d28 = Py_None;
+ __pyx_k29 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":977 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1358 */
Py_INCREF(Py_None);
- __pyx_d29 = Py_None;
+ __pyx_k30 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1001 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1453 */
Py_INCREF(Py_None);
- __pyx_d30 = Py_None;
+ __pyx_k31 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1022 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1542 */
Py_INCREF(Py_None);
- __pyx_d31 = Py_None;
+ __pyx_k32 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1043 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1641 */
Py_INCREF(Py_None);
- __pyx_d32 = Py_None;
+ __pyx_k33 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1064 */
- __pyx_7 = PyFloat_FromDouble(0.0); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; goto __pyx_L1;}
- __pyx_d33 = __pyx_7;
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1664 */
+ __pyx_7 = PyFloat_FromDouble(0.0); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; goto __pyx_L1;}
+ __pyx_k34 = __pyx_7;
__pyx_7 = 0;
- __pyx_8 = PyFloat_FromDouble(1.0); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; goto __pyx_L1;}
- __pyx_d34 = __pyx_8;
+ __pyx_8 = PyFloat_FromDouble(1.0); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; goto __pyx_L1;}
+ __pyx_k35 = __pyx_8;
__pyx_8 = 0;
Py_INCREF(Py_None);
- __pyx_d35 = Py_None;
+ __pyx_k36 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1086 */
- __pyx_9 = PyFloat_FromDouble(0.0); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; goto __pyx_L1;}
- __pyx_d36 = __pyx_9;
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1703 */
+ __pyx_9 = PyFloat_FromDouble(0.0); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; goto __pyx_L1;}
+ __pyx_k37 = __pyx_9;
__pyx_9 = 0;
- __pyx_10 = PyFloat_FromDouble(1.0); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; goto __pyx_L1;}
- __pyx_d37 = __pyx_10;
+ __pyx_10 = PyFloat_FromDouble(1.0); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; goto __pyx_L1;}
+ __pyx_k38 = __pyx_10;
__pyx_10 = 0;
Py_INCREF(Py_None);
- __pyx_d38 = Py_None;
+ __pyx_k39 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1108 */
- __pyx_11 = PyFloat_FromDouble(0.0); if (!__pyx_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; goto __pyx_L1;}
- __pyx_d39 = __pyx_11;
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1827 */
+ __pyx_11 = PyFloat_FromDouble(0.0); if (!__pyx_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1827; goto __pyx_L1;}
+ __pyx_k40 = __pyx_11;
__pyx_11 = 0;
- __pyx_12 = PyFloat_FromDouble(1.0); if (!__pyx_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; goto __pyx_L1;}
- __pyx_d40 = __pyx_12;
+ __pyx_12 = PyFloat_FromDouble(1.0); if (!__pyx_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1827; goto __pyx_L1;}
+ __pyx_k41 = __pyx_12;
__pyx_12 = 0;
Py_INCREF(Py_None);
- __pyx_d41 = Py_None;
+ __pyx_k42 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1130 */
- __pyx_13 = PyFloat_FromDouble(0.0); if (!__pyx_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; goto __pyx_L1;}
- __pyx_d42 = __pyx_13;
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1851 */
+ __pyx_13 = PyFloat_FromDouble(0.0); if (!__pyx_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1851; goto __pyx_L1;}
+ __pyx_k43 = __pyx_13;
__pyx_13 = 0;
- __pyx_14 = PyFloat_FromDouble(1.0); if (!__pyx_14) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; goto __pyx_L1;}
- __pyx_d43 = __pyx_14;
+ __pyx_14 = PyFloat_FromDouble(1.0); if (!__pyx_14) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1851; goto __pyx_L1;}
+ __pyx_k44 = __pyx_14;
__pyx_14 = 0;
Py_INCREF(Py_None);
- __pyx_d44 = Py_None;
+ __pyx_k45 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1159 */
- __pyx_15 = PyFloat_FromDouble(1.0); if (!__pyx_15) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; goto __pyx_L1;}
- __pyx_d45 = __pyx_15;
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1982 */
+ __pyx_15 = PyFloat_FromDouble(1.0); if (!__pyx_15) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1982; goto __pyx_L1;}
+ __pyx_k46 = __pyx_15;
__pyx_15 = 0;
Py_INCREF(Py_None);
- __pyx_d46 = Py_None;
+ __pyx_k47 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1181 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2006 */
Py_INCREF(Py_None);
- __pyx_d47 = Py_None;
+ __pyx_k48 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1209 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2036 */
Py_INCREF(Py_None);
- __pyx_d48 = Py_None;
+ __pyx_k49 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1246 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2075 */
Py_INCREF(Py_None);
- __pyx_d49 = Py_None;
+ __pyx_k50 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1278 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2109 */
Py_INCREF(Py_None);
- __pyx_d50 = Py_None;
+ __pyx_k51 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1313 */
- __pyx_16 = PyFloat_FromDouble(1.0); if (!__pyx_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; goto __pyx_L1;}
- __pyx_d51 = __pyx_16;
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2146 */
+ __pyx_16 = PyFloat_FromDouble(1.0); if (!__pyx_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2146; goto __pyx_L1;}
+ __pyx_k52 = __pyx_16;
__pyx_16 = 0;
Py_INCREF(Py_None);
- __pyx_d52 = Py_None;
+ __pyx_k53 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1333 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2168 */
Py_INCREF(Py_None);
- __pyx_d53 = Py_None;
+ __pyx_k54 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1354 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2260 */
Py_INCREF(Py_None);
- __pyx_d54 = Py_None;
+ __pyx_k55 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1381 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2326 */
Py_INCREF(Py_None);
- __pyx_d55 = Py_None;
+ __pyx_k56 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1426 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2373 */
Py_INCREF(Py_None);
- __pyx_d56 = Py_None;
+ __pyx_k57 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1452 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2401 */
Py_INCREF(Py_None);
- __pyx_d57 = Py_None;
+ __pyx_k58 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1510 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2534 */
Py_INCREF(Py_None);
- __pyx_d58 = Py_None;
+ __pyx_k59 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1560 */
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2627 */
Py_INCREF(Py_None);
- __pyx_d59 = Py_None;
+ __pyx_k60 = Py_None;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1698 */
- __pyx_17 = PyObject_CallObject(((PyObject *)__pyx_ptype_6mtrand_RandomState), 0); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1698; goto __pyx_L1;}
- if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_17) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1698; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2791 */
+ __pyx_17 = PyObject_CallObject(((PyObject *)__pyx_ptype_6mtrand_RandomState), 0); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2791; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_17) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2791; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1699 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_seed); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2792 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2792; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_seed); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2792; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_seed, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_seed, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2792; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1700 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_get_state); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2793 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_get_state); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1701 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_set_state); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2794 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_set_state); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1702 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_random_sample); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2795 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2795; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_random_sample); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2795; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2795; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1703 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_randint); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2796 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_randint); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1704 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_bytes); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2797 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2797; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_bytes); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2797; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2797; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1705 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1705; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_uniform); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1705; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2798 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_uniform); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1705; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1706 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_rand); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2799 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_rand); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1707 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_randn); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2800 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2800; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_randn); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2800; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2800; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1708 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_random_integers); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2801 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_random_integers); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1709 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_normal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2802 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_normal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1710 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_normal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2803 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_normal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1711 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_beta); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2804 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_beta); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1712 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_exponential); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2805 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_exponential); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1713 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_exponential); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2806 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2806; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_exponential); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2806; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2806; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1714 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1714; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_gamma); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1714; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2807 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_gamma); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1714; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1715 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_gamma); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2808 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_gamma); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1716 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_f); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2809 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_f); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1717 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_noncentral_f); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2810 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_noncentral_f); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1718 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_chisquare); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2811 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2811; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_chisquare); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2811; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2811; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1719 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_noncentral_chisquare); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2812 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_noncentral_chisquare); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1720 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_cauchy); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2813 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_cauchy); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1721 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_t); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2814 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2814; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_t); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2814; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2814; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1722 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_vonmises); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2815 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2815; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_vonmises); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2815; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2815; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1723 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_pareto); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2816 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_pareto); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1724 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_weibull); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2817 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2817; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_weibull); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2817; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2817; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1725 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1725; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_power); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1725; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2818 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_power); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1725; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1726 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_laplace); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2819 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_laplace); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_laplace, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_laplace, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1727 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1727; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_gumbel); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1727; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2820 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2820; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_gumbel); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2820; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_gumbel, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1727; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_gumbel, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2820; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1728 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1728; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_logistic); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1728; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2821 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2821; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_logistic); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2821; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_logistic, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1728; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_logistic, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2821; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1729 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1729; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_lognormal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1729; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2822 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_lognormal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_lognormal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1729; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_lognormal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1730 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_rayleigh); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2823 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2823; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_rayleigh); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2823; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_rayleigh, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_rayleigh, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2823; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1731 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_wald); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2824 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2824; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_wald); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2824; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_wald, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_wald, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2824; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1732 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1732; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_triangular); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1732; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2825 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2825; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_triangular); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2825; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_triangular, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1732; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_triangular, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2825; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1734 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_binomial); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2827 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2827; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_binomial); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2827; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2827; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1735 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_negative_binomial); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2828 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2828; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_negative_binomial); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2828; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2828; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1736 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_poisson); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2829 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2829; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_poisson); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2829; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2829; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1737 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_zipf); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2830 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_zipf); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_zipf, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_zipf, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1738 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_geometric); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2831 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_geometric); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_geometric, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_geometric, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1739 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_hypergeometric); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2832 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2832; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_hypergeometric); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2832; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_hypergeometric, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_hypergeometric, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2832; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1740 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_logseries); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2833 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_logseries); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_logseries, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_logseries, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1742 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1742; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_multivariate_normal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1742; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2835 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_multivariate_normal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1742; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1743 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_multinomial); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2836 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2836; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_multinomial); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2836; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2836; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1744 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_dirichlet); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2837 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2837; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_dirichlet); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2837; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_dirichlet, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_dirichlet, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2837; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1746 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_shuffle); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2839 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2839; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_shuffle); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2839; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2839; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
- /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1747 */
- __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; goto __pyx_L1;}
- __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_permutation); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; goto __pyx_L1;}
+ /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":2840 */
+ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2840; goto __pyx_L1;}
+ __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_permutation); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2840; goto __pyx_L1;}
Py_DECREF(__pyx_17); __pyx_17 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_permutation, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; goto __pyx_L1;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_permutation, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2840; goto __pyx_L1;}
Py_DECREF(__pyx_18); __pyx_18 = 0;
return;
__pyx_L1:;
@@ -9702,6 +9919,136 @@ static void __pyx_init_filenames(void) {
__pyx_f = __pyx_filenames;
}
+static int __Pyx_GetStarArgs(
+ PyObject **args,
+ PyObject **kwds,
+ char *kwd_list[],
+ Py_ssize_t nargs,
+ PyObject **args2,
+ PyObject **kwds2,
+ char rqd_kwds[])
+{
+ PyObject *x = 0, *args1 = 0, *kwds1 = 0;
+ int i;
+ char **p;
+
+ if (args2)
+ *args2 = 0;
+ if (kwds2)
+ *kwds2 = 0;
+
+ if (args2) {
+ args1 = PyTuple_GetSlice(*args, 0, nargs);
+ if (!args1)
+ goto bad;
+ *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_GET_SIZE(*args));
+ if (!*args2)
+ goto bad;
+ }
+ else if (PyTuple_GET_SIZE(*args) > nargs) {
+ int m = nargs;
+ int n = PyTuple_GET_SIZE(*args);
+ PyErr_Format(PyExc_TypeError,
+ "function takes at most %d positional arguments (%d given)",
+ m, n);
+ goto bad;
+ }
+ else {
+ args1 = *args;
+ Py_INCREF(args1);
+ }
+
+ if (rqd_kwds && !*kwds)
+ for (i = 0, p = kwd_list; *p; i++, p++)
+ if (rqd_kwds[i])
+ goto missing_kwarg;
+
+ if (kwds2) {
+ if (*kwds) {
+ kwds1 = PyDict_New();
+ if (!kwds1)
+ goto bad;
+ *kwds2 = PyDict_Copy(*kwds);
+ if (!*kwds2)
+ goto bad;
+ for (i = 0, p = kwd_list; *p; i++, p++) {
+ x = PyDict_GetItemString(*kwds, *p);
+ if (x) {
+ if (PyDict_SetItemString(kwds1, *p, x) < 0)
+ goto bad;
+ if (PyDict_DelItemString(*kwds2, *p) < 0)
+ goto bad;
+ }
+ else if (rqd_kwds && rqd_kwds[i])
+ goto missing_kwarg;
+ }
+ }
+ else {
+ *kwds2 = PyDict_New();
+ if (!*kwds2)
+ goto bad;
+ }
+ }
+ else {
+ kwds1 = *kwds;
+ Py_XINCREF(kwds1);
+ if (rqd_kwds && *kwds)
+ for (i = 0, p = kwd_list; *p; i++, p++)
+ if (rqd_kwds[i] && !PyDict_GetItemString(*kwds, *p))
+ goto missing_kwarg;
+ }
+
+ *args = args1;
+ *kwds = kwds1;
+ return 0;
+missing_kwarg:
+ PyErr_Format(PyExc_TypeError,
+ "required keyword argument '%s' is missing", *p);
+bad:
+ Py_XDECREF(args1);
+ Py_XDECREF(kwds1);
+ if (args2) {
+ Py_XDECREF(*args2);
+ }
+ if (kwds2) {
+ Py_XDECREF(*kwds2);
+ }
+ return -1;
+}
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
+ PyObject *__import__ = 0;
+ PyObject *empty_list = 0;
+ PyObject *module = 0;
+ PyObject *global_dict = 0;
+ PyObject *empty_dict = 0;
+ PyObject *list;
+ __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
+ if (!__import__)
+ goto bad;
+ if (from_list)
+ list = from_list;
+ else {
+ empty_list = PyList_New(0);
+ if (!empty_list)
+ goto bad;
+ list = empty_list;
+ }
+ global_dict = PyModule_GetDict(__pyx_m);
+ if (!global_dict)
+ goto bad;
+ empty_dict = PyDict_New();
+ if (!empty_dict)
+ goto bad;
+ module = PyObject_CallFunction(__import__, "OOOO",
+ name, global_dict, empty_dict, list);
+bad:
+ Py_XDECREF(empty_list);
+ Py_XDECREF(__import__);
+ Py_XDECREF(empty_dict);
+ return module;
+}
+
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
PyObject *result;
result = PyObject_GetAttr(dict, name);
@@ -9837,103 +10184,6 @@ bad:
return -1;
}
-static int __Pyx_GetStarArgs(
- PyObject **args,
- PyObject **kwds,
- char *kwd_list[],
- Py_ssize_t nargs,
- PyObject **args2,
- PyObject **kwds2,
- char rqd_kwds[])
-{
- PyObject *x = 0, *args1 = 0, *kwds1 = 0;
- int i;
- char **p;
-
- if (args2)
- *args2 = 0;
- if (kwds2)
- *kwds2 = 0;
-
- if (args2) {
- args1 = PyTuple_GetSlice(*args, 0, nargs);
- if (!args1)
- goto bad;
- *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_GET_SIZE(*args));
- if (!*args2)
- goto bad;
- }
- else if (PyTuple_GET_SIZE(*args) > nargs) {
- int m = nargs;
- int n = PyTuple_GET_SIZE(*args);
- PyErr_Format(PyExc_TypeError,
- "function takes at most %d positional arguments (%d given)",
- m, n);
- goto bad;
- }
- else {
- args1 = *args;
- Py_INCREF(args1);
- }
-
- if (rqd_kwds && !*kwds)
- for (i = 0, p = kwd_list; *p; i++, p++)
- if (rqd_kwds[i])
- goto missing_kwarg;
-
- if (kwds2) {
- if (*kwds) {
- kwds1 = PyDict_New();
- if (!kwds1)
- goto bad;
- *kwds2 = PyDict_Copy(*kwds);
- if (!*kwds2)
- goto bad;
- for (i = 0, p = kwd_list; *p; i++, p++) {
- x = PyDict_GetItemString(*kwds, *p);
- if (x) {
- if (PyDict_SetItemString(kwds1, *p, x) < 0)
- goto bad;
- if (PyDict_DelItemString(*kwds2, *p) < 0)
- goto bad;
- }
- else if (rqd_kwds && rqd_kwds[i])
- goto missing_kwarg;
- }
- }
- else {
- *kwds2 = PyDict_New();
- if (!*kwds2)
- goto bad;
- }
- }
- else {
- kwds1 = *kwds;
- Py_XINCREF(kwds1);
- if (rqd_kwds && *kwds)
- for (i = 0, p = kwd_list; *p; i++, p++)
- if (rqd_kwds[i] && !PyDict_GetItemString(*kwds, *p))
- goto missing_kwarg;
- }
-
- *args = args1;
- *kwds = kwds1;
- return 0;
-missing_kwarg:
- PyErr_Format(PyExc_TypeError,
- "required keyword argument '%s' is missing", *p);
-bad:
- Py_XDECREF(args1);
- Py_XDECREF(kwds1);
- if (args2) {
- Py_XDECREF(*args2);
- }
- if (kwds2) {
- Py_XDECREF(*kwds2);
- }
- return -1;
-}
-
static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
if (!type) {
PyErr_Format(PyExc_SystemError, "Missing type object");
@@ -9946,39 +10196,6 @@ static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
return 0;
}
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
- PyObject *__import__ = 0;
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
- if (!__import__)
- goto bad;
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- module = PyObject_CallFunction(__import__, "OOOO",
- name, global_dict, empty_dict, list);
-bad:
- Py_XDECREF(empty_list);
- Py_XDECREF(__import__);
- Py_XDECREF(empty_dict);
- return module;
-}
-
static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v) {
PyTypeObject *t = o->ob_type;
int r;
@@ -9994,13 +10211,21 @@ static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v) {
return r;
}
+static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
+ while (t->p) {
+ *t->p = PyString_InternFromString(t->s);
+ if (!*t->p)
+ return -1;
+ ++t;
+ }
+ return 0;
+}
+
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
while (t->p) {
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
if (!*t->p)
return -1;
- if (t->i)
- PyString_InternInPlace(t->p);
++t;
}
return 0;
diff --git a/numpy/random/mtrand/mtrand.pyx b/numpy/random/mtrand/mtrand.pyx
index 1551270a4..ae9f314ca 100644
--- a/numpy/random/mtrand/mtrand.pyx
+++ b/numpy/random/mtrand/mtrand.pyx
@@ -467,22 +467,29 @@ cdef double kahan_sum(double *darr, long n):
return sum
cdef class RandomState:
- """Container for the Mersenne Twister PRNG.
+ """
+ RandomState(seed=None)
- Constructor
- -----------
- RandomState(seed=None): initializes the PRNG with the given seed. See the
- seed() method for details.
+ Container for the Mersenne Twister PRNG.
- Distribution Methods
- -----------------
- RandomState exposes a number of methods for generating random numbers drawn
- from a variety of probability distributions. In addition to the
+ `RandomState` exposes a number of methods for generating random numbers
+ drawn from a variety of probability distributions. In addition to the
distribution-specific arguments, each method takes a keyword argument
- size=None. If size is None, then a single value is generated and returned.
- If size is an integer, then a 1-D numpy array filled with generated values
- is returned. If size is a tuple, then a numpy array with that shape is
- filled and returned.
+ `size` that defaults to ``None``. If `size` is ``None``, then a single
+ value is generated and returned. If `size` is an integer, then a 1-D
+ numpy array filled with generated values is returned. If size is a tuple,
+ then a numpy array with that shape is filled and returned.
+
+ Parameters
+ ----------
+ seed : {None, int, array-like}
+ Random seed initializing the PRNG.
+ Can be an integer, an array (or other sequence) of integers of
+ any length, or ``None``.
+ If `seed` is ``None``, then `RandomState` will try to read data from
+ ``/dev/urandom`` (or the Windows analogue) if available or seed from
+ the clock otherwise.
+
"""
cdef rk_state *internal_state
@@ -497,14 +504,16 @@ cdef class RandomState:
self.internal_state = NULL
def seed(self, seed=None):
- """Seed the generator.
-
+ """
seed(seed=None)
+ Seed the generator.
+
seed can be an integer, an array (or other sequence) of integers of any
length, or None. If seed is None, then RandomState will try to read data
from /dev/urandom (or the Windows analogue) if available or seed from
the clock otherwise.
+
"""
cdef rk_error errcode
cdef ndarray obj "arrayObject_obj"
@@ -521,9 +530,13 @@ cdef class RandomState:
obj.dimensions[0])
def get_state(self):
- """Return a tuple representing the internal state of the generator.
+ """
+ get_state()
+
+ Return a tuple representing the internal state of the generator::
+
+ ('MT19937', int key[624], int pos, int has_gauss, float cached_gaussian)
- get_state() -> ('MT19937', int key[624], int pos, int has_gauss, float cached_gaussian)
"""
cdef ndarray state "arrayObject_state"
state = <ndarray>np.empty(624, np.uint)
@@ -533,7 +546,10 @@ cdef class RandomState:
self.internal_state.has_gauss, self.internal_state.gauss)
def set_state(self, state):
- """Set the state from a tuple.
+ """
+ set_state(state)
+
+ Set the state from a tuple.
state = ('MT19937', int key[624], int pos, int has_gauss, float cached_gaussian)
@@ -542,7 +558,6 @@ cdef class RandomState:
state = ('MT19937', int key[624], int pos)
- set_state(state)
"""
cdef ndarray obj "arrayObject_obj"
cdef int pos
@@ -579,25 +594,50 @@ cdef class RandomState:
# Basic distributions:
def random_sample(self, size=None):
- """Return random floats in the half-open interval [0.0, 1.0).
+ """
+ random_sample(size=None)
+
+ Return random floats in the half-open interval [0.0, 1.0).
- random_sample(size=None) -> random values
"""
return cont0_array(self.internal_state, rk_double, size)
def tomaxint(self, size=None):
- """Returns random integers x such that 0 <= x <= sys.maxint.
+ """
+ tomaxint(size=None)
+
+ Uniformly sample discrete random integers `x` such that
+ ``0 <= x <= sys.maxint``.
+
+ Parameters
+ ----------
+ size : tuple of ints, int, optional
+ Shape of output. If the given size is, for example, (m,n,k),
+ m*n*k samples are generated. If no shape is specified, a single sample
+ is returned.
+
+ Returns
+ -------
+ out : ndarray
+ Drawn samples, with shape `size`.
+
+ See Also
+ --------
+ randint : Uniform sampling over a given half-open interval of integers.
+ random_integers : Uniform sampling over a given closed interval of
+ integers.
- tomaxint(size=None) -> random values
"""
return disc0_array(self.internal_state, rk_long, size)
def randint(self, low, high=None, size=None):
- """Return random integers x such that low <= x < high.
+ """
+ randint(low, high=None, size=None)
- randint(low, high=None, size=None) -> random values
+ Return random integers x such that low <= x < high.
If high is None, then 0 <= x < low.
+
"""
cdef long lo, hi, diff
cdef long *array_data
@@ -627,9 +667,26 @@ cdef class RandomState:
return array
def bytes(self, unsigned int length):
- """Return random bytes.
+ """
+ bytes(length)
+
+ Return random bytes.
+
+ Parameters
+ ----------
+ length : int
+ Number of random bytes.
+
+ Returns
+ -------
+ out : str
+ String of length `N`.
+
+ Examples
+ --------
+ >>> np.random.bytes(10)
+ ' eh\x85\x022SZ\xbf\xa4' #random
- bytes(length) -> str
"""
cdef void *bytes
bytestring = PyString_FromStringAndSize(NULL, length)
@@ -638,9 +695,75 @@ cdef class RandomState:
return bytestring
def uniform(self, low=0.0, high=1.0, size=None):
- """Uniform distribution over [low, high).
+ """
+ uniform(low=0.0, high=1.0, size=1)
+
+ Draw samples from a uniform distribution.
+
+ Samples are uniformly distributed over the half-open interval
+ ``[low, high)`` (includes low, but excludes high). In other words,
+ any value within the given interval is equally likely to be drawn
+ by `uniform`.
+
+ Parameters
+ ----------
+ low : float, optional
+ Lower boundary of the output interval. All values generated will be
+ greater than or equal to low. The default value is 0.
+ high : float
+ Upper boundary of the output interval. All values generated will be
+ less than high. The default value is 1.0.
+ size : tuple of ints, int, optional
+ Shape of output. If the given size is, for example, (m,n,k),
+ m*n*k samples are generated. If no shape is specified, a single sample
+ is returned.
+
+ Returns
+ -------
+ out : ndarray
+ Drawn samples, with shape `size`.
+
+ See Also
+ --------
+ randint : Discrete uniform distribution, yielding integers.
+ random_integers : Discrete uniform distribution over the closed interval
+ ``[low, high]``.
+ random_sample : Floats uniformly distributed over ``[0, 1)``.
+ random : Alias for `random_sample`.
+ rand : Convenience function that accepts dimensions as input, e.g.,
+ ``rand(2,2)`` would generate a 2-by-2 array of floats, uniformly
+ distributed over ``[0, 1)``.
+
+ Notes
+ -----
+ The probability density function of the uniform distribution is
+
+ .. math:: p(x) = \\frac{1}{b - a}
+
+ anywhere within the interval ``[a, b)``, and zero elsewhere.
+
+ Examples
+ --------
+ Draw samples from the distribution:
+
+ >>> s = np.random.uniform(-1,0,1000)
+
+ All values are within the given interval:
+
+ >>> np.all(s >= -1)
+ True
+
+ >>> np.all(s < 0)
+ True
+
+ Display the histogram of the samples, along with the
+ probability density function:
+
+ >>> import matplotlib.pyplot as plt
+ >>> count, bins, ignored = plt.hist(s, 15, normed=True)
+ >>> plt.plot(bins, np.ones_like(bins), linewidth=2, color='r')
+ >>> plt.show()
- uniform(low=0.0, high=1.0, size=None) -> random values
"""
cdef ndarray olow, ohigh, odiff
cdef double flow, fhigh
@@ -660,14 +783,41 @@ cdef class RandomState:
return cont2_array(self.internal_state, rk_uniform, size, olow, odiff)
def rand(self, *args):
- """Return an array of the given dimensions which is initialized to
- random numbers from a uniform distribution in the range [0,1).
+ """
+ rand(d0, d1, ..., dn)
- rand(d0, d1, ..., dn) -> random values
+ Random values in a given shape.
- Note: This is a convenience function. If you want an
- interface that takes a tuple as the first argument
- use numpy.random.random_sample(shape_tuple).
+ Create an array of the given shape and propagate it with
+ random samples from a uniform distribution
+ over ``[0, 1)``.
+
+ Parameters
+ ----------
+ d0, d1, ..., dn : int
+ Shape of the output.
+
+ Returns
+ -------
+ out : ndarray, shape ``(d0, d1, ..., dn)``
+ Random values.
+
+ See Also
+ --------
+ random
+
+ Notes
+ -----
+ This is a convenience function. If you want an interface that
+ takes a shape-tuple as the first argument, refer to
+ `random`.
+
+ Examples
+ --------
+ >>> np.random.rand(3,2)
+ array([[ 0.14022471, 0.96360618], #random
+ [ 0.37601032, 0.25528411], #random
+ [ 0.49313049, 0.94909878]]) #random
"""
if len(args) == 0:
@@ -676,14 +826,16 @@ cdef class RandomState:
return self.random_sample(size=args)
def randn(self, *args):
- """Returns zero-mean, unit-variance Gaussian random numbers in an
- array of shape (d0, d1, ..., dn).
+ """
+ randn(d0, d1, ..., dn)
- randn(d0, d1, ..., dn) -> random values
+ Returns zero-mean, unit-variance Gaussian random numbers in an
+ array of shape (d0, d1, ..., dn).
Note: This is a convenience function. If you want an
interface that takes a tuple as the first argument
use numpy.random.standard_normal(shape_tuple).
+
"""
if len(args) == 0:
return self.standard_normal()
@@ -691,11 +843,13 @@ cdef class RandomState:
return self.standard_normal(args)
def random_integers(self, low, high=None, size=None):
- """Return random integers x such that low <= x <= high.
+ """
+ random_integers(low, high=None, size=None)
- random_integers(low, high=None, size=None) -> random values.
+ Return random integers x such that low <= x <= high.
If high is None, then 1 <= x <= low.
+
"""
if high is None:
high = low
@@ -704,16 +858,95 @@ cdef class RandomState:
# Complicated, continuous distributions:
def standard_normal(self, size=None):
- """Standard Normal distribution (mean=0, stdev=1).
+ """
+ standard_normal(size=None)
+
+ Standard Normal distribution (mean=0, stdev=1).
- standard_normal(size=None) -> random values
"""
return cont0_array(self.internal_state, rk_gauss, size)
def normal(self, loc=0.0, scale=1.0, size=None):
- """Normal distribution (mean=loc, stdev=scale).
+ """
+ normal(loc=0.0, scale=1.0, size=None)
+
+ Draw random samples from a normal (Gaussian) distribution.
+
+ The probability density function of the normal distribution, first
+ derived by De Moivre and 200 years later by both Gauss and Laplace
+ independently [2]_, is often called the bell curve because of
+ its characteristic shape (see the example below).
+
+ The normal distributions occurs often in nature. For example, it
+ describes the commonly occurring distribution of samples influenced
+ by a large number of tiny, random disturbances, each with its own
+ unique distribution [2]_.
+
+ Parameters
+ ----------
+ loc : float
+ Mean ("centre") of the distribution.
+ scale : float
+ Standard deviation (spread or "width") of the distribution.
+ size : tuple of ints
+ Output shape. If the given shape is, e.g., ``(m, n, k)``, then
+ ``m * n * k`` samples are drawn.
+
+ See Also
+ --------
+ scipy.stats.distributions.norm : probability density function,
+ distribution or cumulative density function, etc.
+
+ Notes
+ -----
+ The probability density for the Gaussian distribution is
+
+ .. math:: p(x) = \\frac{1}{\\sqrt{ 2 \\pi \\sigma^2 }}
+ e^{ - \\frac{ (x - \\mu)^2 } {2 \\sigma^2} },
+
+ where :math:`\\mu` is the mean and :math:`\\sigma` the standard deviation.
+ The square of the standard deviation, :math:`\\sigma^2`, is called the
+ variance.
+
+ The function has its peak at the mean, and its "spread" increases with
+ the standard deviation (the function reaches 0.607 times its maximum at
+ :math:`x + \\sigma` and :math:`x - \\sigma` [2]_). This implies that
+ `numpy.random.normal` is more likely to return samples lying close to the
+ mean, rather than those far away.
+
+ References
+ ----------
+ .. [1] Wikipedia, "Normal distribution",
+ http://en.wikipedia.org/wiki/Normal_distribution
+ .. [2] P. R. Peebles Jr., "Central Limit Theorem" in "Probability, Random
+ Variables and Random Signal Principles", 4th ed., 2001,
+ pp. 51, 51, 125.
+
+ Examples
+ --------
+ Draw samples from the distribution:
+
+ >>> mu, sigma = 0, 0.1 # mean and standard deviation
+ >>> s = np.random.normal(mu, sigma, 1000)
+
+ Verify the mean and the variance:
+
+ >>> abs(mu - np.mean(s)) < 0.01
+ True
+
+ >>> abs(sigma - np.std(s, ddof=1)) < 0.01
+ True
+
+ Display the histogram of the samples, along with
+ the probability density function:
+
+ >>> import matplotlib.pyplot as plt
+ >>> count, bins, ignored = plt.hist(s, 30, normed=True)
+ >>> plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) * \
+ ... np.exp( - (bins - mu)**2 / (2 * sigma**2) ),
+ ... linewidth=2, color='r')
+ >>> plt.show()
- normal(loc=0.0, scale=1.0, size=None) -> random values
"""
cdef ndarray oloc, oscale
cdef double floc, fscale
@@ -734,9 +967,41 @@ cdef class RandomState:
return cont2_array(self.internal_state, rk_normal, size, oloc, oscale)
def beta(self, a, b, size=None):
- """Beta distribution over [0, 1].
+ """
+ beta(a, b, size=None)
+
+ The Beta distribution over ``[0, 1]``.
+
+ The Beta distribution is a special case of the Dirichlet distribution,
+ and is related to the Gamma distribution. It has the probability
+ distribution function
+
+ .. math:: f(x; a,b) = \\frac{1}{B(\\alpha, \\beta)} x^{\\alpha - 1}
+ (1 - x)^{\\beta - 1},
+
+ where the normalisation, B, is the beta function,
+
+ .. math:: B(\\alpha, \\beta) = \\int_0^1 t^{\\alpha - 1}
+ (1 - t)^{\\beta - 1} dt.
+
+ It is often seen in Bayesian inference and order statistics.
+
+ Parameters
+ ----------
+ a : float
+ Alpha, non-negative.
+ b : float
+ Beta, non-negative.
+ size : tuple of ints, optional
+ The number of samples to draw. The ouput is packed according to
+ the size given.
+
+ Returns
+ -------
+ out : ndarray
+ Array of the given shape, containing values drawn from a
+ Beta distribution.
- beta(a, b, size=None) -> random values
"""
cdef ndarray oa, ob
cdef double fa, fb
@@ -761,9 +1026,38 @@ cdef class RandomState:
return cont2_array(self.internal_state, rk_beta, size, oa, ob)
def exponential(self, scale=1.0, size=None):
- """Exponential distribution.
+ """
+ exponential(scale=1.0, size=None)
+
+ Exponential distribution.
+
+ Its probability density function is
+
+ .. math:: f(x; \\lambda) = \\lambda \\exp(-\\lambda x),
+
+ for ``x > 0`` and 0 elsewhere. :math:`lambda` is
+ known as the rate parameter.
+
+ The exponential distribution is a continuous analogue of the
+ geometric distribution. It describes many common situations, such as
+ the size of raindrops measured over many rainstorms [1]_, or the time
+ between page requests to Wikipedia [2]_.
+
+ Parameters
+ ----------
+ scale : float
+ The rate parameter, :math:`\\lambda`.
+ size : tuple of ints
+ Number of samples to draw. The output is shaped
+ according to `size`.
+
+ References
+ ----------
+ .. [1] Peyton Z. Peebles Jr., "Probability, Random Variables and
+ Random Signal Principles", 4th ed, 2001, p. 57.
+ .. [2] "Poisson Process", Wikipedia,
+ http://en.wikipedia.org/wiki/Poisson_process
- exponential(scale=1.0, size=None) -> random values
"""
cdef ndarray oscale
cdef double fscale
@@ -782,16 +1076,20 @@ cdef class RandomState:
return cont1_array(self.internal_state, rk_exponential, size, oscale)
def standard_exponential(self, size=None):
- """Standard exponential distribution (scale=1).
+ """
+ standard_exponential(size=None)
+
+ Standard exponential distribution (scale=1).
- standard_exponential(size=None) -> random values
"""
return cont0_array(self.internal_state, rk_standard_exponential, size)
def standard_gamma(self, shape, size=None):
- """Standard Gamma distribution.
+ """
+ standard_gamma(shape, size=None)
+
+ Standard Gamma distribution.
- standard_gamma(shape, size=None) -> random values
"""
cdef ndarray oshape
cdef double fshape
@@ -809,9 +1107,11 @@ cdef class RandomState:
return cont1_array(self.internal_state, rk_standard_gamma, size, oshape)
def gamma(self, shape, scale=1.0, size=None):
- """Gamma distribution.
+ """
+ gamma(shape, scale=1.0, size=None)
+
+ Gamma distribution.
- gamma(shape, scale=1.0, size=None) -> random values
"""
cdef ndarray oshape, oscale
cdef double fshape, fscale
@@ -835,9 +1135,11 @@ cdef class RandomState:
return cont2_array(self.internal_state, rk_gamma, size, oshape, oscale)
def f(self, dfnum, dfden, size=None):
- """F distribution.
+ """
+ f(dfnum, dfden, size=None)
+
+ F distribution.
- f(dfnum, dfden, size=None) -> random values
"""
cdef ndarray odfnum, odfden
cdef double fdfnum, fdfden
@@ -862,9 +1164,11 @@ cdef class RandomState:
return cont2_array(self.internal_state, rk_f, size, odfnum, odfden)
def noncentral_f(self, dfnum, dfden, nonc, size=None):
- """Noncentral F distribution.
+ """
+ noncentral_f(dfnum, dfden, nonc, size=None)
+
+ Noncentral F distribution.
- noncentral_f(dfnum, dfden, nonc, size=None) -> random values
"""
cdef ndarray odfnum, odfden, ononc
cdef double fdfnum, fdfden, fnonc
@@ -898,9 +1202,68 @@ cdef class RandomState:
odfden, ononc)
def chisquare(self, df, size=None):
- """Chi^2 distribution.
+ """
+ chisquare(df, size=None)
+
+ Draw samples from a chi-square distribution.
+
+ When `df` independent random variables, each with standard
+ normal distributions (mean 0, variance 1), are squared and summed,
+ the resulting distribution is chi-square (see Notes). This
+ distribution is often used in hypothesis testing.
+
+ Parameters
+ ----------
+ df : int
+ Number of degrees of freedom.
+ size : tuple of ints, int, optional
+ Size of the returned array. By default, a scalar is
+ returned.
+
+ Returns
+ -------
+ output : ndarray
+ Samples drawn from the distribution, packed in a `size`-shaped
+ array.
+
+ Raises
+ ------
+ ValueError
+ When `df` <= 0 or when an inappropriate `size` (e.g. ``size=-1``)
+ is given.
+
+ Notes
+ -----
+ The variable obtained by summing the squares of `df` independent,
+ standard normally distributed random variables:
+
+ .. math:: Q = \\sum_{i=0}^{\\mathtt{df}} X^2_i
+
+ is chi-square distributed, denoted
+
+ .. math:: Q \\sim \\chi^2_k.
+
+ The probability density function of the chi-squared distribution is
+
+ .. math:: p(x) = \\frac{(1/2)^{k/2}}{\\Gamma(k/2)}
+ x^{k/2 - 1} e^{-x/2},
+
+ where :math:`\\Gamma` is the gamma function,
+
+ .. math:: \\Gamma(x) = \\int_0^{-\\infty} t^{x - 1} e^{-t} dt.
+
+ References
+ ----------
+ .. [1] NIST/SEMATECH e-Handbook of Statistical Methods,
+ http://www.itl.nist.gov/div898/handbook/eda/section3/eda3666.htm
+ .. [2] Wikipedia, "Chi-square distribution",
+ http://en.wikipedia.org/wiki/Chi-square_distribution
+
+ Examples
+ --------
+ >>> np.random.chisquare(2,4)
+ array([ 1.89920014, 9.00867716, 3.13710533, 5.62318272])
- chisquare(df, size=None) -> random values
"""
cdef ndarray odf
cdef double fdf
@@ -919,9 +1282,23 @@ cdef class RandomState:
return cont1_array(self.internal_state, rk_chisquare, size, odf)
def noncentral_chisquare(self, df, nonc, size=None):
- """Noncentral Chi^2 distribution.
+ """
+ noncentral_chisquare(df, nonc, size=None)
+
+ Draw samples from a noncentral chi-square distribution.
+
+ The noncentral :math:`\\chi^2` distribution is a generalisation of
+ the :math:`\\chi^2` distribution.
+
+ Parameters
+ ----------
+ df : int
+ Degrees of freedom.
+ nonc : float
+ Non-centrality.
+ size : tuple of ints
+ Shape of the output.
- noncentral_chisquare(df, nonc, size=None) -> random values
"""
cdef ndarray odf, ononc
cdef double fdf, fnonc
@@ -947,16 +1324,20 @@ cdef class RandomState:
odf, ononc)
def standard_cauchy(self, size=None):
- """Standard Cauchy with mode=0.
-
+ """
standard_cauchy(size=None)
+
+ Standard Cauchy with mode=0.
+
"""
return cont0_array(self.internal_state, rk_standard_cauchy, size)
def standard_t(self, df, size=None):
- """Standard Student's t distribution with df degrees of freedom.
-
+ """
standard_t(df, size=None)
+
+ Standard Student's t distribution with df degrees of freedom.
+
"""
cdef ndarray odf
cdef double fdf
@@ -975,10 +1356,81 @@ cdef class RandomState:
return cont1_array(self.internal_state, rk_standard_t, size, odf)
def vonmises(self, mu, kappa, size=None):
- """von Mises circular distribution with mode mu and dispersion parameter
- kappa on [-pi, pi].
+ """
+ vonmises(mu=0.0, kappa=1.0, size=None)
+
+ Draw samples from a von Mises distribution.
+
+ Samples are drawn from a von Mises distribution with specified mode (mu)
+ and dispersion (kappa), on the interval [-pi, pi].
+
+ The von Mises distribution (also known as the circular normal
+ distribution) is a continuous probability distribution on the circle. It
+ may be thought of as the circular analogue of the normal distribution.
+
+ Parameters
+ ----------
+ mu : float
+ Mode ("center") of the distribution.
+ kappa : float, >= 0.
+ Dispersion of the distribution.
+ size : {tuple, int}
+ Output shape. If the given shape is, e.g., ``(m, n, k)``, then
+ ``m * n * k`` samples are drawn.
+
+ Returns
+ -------
+ samples : {ndarray, scalar}
+ The returned samples live on the unit circle [-\\pi, \\pi].
+
+ See Also
+ --------
+ scipy.stats.distributions.vonmises : probability density function,
+ distribution or cumulative density function, etc.
+
+ Notes
+ -----
+ The probability density for the von Mises distribution is
+
+ .. math:: p(x) = \\frac{e^{\\kappa cos(x-\\mu)}}{2\\pi I_0(\\kappa)},
+
+ where :math:`\\mu` is the mode and :math:`\\kappa` the dispersion,
+ and :math:`I_0(\\kappa)` is the modified Bessel function of order 0.
+
+ The von Mises, named for Richard Edler von Mises, born in
+ Austria-Hungary, in what is now the Ukraine. He fled to the United
+ States in 1939 and became a professor at Harvard. He worked in
+ probability theory, aerodynamics, fluid mechanics, and philosophy of
+ science.
+
+ References
+ ----------
+ .. [1] Abramowitz, M. and Stegun, I. A. (ed.), Handbook of Mathematical
+ Functions, National Bureau of Standards, 1964; reprinted Dover
+ Publications, 1965.
+ .. [2] von Mises, Richard, 1964, Mathematical Theory of Probability
+ and Statistics (New York: Academic Press).
+ .. [3] Wikipedia, "Von Mises distribution",
+ http://en.wikipedia.org/wiki/Von_Mises_distribution
+
+ Examples
+ --------
+ Draw samples from the distribution:
+
+ >>> mu, kappa = 0.0, 4.0 # mean and dispersion
+ >>> s = np.random.vonmises(mu, kappa, 1000)
+
+ Display the histogram of the samples, along with
+ the probability density function:
+
+ >>> import matplotlib.pyplot as plt
+ >>> import scipy.special as sps
+ >>> count, bins, ignored = plt.hist(s, 50, normed=True)
+ >>> x = arange(-pi, pi, 2*pi/50.)
+ >>> y = -np.exp(kappa*np.cos(x-mu))/(2*pi*sps.jn(0,kappa))
+ >>> plt.plot(x, y/max(y), linewidth=2, color='r')
+ >>> plt.show()
- vonmises(mu, kappa, size=None)
"""
cdef ndarray omu, okappa
cdef double fmu, fkappa
@@ -999,9 +1451,77 @@ cdef class RandomState:
return cont2_array(self.internal_state, rk_vonmises, size, omu, okappa)
def pareto(self, a, size=None):
- """Pareto distribution.
-
+ """
pareto(a, size=None)
+
+ Draw samples from a Pareto distribution with specified shape.
+
+ This is a simplified version of the Generalized Pareto distribution
+ (available in SciPy), with the scale set to one and the location set to
+ zero. Most authors default the location to one.
+
+ The Pareto distribution must be greater than zero, and is unbounded above.
+ It is also known as the "80-20 rule". In this distribution, 80 percent of
+ the weights are in the lowest 20 percent of the range, while the other 20
+ percent fill the remaining 80 percent of the range.
+
+ Parameters
+ ----------
+ shape : float, > 0.
+ Shape of the distribution.
+ size : tuple of ints
+ Output shape. If the given shape is, e.g., ``(m, n, k)``, then
+ ``m * n * k`` samples are drawn.
+
+ See Also
+ --------
+ scipy.stats.distributions.genpareto.pdf : probability density function,
+ distribution or cumulative density function, etc.
+
+ Notes
+ -----
+ The probability density for the Pareto distribution is
+
+ .. math:: p(x) = \\frac{am^a}{x^{a+1}}
+
+ where :math:`a` is the shape and :math:`m` the location
+
+ The Pareto distribution, named after the Italian economist Vilfredo Pareto,
+ is a power law probability distribution useful in many real world problems.
+ Outside the field of economics it is generally referred to as the Bradford
+ distribution. Pareto developed the distribution to describe the
+ distribution of wealth in an economy. It has also found use in insurance,
+ web page access statistics, oil field sizes, and many other problems,
+ including the download frequency for projects in Sourceforge [1]. It is
+ one of the so-called "fat-tailed" distributions.
+
+
+ References
+ ----------
+ .. [1] Francis Hunt and Paul Johnson, On the Pareto Distribution of
+ Sourceforge projects.
+ .. [2] Pareto, V. (1896). Course of Political Economy. Lausanne.
+ .. [3] Reiss, R.D., Thomas, M.(2001), Statistical Analysis of Extreme
+ Values, Birkhauser Verlag, Basel, pp 23-30.
+ .. [4] Wikipedia, "Pareto distribution",
+ http://en.wikipedia.org/wiki/Pareto_distribution
+
+ Examples
+ --------
+ Draw samples from the distribution:
+
+ >>> a, m = 3., 1. # shape and mode
+ >>> s = np.random.pareto(a, 1000) + m
+
+ Display the histogram of the samples, along with
+ the probability density function:
+
+ >>> import matplotlib.pyplot as plt
+ >>> count, bins, ignored = plt.hist(s, 100, normed=True, align='center')
+ >>> fit = a*m**a/bins**(a+1)
+ >>> plt.plot(bins, max(count)*fit/max(fit),linewidth=2, color='r')
+ >>> plt.show()
+
"""
cdef ndarray oa
cdef double fa
@@ -1020,9 +1540,87 @@ cdef class RandomState:
return cont1_array(self.internal_state, rk_pareto, size, oa)
def weibull(self, a, size=None):
- """Weibull distribution.
-
+ """
weibull(a, size=None)
+
+ Weibull distribution.
+
+ Draw samples from a 1-parameter Weibull distribution with the given
+ shape parameter.
+
+ .. math:: X = (-ln(U))^{1/a}
+
+ Here, U is drawn from the uniform distribution over (0,1].
+
+ The more common 2-parameter Weibull, including a scale parameter
+ :math:`\\lambda` is just :math:`X = \\lambda(-ln(U))^{1/a}`.
+
+ The Weibull (or Type III asymptotic extreme value distribution for smallest
+ values, SEV Type III, or Rosin-Rammler distribution) is one of a class of
+ Generalized Extreme Value (GEV) distributions used in modeling extreme
+ value problems. This class includes the Gumbel and Frechet distributions.
+
+ Parameters
+ ----------
+ a : float
+ Shape of the distribution.
+ size : tuple of ints
+ Output shape. If the given shape is, e.g., ``(m, n, k)``, then
+ ``m * n * k`` samples are drawn.
+
+ See Also
+ --------
+ scipy.stats.distributions.weibull : probability density function,
+ distribution or cumulative density function, etc.
+
+ gumbel, scipy.stats.distributions.genextreme
+
+ Notes
+ -----
+ The probability density for the Weibull distribution is
+
+ .. math:: p(x) = \\frac{a}
+ {\\lambda}(\\frac{x}{\\lambda})^{a-1}e^{-(x/\\lambda)^a},
+
+ where :math:`a` is the shape and :math:`\\lambda` the scale.
+
+ The function has its peak (the mode) at
+ :math:`\\lambda(\\frac{a-1}{a})^{1/a}`.
+
+ When ``a = 1``, the Weibull distribution reduces to the exponential
+ distribution.
+
+ References
+ ----------
+ .. [1] Waloddi Weibull, Professor, Royal Technical University, Stockholm,
+ 1939 "A Statistical Theory Of The Strength Of Materials",
+ Ingeniorsvetenskapsakademiens Handlingar Nr 151, 1939,
+ Generalstabens Litografiska Anstalts Forlag, Stockholm.
+ .. [2] Waloddi Weibull, 1951 "A Statistical Distribution Function of Wide
+ Applicability", Journal Of Applied Mechanics ASME Paper.
+ .. [3] Wikipedia, "Weibull distribution",
+ http://en.wikipedia.org/wiki/Weibull_distribution
+
+ Examples
+ --------
+ Draw samples from the distribution:
+
+ >>> a = 5. # shape
+ >>> s = np.random.weibull(a, 1000)
+
+ Display the histogram of the samples, along with
+ the probability density function:
+
+ >>> import matplotlib.pyplot as plt
+ >>> def weib(x,n,a):
+ ... return (a/n)*(x/n)**(a-1)*exp(-(x/n)**a)
+
+ >>> count, bins, ignored = plt.hist(numpy.random.weibull(5.,1000))
+ >>> scale = count.max()/weib(x, 1., 5.).max()
+ >>> x = arange(1,100.)/50.
+ >>> plt.plot(x, weib(x, 1., 5.)*scale)
+ >>> plt.show()
+
"""
cdef ndarray oa
cdef double fa
@@ -1041,9 +1639,11 @@ cdef class RandomState:
return cont1_array(self.internal_state, rk_weibull, size, oa)
def power(self, a, size=None):
- """Power distribution.
-
+ """
power(a, size=None)
+
+ Power distribution.
+
"""
cdef ndarray oa
cdef double fa
@@ -1062,9 +1662,26 @@ cdef class RandomState:
return cont1_array(self.internal_state, rk_power, size, oa)
def laplace(self, loc=0.0, scale=1.0, size=None):
- """Laplace distribution.
-
+ """
laplace(loc=0.0, scale=1.0, size=None)
+
+ Laplace or double exponential distribution.
+
+ It has the probability density function
+
+ .. math:: f(x; \\mu, \\lambda) = \\frac{1}{2\\lambda}
+ \\exp\\left(-\\frac{|x - \\mu|}{\\lambda}\\right).
+
+ The Laplace distribution is similar to the Gaussian/normal distribution,
+ but is sharper at the peak and has fatter tails.
+
+ Parameters
+ ----------
+ loc : float
+ The position, :math:`\\mu`, of the distribution peak.
+ scale : float
+ :math:`\\lambda`, the exponential decay.
+
"""
cdef ndarray oloc, oscale
cdef double floc, fscale
@@ -1084,9 +1701,111 @@ cdef class RandomState:
return cont2_array(self.internal_state, rk_laplace, size, oloc, oscale)
def gumbel(self, loc=0.0, scale=1.0, size=None):
- """Gumbel distribution.
-
+ """
gumbel(loc=0.0, scale=1.0, size=None)
+
+ Gumbel distribution.
+
+ Draw samples from a Gumbel distribution with specified location (or mean)
+ and scale (or standard deviation).
+
+ The Gumbel (or Smallest Extreme Value (SEV) or the Smallest Extreme Value
+ Type I) distribution is one of a class of Generalized Extreme Value (GEV)
+ distributions used in modeling extreme value problems. The Gumbel is a
+ special case of the Extreme Value Type I distribution for maximums from
+ distributions with "exponential-like" tails, it may be derived by
+ considering a Gaussian process of measurements, and generating the pdf for
+ the maximum values from that set of measurements (see examples).
+
+ Parameters
+ ----------
+ loc : float
+ The location of the mode of the distribution.
+ scale : float
+ The scale parameter of the distribution.
+ size : tuple of ints
+ Output shape. If the given shape is, e.g., ``(m, n, k)``, then
+ ``m * n * k`` samples are drawn.
+
+ See Also
+ --------
+ scipy.stats.gumbel : probability density function,
+ distribution or cumulative density function, etc.
+ weibull, scipy.stats.genextreme
+
+ Notes
+ -----
+ The probability density for the Gumbel distribution is
+
+ .. math:: p(x) = \\frac{e^{-(x - \\mu)/ \\beta}}{\\beta} e^{ -e^{-(x - \\mu)/
+ \\beta}},
+
+ where :math:`\\mu` is the mode, a location parameter, and :math:`\\beta`
+ is the scale parameter.
+
+ The Gumbel (named for German mathematician Emil Julius Gumbel) was used
+ very early in the hydrology literature, for modeling the occurrence of
+ flood events. It is also used for modeling maximum wind speed and rainfall
+ rates. It is a "fat-tailed" distribution - the probability of an event in
+ the tail of the distribution is larger than if one used a Gaussian, hence
+ the surprisingly frequent occurrence of 100-year floods. Floods were
+ initially modeled as a Gaussian process, which underestimated the frequency
+ of extreme events.
+
+ It is one of a class of extreme value distributions, the Generalized
+ Extreme Value (GEV) distributions, which also includes the Weibull and
+ Frechet.
+
+ The function has a mean of :math:`\\mu + 0.57721\\beta` and a variance of
+ :math:`\\frac{\\pi^2}{6}\\beta^2`.
+
+ References
+ ----------
+ .. [1] Gumbel, E.J. (1958). Statistics of Extremes. Columbia University
+ Press.
+ .. [2] Reiss, R.-D. and Thomas M. (2001), Statistical Analysis of Extreme
+ Values, from Insurance, Finance, Hydrology and Other Fields,
+ Birkhauser Verlag, Basel: Boston : Berlin.
+ .. [3] Wikipedia, "Gumbel distribution",
+ http://en.wikipedia.org/wiki/Gumbel_distribution
+
+ Examples
+ --------
+ Draw samples from the distribution:
+
+ >>> mu, beta = 0, 0.1 # location and scale
+ >>> s = np.random.gumbel(mu, beta, 1000)
+
+ Display the histogram of the samples, along with
+ the probability density function:
+
+ >>> import matplotlib.pyplot as plt
+ >>> count, bins, ignored = plt.hist(s, 30, normed=True)
+ >>> plt.plot(bins, (1/beta)*np.exp(-(bins - mu)/beta)* \
+ ... np.exp( -np.exp( -(bins - mu) /beta) ),
+ ... linewidth=2, color='r')
+ >>> plt.show()
+
+ Show how an extreme value distribution can arise from a Gaussian process
+ and compare to a Gaussian:
+
+ >>> means = []
+ >>> maxima = []
+ >>> for i in range(0,1000) :
+ ... a = np.random.normal(mu, beta, 1000)
+ ... means.append(a.mean())
+ ... maxima.append(a.max())
+ >>> count, bins, ignored = plt.hist(maxima, 30, normed=True)
+ >>> beta = np.std(maxima)*np.pi/np.sqrt(6)
+ >>> mu = np.mean(maxima) - 0.57721*beta
+ >>> plt.plot(bins, (1/beta)*np.exp(-(bins - mu)/beta)* \
+ ... np.exp( -np.exp( -(bins - mu) /beta) ),
+ ... linewidth=2, color='r')
+ >>> plt.plot(bins, 1/(beta * np.sqrt(2 * np.pi)) * \
+ ... np.exp( - (bins - mu)**2 / (2 * beta**2) ),
+ ... linewidth=2, color='g')
+ >>> plt.show()
+
"""
cdef ndarray oloc, oscale
cdef double floc, fscale
@@ -1106,9 +1825,11 @@ cdef class RandomState:
return cont2_array(self.internal_state, rk_gumbel, size, oloc, oscale)
def logistic(self, loc=0.0, scale=1.0, size=None):
- """Logistic distribution.
-
+ """
logistic(loc=0.0, scale=1.0, size=None)
+
+ Logistic distribution.
+
"""
cdef ndarray oloc, oscale
cdef double floc, fscale
@@ -1128,14 +1849,116 @@ cdef class RandomState:
return cont2_array(self.internal_state, rk_logistic, size, oloc, oscale)
def lognormal(self, mean=0.0, sigma=1.0, size=None):
- """Log-normal distribution.
+ """
+ lognormal(mean=0.0, sigma=1.0, size=None)
- Note that the mean parameter is not the mean of this distribution, but
- the underlying normal distribution.
+ Log-normal distribution.
- lognormal(mean, sigma) <=> exp(normal(mean, sigma))
+ Draw samples from a log-normal distribution with specified mean, standard
+ deviation, and shape. Note that the mean and standard deviation are not the
+ values for the distribution itself, but of the underlying normal
+ distribution it is derived from.
+
+
+ Parameters
+ ----------
+ mean : float
+ Mean value of the underlying normal distribution
+ sigma : float, >0.
+ Standard deviation of the underlying normal distribution
+ size : tuple of ints
+ Output shape. If the given shape is, e.g., ``(m, n, k)``, then
+ ``m * n * k`` samples are drawn.
+
+ See Also
+ --------
+ scipy.stats.lognorm : probability density function, distribution,
+ cumulative density function, etc.
+
+ Notes
+ -----
+ A variable `x` has a log-normal distribution if `log(x)` is normally
+ distributed.
+
+ The probability density function for the log-normal distribution is
+
+ .. math:: p(x) = \\frac{1}{\\sigma x \\sqrt{2\\pi}}
+ e^{(-\\frac{(ln(x)-\\mu)^2}{2\\sigma^2})}
+
+ where :math:`\\mu` is the mean and :math:`\\sigma` is the standard deviation
+ of the normally distributed logarithm of the variable.
+
+ A log normal distribution results if a random variable is the *product* of
+ a large number of independent, identically-distributed variables in the
+ same way that a normal distribution results if the variable is the *sum*
+ of a large number of independent, identically-distributed variables
+ (see the last example). It is one of the so-called "fat-tailed"
+ distributions.
+
+ The log-normal distribution is commonly used to model the lifespan of units
+ with fatigue-stress failure modes. Since this includes
+ most mechanical systems, the lognormal distribution has widespread
+ application.
+
+ It is also commonly used to model oil field sizes, species abundance, and
+ latent periods of infectious diseases.
+
+ References
+ ----------
+ .. [1] Eckhard Limpert, Werner A. Stahel, and Markus Abbt, "Log-normal
+ Distributions across the Sciences: Keys and Clues", May 2001
+ Vol. 51 No. 5 BioScience
+ http://stat.ethz.ch/~stahel/lognormal/bioscience.pdf
+ .. [2] Reiss, R.D., Thomas, M.(2001), Statistical Analysis of Extreme
+ Values, Birkhauser Verlag, Basel, pp 31-32.
+ .. [3] Wikipedia, "Lognormal distribution",
+ http://en.wikipedia.org/wiki/Lognormal_distribution
+
+ Examples
+ --------
+ Draw samples from the distribution:
+
+ >>> mu, sigma = 3., 1. # mean and standard deviation
+ >>> s = np.random.lognormal(mu, sigma, 1000)
+
+ Display the histogram of the samples, along with
+ the probability density function:
+
+ >>> import matplotlib.pyplot as plt
+ >>> count, bins, ignored = plt.hist(s, 100, normed=True, align='center')
+
+ >>> x = np.linspace(min(bins), max(bins), 10000)
+ >>> pdf = np.exp(-(np.log(x) - mu)**2 / (2 * sigma**2)) \
+ ... / (x * sigma * np.sqrt(2 * np.pi))
+
+ >>> plt.plot(x, pdf, linewidth=2, color='r')
+ >>> plt.axis('tight')
+ >>> plt.show()
+
+ Demonstrate that taking the products of random samples from a uniform
+ distribution can be fit well by a log-normal pdf.
+
+ >>> # Generate a thousand samples: each is the product of 100 random
+ >>> # values, drawn from a normal distribution.
+ >>> b = []
+ >>> for i in range(1000):
+ ... a = 10. + np.random.random(100)
+ ... b.append(np.product(a))
+
+ >>> b = np.array(b) / np.min(b) # scale values to be positive
+
+ >>> count, bins, ignored = plt.hist(b, 100, normed=True, align='center')
+
+ >>> sigma = np.std(np.log(b))
+ >>> mu = np.mean(np.log(b))
+
+ >>> x = np.linspace(min(bins), max(bins), 10000)
+ >>> pdf = np.exp(-(np.log(x) - mu)**2 / (2 * sigma**2)) \
+ ... / (x * sigma * np.sqrt(2 * np.pi))
+
+ >>> plt.plot(x, pdf, color='r', linewidth=2)
+ >>> plt.show()
- lognormal(mean=0.0, sigma=1.0, size=None)
"""
cdef ndarray omean, osigma
cdef double fmean, fsigma
@@ -1157,9 +1980,11 @@ cdef class RandomState:
return cont2_array(self.internal_state, rk_lognormal, size, omean, osigma)
def rayleigh(self, scale=1.0, size=None):
- """Rayleigh distribution.
-
+ """
rayleigh(scale=1.0, size=None)
+
+ Rayleigh distribution.
+
"""
cdef ndarray oscale
cdef double fscale
@@ -1179,9 +2004,11 @@ cdef class RandomState:
return cont1_array(self.internal_state, rk_rayleigh, size, oscale)
def wald(self, mean, scale, size=None):
- """Wald (inverse Gaussian) distribution.
-
+ """
wald(mean, scale, size=None)
+
+ Wald (inverse Gaussian) distribution.
+
"""
cdef ndarray omean, oscale
cdef double fmean, fscale
@@ -1207,10 +2034,12 @@ cdef class RandomState:
def triangular(self, left, mode, right, size=None):
- """Triangular distribution starting at left, peaking at mode, and
+ """
+ triangular(left, mode, right, size=None)
+
+ Triangular distribution starting at left, peaking at mode, and
ending at right (left <= mode <= right).
- triangular(left, mode, right, size=None)
"""
cdef ndarray oleft, omode, oright
cdef double fleft, fmode, fright
@@ -1244,9 +2073,11 @@ cdef class RandomState:
# Complicated, discrete distributions:
def binomial(self, n, p, size=None):
- """Binomial distribution of n trials and p probability of success.
+ """
+ binomial(n, p, size=None)
+
+ Binomial distribution of n trials and p probability of success.
- binomial(n, p, size=None) -> random values
"""
cdef ndarray on, op
cdef long ln
@@ -1276,9 +2107,11 @@ cdef class RandomState:
return discnp_array(self.internal_state, rk_binomial, size, on, op)
def negative_binomial(self, n, p, size=None):
- """Negative Binomial distribution.
+ """
+ negative_binomial(n, p, size=None)
+
+ Negative Binomial distribution.
- negative_binomial(n, p, size=None) -> random values
"""
cdef ndarray on
cdef ndarray op
@@ -1311,9 +2144,11 @@ cdef class RandomState:
on, op)
def poisson(self, lam=1.0, size=None):
- """Poisson distribution.
+ """
+ poisson(lam=1.0, size=None)
+
+ Poisson distribution.
- poisson(lam=1.0, size=None) -> random values
"""
cdef ndarray olam
cdef double flam
@@ -1331,9 +2166,80 @@ cdef class RandomState:
return discd_array(self.internal_state, rk_poisson, size, olam)
def zipf(self, a, size=None):
- """Zipf distribution.
-
+ """
zipf(a, size=None)
+
+ Draw samples from a Zipf distribution.
+
+ Samples are drawn from a Zipf distribution with specified parameter (a),
+ where a > 1.
+
+ The zipf distribution (also known as the zeta
+ distribution) is a continuous probability distribution that satisfies
+ Zipf's law, where the frequency of an item is inversely proportional to
+ its rank in a frequency table.
+
+ Parameters
+ ----------
+ a : float
+ parameter, > 1.
+ size : {tuple, int}
+ Output shape. If the given shape is, e.g., ``(m, n, k)``, then
+ ``m * n * k`` samples are drawn.
+
+ Returns
+ -------
+ samples : {ndarray, scalar}
+ The returned samples are greater than or equal to one.
+
+ See Also
+ --------
+ scipy.stats.distributions.zipf : probability density function,
+ distribution or cumulative density function, etc.
+
+ Notes
+ -----
+ The probability density for the Zipf distribution is
+
+ .. math:: p(x) = \\frac{x^{-a}}{\\zeta(a)},
+
+ where :math:`\\zeta` is the Riemann Zeta function.
+
+ Named after the American linguist George Kingsley Zipf, who noted that
+ the frequency of any word in a sample of a language is inversely
+ proportional to its rank in the frequency table.
+
+
+ References
+ ----------
+ .. [1] Weisstein, Eric W. "Zipf Distribution." From MathWorld--A Wolfram
+ Web Resource. http://mathworld.wolfram.com/ZipfDistribution.html
+ .. [2] Wikipedia, "Zeta distribution",
+ http://en.wikipedia.org/wiki/Zeta_distribution
+ .. [3] Wikipedia, "Zipf's Law",
+ http://en.wikipedia.org/wiki/Zipf%27s_law
+ .. [4] Zipf, George Kingsley (1932): Selected Studies of the Principle
+ of Relative Frequency in Language. Cambridge (Mass.).
+
+ Examples
+ --------
+ Draw samples from the distribution:
+
+ >>> a = 2. # parameter
+ >>> s = np.random.zipf(a, 1000)
+
+ Display the histogram of the samples, along with
+ the probability density function:
+
+ >>> import matplotlib.pyplot as plt
+ >>> import scipy.special as sps
+ Truncate s values at 50 so plot is interesting
+ >>> count, bins, ignored = plt.hist(s[s<50], 50, normed=True)
+ >>> x = arange(1., 50.)
+ >>> y = x**(-a)/sps.zetac(a)
+ >>> plt.plot(x, y/max(y), linewidth=2, color='r')
+ >>> plt.show()
+
"""
cdef ndarray oa
cdef double fa
@@ -1352,10 +2258,49 @@ cdef class RandomState:
return discd_array(self.internal_state, rk_zipf, size, oa)
def geometric(self, p, size=None):
- """Geometric distribution with p being the probability of "success" on
- an individual trial.
-
+ """
geometric(p, size=None)
+
+ Draw samples from the geometric distribution.
+
+ Bernoulli trials are experiments with one of two outcomes:
+ success or failure (an example of such an experiment is flipping
+ a coin). The geometric distribution models the number of trials
+ that must be run in order to achieve success. It is therefore
+ supported on the positive integers, ``k = 1, 2, ...``.
+
+ The probability mass function of the geometric distribution is
+
+ .. math:: f(k) = (1 - p)^{k - 1} p
+
+ where `p` is the probability of success of an individual trial.
+
+ Parameters
+ ----------
+ p : float
+ The probability of success of an individual trial.
+ size : tuple of ints
+ Number of values to draw from the distribution. The output
+ is shaped according to `size`.
+
+ Returns
+ -------
+ out : ndarray
+ Samples from the geometric distribution, shaped according to
+ `size`.
+
+ Examples
+ --------
+ Draw ten thousand values from the geometric distribution,
+ with the probability of an individual success equal to 0.35:
+
+ >>> z = np.random.geometric(p=0.35, size=10000)
+
+ How many trials succeeded after a single run?
+
+ >>> (z == 1).sum() / 10000.
+ 0.34889999999999999 #random
+
"""
cdef ndarray op
cdef double fp
@@ -1379,14 +2324,16 @@ cdef class RandomState:
return discd_array(self.internal_state, rk_geometric, size, op)
def hypergeometric(self, ngood, nbad, nsample, size=None):
- """Hypergeometric distribution.
+ """
+ hypergeometric(ngood, nbad, nsample, size=None)
+
+ Hypergeometric distribution.
Consider an urn with ngood "good" balls and nbad "bad" balls. If one
were to draw nsample balls from the urn without replacement, then
the hypergeometric distribution describes the distribution of "good"
balls in the sample.
- hypergeometric(ngood, nbad, nsample, size=None)
"""
cdef ndarray ongood, onbad, onsample
cdef long lngood, lnbad, lnsample
@@ -1424,9 +2371,11 @@ cdef class RandomState:
ongood, onbad, onsample)
def logseries(self, p, size=None):
- """Logarithmic series distribution.
-
+ """
logseries(p, size=None)
+
+ Logarithmic series distribution.
+
"""
cdef ndarray op
cdef double fp
@@ -1450,21 +2399,96 @@ cdef class RandomState:
# Multivariate distributions:
def multivariate_normal(self, mean, cov, size=None):
- """Return an array containing multivariate normally distributed random numbers
- with specified mean and covariance.
+ """
+ multivariate_normal(mean, cov[, size])
+
+ Draw random samples from a multivariate normal distribution.
+
+ The multivariate normal, multinormal or Gaussian distribution is a
+ generalisation of the one-dimensional normal distribution to higher
+ dimensions.
+
+ Such a distribution is specified by its mean and covariance matrix,
+ which are analogous to the mean (average or "centre") and variance
+ (standard deviation squared or "width") of the one-dimensional normal
+ distribution.
+
+ Parameters
+ ----------
+ mean : (N,) ndarray
+ Mean of the N-dimensional distribution.
+ cov : (N,N) ndarray
+ Covariance matrix of the distribution.
+ size : tuple of ints, optional
+ Given a shape of, for example, (m,n,k), m*n*k samples are
+ generated, and packed in an m-by-n-by-k arrangement. Because each
+ sample is N-dimensional, the output shape is (m,n,k,N). If no
+ shape is specified, a single sample is returned.
+
+ Returns
+ -------
+ out : ndarray
+ The drawn samples, arranged according to `size`. If the
+ shape given is (m,n,...), then the shape of `out` is is
+ (m,n,...,N).
+
+ In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
+ value drawn from the distribution.
+
+ Notes
+ -----
+ The mean is a coordinate in N-dimensional space, which represents the
+ location where samples are most likely to be generated. This is
+ analogous to the peak of the bell curve for the one-dimensional or
+ univariate normal distribution.
+
+ Covariance indicates the level to which two variables vary together.
+ From the multivariate normal distribution, we draw N-dimensional
+ samples, :math:`X = [x_1, x_2, ... x_N]`. The covariance matrix
+ element :math:`C_{ij}` is the covariance of :math:`x_i` and :math:`x_j`.
+ The element :math:`C_{ii}` is the variance of :math:`x_i` (i.e. its
+ "spread").
+
+ Instead of specifying the full covariance matrix, popular
+ approximations include:
+
+ - Spherical covariance (`cov` is a multiple of the identity matrix)
+ - Diagonal covariance (`cov` has non-negative elements, and only on
+ the diagonal)
- multivariate_normal(mean, cov) -> random values
- multivariate_normal(mean, cov, [m, n, ...]) -> random values
+ This geometrical property can be seen in two dimensions by plotting
+ generated data-points:
- mean must be a 1 dimensional array. cov must be a square two dimensional
- array with the same number of rows and columns as mean has elements.
+ >>> mean = [0,0]
+ >>> cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or y-axis
- The first form returns a single 1-D array containing a multivariate
- normal.
+ >>> import matplotlib.pyplot as plt
+ >>> x,y = np.random.multivariate_normal(mean,cov,5000).T
+ >>> plt.plot(x,y,'x'); plt.axis('equal'); plt.show()
+
+ Note that the covariance matrix must be non-negative definite.
+
+ References
+ ----------
+ .. [1] A. Papoulis, "Probability, Random Variables, and Stochastic
+ Processes," 3rd ed., McGraw-Hill Companies, 1991
+ .. [2] R.O. Duda, P.E. Hart, and D.G. Stork, "Pattern Classification,"
+ 2nd ed., Wiley, 2001.
+
+ Examples
+ --------
+ >>> mean = (1,2)
+ >>> cov = [[1,0],[1,0]]
+ >>> x = np.random.multivariate_normal(mean,cov,(3,3))
+ >>> x.shape
+ (3, 3, 2)
+
+ The following is probably true, given that 0.6 is roughly twice the
+ standard deviation:
+
+ >>> print list( (x[0,0,:] - mean) < 0.6 )
+ [True, True]
- The second form returns an array of shape (m, n, ..., cov.shape[0]).
- In this case, output[i,j,...,:] is a 1-D array containing a multivariate
- normal.
"""
# Check preconditions on arguments
mean = np.array(mean)
@@ -1508,13 +2532,56 @@ cdef class RandomState:
return x
def multinomial(self, long n, object pvals, size=None):
- """Multinomial distribution.
+ """
+ multinomial(n, pvals, size=None)
+
+ Draw samples from a multinomial distribution.
- multinomial(n, pvals, size=None) -> random values
+ The multinomial distribution is a multivariate generalisation of the
+ binomial distribution. Take an experiment with one of ``p``
+ possible outcomes. An example of such an experiment is throwing a dice,
+ where the outcome can be 1 through 6. Each sample drawn from the
+ distribution represents `n` such experiments. Its values,
+ ``X_i = [X_0, X_1, ..., X_p]``, represent the number of times the outcome
+ was ``i``.
+
+ Parameters
+ ----------
+ n : int
+ Number of experiments.
+ pvals : sequence of floats, length p
+ Probabilities of each of the ``p`` different outcomes. These
+ should sum to 1 (however, the last element is always assumed to
+ account for the remaining probability, as long as
+ ``sum(pvals[:-1]) <= 1)``.
+ size : tuple of ints
+ Given a `size` of ``(M, N, K)``, then ``M*N*K`` samples are drawn,
+ and the output shape becomes ``(M, N, K, p)``, since each sample
+ has shape ``(p,)``.
+
+ Examples
+ --------
+ Throw a dice 20 times:
+
+ >>> np.random.multinomial(20, [1/6.]*6, size=1)
+ array([[4, 1, 7, 5, 2, 1]])
+
+ It landed 4 times on 1, once on 2, etc.
+
+ Now, throw the dice 20 times, and 20 times again:
+
+ >>> np.random.multinomial(20, [1/6.]*6, size=2)
+ array([[3, 4, 3, 3, 4, 3],
+ [2, 4, 3, 4, 0, 7]])
+
+ For the first run, we threw 3 times 1, 4 times 2, etc. For the second,
+ we threw 2 times 1, 4 times 2, etc.
+
+ A loaded dice is more likely to land on number 6:
+
+ >>> np.random.multinomial(100, [1/7.]*5)
+ array([13, 16, 13, 16, 42])
- pvals is a sequence of probabilities that should sum to 1 (however, the
- last element is always assumed to account for the remaining probability
- as long as sum(pvals[:-1]) <= 1).
"""
cdef long d
cdef ndarray parr "arrayObject_parr", mnarr "arrayObject_mnarr"
@@ -1558,7 +2625,10 @@ cdef class RandomState:
return multin
def dirichlet(self, object alpha, size=None):
- """dirichlet(alpha, size=None)
+ """
+ dirichlet(alpha, size=None)
+
+ Draw samples from the Dirichlet distribution.
Draw `size` samples of dimension k from a Dirichlet distribution. A
Dirichlet-distributed random variable can be seen as a multivariate
@@ -1575,12 +2645,12 @@ cdef class RandomState:
Notes
-----
- .. math:: X \\approx \\prod_{i=1}^{k}{x^{\\alpha_i-1}_i}
+ .. math:: X \approx \prod_{i=1}^{k}{x^{\alpha_i-1}_i}
Uses the following property for computation: for each dimension,
draw a random sample y_i from a standard gamma generator of shape
`alpha_i`, then
- :math:`X = \\frac{1}{\\sum_{i=1}^k{y_i}} (y_1, \\ldot, y_n)` is
+ :math:`X = \frac{1}{\sum_{i=1}^k{y_i}} (y_1, \ldots, y_n)` is
Dirichlet distributed.
References
@@ -1649,9 +2719,11 @@ cdef class RandomState:
# Shuffling and permutations:
def shuffle(self, object x):
- """Modify a sequence in-place by shuffling its contents.
-
+ """
shuffle(x)
+
+ Modify a sequence in-place by shuffling its contents.
+
"""
cdef long i, j
cdef int copy
@@ -1683,10 +2755,31 @@ cdef class RandomState:
i = i - 1
def permutation(self, object x):
- """Given an integer, return a shuffled sequence of integers >= 0 and
- < x; given a sequence, return a shuffled array copy.
-
+ """
permutation(x)
+
+ Randomly permute a sequence, or return a permuted range.
+
+ Parameters
+ ----------
+ x : int or array_like
+ If `x` is an integer, randomly permute ``np.arange(x)``.
+ If `x` is an array, make a copy and shuffle the elements
+ randomly.
+
+ Returns
+ -------
+ out : ndarray
+ Permuted sequence or array range.
+
+ Examples
+ --------
+ >>> np.random.permutation(10)
+ array([1, 7, 4, 3, 0, 9, 2, 5, 8, 6])
+
+ >>> np.random.permutation([1, 4, 9, 12, 15])
+ array([15, 1, 9, 4, 12])
+
"""
if isinstance(x, (int, np.integer)):
arr = np.arange(x)
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py
index 749a825b1..af22e68ac 100644
--- a/numpy/testing/utils.py
+++ b/numpy/testing/utils.py
@@ -126,8 +126,40 @@ def build_err_msg(arrays, err_msg, header='Items are not equal:',
return '\n'.join(msg)
def assert_equal(actual,desired,err_msg='',verbose=True):
- """ Raise an assertion if two items are not
- equal. I think this should be part of unittest.py
+ """
+ Raise an assertion if two objects are not equal.
+
+ Given two objects (lists, tuples, dictionaries or numpy arrays), check
+ that all elements of these objects are equal. An exception is raised at
+ the first conflicting values.
+
+ Parameters
+ ----------
+ actual : list, tuple, dict or ndarray
+ The object to check.
+ desired : list, tuple, dict or ndarray
+ The expected object.
+ err_msg : string
+ The error message to be printed in case of failure.
+ verbose : bool
+ If True, the conflicting values are appended to the error message.
+
+ Raises
+ ------
+ AssertionError
+ If actual and desired are not equal.
+
+ Examples
+ --------
+ >>> np.testing.assert_equal([4,5], [4,6]) # doctest:+ELLIPSIS
+ ...
+ <type 'exceptions.AssertionError'>:
+ Items are not equal:
+ item=1
+ <BLANKLINE>
+ ACTUAL: 5
+ DESIRED: 6
+
"""
if isinstance(desired, dict):
assert isinstance(actual, dict), repr(type(actual))