<commit_before>from dask.distributed import dask_client_from_ipclient
import numpy as np
from numpy.testing import assert_array_almost_equal
import dask.array as da


def test_dask_client_from_ipclient():
    from IPython.parallel import Client
    c = Client()
    dask_client = dask_client_from_ipclient(c)

    # data
    a = np.arange(100).reshape(10, 10)
    d = da.from_array(a, ((5, 5), (5, 5)))

    # test array.mean
    expected = a.mean(axis=0)
    d1 = d.mean(axis=0)
    result = d1.compute(get=dask_client.get)
    assert_array_almost_equal(result, expected)

    # test ghosting
    d2 = da.ghost.ghost(d, depth=1, boundary='reflect')
    d3 = da.ghost.trim_internal(d2, {0: 1, 1: 1})
    result1 = d3.compute(get=dask_client.get)<commit_msg>Skip tests on missing IPython or numpy import<commit_after>import pytest

np = pytest.importorskip('numpy')
pytest.importorskip('IPython.parallel')

import numpy as np
from numpy.testing import assert_array_almost_equal

from dask.distributed import dask_client_from_ipclient
import dask.array as da


def test_dask_client_from_ipclient():
    from IPython.parallel import Client
    c = Client()
    dask_client = dask_client_from_ipclient(c)

    # data
    a = np.arange(100).reshape(10, 10)
    d = da.from_array(a, ((5, 5), (5, 5)))

    # test array.mean
    expected = a.mean(axis=0)
    d1 = d.mean(axis=0)
    result = d1.compute(get=dask_client.get)
    assert_array_almost_equal(result, expected)

    # test ghosting
    d2 = da.ghost.ghost(d, depth=1, boundary='reflect')
    d3 = da.ghost.trim_internal(d2, {0: 1, 1: 1})
    result1 = d3.compute(get=dask_client.get)
{'fraction_non_alphanumeric': 0.11606597434331094, 'fraction_numerical': 0.030543677458766034, 'mean_word_length': 3.963636363636364, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7548166', 'n_tokens_mistral': 642, 'n_tokens_neox': 607, 'n_words': 131}