You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Things are passing now with strict=True by default (cc @TomAugspurger). Summarizing the changes in this PR:
Most of the changes here are removing old xfails that have since been fixed and are now passing
Added strict=False to test_deep_bases_win_over_dependents in dask/tests/test_order.py. I think this test is supposed to fail for some graphs, but not others. It would be great to get another set of eyes on that test.
Added strict=False to test_Array_numpy_gufunc_call__array_ufunc__01 and test_Array_numpy_gufunc_call__array_ufunc__02 in dask/array/tests/test_array_core.py. These test gufuncs from the private _umath_linalg module in NumPy. Currently, test_Array_numpy_gufunc_call__array_ufunc__02 fails due to an issue with meta (see traceback below) which went unnoticed because both these tests were marked as xfail. Will open up separate issue to track this.
==================================================== FAILURES =====================================================
__________________________________ test_Array_numpy_gufunc_call__array_ufunc__02 __________________________________
@pytest.mark.skipif(
LooseVersion(np.__version__) < "1.14.0",
reason="NumPy doesn't have `np.linalg._umath_linalg` yet",
)
# @pytest.mark.xfail(reason="Protect from `np.linalg._umath_linalg.eig` breaking")
def test_Array_numpy_gufunc_call__array_ufunc__02():
x = da.random.normal(size=(3, 10, 10), chunks=(2, 10, 10))
nx = x.compute()
nw, nv = np.linalg._umath_linalg.eig(nx)
> w, v = np.linalg._umath_linalg.eig(x, output_dtypes=(float, float))
dask/array/tests/test_array_core.py:262:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dask/array/core.py:1122: in __array_ufunc__
numpy_ufunc, numpy_ufunc.signature, *inputs, **kwargs
dask/array/gufunc.py:481: in apply_gufunc
meta = meta_from_array(meta, len(output_shape), dtype=odt)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = array([], shape=(0, 0), dtype=complex128), ndim = 2, dtype = <class 'float'>
def meta_from_array(x, ndim=None, dtype=None):
""" Normalize an array to appropriate meta object
Parameters
----------
x: array-like, callable
Either an object that looks sufficiently like a Numpy array,
or a callable that accepts shape and dtype keywords
ndim: int
Number of dimensions of the array
dtype: Numpy dtype
A valid input for ``np.dtype``
Returns
-------
array-like with zero elements of the correct dtype
"""
# If using x._meta, x must be a Dask Array, some libraries (e.g. zarr)
# implement a _meta attribute that are incompatible with Dask Array._meta
if hasattr(x, "_meta") and isinstance(x, Array):
x = x._meta
if dtype is None and x is None:
raise ValueError("You must specify the meta or dtype of the array")
if np.isscalar(x):
x = np.array(x)
if x is None:
x = np.ndarray
if isinstance(x, type):
x = x(shape=(0,) * (ndim or 0), dtype=dtype)
if (
not hasattr(x, "shape")
or not hasattr(x, "dtype")
or not isinstance(x.shape, tuple)
):
return x
if isinstance(x, list) or isinstance(x, tuple):
ndims = [
0
if isinstance(a, numbers.Number)
else a.ndim
if hasattr(a, "ndim")
else len(a)
for a in x
]
a = [a if nd == 0 else meta_from_array(a, nd) for a, nd in zip(x, ndims)]
return a if isinstance(x, list) else tuple(x)
if ndim is None:
ndim = x.ndim
try:
meta = x[tuple(slice(0, 0, None) for _ in range(x.ndim))]
if meta.ndim != ndim:
if ndim > x.ndim:
meta = meta[(Ellipsis,) + tuple(None for _ in range(ndim - meta.ndim))]
meta = meta[tuple(slice(0, 0, None) for _ in range(meta.ndim))]
elif ndim == 0:
meta = meta.sum()
else:
meta = meta.reshape((0,) * ndim)
except Exception:
meta = np.empty((0,) * ndim, dtype=dtype or x.dtype)
if np.isscalar(meta):
meta = np.array(meta)
if dtype and meta.dtype != dtype:
> meta = meta.astype(dtype)
E numpy.ComplexWarning: Casting complex values to real discards the imaginary part
dask/array/utils.py:105: ComplexWarning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is intended to fix #5120. I'll incrementally go through and set
strict=Falseappropriatelyblack dask/flake8 dask