From 744943768bc5ab79027adad9f04bd61a7b2d42a8 Mon Sep 17 00:00:00 2001 From: Jesper Nielsen <44195043+jesnie@users.noreply.github.com> Date: Wed, 2 Feb 2022 17:01:15 +0000 Subject: [PATCH] Use iv.num_inducing instead of len(iv), for compatibility with future GPflow. (#66) --- gpflux/layers/gp_layer.py | 2 +- gpflux/runtime_checks.py | 2 +- tests/gpflux/test_helpers.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gpflux/layers/gp_layer.py b/gpflux/layers/gp_layer.py index 6f1b6062..a9324555 100644 --- a/gpflux/layers/gp_layer.py +++ b/gpflux/layers/gp_layer.py @@ -204,7 +204,7 @@ def __init__( ) num_inducing, self.num_latent_gps = ( - len(inducing_variable), + inducing_variable.num_inducing, num_latent_gps, ) diff --git a/gpflux/runtime_checks.py b/gpflux/runtime_checks.py index d33080dd..c8bb3ce5 100644 --- a/gpflux/runtime_checks.py +++ b/gpflux/runtime_checks.py @@ -70,5 +70,5 @@ def verify_compatibility( f"the number of separate independent inducing_variables ({latent_inducing_points})" ) - num_inducing_points = len(inducing_variable) # currently the same for each dim + num_inducing_points = inducing_variable.num_inducing # currently the same for each dim return num_inducing_points, num_latent_gps diff --git a/tests/gpflux/test_helpers.py b/tests/gpflux/test_helpers.py index 7354ee96..04517deb 100644 --- a/tests/gpflux/test_helpers.py +++ b/tests/gpflux/test_helpers.py @@ -95,7 +95,7 @@ def test_construct_inducing_separate_independent_custom_list(z_init): assert isinstance(moiv, SeparateIndependentInducingVariables) assert isinstance(moiv, MultioutputInducingVariables) for i, iv in enumerate(moiv.inducing_variable_list): - assert len(iv) == num_inducing[i] + assert iv.num_inducing == num_inducing[i] @pytest.mark.parametrize("z_init", [True, False]) @@ -116,7 +116,7 @@ def test_construct_inducing_separate_independent_duplicates(z_init): assert isinstance(moiv, SeparateIndependentInducingVariables) assert isinstance(moiv, MultioutputInducingVariables) for iv in moiv.inducing_variable_list: - assert len(iv) == num_inducing + assert iv.num_inducing == num_inducing @pytest.mark.parametrize("z_init", [True, False]) @@ -136,7 +136,7 @@ def test_construct_inducing_shared_independent_duplicates(z_init): assert isinstance(moiv, SharedIndependentInducingVariables) assert isinstance(moiv, MultioutputInducingVariables) - assert len(moiv.inducing_variable) == num_inducing + assert moiv.inducing_variable.num_inducing == num_inducing def test_construct_mean_function_Identity(): @@ -170,7 +170,7 @@ def test_construct_gp_layer(): # inducing variable assert isinstance(layer.inducing_variable, SharedIndependentInducingVariables) assert isinstance(layer.inducing_variable.inducing_variable, InducingPoints) - assert len(layer.inducing_variable.inducing_variable) == num_inducing + assert layer.inducing_variable.inducing_variable.num_inducing == num_inducing # mean function assert isinstance(layer.mean_function, gpflow.mean_functions.Zero)