TestUnitDelay TestUnitDelay Icon

Examples.TestUnitDelay

Test component that validates the UnitDelay component.

This component tests a UnitDelay with a PeriodicClock at dt=0.1s and initial_condition=1.0. A step input changes from 0 to 5 at t=0.5s. The UnitDelay (z^-1) should output the previous sample value, delayed by one sample period. The test verifies that the output matches the input delayed by exactly one time step, with the first output being the initial condition.

Usage

DiscreteComponents.Examples.TestUnitDelay()

Behavior

Behavior of this component cannot be rendered because it includes path variables.

Source

"""
Test component that validates the UnitDelay component.

This component tests a UnitDelay with a PeriodicClock at dt=0.1s and initial_condition=1.0.
A step input changes from 0 to 5 at t=0.5s. The UnitDelay (z^-1) should output the previous
sample value, delayed by one sample period. The test verifies that the output matches the
input delayed by exactly one time step, with the first output being the initial condition.
"""
test component TestUnitDelay
  step = BlockComponents.Step(start_time = 0.41, offset = 0.0, height = 5.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -60, "y1": 50, "x2": 40, "y2": 150, "rot": 0}
      },
      "tags": []
    }
  }
  delay = DiscreteComponents.UnitDelay(initial_condition = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 295, "y1": 50, "x2": 395, "y2": 150, "rot": 0}
      },
      "tags": []
    }
  }
  terminator = BlockComponents.Terminator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 431, "y1": 50, "x2": 531, "y2": 150, "rot": 0}
      },
      "tags": []
    }
  }
  periodicsampler = DiscreteComponents.PeriodicSampler(dt = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 110, "y1": 50, "x2": 210, "y2": 150, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(delay.y, terminator.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(step.y, periodicsampler.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(periodicsampler.y, delay.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {
  "Dyad": {
    "tests": {"case1": {"stop": 2, "expect": {"signals": ["step.y", "delay.y"]}}},
    "doc": {"behavior": false}
  }
}
end
Flattened Source
"""
Test component that validates the UnitDelay component.

This component tests a UnitDelay with a PeriodicClock at dt=0.1s and initial_condition=1.0.
A step input changes from 0 to 5 at t=0.5s. The UnitDelay (z^-1) should output the previous
sample value, delayed by one sample period. The test verifies that the output matches the
input delayed by exactly one time step, with the first output being the initial condition.
"""
test component TestUnitDelay
  step = BlockComponents.Step(start_time = 0.41, offset = 0.0, height = 5.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -60, "y1": 50, "x2": 40, "y2": 150, "rot": 0}
      },
      "tags": []
    }
  }
  delay = DiscreteComponents.UnitDelay(initial_condition = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 295, "y1": 50, "x2": 395, "y2": 150, "rot": 0}
      },
      "tags": []
    }
  }
  terminator = BlockComponents.Terminator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 431, "y1": 50, "x2": 531, "y2": 150, "rot": 0}
      },
      "tags": []
    }
  }
  periodicsampler = DiscreteComponents.PeriodicSampler(dt = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 110, "y1": 50, "x2": 210, "y2": 150, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(delay.y, terminator.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(step.y, periodicsampler.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(periodicsampler.y, delay.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {
  "Dyad": {
    "tests": {"case1": {"stop": 2, "expect": {"signals": ["step.y", "delay.y"]}}},
    "doc": {"behavior": false}
  }
}
end


Test Cases

Test Case case1

plt
Example block output
plt
Example block output