@@ -805,12 +805,12 @@ def test_logging_sampled_basic_rvs_prior(self, caplog):
805
805
806
806
with m :
807
807
pm .sample_prior_predictive (samples = 1 )
808
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [x, z]" )]
808
+ assert caplog .record_tuples == [("pymc.sampling.forward " , logging .INFO , "Sampling: [x, z]" )]
809
809
caplog .clear ()
810
810
811
811
with m :
812
812
pm .sample_prior_predictive (samples = 1 , var_names = ["x" ])
813
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [x]" )]
813
+ assert caplog .record_tuples == [("pymc.sampling.forward " , logging .INFO , "Sampling: [x]" )]
814
814
caplog .clear ()
815
815
816
816
def test_logging_sampled_basic_rvs_posterior (self , caplog ):
@@ -823,40 +823,44 @@ def test_logging_sampled_basic_rvs_posterior(self, caplog):
823
823
idata = az_from_dict (posterior = {"x" : np .zeros (5 ), "x_det" : np .ones (5 ), "y" : np .ones (5 )})
824
824
with m :
825
825
pm .sample_posterior_predictive (idata )
826
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [z]" )]
826
+ assert caplog .record_tuples == [("pymc.sampling.forward " , logging .INFO , "Sampling: [z]" )]
827
827
caplog .clear ()
828
828
829
829
with m :
830
830
pm .sample_posterior_predictive (idata , var_names = ["y" , "z" ])
831
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [y, z]" )]
831
+ assert caplog .record_tuples == [("pymc.sampling.forward " , logging .INFO , "Sampling: [y, z]" )]
832
832
caplog .clear ()
833
833
834
834
# Resampling `x` will force resampling of `y`, even if it is in trace
835
835
with m :
836
836
pm .sample_posterior_predictive (idata , var_names = ["x" , "z" ])
837
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [x, y, z]" )]
837
+ assert caplog .record_tuples == [
838
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [x, y, z]" )
839
+ ]
838
840
caplog .clear ()
839
841
840
842
# Missing deterministic `x_det` does not show in the log, even if it is being
841
843
# recomputed, only `y` RV shows
842
844
idata = az_from_dict (posterior = {"x" : np .zeros (5 )})
843
845
with m :
844
846
pm .sample_posterior_predictive (idata )
845
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [y, z]" )]
847
+ assert caplog .record_tuples == [("pymc.sampling.forward " , logging .INFO , "Sampling: [y, z]" )]
846
848
caplog .clear ()
847
849
848
850
# Missing deterministic `x_det` does not cause recomputation of downstream `y` RV
849
851
idata = az_from_dict (posterior = {"x" : np .zeros (5 ), "y" : np .ones (5 )})
850
852
with m :
851
853
pm .sample_posterior_predictive (idata )
852
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [z]" )]
854
+ assert caplog .record_tuples == [("pymc.sampling.forward " , logging .INFO , "Sampling: [z]" )]
853
855
caplog .clear ()
854
856
855
857
# Missing `x` causes sampling of downstream `y` RV, even if it is present in trace
856
858
idata = az_from_dict (posterior = {"y" : np .ones (5 )})
857
859
with m :
858
860
pm .sample_posterior_predictive (idata )
859
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [x, y, z]" )]
861
+ assert caplog .record_tuples == [
862
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [x, y, z]" )
863
+ ]
860
864
caplog .clear ()
861
865
862
866
def test_logging_sampled_basic_rvs_posterior_deterministic (self , caplog ):
@@ -871,7 +875,7 @@ def test_logging_sampled_basic_rvs_posterior_deterministic(self, caplog):
871
875
idata = az_from_dict (posterior = {"x" : np .zeros (5 ), "x_det" : np .ones (5 ), "y" : np .ones (5 )})
872
876
with m :
873
877
pm .sample_posterior_predictive (idata , var_names = ["x_det" , "z" ])
874
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [y, z]" )]
878
+ assert caplog .record_tuples == [("pymc.sampling.forward " , logging .INFO , "Sampling: [y, z]" )]
875
879
caplog .clear ()
876
880
877
881
@staticmethod
@@ -938,19 +942,25 @@ def test_logging_sampled_basic_rvs_posterior_mutable(self, mock_sample_results,
938
942
# MultiTrace will only have the actual MCMC posterior samples but no information on
939
943
# the MutableData and mutable coordinate values, so it will always assume they are volatile
940
944
# and resample their descendants
941
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [a, b, sigma, y]" )]
945
+ assert caplog .record_tuples == [
946
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [a, b, sigma, y]" )
947
+ ]
942
948
caplog .clear ()
943
949
elif kind == "InferenceData" :
944
950
# InferenceData has all MCMC posterior samples and the values for both coordinates and
945
951
# data containers. This enables it to see that no data has changed and it should only
946
952
# resample the observed variable
947
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [y]" )]
953
+ assert caplog .record_tuples == [
954
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [y]" )
955
+ ]
948
956
caplog .clear ()
949
957
elif kind == "Dataset" :
950
958
# Dataset has all MCMC posterior samples and the values of the coordinates. This
951
959
# enables it to see that the coordinates have not changed, but the MutableData is
952
960
# assumed volatile by default
953
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [b, y]" )]
961
+ assert caplog .record_tuples == [
962
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [b, y]" )
963
+ ]
954
964
caplog .clear ()
955
965
956
966
original_offsets = model ["offsets" ].get_value ()
@@ -959,13 +969,19 @@ def test_logging_sampled_basic_rvs_posterior_mutable(self, mock_sample_results,
959
969
pm .set_data ({"offsets" : original_offsets + 1 })
960
970
pm .sample_posterior_predictive (samples )
961
971
if kind == "MultiTrace" :
962
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [a, b, sigma, y]" )]
972
+ assert caplog .record_tuples == [
973
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [a, b, sigma, y]" )
974
+ ]
963
975
caplog .clear ()
964
976
elif kind == "InferenceData" :
965
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [b, y]" )]
977
+ assert caplog .record_tuples == [
978
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [b, y]" )
979
+ ]
966
980
caplog .clear ()
967
981
elif kind == "Dataset" :
968
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [b, y]" )]
982
+ assert caplog .record_tuples == [
983
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [b, y]" )
984
+ ]
969
985
caplog .clear ()
970
986
971
987
with model :
@@ -974,13 +990,19 @@ def test_logging_sampled_basic_rvs_posterior_mutable(self, mock_sample_results,
974
990
pm .set_data ({"offsets" : original_offsets , "y_obs" : np .zeros ((10 , 4 ))})
975
991
pm .sample_posterior_predictive (samples )
976
992
if kind == "MultiTrace" :
977
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [a, b, sigma, y]" )]
993
+ assert caplog .record_tuples == [
994
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [a, b, sigma, y]" )
995
+ ]
978
996
caplog .clear ()
979
997
elif kind == "InferenceData" :
980
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [a, sigma, y]" )]
998
+ assert caplog .record_tuples == [
999
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [a, sigma, y]" )
1000
+ ]
981
1001
caplog .clear ()
982
1002
elif kind == "Dataset" :
983
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [a, b, sigma, y]" )]
1003
+ assert caplog .record_tuples == [
1004
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [a, b, sigma, y]" )
1005
+ ]
984
1006
caplog .clear ()
985
1007
986
1008
with model :
@@ -990,13 +1012,19 @@ def test_logging_sampled_basic_rvs_posterior_mutable(self, mock_sample_results,
990
1012
pm .set_data ({"offsets" : original_offsets + 1 , "y_obs" : np .zeros ((10 , 3 ))})
991
1013
pm .sample_posterior_predictive (samples )
992
1014
if kind == "MultiTrace" :
993
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [a, b, sigma, y]" )]
1015
+ assert caplog .record_tuples == [
1016
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [a, b, sigma, y]" )
1017
+ ]
994
1018
caplog .clear ()
995
1019
elif kind == "InferenceData" :
996
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [a, b, sigma, y]" )]
1020
+ assert caplog .record_tuples == [
1021
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [a, b, sigma, y]" )
1022
+ ]
997
1023
caplog .clear ()
998
1024
elif kind == "Dataset" :
999
- assert caplog .record_tuples == [("pymc" , logging .INFO , "Sampling: [a, b, sigma, y]" )]
1025
+ assert caplog .record_tuples == [
1026
+ ("pymc.sampling.forward" , logging .INFO , "Sampling: [a, b, sigma, y]" )
1027
+ ]
1000
1028
caplog .clear ()
1001
1029
1002
1030
0 commit comments