docstr: Testing our SPM-ified version of `run_MMP` with
  2 hidden state factors & 2 outcome modalities, at a random fixed
  timestep during the generative process
docstr_tok: ["Testing","our","SPM-ified","version","of","`","run_MMP","`","with","2","hidden","state","factors","&","2","outcome","modalities",",","at","a","random","fixed","timestep","during","the","generative","process"]
code: def test_mmp_b(self):
      """Testing our SPM-ified version of `run_MMP` with
      2 hidden state factors & 2 outcome modalities, at a random fixed
      timestep during the generative process"""
  
      array_path = os.path.join(os.getcwd(), DATA_PATH + "mmp_b.mat")
      mat_contents = loadmat(file_name=array_path)
  
      A = mat_contents["A"][0]
      B = mat_contents["B"][0]
      prev_obs = mat_contents["obs_idx"].astype("int64")
      policy = mat_contents["policy"].astype("int64") - 1
      curr_t = mat_contents["t"][0, 0].astype("int64") - 1
      t_horizon = mat_contents["t_horizon"][0, 0].astype("int64")
      prev_actions = (
          mat_contents["previous_actions"].astype("int64") - 1
      )
      result_spm = mat_contents["qs"][0]
      likelihoods = mat_contents["likelihoods"][0]
  
      num_obs, num_states, _, num_factors = get_model_dimensions(A, B)
      prev_obs = convert_observation_array(
          prev_obs[:, max(0, curr_t - t_horizon) : (curr_t + 1)],
          num_obs,
      )
  
      prev_actions = prev_actions[(max(0, curr_t - t_horizon)) :, :]
      lh_seq = get_joint_likelihood_seq(A, prev_obs, num_states)
      qs_seq, _ = run_mmp(
          lh_seq,
          B,
          policy,
          prev_actions=prev_actions,
          prior=None,
          num_iter=5,
          grad_descent=True,
      )
  
      result_pymdp = qs_seq[-1]
      for f in range(num_factors):
          self.assertTrue(
              np.isclose(result_spm[f].squeeze(), result_pymdp[f]).all()
          )
  
file_path: pymdp/test/test_mmp.py
imports: import os
  import unittest
  import numpy
  from scipy.io import loadmat
  from pymdp.utils import get_model_dimensions, convert_observation_array
  from pymdp.algos import run_mmp
  from pymdp.maths import get_joint_likelihood_seq
label_desc: Use image node_id 2 for calling the MMP obj's underlying member method code with example usage: obj.test_mmp_b() without return types