Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MPI_OUT_BASE := unittest.out
MPI_OUT_PREFIX := ${PARALLEL_OUT_DIR}/${PYTHON_VERSION}-${MPI_OUT_BASE}


MPI_ONLY_LAUNCH_TEST := mpiexec -np 5 python ./distarray/globalapi/tests/launch_mpi.py
MPI_ONLY_LAUNCH_TEST := mpiexec -np 5 python ./distarray/globalapi/tests/launch_mpi.py

# see if we're using MPICH2, else assume OpenMPI
ifneq (,$(findstring MPICH2,$(shell mpicc -v 2>&1)))
Expand Down Expand Up @@ -98,7 +98,7 @@ test_mpi_with_coverage:
test: test_ipython test_mpi test_engines
.PHONY: test

test_with_coverage: test_ipython_with_coverage test_mpi_with_coverage test_engines_with_coverage
test_with_coverage: test_ipython_with_coverage test_mpi_with_coverage test_engines_with_coverage
.PHONY: test_with_coverage

coverage_report:
Expand Down
21 changes: 13 additions & 8 deletions distarray/globalapi/tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

from numpy.testing import assert_allclose, assert_array_equal

from distarray.testing import DefaultContextTestCase, IPythonContextTestCase, check_targets
from distarray.testing import (DefaultContextTestCase, IPythonContextTestCase,
check_targets)
from distarray.globalapi.context import Context
from distarray.globalapi.maps import Distribution
from distarray.mpionly_utils import is_solo_mpi_process
Expand Down Expand Up @@ -53,7 +54,7 @@ def test_local_sin(self):
def local_sin(da):
return numpy.sin(da)
self.context.register(local_sin)

db = self.context.local_sin(self.da)
assert_allclose(0, db.tondarray(), atol=1e-14)

Expand Down Expand Up @@ -132,7 +133,8 @@ def local_add_supermix(da, num1, db, num2, dc, num3=99, num4=66):
dm.fill(22)
dn = self.context.empty(self.da.distribution)
dn.fill(44)
do = self.context.local_add_supermix(self.da, 11, dm, 33, dc=dn, num3=55)
do = self.context.local_add_supermix(self.da, 11, dm,
33, dc=dn, num3=55)
expected = 2 * numpy.pi + 11 + 22 + 33 + 44 + 55 + 66
assert_allclose(do.tondarray(), expected)

Expand All @@ -146,7 +148,7 @@ def local_none(da):
self.assertTrue(dp is None)

def test_parameterless(self):

def parameterless():
"""This is a parameterless function."""
return None
Expand Down Expand Up @@ -304,10 +306,10 @@ def test_2D(self):
def test_3D(self):
a = self.context.empty((3, 3, 3))
db = Distribution(self.context, (3, 3, 3),
dist=('n', 'b', 'n'))
dist=('n', 'b', 'n'))
b = self.context.empty(db)
dc = Distribution(self.context, (3, 3, 3),
dist=('n', 'n', 'b'))
dist=('n', 'n', 'b'))
c = self.context.empty(dc)
self.assertEqual(a.grid_shape, (3, 1, 1))
self.assertEqual(b.grid_shape, (1, 3, 1))
Expand Down Expand Up @@ -402,18 +404,21 @@ def foo():

def test_apply_distarray(self):

da = self.context.empty((len(self.context.targets),), dtype=numpy.uint32)
da = self.context.empty((len(self.context.targets),),
dtype=numpy.uint32)

def local_label(la):
la.ndarray.fill(la.comm.rank)

# Testing that we can pass in `da` and `apply()` extracts `da.key` automatically.
# Testing that we can pass in `da`
# and `apply()` extracts `da.key` automatically.
self.context.apply(local_label, (da,))
assert_array_equal(da.tondarray(), range(len(self.context.targets)))

self.context.apply(local_label, kwargs={'la': da})
assert_array_equal(da.tondarray(), range(len(self.context.targets)))


class TestGetBaseComm(DefaultContextTestCase):

ntargets = 'any'
Expand Down
Loading