Module Import alias Import alias identifier ImportFrom alias Expr Str Assign NameStore Num FunctionDef arguments args NameParam NameParam defaults Num body Assign NameStore ListLoad Str Str Str Str Str Assign NameStore ListLoad NameLoad NameLoad Call NameLoad keyword Num Call NameLoad keyword Num NameLoad Assign NameStore ListLoad Num Num Num Num Num Assign NameStore ListLoad Num Num Assign NameStore ListLoad ListLoad Num Num Num ListLoad Num Num Assign TupleStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call NameLoad Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad keyword NameLoad Return TupleLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args defaults body Pass decorator_list FunctionDef arguments args NameParam defaults Num body Assign TupleStore NameStore NameStore NameStore NameStore NameStore NameStore Call NameLoad NameLoad Assign NameStore ListLoad ListLoad TupleLoad NameLoad Num Num ListLoad TupleLoad NameLoad Num Num Assign NameStore ListLoad TupleLoad Num Num Num TupleLoad BinOpFloorDiv NameLoad Num Num Num TupleLoad NameLoad Num Num TupleLoad BinOpAdd NameLoad Num Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index Num Assign NameStore ListLoad TupleLoad NameLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index Num With Call AttributeLoad NameLoad attr NameLoad body Assert CompareEq SubscriptLoad NameLoad Index Num Num Assign NameStore ListLoad TupleLoad NameLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index Num With Call AttributeLoad NameLoad attr NameLoad body Assert CompareEq SubscriptLoad NameLoad Index Num Num Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad BinOpAdd NameLoad Num Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index Num Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad BinOpAdd NameLoad Num Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index Num Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad BinOpAdd NameLoad Num Num Num With Call AttributeLoad NameLoad attr NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index Num Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad BinOpAdd NameLoad Num Num Num With Call AttributeLoad NameLoad attr NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index Num decorator_list FunctionDef arguments args NameParam defaults Num body Pass decorator_list FunctionDef arguments args NameParam defaults Num body Assign TupleStore NameStore NameStore NameStore NameStore NameStore NameStore Call NameLoad NameLoad Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num Assign NameStore ListLoad With Call AttributeLoad NameLoad attr NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad BinOpSub NameLoad Num Num Num Assign NameStore ListLoad With Call AttributeLoad NameLoad attr NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num Assign NameStore ListLoad With Call AttributeLoad NameLoad attr NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad BinOpAdd NameLoad Num Num Num Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num With Call AttributeLoad NameLoad attr NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index Num Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num Assign NameStore ListLoad TupleLoad NameLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assert CompareEq NameLoad UnaryOpUSub Call NameLoad Str Assert Call NameLoad NameLoad NameLoad Assign NameStore ListLoad TupleLoad NameLoad Num Num Assign NameStore ListLoad TupleLoad NameLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assert CompareEq NameLoad Num Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Slice Num Assert CompareEq NameLoad NameLoad Assign NameStore ListLoad TupleLoad NameLoad Num Num Assign NameStore ListLoad TupleLoad Num Num Num TupleLoad BinOpFloorDiv NameLoad Num Num Num TupleLoad NameLoad Num Num TupleLoad BinOpAdd NameLoad Num Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assert CompareEq NameLoad NameLoad Assign NameStore ListLoad TupleLoad NameLoad Num Num Assign NameStore ListLoad TupleLoad Num Num Num TupleLoad BinOpFloorDiv NameLoad Num Num Num TupleLoad NameLoad Num Num TupleLoad BinOpAdd NameLoad Num Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assert CompareEq NameLoad NameLoad Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assert Call NameLoad NameLoad NameLoad Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num Assign NameStore ListLoad TupleLoad NameLoad Num Num TupleLoad NameLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad Assert Call NameLoad NameLoad NameLoad decorator_list
N/A N/A pytest N/A crosscat.tests.synthetic_data_generator sdg crosscat.LocalEngine LocalEngine N/A 
This test suite ensures that invoking simple_predictive_probability_observed
and simple_predictive_probability_unobserved from sample_utils.py with various
constraint Y and query Q patterns does not throw runtime errors.

