[go: nahoru, domu]

Skip to content

Commit

Permalink
Fix a few more issues.
Browse files Browse the repository at this point in the history
- Changing the language_level to 3 introduces some small issues.
- The tox.ini file is picked up first before setup.cfg.
- Try adding a bit of sleep before testing the xmlrpc server shutdown.
  • Loading branch information
prabhuramachandran committed Apr 23, 2020
1 parent 3e35750 commit f8f5b2e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
38 changes: 19 additions & 19 deletions pysph/base/tests/test_device_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def check_import(backend):
pytest.importorskip('pycuda')


test_all_backends = pytest.mark.parametrize('backend',
check_all_backends = pytest.mark.parametrize('backend',
['cython', 'opencl', 'cuda'])


class TestDeviceHelper(object):
def setup(self):
self.pa = get_particle_array(name='f', x=[0.0, 1.0], m=1.0, rho=2.0)

@test_all_backends
@check_all_backends
def test_simple(self, backend):
check_import(backend)
self.setup()
Expand All @@ -48,7 +48,7 @@ def test_simple(self, backend):
assert np.allclose(pa.rho, h.rho.get())
assert np.allclose(pa.tag, h.tag.get())

@test_all_backends
@check_all_backends
def test_push_correctly_sets_values_with_args(self, backend):
check_import(backend)
self.setup()
Expand All @@ -71,7 +71,7 @@ def test_push_correctly_sets_values_with_args(self, backend):
assert np.allclose(pa.rho, h.rho.get())
assert np.allclose(pa.tag, h.tag.get())

@test_all_backends
@check_all_backends
def test_push_correctly_sets_values_with_no_args(self, backend):
check_import(backend)
self.setup()
Expand All @@ -94,7 +94,7 @@ def test_push_correctly_sets_values_with_no_args(self, backend):
assert np.allclose(pa.rho, h.rho.get())
assert np.allclose(pa.tag, h.tag.get())

@test_all_backends
@check_all_backends
def test_pull_correctly_sets_values_with_args(self, backend):
check_import(backend)
self.setup()
Expand All @@ -117,7 +117,7 @@ def test_pull_correctly_sets_values_with_args(self, backend):
assert np.allclose(pa.rho, h.rho.get())
assert np.allclose(pa.tag, h.tag.get())

@test_all_backends
@check_all_backends
def test_pull_correctly_sets_values_with_no_args(self, backend):
check_import(backend)
self.setup()
Expand All @@ -140,7 +140,7 @@ def test_pull_correctly_sets_values_with_no_args(self, backend):
assert np.allclose(pa.rho, h.rho.get())
assert np.allclose(pa.tag, h.tag.get())

@test_all_backends
@check_all_backends
def test_max_provides_maximum(self, backend):
check_import(backend)
self.setup()
Expand All @@ -151,7 +151,7 @@ def test_max_provides_maximum(self, backend):
# Then
assert h.max('x') == 1.0

@test_all_backends
@check_all_backends
def test_that_adding_removing_prop_to_array_updates_gpu(self, backend):
check_import(backend)
self.setup()
Expand All @@ -174,7 +174,7 @@ def test_that_adding_removing_prop_to_array_updates_gpu(self, backend):
assert 'test' not in h._data
assert 'test' not in h.properties

@test_all_backends
@check_all_backends
def test_resize_works(self, backend):
check_import(backend)
self.setup()
Expand Down Expand Up @@ -208,7 +208,7 @@ def test_resize_works(self, backend):
assert np.allclose(pa.rho, h.rho.get())
assert np.allclose(pa.tag, h.tag.get())

@test_all_backends
@check_all_backends
def test_get_number_of_particles(self, backend):
check_import(backend)
self.setup()
Expand All @@ -228,7 +228,7 @@ def test_get_number_of_particles(self, backend):
assert h.get_number_of_particles() == 5
assert h.get_number_of_particles(real=True) == 3

@test_all_backends
@check_all_backends
def test_align(self, backend):
check_import(backend)
self.setup()
Expand Down Expand Up @@ -256,7 +256,7 @@ def test_align(self, backend):
expect = x[::-1, :].ravel()
assert np.all(h.force.get() == expect)

@test_all_backends
@check_all_backends
def test_align_particles(self, backend):
check_import(backend)
self.setup()
Expand All @@ -276,7 +276,7 @@ def test_align_particles(self, backend):
x = h.x.get()
assert np.all(np.sort(x[:-2]) == np.array([2., 3., 5.]))

@test_all_backends
@check_all_backends
def test_remove_particles(self, backend):
check_import(backend)
self.setup()
Expand All @@ -297,7 +297,7 @@ def test_remove_particles(self, backend):
# Then
assert np.all(np.sort(h.x.get()) == np.array([2., 5.]))

@test_all_backends
@check_all_backends
def test_remove_tagged_particles(self, backend):
check_import(backend)
self.setup()
Expand All @@ -316,7 +316,7 @@ def test_remove_tagged_particles(self, backend):
# Then
assert np.all(np.sort(h.x.get()) == np.array([2., 3., 5.]))

@test_all_backends
@check_all_backends
def test_add_particles(self, backend):
check_import(backend)
self.setup()
Expand All @@ -333,7 +333,7 @@ def test_add_particles(self, backend):
# Then
assert np.all(np.sort(h.x.get()) == np.array([0., 0., 0., 0., 0., 1.]))

@test_all_backends
@check_all_backends
def test_extend(self, backend):
check_import(backend)
self.setup()
Expand All @@ -349,7 +349,7 @@ def test_extend(self, backend):
# Then
assert h.get_number_of_particles() == 6

@test_all_backends
@check_all_backends
def test_append_parray(self, backend):
check_import(backend)
self.setup()
Expand All @@ -365,7 +365,7 @@ def test_append_parray(self, backend):
# Then
assert h.get_number_of_particles() == 4

@test_all_backends
@check_all_backends
def test_empty_clone(self, backend):
check_import(backend)
self.setup()
Expand All @@ -382,7 +382,7 @@ def test_empty_clone(self, backend):
assert result_pa.gpu.get_number_of_particles() == 0
assert result_pa.name == 'f'

@test_all_backends
@check_all_backends
def test_extract_particles(self, backend):
check_import(backend)
self.setup()
Expand Down
5 changes: 5 additions & 0 deletions pysph/solver/tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import shutil
import sys
from tempfile import mkdtemp
import time

from pysph.solver.application import Application
from pysph.solver.solver import Solver
Expand Down Expand Up @@ -159,4 +160,8 @@ def test_app_stops_xml_rpc_interface_at_end(self):
app._interfaces[0], XMLRPCInterface
))
port1 = get_free_port(9000)
count = 0
while port1 != port and count < 4:
time.sleep(0.5)
count += 1
self.assertEqual(port1, port)
2 changes: 1 addition & 1 deletion pysph/sph/gas_dynamics/gsph.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def interpolate(self, hi=0.0, hj=0.0, rhoi=0.0, rhoj=0.0,
(3.0/8.0)*hij4*(aij*dij + bij*cij) +
0.5*hij2*cij*dij)/vij
else:
printf("%s", "Unknown interpolation type")
printf(b"%s", b"Unknown interpolation type")

result[0] = vij_i2
result[1] = vij_j2
Expand Down
4 changes: 2 additions & 2 deletions pysph/sph/gas_dynamics/riemann_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def exact(rhol=0.0, rhor=1.0, pl=0.0, pr=1.0,
pold = p

if i == niter - 1:
printf("%s", "Divergence in Newton-Raphson Iteration")
printf(b"%s", b"Divergence in Newton-Raphson Iteration")
return 1

# compute the velocity in the star region 'um'
Expand Down Expand Up @@ -709,7 +709,7 @@ def hllc(rhol=0.0, rhor=1.0, pl=0.0, pr=1.0, ul=0.0, ur=1.0,
ustar = ur

else:
printf("%s", "Incorrect wave speeds")
printf(b"%s", b"Incorrect wave speeds")
return 1

result[0] = pstar
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ skip_missing_interpreters = True

[pytest]
addopts = -m "not slow"
markers =
slow: marks tests as slow (deselect with '-m "not slow"')
parallel: tests that require MPI

[testenv]
sitepackages = True
Expand Down

0 comments on commit f8f5b2e

Please sign in to comment.