# -*- coding: utf-8 -*-

from __future__ import absolute_import

import dask.array.utils


def _assert_eq_nan(a, b, **kwargs):
    a = a.copy()
    b = b.copy()

    a_nan = (a != a)
    b_nan = (b != b)

    a[a_nan] = 0
    b[b_nan] = 0

    dask.array.utils.assert_eq(a_nan, b_nan, **kwargs)
    dask.array.utils.assert_eq(a, b, **kwargs)

# -*- coding: utf-8 -*-

from __future__ import absolute_import

import dask.array.utils


def _assert_eq_nan(a, b, **kwargs):
    a = a.copy()
    b = b.copy()

    a = a[...]
    b = b[...]

    a_nan = (a != a)
    b_nan = (b != b)

    a[a_nan] = 0
    b[b_nan] = 0

    dask.array.utils.assert_eq(a_nan, b_nan, **kwargs)
    dask.array.utils.assert_eq(a, b, **kwargs)

Handle scalar values in _assert_eq_nan
Handle scalar values in _assert_eq_nan

Add some special handling in `_assert_eq_nan` to handle having scalar
values passed in. Basically ensure that everything provided is an array.
This is a no-op for arrays, but converts scalars into 0-D arrays. By
doing this, we are able to use the same `nan` handling code. Also
convert the 0-D arrays back to scalars. This means a 0-D array will be
treated as a scalar in the end. However Dask doesn't really have a way
to differentiate the two. So this is fine.
