4242from pytensor .graph .traversal import ancestors , general_toposort , walk
4343from pytensor .tensor .random .var import RandomGeneratorSharedVariable
4444from pytensor .tensor .sharedvar import SharedVariable , TensorSharedVariable
45- from pytensor .tensor .variable import TensorConstant , TensorVariable
45+ from pytensor .tensor .variable import TensorConstant
4646from rich .console import Console
4747from rich .progress import BarColumn , TextColumn , TimeElapsedColumn , TimeRemainingColumn
4848from rich .theme import Theme
@@ -1032,10 +1032,8 @@ def vectorize_over_posterior(
10321032 If random variables are found in the graph and `allow_rvs_in_graph` is False
10331033 """
10341034 # Identify which free RVs are needed to compute `outputs`
1035- needed_rvs : list [TensorVariable ] = [
1036- cast (TensorVariable , rv )
1037- for rv in ancestors (outputs , blockers = input_rvs )
1038- if rv in set (input_rvs )
1035+ needed_rvs : list [Variable ] = [
1036+ rv for rv in ancestors (outputs , blockers = input_rvs ) if rv in set (input_rvs )
10391037 ]
10401038
10411039 # Replace needed_rvs with actual posterior samples
@@ -1044,7 +1042,7 @@ def vectorize_over_posterior(
10441042 for rv in needed_rvs :
10451043 posterior_samples = posterior [rv .name ].data
10461044
1047- replace_dict [rv ] = pt .constant (posterior_samples .astype (rv .dtype ), name = rv .name )
1045+ replace_dict [rv ] = pt .constant (posterior_samples .astype (rv .dtype ), name = rv .name ) # type: ignore[attr-defined]
10481046
10491047 # Replace the rvs that remain in the graph with resized versions
10501048 all_rvs = rvs_in_graph (outputs )
0 commit comments