code: def testGetVar(self):
      # for forward filter
      self.dlm5.fitForwardFilter()
      filteredTrend = self.dlm5.getVar(filterType="forwardFilter")
      self.assertEqual(len(filteredTrend), self.dlm5.n)
      diff = 0.0
      for i in range(len(filteredTrend)):
          diff += abs(
              filteredTrend[i]
              - self.dlm5.result.filteredObsVar[i][0, 0]
          )
      self.assertAlmostEqual(diff, 0)
  
      # for component with forward filter
      arTrend = self.dlm5.getVar(filterType="forwardFilter", name="ar2")
      trueAr = [item[1, 1] for item in self.dlm5.result.filteredCov]
      comp = self.dlm5.builder.automaticComponents["ar2"]
      for i in range(len(trueAr)):
          comp.updateEvaluation(i, self.data5)
          trueAr[i] = comp.evaluation * trueAr[i] * comp.evaluation.T
  
      diff = 0.0
      for i in range(len(arTrend)):
          diff += abs(arTrend[i] - trueAr[i])
      self.assertAlmostEqual(diff, 0)
  
      # for backward smoother
      self.dlm5.fitBackwardSmoother()
      filteredTrend = self.dlm5.getVar(filterType="backwardSmoother")
      diff = 0.0
      for i in range(len(filteredTrend)):
          diff += abs(
              filteredTrend[i]
              - self.dlm5.result.smoothedObsVar[i][0, 0]
          )
      self.assertAlmostEqual(diff, 0)
  
      # for component with backward smoother
      arTrend = self.dlm5.getVar(
          filterType="backwardSmoother", name="ar2"
      )
      trueAr = [item[1, 1] for item in self.dlm5.result.smoothedCov]
      comp = self.dlm5.builder.automaticComponents["ar2"]
      for i in range(len(trueAr)):
          comp.updateEvaluation(i, self.data5)
          trueAr[i] = comp.evaluation * trueAr[i] * comp.evaluation.T
  
      diff = 0.0
      for i in range(len(arTrend)):
          diff += abs(arTrend[i] - trueAr[i])
      self.assertAlmostEqual(diff, 0)
  
imports: import numpy
  import unittest
  from pydlm.modeler.trends import trend
  from pydlm.modeler.seasonality import seasonality
  from pydlm.modeler.dynamic import dynamic
  from pydlm.modeler.autoReg import autoReg
  from pydlm.dlm import dlm
label_desc: Use image node_id 24 for calling the testDlm obj's underlying member method code with example usage: obj.testGetVar() without return types