Skip to content

Testing deprecations #1825

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pip-log.txt
.tox
nosetests.xml
.cache
.ropeproject/

# Translations
*.mo
Expand All @@ -51,4 +52,7 @@ doc/_build
doc/generated
xarray/version.py

# Sync tools
Icon*

.ipynb_checkpoints
2 changes: 1 addition & 1 deletion xarray/conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def ensure_dtype_not_object(var, name=None):
fill_value = u''
else:
# insist on using float for numeric values
if not np.issubdtype(inferred_dtype, float):
if not np.issubdtype(inferred_dtype, np.floating):
inferred_dtype = np.dtype(float)
fill_value = inferred_dtype.type(np.nan)

Expand Down
6 changes: 3 additions & 3 deletions xarray/core/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def maybe_promote(dtype):
fill_value : Valid missing value for the promoted dtype.
"""
# N.B. these casting rules should match pandas
if np.issubdtype(dtype, float):
if np.issubdtype(dtype, np.floating):
fill_value = np.nan
elif np.issubdtype(dtype, int):
elif np.issubdtype(dtype, np.signedinteger):
# convert to floating point so NaN is valid
dtype = float
fill_value = np.nan
elif np.issubdtype(dtype, complex):
elif np.issubdtype(dtype, np.complexfloating):
fill_value = np.nan + np.nan * 1j
elif np.issubdtype(dtype, np.datetime64):
fill_value = np.datetime64('NaT')
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ def __array__(self, dtype=None):
if isinstance(array, pd.PeriodIndex):
with suppress(AttributeError):
# this might not be public API
array = array.asobject
array = array.astype('object')
return np.asarray(array.values, dtype=dtype)

@property
Expand Down
9 changes: 9 additions & 0 deletions xarray/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@


def _importorskip(modname, minversion=None):
"""
This is deprecated - instead use pytest.importorskip. For example:

matplotlib = pytest.importorskip('matplotlib', minversion='1.9.0')

"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't this can work until pytest-dev/pytest#568 is fixed.

try:
mod = importlib.import_module(modname)
has = True
Expand Down Expand Up @@ -109,6 +115,9 @@ def _importorskip(modname, minversion=None):


class TestCase(unittest.TestCase):
"""
These functions are all deprecated. Instead, use functions in xr.testing
"""
if PY3:
# Python 3 assertCountEqual is roughly equivalent to Python 2
# assertItemsEqual
Expand Down