code: def test_saver_kf():
      kf = kinematic_kf(3, 2, dt=0.1, dim_z=3)
      s = Saver(kf)
  
      for i in range(10):
          kf.predict()
          kf.update([i, i, i])
          s.save()
  
      # this will assert if the KalmanFilter did not properly assert
      s.to_array()
      assert len(s.x) == 10
      assert len(s.y) == 10
      assert len(s.K) == 10
      assert len(s) == len(s.x)
  
      # Force an exception to occur my malforming K
      kf = kinematic_kf(3, 2, dt=0.1, dim_z=3)
      kf.K = 0.0
      s2 = Saver(kf)
  
      for i in range(10):
          kf.predict()
          kf.update([i, i, i])
          s2.save()
  
      # this should raise an exception because K is malformed
      try:
          s2.to_array()
          assert (
              False
          ), "Should not have been able to convert s.K into an array"
      except:
          pass
  
file_path: filterpy/filterpy/common/tests/test_helpers.py
imports: from filterpy.common import kinematic_kf, Saver, inv_diagonal, outer_product_sum
  import numpy
  from filterpy.kalman import MerweScaledSigmaPoints, UnscentedKalmanFilter, ExtendedKalmanFilter
label_desc: Use image node_id 3 for calling a global function with example usage: test_saver_kf() without return types