@@ -264,32 +264,38 @@ def get_fantasy_model(
264264 # whitened / unwhitened variational strategies
265265 if not self .has_fantasy_strategy :
266266 raise NotImplementedError (
267- "No fantasy model support for " ,
268- self .__name__ ,
269- ". Only VariationalStrategy and UnwhitenedVariationalStrategy are currently supported." ,
267+ f"No fantasy model support for { self .__class__ .__name__ } . "
268+ "Only VariationalStrategy and UnwhitenedVariationalStrategy are currently supported."
270269 )
270+ else :
271+ from . import CholeskyVariationalDistribution # Circular import otherwise
272+
273+ if not isinstance (self ._variational_distribution , CholeskyVariationalDistribution ):
274+ raise NotImplementedError (
275+ "Fantasy models are only support for variational models with CholeskyVariationalDistribution."
276+ )
277+
271278 if not isinstance (self .model .likelihood , GaussianLikelihood ):
272279 raise NotImplementedError (
273- "No fantasy model support for " ,
274- self .model .likelihood ,
275- ". Only GaussianLikelihoods are currently supported." ,
280+ f"No fantasy model support for { self .model .likelihood .__class__ .__name__ } . "
281+ "Only GaussianLikelihoods are currently supported."
276282 )
277283 # we assume that either the user has given the model a mean_module and a covar_module
278284 # or that it will be passed into the get_fantasy_model function. we check for these.
279285 if mean_module is None :
280286 mean_module = getattr (self .model , "mean_module" , None )
281287 if mean_module is None :
282288 raise ModuleNotFoundError (
283- "Either you must provide a mean_module as input to get_fantasy_model" ,
284- "or it must be an attribute of the model called mean_module." ,
289+ "Either you must provide a mean_module as input to get_fantasy_model "
290+ "or it must be an attribute of the model called mean_module."
285291 )
286292 if covar_module is None :
287293 covar_module = getattr (self .model , "covar_module" , None )
288294 if covar_module is None :
289295 # raise an error
290296 raise ModuleNotFoundError (
291- "Either you must provide a covar_module as input to get_fantasy_model" ,
292- "or it must be an attribute of the model called covar_module." ,
297+ "Either you must provide a covar_module as input to get_fantasy_model "
298+ "or it must be an attribute of the model called covar_module."
293299 )
294300
295301 # first we construct an exact model over the inducing points with the inducing covariance
0 commit comments