From 2ccea7bcc1a736fdc8d1d7226c0d579eb483646c Mon Sep 17 00:00:00 2001 From: Manuel Guenther <manuel.guenther@idiap.ch> Date: Mon, 1 Jun 2015 14:53:04 +0200 Subject: [PATCH] Fixed sampling test issue; added generic grid configuration and tests --- bob/bio/base/config/grid/grid.py | 4 ++++ bob/bio/base/test/test_utils.py | 22 +++++++++++++++++++--- setup.py | 3 ++- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 bob/bio/base/config/grid/grid.py diff --git a/bob/bio/base/config/grid/grid.py b/bob/bio/base/config/grid/grid.py new file mode 100644 index 00000000..f4c3852d --- /dev/null +++ b/bob/bio/base/config/grid/grid.py @@ -0,0 +1,4 @@ +import bob.bio.base + +# define the queue using all the default parameters +grid = bob.bio.base.grid.Grid() diff --git a/bob/bio/base/test/test_utils.py b/bob/bio/base/test/test_utils.py index a3abdad7..b8781f90 100644 --- a/bob/bio/base/test/test_utils.py +++ b/bob/bio/base/test/test_utils.py @@ -22,6 +22,22 @@ def test_resources(): assert isinstance (cls, bob.bio.base.algorithm.PCA) +def test_grid(): + # try to load the grid configurations + g = bob.bio.base.load_resource("grid", "grid") + assert not g.is_local() + + g = bob.bio.base.load_resource("local-p4", "grid") + assert g.is_local() + assert g.number_of_parallel_processes == 4 + g = bob.bio.base.load_resource("local-p8", "grid") + assert g.is_local() + assert g.number_of_parallel_processes == 8 + g = bob.bio.base.load_resource("local-p16", "grid") + assert g.is_local() + assert g.number_of_parallel_processes == 16 + + def test_io(): # Test that bob.bio.base.load and save works as expected filename = bob.io.base.test_utils.temporary_filename() @@ -64,13 +80,13 @@ def test_io(): def test_sampling(): # test selection of elements indices = bob.bio.base.selected_indices(100, 10) - assert indices == range(5, 100, 10) + assert indices == list(range(5, 100, 10)) indices = bob.bio.base.selected_indices(100, 300) - assert indices == range(100) + assert indices == list(range(100)) indices = bob.bio.base.selected_indices(100, None) - assert indices == range(100) + assert indices == list(range(100)) array = numpy.arange(100) elements = bob.bio.base.selected_elements(array, 10) diff --git a/setup.py b/setup.py index f0d76157..6b85a5b3 100644 --- a/setup.py +++ b/setup.py @@ -133,7 +133,8 @@ setup( 'bob.bio.grid': [ 'local-p4 = bob.bio.base.config.grid.local:grid', 'local-p8 = bob.bio.base.config.grid.local:grid_p8', - 'local-p16 = bob.bio.base.config.grid.local:grid_p16' + 'local-p16 = bob.bio.base.config.grid.local:grid_p16', + 'grid = bob.bio.base.config.grid.grid:grid' ], }, -- GitLab