Commit ec625b05 authored by hazrmard's avatar hazrmard
Browse files

standard.py: 0 indexing behavior when simulating.

parent c95e806c
......@@ -106,6 +106,7 @@ class Trapezoid(nn.Module):
Returns:
np.ndarray -- array of shape `N x Outputs`,
"""
# pylint: disable=not-callable
self._init(x0, u)
xdim = self.dims
if isinstance(t, Number):
......
......@@ -65,9 +65,9 @@ class Trapezoid:
np.ndarray -- array of shape `N x Outputs`,
"""
# t: 0 1 2 3 4 5
# x: x0 ( )
# u: u u u u u u
#
# x: x0 ( )
# u: u u u u u u
# y: y y y y y y
xdim = self.dims
if isinstance(t, Number):
t = np.linspace(0, t, len(u) + 1, endpoint=True)
......@@ -140,7 +140,7 @@ class SS_ODE(Trapezoid):
-> Tuple[np.ndarray, np.ndarray]:
if isinstance(t, Number):
t = np.linspace(0, t, len(u), endpoint=False)
t = np.concatenate(([t[0]], t), axis=0)
t = np.concatenate(([t[0]], t), axis=0) # len(t) increased by 1 now
u = np.concatenate(([u[0]-u[0]], u), axis=0)
X = np.zeros((len(t), self.dims))
Y = np.zeros((len(t), self.outputs))
......
......@@ -2,13 +2,11 @@
Unit tests for code.
"""
from unittest import TestCase, main
import numpy as np
from .state_space import Trapezoid, LTISystem, SS_ODE
from .standard import Trapezoid, LTISystem, SS_ODE
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment