1414from  pymc .model .transform .optimization  import  freeze_dims_and_data 
1515from  pymc .util  import  RandomState 
1616from  pytensor  import  Variable , graph_replace 
17- from  pytensor .compile  import  get_mode 
1817from  rich .box  import  SIMPLE_HEAD 
1918from  rich .console  import  Console 
2019from  rich .table  import  Table 
@@ -222,7 +221,6 @@ def __init__(
222221        verbose : bool  =  True ,
223222        measurement_error : bool  =  False ,
224223    ):
225-         self ._fit_mode : str  |  None  =  None 
226224        self ._fit_coords : dict [str , Sequence [str ]] |  None  =  None 
227225        self ._fit_dims : dict [str , Sequence [str ]] |  None  =  None 
228226        self ._fit_data : pt .TensorVariable  |  None  =  None 
@@ -819,7 +817,6 @@ def build_statespace_graph(
819817        self ,
820818        data : np .ndarray  |  pd .DataFrame  |  pt .TensorVariable ,
821819        register_data : bool  =  True ,
822-         mode : str  |  None  =  None ,
823820        missing_fill_value : float  |  None  =  None ,
824821        cov_jitter : float  |  None  =  JITTER_DEFAULT ,
825822        save_kalman_filter_outputs_in_idata : bool  =  False ,
@@ -889,7 +886,6 @@ def build_statespace_graph(
889886        filter_outputs  =  self .kalman_filter .build_graph (
890887            pt .as_tensor_variable (data ),
891888            * self .unpack_statespace (),
892-             mode = mode ,
893889            missing_fill_value = missing_fill_value ,
894890            cov_jitter = cov_jitter ,
895891        )
@@ -900,7 +896,7 @@ def build_statespace_graph(
900896        filtered_covariances , predicted_covariances , observed_covariances  =  covs 
901897        if  save_kalman_filter_outputs_in_idata :
902898            smooth_states , smooth_covariances  =  self ._build_smoother_graph (
903-                 filtered_states , filtered_covariances , self .unpack_statespace (),  mode = mode 
899+                 filtered_states , filtered_covariances , self .unpack_statespace ()
904900            )
905901            all_kf_outputs  =  [* states , smooth_states , * covs , smooth_covariances ]
906902            self ._register_kalman_filter_outputs_with_pymc_model (all_kf_outputs )
@@ -919,7 +915,6 @@ def build_statespace_graph(
919915
920916        self ._fit_coords  =  pm_mod .coords .copy ()
921917        self ._fit_dims  =  pm_mod .named_vars_to_dims .copy ()
922-         self ._fit_mode  =  mode 
923918
924919    def  _build_smoother_graph (
925920        self ,
@@ -964,7 +959,7 @@ def _build_smoother_graph(
964959            * _ , T , Z , R , H , Q  =  matrices 
965960
966961            smooth_states , smooth_covariances  =  self .kalman_smoother .build_graph (
967-                 T , R , Q , filtered_states , filtered_covariances , mode = mode ,  cov_jitter = cov_jitter 
962+                 T , R , Q , filtered_states , filtered_covariances , cov_jitter = cov_jitter 
968963            )
969964            smooth_states .name  =  "smooth_states" 
970965            smooth_covariances .name  =  "smooth_covariances" 
@@ -1082,7 +1077,6 @@ def _kalman_filter_outputs_from_dummy_graph(
10821077            R ,
10831078            H ,
10841079            Q ,
1085-             mode = self ._fit_mode ,
10861080        )
10871081
10881082        filter_outputs .pop (- 1 )
@@ -1092,7 +1086,7 @@ def _kalman_filter_outputs_from_dummy_graph(
10921086        filtered_covariances , predicted_covariances , _  =  covariances 
10931087
10941088        [smoothed_states , smoothed_covariances ] =  self .kalman_smoother .build_graph (
1095-             T , R , Q , filtered_states , filtered_covariances ,  mode = self . _fit_mode 
1089+             T , R , Q , filtered_states , filtered_covariances 
10961090        )
10971091
10981092        grouped_outputs  =  [
@@ -1208,7 +1202,6 @@ def _sample_conditional(
12081202                    for  name  in  FILTER_OUTPUT_TYPES 
12091203                    for  suffix  in  ["" , "_observed" ]
12101204                ],
1211-                 compile_kwargs = {"mode" : get_mode (self ._fit_mode )},
12121205                random_seed = random_seed ,
12131206                ** kwargs ,
12141207            )
@@ -1308,7 +1301,6 @@ def _sample_unconditional(
13081301                * matrices ,
13091302                steps = steps ,
13101303                dims = dims ,
1311-                 mode = self ._fit_mode ,
13121304                sequence_names = self .kalman_filter .seq_names ,
13131305                k_endog = self .k_endog ,
13141306            )
@@ -1323,7 +1315,6 @@ def _sample_unconditional(
13231315            idata_unconditional  =  pm .sample_posterior_predictive (
13241316                group_idata ,
13251317                var_names = [f"{ group }  _latent" , f"{ group }  _observed" ],
1326-                 compile_kwargs = {"mode" : self ._fit_mode },
13271318                random_seed = random_seed ,
13281319                ** kwargs ,
13291320            )
@@ -1547,7 +1538,6 @@ def sample_statespace_matrices(
15471538            matrix_idata  =  pm .sample_posterior_predictive (
15481539                idata  if  group  ==  "posterior"  else  idata .prior ,
15491540                var_names = matrix_names ,
1550-                 compile_kwargs = {"mode" : self ._fit_mode },
15511541                extend_inferencedata = False ,
15521542            )
15531543
@@ -2094,7 +2084,6 @@ def forecast(
20942084                * matrices ,
20952085                steps = len (forecast_index ),
20962086                dims = dims ,
2097-                 mode = self ._fit_mode ,
20982087                sequence_names = self .kalman_filter .seq_names ,
20992088                k_endog = self .k_endog ,
21002089                append_x0 = False ,
@@ -2109,7 +2098,6 @@ def forecast(
21092098            idata_forecast  =  pm .sample_posterior_predictive (
21102099                idata ,
21112100                var_names = ["forecast_latent" , "forecast_observed" ],
2112-                 compile_kwargs = {"mode" : self ._fit_mode },
21132101                random_seed = random_seed ,
21142102                ** kwargs ,
21152103            )
@@ -2260,28 +2248,13 @@ def irf_step(shock, x, c, T, R):
22602248                non_sequences = [c , T , R ],
22612249                n_steps = n_steps ,
22622250                strict = True ,
2263-                 mode = self ._fit_mode ,
22642251            )
22652252
22662253            pm .Deterministic ("irf" , irf , dims = [TIME_DIM , ALL_STATE_DIM ])
22672254
2268-             compile_kwargs  =  kwargs .get ("compile_kwargs" , {})
2269-             if  "mode"  not  in   compile_kwargs .keys ():
2270-                 compile_kwargs  =  {"mode" : self ._fit_mode }
2271-             else :
2272-                 mode  =  compile_kwargs .get ("mode" )
2273-                 if  mode  is  not   None  and  mode  !=  self ._fit_mode :
2274-                     raise  ValueError (
2275-                         f"User provided compile mode ({ mode }  ) does not match the compile mode used to " 
2276-                         f"construct the model ({ self ._fit_mode }  )." 
2277-                     )
2278- 
2279-                 compile_kwargs .update ({"mode" : self ._fit_mode })
2280- 
22812255            irf_idata  =  pm .sample_posterior_predictive (
22822256                idata ,
22832257                var_names = ["irf" ],
2284-                 compile_kwargs = compile_kwargs ,
22852258                random_seed = random_seed ,
22862259                ** kwargs ,
22872260            )
0 commit comments