/usr/lib/python2.7/dist-packages/PySPH-1.0a4.dev0-py2.7-linux-x86_64.egg/pysph/parallel/tests/reduce_array.py is in python-pysph 0~20160514.git91867dc-4build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | """Test if the mpi_reduce_array function works correctly.
"""
import mpi4py.MPI as mpi
import numpy as np
from pysph.base.reduce_array import serial_reduce_array, mpi_reduce_array
comm = mpi.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
n = 5
data = np.ones(n)*(rank + 1)
full_data = []
for i in range(size):
full_data = np.concatenate([full_data, np.ones(n)*(i+1)])
for op in ('sum', 'prod', 'min', 'max'):
serial_data = serial_reduce_array(data, op)
result = mpi_reduce_array(serial_data, op)
expect = getattr(np, op)(full_data)
msg = "For op %s: Expected %s, got %s"%(op, expect, result)
assert expect == result, msg
|