<commit_before><commit_msg>Added a test for create_comm_with_list.<commit_after>import unittest
import numpy
from numpy.testing import assert_array_equal

import distarray.local.denselocalarray as dla
from distarray.testing import comm_null_passes
from distarray.mpiutils import MPI, create_comm_with_list


class TestCreateCommWithList(unittest.TestCase):
    """ Test creating MPI comm with comm_with_list(). """

    def setUp(self):
        self.nodes = [0, 1, 2, 3]
        self.comm = create_comm_with_list(self.nodes)

    def tearDown(self):
        if self.comm != MPI.COMM_NULL:
            self.comm.Free()

    @comm_null_passes
    def test_zeros(self):
        """ A very simple test that really checks the MPI comm. """
        size = len(self.nodes)
        nrows = size * 3
        a = dla.zeros((nrows, 20), comm=self.comm)
        expected = numpy.zeros((nrows // size, 20))
        assert_array_equal(a.local_array, expected)


if __name__ == '__main__':
    try:
        unittest.main()
    except SystemExit:
        pass
{'fraction_non_alphanumeric': 0.0987535953978907, 'fraction_numerical': 0.00862895493767977, 'mean_word_length': 3.046511627906977, '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': '4815066', 'n_tokens_mistral': 341, 'n_tokens_neox': 323, 'n_words': 84}