Skip to content

Commit

Permalink
no more old numpy supports. Mixed feelings about this
Browse files Browse the repository at this point in the history
  • Loading branch information
keflavich committed May 8, 2017
1 parent 65e7cee commit 3c8f699
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions astropy/utils/compat/numpycompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ...utils import minversion


__all__ = ['NUMPY_LT_1_8', 'NUMPY_LT_1_9', 'NUMPY_LT_1_9_1', 'NUMPY_LT_1_10',
__all__ = ['NUMPY_LT_1_9', 'NUMPY_LT_1_9_1', 'NUMPY_LT_1_10',
'NUMPY_LT_1_10_4', 'NUMPY_LT_1_11', 'NUMPY_LT_1_12']

# TODO: It might also be nice to have aliases to these named for specific
Expand All @@ -20,30 +20,3 @@
NUMPY_LT_1_11 = not minversion('numpy', '1.11.0')
NUMPY_LT_1_12 = not minversion('numpy', '1.12')
NUMPY_GE_1_13 = minversion('numpy', '1.13dev')


def _monkeypatch_unicode_mask_fill_values():
"""
Numpy < 1.8.0 on Python 2 does not support Unicode fill values, since
it assumes that all of the string dtypes are ``S`` and ``V`` (not ``U``).
This monkey patches the function that validates and corrects a
fill value to handle this case.
"""
if NUMPY_LT_1_8 and six.PY2:
import numpy as np
from numpy.ma import core as ma_core
_check_fill_value_original = ma_core._check_fill_value

def _check_fill_value(fill_value, ndtype):
if (not ndtype.fields and
isinstance(fill_value, six.string_types) and
ndtype.char in 'SVU'):
return np.array(fill_value, copy=False, dtype=ndtype)
return _check_fill_value_original(fill_value, ndtype)

ma_core._check_fill_value = _check_fill_value


if not _ASTROPY_SETUP_:
_monkeypatch_unicode_mask_fill_values()

0 comments on commit 3c8f699

Please sign in to comment.