From 2ee7c72e56b5ef16f3838f86de8ad0d435b9b4e0 Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Fri, 30 Mar 2018 08:32:27 -0600 Subject: BUG: np.squeeze() now respects older API axis expectation * Fixes Issue #10779 by removing the interception of an otherwise normal Exception when an object implemented with the expectation that squeeze() does not accept an axis argument receives an axis argument * Added unit tests that enforce respect for the old API expectation in objects, and ensure that silent success (or forced usage of the new API on objects) is no longer the case * Updated compatibility notes to explain this change --- numpy/core/fromnumeric.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'numpy/core/fromnumeric.py') diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 10256c3c0..e81a4a039 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1276,13 +1276,10 @@ def squeeze(a, axis=None): squeeze = a.squeeze except AttributeError: return _wrapit(a, 'squeeze') - try: - # First try to use the new axis= parameter - return squeeze(axis=axis) - except TypeError: - # For backwards compatibility + if axis is None: return squeeze() - + else: + return squeeze(axis=axis) def diagonal(a, offset=0, axis1=0, axis2=1): """ -- cgit v1.2.1