@@ -325,19 +325,17 @@ def predict_linear(
325325 raise ValueError (
326326 f"inputs must have shape { expected_shape } , got { inputs .shape } "
327327 )
328+
329+ next_system_matrix = self .system_matrix
328330 if system_matrix is not None :
329- self .system_matrix = array (system_matrix )
330- self ._validate_system_matrix (self .system_matrix )
331+ next_system_matrix = array (system_matrix )
332+ self ._validate_system_matrix (next_system_matrix )
333+
334+ next_sys_noise = self .sys_noise
331335 if sys_noise is not None :
332- self . sys_noise = self ._as_covariance (
336+ next_sys_noise = self ._as_covariance (
333337 sys_noise , self .state_dim , "sys_noise" , require_pd = False
334338 )
335- self .kinematic_state = self .system_matrix @ self .kinematic_state
336- if inputs is not None :
337- self .kinematic_state = self .kinematic_state + inputs
338- self .covariance = self ._symmetrize (
339- self .system_matrix @ self .covariance @ self .system_matrix .T + self .sys_noise
340- )
341339
342340 axis_matrix = eye (2 )
343341 if shape_system_matrix is not None :
@@ -348,26 +346,48 @@ def predict_linear(
348346 axis_matrix = shape_system_matrix
349347 else :
350348 raise ValueError ("shape_system_matrix must be 3x3 or 2x2" )
349+
350+ next_orientation_process_variance = self .orientation_process_variance
351+ next_axis_sys_noise = self .axis_sys_noise
351352 if shape_sys_noise is not None :
352353 shape_sys_noise = array (shape_sys_noise )
353354 if shape_sys_noise .shape == (3 , 3 ):
354355 shape_sys_noise = self ._as_covariance (
355356 shape_sys_noise , 3 , "shape_sys_noise" , require_pd = False
356357 )
357- self . orientation_process_variance = float (shape_sys_noise [0 , 0 ])
358- self . axis_sys_noise = shape_sys_noise [1 :, 1 :]
358+ next_orientation_process_variance = float (shape_sys_noise [0 , 0 ])
359+ next_axis_sys_noise = shape_sys_noise [1 :, 1 :]
359360 elif shape_sys_noise .shape == (2 , 2 ):
360- self . axis_sys_noise = self ._as_covariance (
361+ next_axis_sys_noise = self ._as_covariance (
361362 shape_sys_noise , 2 , "shape_sys_noise" , require_pd = False
362363 )
363364 else :
364365 raise ValueError ("shape_sys_noise must be 3x3 or 2x2" )
365- self .axis = self .axis @ axis_matrix .T
366- self .axis_covariances = self ._symmetrize_stack (
366+
367+ next_kinematic_state = next_system_matrix @ self .kinematic_state
368+ if inputs is not None :
369+ next_kinematic_state = next_kinematic_state + inputs
370+ next_covariance = self ._symmetrize (
371+ next_system_matrix @ self .covariance @ next_system_matrix .T
372+ + next_sys_noise
373+ )
374+ next_axis = self .axis @ axis_matrix .T
375+ next_axis_covariances = self ._symmetrize_stack (
367376 axis_matrix @ self .axis_covariances @ axis_matrix .T
368- + self . axis_sys_noise .reshape ((1 , 2 , 2 ))
377+ + next_axis_sys_noise .reshape ((1 , 2 , 2 ))
369378 )
370- self ._apply_axis_floor ()
379+ if self .axis_floor is not None :
380+ next_axis = maximum (next_axis , float (self .axis_floor ))
381+
382+ self .system_matrix = next_system_matrix
383+ self .sys_noise = next_sys_noise
384+ self .orientation_process_variance = next_orientation_process_variance
385+ self .axis_sys_noise = next_axis_sys_noise
386+ self .kinematic_state = next_kinematic_state
387+ self .covariance = next_covariance
388+ self .axis = next_axis
389+ self .axis_covariances = next_axis_covariances
390+
371391 if self .log_prior_estimates :
372392 self .store_prior_estimates ()
373393 if self .log_prior_extents :
0 commit comments