docstr: Test that we can add predictions to a previously-existing InferenceData.
docstr_tok: ["Test","that","we","can","add","predictions","to","a","previously-existing","InferenceData","."]
code: def test_predictions_to_idata(self, data, eight_schools_params):
      "Test that we can add predictions to a previously-existing InferenceData."
      test_dict = {
          "posterior": ["mu", "tau", "eta", "theta"],
          "sample_stats": ["diverging", "lp"],
          "predictions": ["obs"],
          "prior": ["mu", "tau", "eta", "theta"],
          "observed_data": ["obs"],
      }
  
      # check adding non-destructively
      inference_data, _ = self.get_predictions_inference_data(
          data, eight_schools_params, False
      )
      fails = check_multiple_attrs(test_dict, inference_data)
      assert not fails
      for key, ivalues in inference_data.predictions.items():
          assert (
              len(ivalues["chain"])
              == inference_data.posterior.sizes["chain"]
          )  # same chains as in posterior
  
      # check adding in place
      (
          inference_data,
          posterior_predictive,
      ) = self.get_predictions_inference_data(
          data, eight_schools_params, True
      )
      fails = check_multiple_attrs(test_dict, inference_data)
      assert not fails
      for key, ivalues in inference_data.predictions.items():
          assert (
              len(ivalues["chain"])
              == inference_data.posterior.sizes["chain"]
          )
  
imports: import warnings
  from typing import Dict, Tuple
  import numpy
  import pytensor.tensor
  import pytest
  from arviz import InferenceData
  from arviz.tests.helpers import check_multiple_attrs
  from numpy import ma
  from pytensor.tensor.subtensor import AdvancedIncSubtensor, AdvancedIncSubtensor1
  import pymc
  from pymc.backends.arviz import InferenceDataConverter, predictions_to_inference_data, to_inference_data
  from pymc.exceptions import ImputationWarning
label_desc: Use image node_id 6 for calling the TestDataPyMC obj's underlying member method code with example usage: obj.test_predictions_to_idata(data, eight_schools_params) without return types