From 3bb0d80f34e67496c57a8a4177787271e0c34acf Mon Sep 17 00:00:00 2001 From: ST John Date: Sat, 23 Sep 2023 22:16:57 +0300 Subject: [PATCH] fix deprecation of `dtc` --- src/deprecations.jl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/deprecations.jl b/src/deprecations.jl index 49975b7e..c7db3617 100644 --- a/src/deprecations.jl +++ b/src/deprecations.jl @@ -6,5 +6,17 @@ plt, gp; samples=n, kwargs... ) -@deprecate elbo(dtc::DTC, fx, y) approx_log_evidence(dtc, fx, y) -@deprecate dtc(vfe::Union{VFE,DTC}, fx, y) approx_log_evidence(vfe, fx, y) +@deprecate dtc(dtc::DTC, fx, y) approx_log_evidence(dtc, fx, y) + +function _warn_elbo_called_with_DTC(dtc::DTC, fx, y) + @warn "`elbo` was called with an object of type `DTC`, but should only be called with the `VFE` type instead" + return elbo(VFE(dtc.fz), fx, y) +end + +function _warn_dtc_called_with_VFE(vfe::VFE, fx, y) + @warn "`dtc` was called with an object of type `VFE`, but instead you should call `approx_log_evidence` with an object of type `DTC`" + return approx_log_evidence(DTC(vfe.fz), fx, y) +end + +@deprecate elbo(dtc::DTC, fx, y) _warn_elbo_called_with_DTC(dtc, fx, y) +@deprecate dtc(vfe::VFE, fx, y) _warn_dtc_called_with_VFE(vfe, fx, y)