-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Deprecate old pandas support #1530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1fc86b8
Deprecate old numpy and pandas support.
fujiisoup e1137dd
Clean up npcompat
fujiisoup c3eb882
recover unintentionally deleted line
fujiisoup cd54052
an empty commit to trigger ci.
fujiisoup 16d109e
remove nanprod. update what's new
fujiisoup 4e0f853
Minor fix related to np.nanprod
fujiisoup e5cc83d
Update installing.rst
fujiisoup da5c16e
Merge branch 'master' into deprecate_old_numpy
shoyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,139 +4,11 @@ | |
import numpy as np | ||
|
||
try: | ||
from numpy import broadcast_to, stack, nanprod, nancumsum, nancumprod | ||
from numpy import nanprod, nancumsum, nancumprod | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can remove |
||
except ImportError: # pragma: no cover | ||
# Code copied from newer versions of NumPy (v1.10 to v1.12). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
# Used under the terms of NumPy's license, see licenses/NUMPY_LICENSE. | ||
|
||
def _maybe_view_as_subclass(original_array, new_array): | ||
if type(original_array) is not type(new_array): | ||
# if input was an ndarray subclass and subclasses were OK, | ||
# then view the result as that subclass. | ||
new_array = new_array.view(type=type(original_array)) | ||
# Since we have done something akin to a view from original_array, we | ||
# should let the subclass finalize (if it has it implemented, i.e., is | ||
# not None). | ||
if new_array.__array_finalize__: | ||
new_array.__array_finalize__(original_array) | ||
return new_array | ||
|
||
def _broadcast_to(array, shape, subok, readonly): | ||
shape = tuple(shape) if np.iterable(shape) else (shape,) | ||
array = np.array(array, copy=False, subok=subok) | ||
if not shape and array.shape: | ||
raise ValueError('cannot broadcast a non-scalar to a scalar array') | ||
if any(size < 0 for size in shape): | ||
raise ValueError('all elements of broadcast shape must be non-' | ||
'negative') | ||
broadcast = np.nditer( | ||
(array,), flags=['multi_index', 'zerosize_ok', 'refs_ok'], | ||
op_flags=['readonly'], itershape=shape, order='C').itviews[0] | ||
result = _maybe_view_as_subclass(array, broadcast) | ||
if not readonly and array.flags.writeable: | ||
result.flags.writeable = True | ||
return result | ||
|
||
def broadcast_to(array, shape, subok=False): | ||
"""Broadcast an array to a new shape. | ||
|
||
Parameters | ||
---------- | ||
array : array_like | ||
The array to broadcast. | ||
shape : tuple | ||
The shape of the desired array. | ||
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 (default). | ||
|
||
Returns | ||
------- | ||
broadcast : array | ||
A readonly view on the original array with the given shape. It is | ||
typically not contiguous. Furthermore, more than one element of a | ||
broadcasted array may refer to a single memory location. | ||
|
||
Raises | ||
------ | ||
ValueError | ||
If the array is not compatible with the new shape according to NumPy's | ||
broadcasting rules. | ||
|
||
Examples | ||
-------- | ||
>>> x = np.array([1, 2, 3]) | ||
>>> np.broadcast_to(x, (3, 3)) | ||
array([[1, 2, 3], | ||
[1, 2, 3], | ||
[1, 2, 3]]) | ||
""" | ||
return _broadcast_to(array, shape, subok=subok, readonly=True) | ||
|
||
def stack(arrays, axis=0): | ||
""" | ||
Join a sequence of arrays along a new axis. | ||
|
||
.. versionadded:: 1.10.0 | ||
|
||
Parameters | ||
---------- | ||
arrays : sequence of ndarrays | ||
Each array must have the same shape. | ||
axis : int, optional | ||
The axis along which the arrays will be stacked. | ||
|
||
Returns | ||
------- | ||
stacked : ndarray | ||
The stacked array has one more dimension than the input arrays. | ||
See Also | ||
-------- | ||
concatenate : Join a sequence of arrays along an existing axis. | ||
split : Split array into a list of multiple sub-arrays of equal size. | ||
|
||
Examples | ||
-------- | ||
>>> arrays = [np.random.randn(3, 4) for _ in range(10)] | ||
>>> np.stack(arrays, axis=0).shape | ||
(10, 3, 4) | ||
|
||
>>> np.stack(arrays, axis=1).shape | ||
(3, 10, 4) | ||
|
||
>>> np.stack(arrays, axis=2).shape | ||
(3, 4, 10) | ||
|
||
>>> a = np.array([1, 2, 3]) | ||
>>> b = np.array([2, 3, 4]) | ||
>>> np.stack((a, b)) | ||
array([[1, 2, 3], | ||
[2, 3, 4]]) | ||
|
||
>>> np.stack((a, b), axis=-1) | ||
array([[1, 2], | ||
[2, 3], | ||
[3, 4]]) | ||
""" | ||
arrays = [np.asanyarray(arr) for arr in arrays] | ||
if not arrays: | ||
raise ValueError('need at least one array to stack') | ||
|
||
shapes = set(arr.shape for arr in arrays) | ||
if len(shapes) != 1: | ||
raise ValueError('all input arrays must have the same shape') | ||
|
||
result_ndim = arrays[0].ndim + 1 | ||
if not -result_ndim <= axis < result_ndim: | ||
msg = 'axis {0} out of bounds [-{1}, {1})'.format(axis, result_ndim) | ||
raise IndexError(msg) | ||
if axis < 0: | ||
axis += result_ndim | ||
|
||
sl = (slice(None),) * axis + (np.newaxis,) | ||
expanded_arrays = [arr[sl] for arr in arrays] | ||
return np.concatenate(expanded_arrays, axis=axis) | ||
|
||
def _replace_nan(a, val): | ||
""" | ||
If `a` is of inexact type, make a copy of `a`, replace NaNs with | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go to the top of the release notes, under a heading "Backwards incompatible changes"
Also: these versions aren't just deprecated -- they are no longer supported at all.