summaryrefslogtreecommitdiff
path: root/numpy/lib/stride_tricks.py
Commit message (Collapse)AuthorAgeFilesLines
* ENH: Support for changing dtype in non-C-contiguous viewsJoseph R. Fox-Rabinovitz2022-01-051-0/+1
| | | | | | | Expires deprecated F-contiguous behavior. Simplifies C code of dtype set descriptor. Adds tests that verify which error condition is triggered. Introduces extra long exception message that upsets linter.
* DOC: broadcast_to() supports int as shape parameterTim Hoffmann2021-07-091-2/+3
|
* MAINT: Do not override `sliding_window_view` module to `numpy`Sebastian Berg2020-11-061-1/+1
|
* API: Do not import sliding_window_view to main namespaceSebastian Berg2020-11-051-12/+11
| | | | | At least for now, lets not import it to the main namespace, since there is no agreement that this is a good idea.
* ENH: Implement sliding window (gh-17394)Klaus Zimmermann2020-11-051-1/+227
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * implement sliding_window_view #7753 Test cases are shown in the issue page. * Add Example Cases * Add step_size and N-dim support * Add shape and step_size check. Remove warning. * Remove shape default Add step_size default's description. * Give proper parameter name 'step' * fix a parameter description mistake * implement test function for sliding_window_view() * implement test function for sliding_window_view() * Fix according to @eric-wieser comments * Change arange to ogrid in Examples * remove np.squeeze on return line * Clarify document to avoid parameter confusion. * add `writable` and more explanation in docs * resolve a write conflit * fixes according to @seberg review * resolve write hazard * remove outdated docs. * change referring according to @mattip. change 'writeable' to 'readonly' as @seberg suggest. remove 'step' as @eric-wieser request * fix test minor error * DOC: Grammar fixes * STY: Add missing line break required by PEP8 * + Change readonly parameter to writeable. + Update writeable description. + Fix a few parameter checks. + Other minor improvements. * Move to new api as proposed by @eric-wieser - Change api to follow suggestion by Eric Wieser in https://github.com/numpy/numpy/pull/10771#issuecomment-524715356 - Update docstring - Add more tests * Improve documentation * Add sliding_window_view to documentation index * Apply suggestions from code review Co-authored-by: Eric Wieser <wieser.eric@gmail.com> * Fix window shape check * Add `sliding_window_view` to __all__ * Add tests for error cases * Add array_function dispatching * Change dispatcher argument defaults to None * Simplify array function dispatching * Added "np." prefix to doctests * Split tests * Improved docstring * Add release note * Fix docstring formatting * Fix doctest * Remove namespacing in documentation indexing * Improve docstring * Improved docstring * Simplified docstring * Improve docstring to make pseudo code stand out * Improve docstring * Add simple application example * Correct release note * Improve link with as_strides * Add note about performance * Tidy up main doc string * Make language on performance warning stronger * Bugfix: pass subok and writeable to as_strided * Add writeable test * Add subok test * Change subok test to use custom array subclass instead of unsupported MaskedArray * Add version added information Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Fanjin <fjzeng@ucsd.edu> Co-authored-by: Fanjin Zeng <Fnjn@users.noreply.github.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: fanjin <fjzeng@outlook.com> Closes gh-7753
* ENH: add function to get broadcast shape from a given set of shapes. (#17535)madhulikajc2020-10-171-2/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ENH: add function to get broadcast shape from a given set of shapes. Add new function numpy.broadcast_shape which takes tuples for the shapes to be broadcast against each other. Return the broadcasted shape as a tuple. See #17217 * Perform array allocations of size 0 for provided shape tuples Co-authored-by: Eric Wieser <wieser.eric@gmail.com> * Test for int as input shape Also update docstring to include both ints and tuples of ints as input * Remove unnecessary array_function_dispatch * Add missing set_module * Add release notes. Add versionadded to docstring. Also fix up docstring details. * follow convention for trailing comma Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> * Change name to broadcast_shapes. Also add test case, and type hint. * follow convention Co-authored-by: Eric Wieser <wieser.eric@gmail.com> * Update docstring Co-authored-by: Eric Wieser <wieser.eric@gmail.com> * Add reference to numpy docs on broadcasting to docstring Also move versionadded * Fix spelling Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com> * Add broadcast_shapes to reference docs and add See Also sections Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com>
* MAINT: Implement keyword-only arguments as syntaxEric Wieser2020-01-061-6/+2
| | | | Now that 2.7 is gone, there is no need to pop manually from kwarg dictionaries.
* MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-051-1/+1
| | | | | | | Inheriting from object was necessary for Python 2 compatibility to use new-style classes. In Python 3, this is unnecessary as there are no old-style classes. Dropping the object is more idiomatic Python.
* MAINT: Remove unnecessary 'from __future__ import ...' statementsJon Dufresne2020-01-031-2/+0
| | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* ENH: Deprecate writeable broadcast_array (#12609)Matti Picus2019-06-281-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the base is not an array (or generally when the flag of the base array was toggled), it is OK to allow setting the writeable flag to True, as long as any ancestor (especially the last one) is writeable. This commit also slightly change the behaviour of the base attribute. --- * ENH: Deprecate writeable broadcast_array * ENH: Make writeable flag enabling more reliable for non-array bases When the base is not an array (or generally when the flag of the base array was toggled), it is OK to allow setting the writeable flag to True, as long as any ancestor (especially the last one) is writeable. * Update doc/release/1.17.0-notes.rst Co-Authored-By: Sebastian Berg <sebastian@sipsolutions.net> * Update doc/release/1.17.0-notes.rst Co-Authored-By: Sebastian Berg <sebastian@sipsolutions.net> * Update numpy/lib/tests/test_stride_tricks.py Co-Authored-By: Sebastian Berg <sebastian@sipsolutions.net> * Update numpy/core/tests/test_multiarray.py Co-Authored-By: Sebastian Berg <sebastian@sipsolutions.net> * DOC: improve warning (from review)
* ENH: Allow broadcast to be called with zero argumentsEric Wieser2019-05-121-2/+0
| | | | | | | Follows on from gh-6905 which reduced the limit from 2 to 1. Let's go all the way to zero. Just as for `broadcast(broadcast(a), b)` is interpreted as `broadcast(a, b)` , this change interprets `broadcast(broadcast(), a)` as `broadcast(a)`.
* MAINT: set preferred __module__ for numpy functionsStephan Hoyer2018-10-231-2/+2
|
* ENH: __array_function__ support for np.lib, part 2/2 (#12119)Stephan Hoyer2018-10-221-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ENH: __array_function__ support for np.lib, part 2 xref GH12028 np.lib.npyio through np.lib.ufunclike * Fix failures in numpy/core/tests/test_overrides.py * CLN: handle depreaction in dispatchers for np.lib.ufunclike * CLN: fewer dispatchers in lib.twodim_base * CLN: fewer dispatchers in lib.shape_base * CLN: more dispatcher consolidation * BUG: fix test failure * Use all method instead of function in assert_equal * DOC: indicate n is array_like in scimath.logn * MAINT: updates per review * MAINT: more conservative changes in assert_array_equal * MAINT: add back in comment * MAINT: casting tweaks in assert_array_equal * MAINT: fixes and tests for assert_array_equal on subclasses
* TST: add broadcast_arrays() kwarg unit test for TypeErrorTyler Reddy2018-08-011-1/+1
| | | | | | | | | * broadcast_arrays() is now tested for the case when an invalid keyword argument is used; the appropriate error string content is also tested for * the TypeError message produced in the above case has been restored to the correct value in Python 3
* DOC: Change array lengths/entries in an example to reduce confusion.Paul van Mulbregt2018-06-141-9/+5
|
* ENH: add NpyIter_Close, nditer__{enter,exit}__mattip2018-04-201-2/+5
|
* BUG: have as_strided() keep custom dtypesAntoine Pitrou2017-05-241-4/+3
| | | | Fixes issue #9161
* BUG: The broadcast shape of no things should be (), not ValueErrorEric Wieser2017-02-131-1/+1
|
* BUG: Fix TypeError when raising TypeErrorEric Wieser2016-05-081-1/+1
| | | Fixes "TypeError: pop expected at least 1 arguments, got 0"
* DOC: fix typoSamuel St-Jean2016-03-091-1/+1
| | | Found this while reading a docstring.
* DOC: Add documentation for as_stridedSebastian Berg2016-02-131-3/+62
|
* ENH: allow single input argument in numpy.broadcastHolger Kohr2016-01-041-3/+0
|
* BUG: error in broadcast_arrays with as_strided arrayStephan Hoyer2015-10-241-3/+6
| | | | Fixes GH6491
* BUG: fix _broadcast_shape (and broadcast_array) for len(args) > 32Stephan Hoyer2015-05-151-0/+4
| | | | Fixes gh-5862
* DOC: note versionadded for broadcast_toEric Moore2015-05-061-0/+4
| | | | closes gh-5839
* Merge pull request #5519 from jaimefrio/array_interface_dtypeCharles Harris2015-03-121-2/+4
|\ | | | | ENH: PyArray_FromInterface checks descr if typestr is np.void
| * ENH: PyArray_FromInterface checks descr if typestr is np.voidjaimefrio2015-03-081-2/+4
| | | | | | | | | | | | | | | | | | | | When the 'typestr' member of the __array_interface__ dictionary defines a np.void dtype, check the 'descr' member, and if it is a valid dtype description and it is not the default one, use it to construct the dtype for the array to return. This fixes #5081, as as_strided no longer has to worry about changing the dtype of the return.
* | BUG: fix broadcast_to for reference typesStephan Hoyer2015-03-011-3/+3
|/
* ENH: add broadcast_to functionStephan Hoyer2015-02-261-55/+104
| | | | | | | | Per the mailing list discussion [1], I have implemented a new function `broadcast_to` that broadcasts an array to a given shape according to numpy's broadcasting rules. [1] http://mail.scipy.org/pipermail/numpy-discussion/2014-December/071796.html
* Convert as_strided input to array firstMarten van Kerkwijk2014-08-271-4/+8
|
* ENH: add subok flag to stride_tricks (and thus broadcast_arrays)Marten van Kerkwijk2014-08-251-5/+19
|
* STY: Make files in numpy/lib PEP8 compliant.Charles Harris2014-07-311-10/+12
| | | | The rules enforced are the same as those used for scipy.
* Fix stride_stricks.as_strided function for object arraysJay Bourque2014-02-261-1/+2
| | | | Currently, calling as_strided for object array results in 'TypeError: Cannot change data-type for object array.'. Fix so that dtype of new array is only set for void dtype, as originally intended.
* STY: Giant comma spacing fixup.Charles Harris2013-08-181-1/+1
| | | | | | | Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long and will need to be broken at some point. OTOH, some lines were already too long and need to be broken at some point. Now seems as good a time as any to do this with open PRs at a minimum.
* Fix issue with broadcast_arrays() and user defined dtypesJay Bourque2013-05-101-1/+4
| | | | broadcast_arrays() does not handle struct and custom dtypes correctly. Dtype of returned broadcasted arrays is always '|V8'. Fix broadcast_arrays() so that dtype of returned arrays is correct dtype for user defined dtypes.
* 2to3: Apply `map` fixer.Charles Harris2013-04-101-2/+2
| | | | | | | | | | | | | | | | | | | In Python 3 `map` is an iterator while in Python 2 it returns a list. The simple fix applied by the fixer is to inclose all instances of map with `list(...)`. This is not needed in all cases, and even where appropriate list comprehensions may be preferred for their clarity. Consequently, this patch attempts to use list comprehensions where it makes sense. When the mapped function has two arguments there is another problem that can arise. In Python 3 map stops execution when the shortest argument list is exhausted, while in Python 2 it stops when the longest argument list is exhausted. Consequently the two argument case might need special care. However, we have been running Python3 converted versions of numpy since 1.5 without problems, so it is probably not something that affects us. Closes #3068
* 2to3: Apply `print` fixer.Charles Harris2013-04-061-1/+1
| | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* 2to3: Use absolute imports.Charles Harris2013-03-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new import `absolute_import` is added the `from __future__ import` statement and The 2to3 `import` fixer is run to make the imports compatible. There are several things that need to be dealt with to make this work. 1) Files meant to be run as scripts run in a different environment than files imported as part of a package, and so changes to those files need to be skipped. The affected script files are: * all setup.py files * numpy/core/code_generators/generate_umath.py * numpy/core/code_generators/generate_numpy_api.py * numpy/core/code_generators/generate_ufunc_api.py 2) Some imported modules are not available as they are created during the build process and consequently 2to3 is unable to handle them correctly. Files that import those modules need a bit of extra work. The affected files are: * core/__init__.py, * core/numeric.py, * core/_internal.py, * core/arrayprint.py, * core/fromnumeric.py, * numpy/__init__.py, * lib/npyio.py, * lib/function_base.py, * fft/fftpack.py, * random/__init__.py Closes #3172
* 2to3: Put `from __future__ import division in every python file.Charles Harris2013-03-011-0/+2
| | | | | | | | This should be harmless, as we already are division clean. However, placement of this import takes some care. In the future a script can be used to append new features without worry, at least until such time as it exceeds a single line. Having that ability will make it easier to deal with absolute imports and printing updates.
* DOC: wiki merge, twodim_base and a few loose ones.rgommers2010-07-311-5/+5
|
* Docstring update: libPauli Virtanen2009-10-021-1/+6
|
* ran reindentJarrod Millman2008-08-081-2/+1
|
* Merge from documentation editor.Stefan van der Walt2008-08-051-2/+4
|
* ENH: Add broadcast_arrays() function to expose broadcasting to pure Python ↵Robert Kern2008-07-031-0/+109
functions that cannot be made to be ufuncs.