Skip to content

Commit 534784b

Browse files
committed
Merge pull request #7954 from cpcloud/drop-np16
CI: Drop numpy 1.6 support
2 parents 1eb9955 + 9ca4a0d commit 534784b

37 files changed

+179
-472
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pip install pandas
9090
```
9191

9292
## Dependencies
93-
- [NumPy](http://www.numpy.org): 1.6.1 or higher
93+
- [NumPy](http://www.numpy.org): 1.7.0 or higher
9494
- [python-dateutil](http://labix.org/python-dateutil): 1.5 or higher
9595
- [pytz](http://pytz.sourceforge.net)
9696
- Needed for time zone support with ``pandas.date_range``

ci/requirements-2.6.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
numpy==1.6.1
1+
numpy==1.7.0
22
cython==0.19.1
33
python-dateutil==1.5
44
pytz==2013b

ci/requirements-2.7_LOCALE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ xlwt==0.7.5
44
openpyxl==1.6.2
55
xlsxwriter==0.4.6
66
xlrd==0.9.2
7-
numpy==1.6.1
7+
numpy==1.7.1
88
cython==0.19.1
99
bottleneck==0.6.0
1010
matplotlib==1.3.0

doc/source/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ installed), make sure you have `nose
247247
Dependencies
248248
------------
249249

250-
* `NumPy <http://www.numpy.org>`__: 1.6.1 or higher
250+
* `NumPy <http://www.numpy.org>`__: 1.7.0 or higher
251251
* `python-dateutil <http://labix.org/python-dateutil>`__ 1.5
252252
* `pytz <http://pytz.sourceforge.net/>`__
253253
* Needed for time zone support

doc/source/timeseries.rst

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,23 +1685,3 @@ yields another ``timedelta64[ns]`` dtypes Series.
16851685
16861686
td * -1
16871687
td * Series([1,2,3,4])
1688-
1689-
Numpy < 1.7 Compatibility
1690-
~~~~~~~~~~~~~~~~~~~~~~~~~
1691-
1692-
Numpy < 1.7 has a broken ``timedelta64`` type that does not correctly work
1693-
for arithmetic. pandas bypasses this, but for frequency conversion as above,
1694-
you need to create the divisor yourself. The ``np.timetimedelta64`` type only
1695-
has 1 argument, the number of **micro** seconds.
1696-
1697-
The following are equivalent statements in the two versions of numpy.
1698-
1699-
.. code-block:: python
1700-
1701-
from distutils.version import LooseVersion
1702-
if LooseVersion(np.__version__) <= '1.6.2':
1703-
y / np.timedelta(86400*int(1e6))
1704-
y / np.timedelta(int(1e6))
1705-
else:
1706-
y / np.timedelta64(1,'D')
1707-
y / np.timedelta64(1,'s')

doc/source/v0.15.0.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ This is a major release from 0.14.1 and includes a small number of API changes,
77
enhancements, and performance improvements along with a large number of bug fixes. We recommend that all
88
users upgrade to this version.
99

10+
.. warning::
11+
12+
pandas >= 0.15.0 will no longer support compatibility with NumPy versions <
13+
1.7.0. If you want to use the latest versions of pandas, please upgrade to
14+
NumPy >= 1.7.0.
15+
1016
- Highlights include:
1117

1218
- The ``Categorical`` type was integrated as a first-class pandas type, see :ref:`here <whatsnew_0150.cat>`

pandas/__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pylint: disable-msg=W0614,W0401,W0611,W0622
22

3+
34
__docformat__ = 'restructuredtext'
45

56
try:
@@ -18,6 +19,7 @@
1819
from datetime import datetime
1920
import numpy as np
2021

22+
2123
# XXX: HACK for NumPy 1.5.1 to suppress warnings
2224
try:
2325
np.seterr(all='ignore')
@@ -27,14 +29,20 @@
2729
# numpy versioning
2830
from distutils.version import LooseVersion
2931
_np_version = np.version.short_version
30-
_np_version_under1p6 = LooseVersion(_np_version) < '1.6'
31-
_np_version_under1p7 = LooseVersion(_np_version) < '1.7'
3232
_np_version_under1p8 = LooseVersion(_np_version) < '1.8'
3333
_np_version_under1p9 = LooseVersion(_np_version) < '1.9'
3434

35+
3536
from pandas.version import version as __version__
3637
from pandas.info import __doc__
3738

39+
40+
if LooseVersion(_np_version) < '1.7.0':
41+
raise ImportError('pandas {0} is incompatible with numpy < 1.7.0, '
42+
'your numpy version is {1}. Please upgrade numpy to'
43+
' >= 1.7.0 to use pandas version {0}'.format(__version__,
44+
_np_version))
45+
3846
# let init-time option registration happen
3947
import pandas.core.config_init
4048

