docstr: Allow pm.Data to be used for index variables, i.e with integers as well as floats.
  See https://github.com/pymc-devs/pymc/issues/3813
docstr_tok: ["Allow","pm.Data","to","be","used","for","index","variables",",","i.e","with","integers","as","well","as","floats",".","See","https",":","\/\/github.com\/pymc-devs\/pymc\/issues\/3813"]
code: def test_shared_data_as_index(self):
      """
      Allow pm.Data to be used for index variables, i.e with integers as well as floats.
      See https://github.com/pymc-devs/pymc/issues/3813
      """
      with pm.Model() as model:
          index = pm.MutableData("index", [2, 0, 1, 0, 2])
          y = pm.MutableData("y", [1.0, 2.0, 3.0, 2.0, 1.0])
          alpha = pm.Normal("alpha", 0, 1.5, size=3)
          pm.Normal("obs", alpha[index], np.sqrt(1e-2), observed=y)
  
          prior_trace = pm.sample_prior_predictive(1000)
          idata = pm.sample(
              1000,
              tune=1000,
              chains=1,
              compute_convergence_checks=False,
          )
  
      # Predict on new data
      new_index = np.array([0, 1, 2])
      new_y = [5.0, 6.0, 9.0]
      with model:
          pm.set_data(new_data={"index": new_index, "y": new_y})
          pp_trace = pm.sample_posterior_predictive(
              idata, var_names=["alpha", "obs"]
          )
  
      assert prior_trace.prior["alpha"].shape == (1, 1000, 3)
      assert idata.posterior["alpha"].shape == (1, 1000, 3)
      assert pp_trace.posterior_predictive["alpha"].shape == (
          1,
          1000,
          3,
      )
      assert pp_trace.posterior_predictive["obs"].shape == (1, 1000, 3)
  
imports: import io
  import itertools
  import re
  import cloudpickle
  import numpy
  import pytensor
  import pytensor.tensor
  import pytest
  from pytensor import shared
  from pytensor.tensor.variable import TensorVariable
  import pymc
  from pymc.data import is_minibatch
  from pymc.pytensorf import GeneratorOp, floatX
label_desc: Use image node_id 6 for calling the TestData obj's underlying member method code with example usage: obj.test_shared_data_as_index() without return types