TODO:
    Whether simple_predictive_probability performs the 'correct' computation in
    carefully constructed cases is not addressed by this test. The design
    choices for what it means to condition on observed/unobserved members is not
    documented anywhere in the repository and must be reverse engineered from
    the spaghetti code.

    Unfortunatley, there is no one place to figure out how the constraints Y
    are being used in the evaluation of the predictive probability. The most
    important functions which indicate how conditional constraints are used are:

        sample_utils.py
            - def get_draw_constraints(X_L, X_D, Y, draw_row, draw_column)
            - def def get_cluster_sampling_constraints(Y, query_row)

        ComponentModel.h
            - get_draw_constrained(int random_seed,
                    const std::vector<double>& constraints) const;
            - calc_element_predictive_logp_constrained(double element,
                const std::vector<double>& constraints) const;

        It is not entirely clear
            - What is the probabilistic reasoning behind the code that takes
                [Y, Q] and produces constraint_dict?
            - How are the constraints marshalled between Python and CPP?
            - When conditioning on a cell in observed row, do we delete the
                already observed value?
            - Why can we not condition one unobserved on another unobserved?
                This behavior throws a RuntimeError (tested below).
 N/A N_ROWS 1000 quick_le N/A N/A seed n_chains N/A 1 N/A N/A cctypes N/A continuous continuous multinomial multinomial continuous N/A distargs N/A None None N/A dict K 9 N/A dict K 7 None N/A cols_to_views N/A 0 0 0 1 1 N/A separation N/A 0.6 0.9 N/A cluster_weights N/A N/A 0.2 0.3 0.5 N/A 0.9 0.1 N/A N/A T M_c M_r N/A N/A sdg gen_data cctypes N_ROWS cols_to_views cluster_weights separation seed seed distargs distargs return_structure True N/A engine N/A LocalEngine N/A N/A X_L X_D N/A N/A engine initialize M_c M_r T seed n_chains n_chains N/A N/A T M_r M_c X_L X_D engine N/A test_simple_predictive_probability_observed N/A N/A N/A N/A N/A N/A test_simple_predictive_probability_unobserved N/A N/A seed N/A 0 N/A N/A N/A T M_r M_c X_L X_D engine N/A quick_le seed N/A Q N/A N/A N/A N_ROWS 0 0.5 N/A N/A N_ROWS 2 1 N/A Y N/A N/A 0 0 1 N/A N/A N_ROWS 2 4 5 N/A N_ROWS 1 0.5 N/A N/A N_ROWS 1 0 1.2 N/A vals N/A N/A engine simple_predictive_probability M_c X_L X_D Y N/A Q N/A 0 N/A vals N/A N/A engine simple_predictive_probability M_c X_L X_D Y N/A Q N/A 1 N/A Y N/A N/A N_ROWS 0 0.5 N/A val N/A N/A engine simple_predictive_probability M_c X_L X_D Y N/A Q N/A 0 N/A N/A N/A pytest raises AssertionError N/A N/A N/A N/A val N/A 0 0 N/A Y N/A N/A N_ROWS 2 1 N/A val N/A N/A engine simple_predictive_probability M_c X_L X_D Y N/A Q N/A 1 N/A N/A N/A pytest raises AssertionError N/A N/A N/A N/A val N/A 0 0 N/A Y N/A N/A N_ROWS 0 1.5 N/A N/A N_ROWS 1 1 1.5 N/A vals N/A N/A engine simple_predictive_probability M_c X_L X_D Y N/A Q N/A 0 N/A Y N/A N/A N_ROWS 2 4 N/A N/A N_ROWS 1 3 5 N/A vals N/A N/A engine simple_predictive_probability M_c X_L X_D Y N/A Q N/A 1 N/A Y N/A N/A N_ROWS 0 1.5 N/A N/A N_ROWS 1 0 2 N/A N/A N/A pytest raises IndexError N/A N/A vals N/A N/A engine simple_predictive_probability M_c X_L X_D Y N/A Q N/A 0 N/A Y N/A N/A N_ROWS 2 4 N/A N/A N_ROWS 1 2 5 N/A N/A N/A pytest raises IndexError N/A N/A vals N/A N/A engine simple_predictive_probability M_c X_L X_D Y N/A Q N/A 1 N/A test_predictive_probability_observed N/A N/A seed N/A 0 N/A N/A N/A test_predictive_probability_unobserved N/A N/A seed N/A 0 N/A N/A N/A T M_r M_c X_L X_D engine N/A quick_le seed N/A Q N/A N/A N_ROWS 1 1.5 N/A N_ROWS 10 2 N/A Y N/A N/A N/A N/A pytest raises ValueError N/A N/A vals N/A N/A engine predictive_probability M_c X_L X_D Y Q N/A Q N/A N/A N_ROWS 1 1.5 N/A N/A N_ROWS 1 10 2 N/A Y N/A N/A N/A N/A pytest raises ValueError N/A N/A vals N/A N/A engine predictive_probability M_c X_L X_D Y Q N/A Q N/A N/A N_ROWS 1 1.5 N/A N_ROWS 1 2 N/A Y N/A N/A N/A N/A pytest raises ValueError N/A N/A val N/A N/A engine predictive_probability M_c X_L X_D Y Q N/A Q N/A N/A N_ROWS 0 1.5 N/A N/A N_ROWS 1 1 2 N/A Y N/A N/A N_ROWS 1 1.5 N/A N_ROWS 2 3 N/A N/A N/A pytest raises Exception N/A N/A val N/A N/A engine predictive_probability M_c X_L X_D Y N/A Q N/A 0 N/A Q N/A N/A N_ROWS 1 1.5 N/A N_ROWS 0 1.3 N/A Y N/A N/A N_ROWS 1 1.6 N/A val N/A N/A engine predictive_probability M_c X_L X_D Y Q N/A N/A val N/A N/A float inf N/A N/A isinstance val float N/A Q N/A N/A N_ROWS 0 1.3 N/A Y N/A N/A N_ROWS 0 1.3 N/A val N/A N/A engine predictive_probability M_c X_L X_D Y Q N/A N/A val 0 N/A Q N/A N/A N_ROWS 1 1.5 N/A N_ROWS 0 1.3 N/A Y N/A N/A N_ROWS 1 1.5 N/A N_ROWS 2 3 N/A val_0 N/A N/A engine predictive_probability M_c X_L X_D Y Q N/A val_1 N/A N/A engine predictive_probability M_c X_L X_D Y N/A Q N/A 1 N/A N/A val_0 val_1 N/A Q N/A N/A N_ROWS 0 0.5 N/A Y N/A N/A 0 0 1 N/A N/A N_ROWS 2 4 5 N/A N_ROWS 1 0.5 N/A N/A N_ROWS 1 0 1.2 N/A val_0 N/A N/A engine predictive_probability M_c X_L X_D Y Q N/A val_1 N/A N/A engine simple_predictive_probability M_c X_L X_D Y Q N/A N/A val_0 val_1 N/A Q N/A N/A N_ROWS 2 1 N/A Y N/A N/A 0 0 1 N/A N/A N_ROWS 2 4 5 N/A N_ROWS 1 0.5 N/A N/A N_ROWS 1 0 1.2 N/A val_0 N/A N/A engine predictive_probability M_c X_L X_D Y Q N/A val_1 N/A N/A engine simple_predictive_probability M_c X_L X_D Y Q N/A N/A val_0 val_1 N/A Q N/A N/A N_ROWS 3 4 N/A N_ROWS 4 1.3 N/A Y N/A N/A N_ROWS 0 1 N/A N_ROWS 1 -0.7 N/A N_ROWS 2 3 N/A val N/A N/A engine predictive_probability M_c X_L X_D Y Q N/A N/A isinstance val float N/A Q N/A N/A N_ROWS 0 1 N/A N_ROWS 1 -0.7 N/A N_ROWS 2 3 N/A Y N/A N/A N_ROWS 3 4 N/A N_ROWS 4 1.3 N/A val N/A N/A engine predictive_probability M_c X_L X_D Y Q N/A N/A isinstance val float N/A