pandas/core/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,12 @@ def ndim(self):
298298

299299
def item(self):
300300
""" return the first element of the underlying data as a python scalar """
301-
return self.values.item()
301+
try:
302+
return self.values.item()
303+
except IndexError:
304+
# copy numpy's message here because Py26 raises an IndexError
305+
raise ValueError('can only convert an array of size 1 to a '
306+
'Python scalar')
302307

303308
@property
304309
def data(self):

pandas/core/common.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,8 @@ def _possibly_cast_to_datetime(value, dtype, coerce=False):
18481848
""" try to cast the array/value to a datetimelike dtype, converting float
18491849
nan to iNaT
18501850
"""
1851+
from pandas.tseries.timedeltas import _possibly_cast_to_timedelta
1852+
from pandas.tseries.tools import to_datetime
18511853

18521854
if dtype is not None:
18531855
if isinstance(dtype, compat.string_types):
@@ -1886,13 +1888,11 @@ def _possibly_cast_to_datetime(value, dtype, coerce=False):
18861888
elif np.prod(value.shape) and value.dtype != dtype:
18871889
try:
18881890
if is_datetime64:
1889-
from pandas.tseries.tools import to_datetime
18901891
value = to_datetime(value, coerce=coerce).values
18911892
elif is_timedelta64:
1892-
from pandas.tseries.timedeltas import \
1893-
_possibly_cast_to_timedelta
1894-
value = _possibly_cast_to_timedelta(value, coerce='compat', dtype=dtype)
1895-
except:
1893+
value = _possibly_cast_to_timedelta(value,
1894+
dtype=dtype)
1895+
except (AttributeError, ValueError):
18961896
pass
18971897

18981898
else:
@@ -1901,28 +1901,20 @@ def _possibly_cast_to_datetime(value, dtype, coerce=False):
19011901

19021902
# catch a datetime/timedelta that is not of ns variety
19031903
# and no coercion specified
1904-
if (is_array and value.dtype.kind in ['M','m']):
1904+
if is_array and value.dtype.kind in ['M', 'm']:
19051905
dtype = value.dtype
19061906

19071907
if dtype.kind == 'M' and dtype != _NS_DTYPE:
19081908
value = value.astype(_NS_DTYPE)
19091909

19101910
elif dtype.kind == 'm' and dtype != _TD_DTYPE:
1911-
from pandas.tseries.timedeltas import \
1912-
_possibly_cast_to_timedelta
1913-
value = _possibly_cast_to_timedelta(value, coerce='compat')
1911+
value = _possibly_cast_to_timedelta(value)
19141912

19151913
# only do this if we have an array and the dtype of the array is not
19161914
# setup already we are not an integer/object, so don't bother with this
19171915
# conversion
1918-
elif (is_array and not (
1919-
issubclass(value.dtype.type, np.integer) or
1920-
value.dtype == np.object_)):
1921-
pass
1922-
1923-
# try to infer if we have a datetimelike here
1924-
# otherwise pass thru
1925-
else:
1916+
elif not (is_array and not (issubclass(value.dtype.type, np.integer) or
1917+
value.dtype == np.object_)):
19261918
value = _possibly_infer_to_datetimelike(value)
19271919

19281920
return value

pandas/core/generic.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pandas.core.internals import BlockManager
1717
import pandas.core.common as com
1818
import pandas.core.datetools as datetools
19-
from pandas import compat, _np_version_under1p7
19+
from pandas import compat
2020
from pandas.compat import map, zip, lrange, string_types, isidentifier, lmap
2121
from pandas.core.common import (isnull, notnull, is_list_like,
2222
_values_from_object, _maybe_promote,
@@ -3613,21 +3613,6 @@ def abs(self):
36133613
-------
36143614
abs: type of caller
36153615
"""
3616-
3617-
# suprimo numpy 1.6 hacking
3618-
# for timedeltas
3619-
if _np_version_under1p7:
3620-
3621-
def _convert_timedeltas(x):
3622-
if x.dtype.kind == 'm':
3623-
return np.abs(x.view('i8')).astype(x.dtype)
3624-
return np.abs(x)
3625-
3626-
if self.ndim == 1:
3627-
return _convert_timedeltas(self)
3628-
elif self.ndim == 2:
3629-
return self.apply(_convert_timedeltas)
3630-
36313616
return np.abs(self)
36323617

36333618
_shared_docs['describe'] = """

0 commit comments

Comments
 (0)