From 3a785fc0926c1dd596a03c388aa4327fcdb71d37 Mon Sep 17 00:00:00 2001 From: Khurram Ghani Date: Mon, 8 Jan 2024 11:47:56 +0000 Subject: [PATCH] Fix test by using sets directly with id Behavior of tensorflow ObjectIdentitySet has change in 2.15, resulting in the set equality comparing wrappers instead of wrapped values. See https://github.com/tensorflow/tensorflow/commit/bc28335cbd05c29a8a0868bfb107d4b940a79680. --- tests/gpflux/layers/test_dedup_trackable_layer.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/gpflux/layers/test_dedup_trackable_layer.py b/tests/gpflux/layers/test_dedup_trackable_layer.py index 93d4efc4..6f110e07 100644 --- a/tests/gpflux/layers/test_dedup_trackable_layer.py +++ b/tests/gpflux/layers/test_dedup_trackable_layer.py @@ -19,7 +19,6 @@ import pytest import tensorflow as tf from tensorflow.python.ops.resource_variable_ops import ResourceVariable -from tensorflow.python.util import object_identity import gpflow from gpflow.utilities import parameter_dict @@ -141,11 +140,10 @@ def test_weights_equals_deduplicated_parameter_dict(model): # We filter out the parameters of type ResourceVariable. # They have been added to the model by the `add_metric` call in the layer. parameters = [p for p in parameter_dict(model).values() if not isinstance(p, ResourceVariable)] - variables = map(lambda p: p.unconstrained_variable, parameters) - deduplicate_variables = object_identity.ObjectIdentitySet(variables) + variables = {id(p.unconstrained_variable) for p in parameters} weights = model.trainable_weights - assert len(weights) == len(deduplicate_variables) + assert len(weights) == len(variables) - weights_set = object_identity.ObjectIdentitySet(weights) - assert weights_set == deduplicate_variables + weights_set = {id(w) for w in weights} + assert weights_set == variables