Skip to content

Commit

Permalink
Catch np.divide warning
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Feb 1, 2016
1 parent 017a894 commit dad6812
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions dask/array/numpy_compat.py
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import numpy as np
import warnings

try:
isclose = np.isclose
Expand All @@ -24,13 +25,14 @@ def full(shape, fill_value, dtype=None, order=None):
# Taken from scikit-learn:
# https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/fixes.py#L84
try:
if (not np.allclose(np.divide(.4, 1, casting="unsafe"),
np.divide(.4, 1, casting="unsafe", dtype=np.float))
or not np.allclose(np.divide(1, .5, dtype='i8'), 2)
or not np.allclose(np.divide(.4, 1), .4)):
raise TypeError('Divide not working with dtype: '
'https://github.com/numpy/numpy/issues/3484')
divide = np.divide
with warnings.catch_warnings():
if (not np.allclose(np.divide(.4, 1, casting="unsafe"),
np.divide(.4, 1, casting="unsafe", dtype=np.float))
or not np.allclose(np.divide(1, .5, dtype='i8'), 2)
or not np.allclose(np.divide(.4, 1), .4)):
raise TypeError('Divide not working with dtype: '
'https://github.com/numpy/numpy/issues/3484')
divide = np.divide

except TypeError:
# Divide with dtype doesn't work on Python 3
Expand Down

0 comments on commit dad6812

Please sign in to comment.