---
url: /dyad/stable/stdlib/DiscreteComponents/tests/Examples.TestSampleWithADEffects.md
description: >-
  Dyad Examples.TestSampleWithADEffects docs.  Test component that validates the
  SampleWithADEffects block.
---

# `Examples.TestSampleWithADEffects` {#Examples.TestSampleWithADEffects}

Test component that validates the SampleWithADEffects block.

Connects a Sine source to a SampleWithADEffects block configured with noise and 3-bit quantization, then feeds the output through a ZeroOrderHold to an integrator. The test verifies that sampling, noise addition, and quantization all work together.

## Usage {#Usage}

`DiscreteComponents.Examples.TestSampleWithADEffects()`

## Behavior {#Behavior}

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

## Source {#Source}

```dyad
"""
Test component that validates the SampleWithADEffects block.

Connects a Sine source to a SampleWithADEffects block configured with noise and
3-bit quantization, then feeds the output through a ZeroOrderHold to an integrator.
The test verifies that sampling, noise addition, and quantization all work together.
"""
test component TestSampleWithADEffects
  sine = BlockComponents.Sources.Sine(frequency = 1, amplitude = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 450, "x2": 120, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  samplewithad = DiscreteComponents.SampleWithADEffects(bits = 3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": 450, "x2": 300, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  zoh = DiscreteComponents.ZeroOrderHold() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 400, "y1": 450, "x2": 500, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  integrator = BlockComponents.Continuous.Integrator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 600, "y1": 450, "x2": 700, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  periodicclock = DiscreteComponents.PeriodicClock(dt = 0.3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 300, "y1": 310, "x2": 200, "y2": 410, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(sine.y, samplewithad.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(samplewithad.y, zoh.u, periodicclock.y) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": 3, "M": [{"x": 340, "y": 360}], "E": -1}
      ],
      "junctions": [{"x": 340, "y": 500}],
      "renderStyle": "standard"
    }
  }
  connect(zoh.y, integrator.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {
  "Dyad": {
    "tests": {
      "case1": {"stop": 10, "expect": {"signals": ["sine.y", "samplewithad.y", "zoh.y"]}}
    },
    "doc": {"behavior": false}
  }
}
end
```

```dyad
"""
Test component that validates the SampleWithADEffects block.

Connects a Sine source to a SampleWithADEffects block configured with noise and
3-bit quantization, then feeds the output through a ZeroOrderHold to an integrator.
The test verifies that sampling, noise addition, and quantization all work together.
"""
test component TestSampleWithADEffects
  sine = BlockComponents.Sources.Sine(frequency = 1, amplitude = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 450, "x2": 120, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  samplewithad = DiscreteComponents.SampleWithADEffects(bits = 3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": 450, "x2": 300, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  zoh = DiscreteComponents.ZeroOrderHold() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 400, "y1": 450, "x2": 500, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  integrator = BlockComponents.Continuous.Integrator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 600, "y1": 450, "x2": 700, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  periodicclock = DiscreteComponents.PeriodicClock(dt = 0.3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 300, "y1": 310, "x2": 200, "y2": 410, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(sine.y, samplewithad.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(samplewithad.y, zoh.u, periodicclock.y) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": 3, "M": [{"x": 340, "y": 360}], "E": -1}
      ],
      "junctions": [{"x": 340, "y": 500}],
      "renderStyle": "standard"
    }
  }
  connect(zoh.y, integrator.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {
  "Dyad": {
    "tests": {
      "case1": {"stop": 10, "expect": {"signals": ["sine.y", "samplewithad.y", "zoh.y"]}}
    },
    "doc": {"behavior": false}
  }
}
end
```

## Test Cases {#Test-Cases}

### Test Case `case1` {#Test-Case-case1}

```julia
plt
```

![](aiwfhgr.svg)

```julia
plt
```

![](ujpakpa.svg)

```julia
plt
```

![](uejyibd.svg)

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Integrator`](Examples.TestSampleWithADEffects.md)

  * [`PeriodicClock`](Examples.TestSampleWithADEffects.md)

  * [`SampleWithADEffects`](Examples.TestSampleWithADEffects.md)

  * [`Sine`](Examples.TestSampleWithADEffects.md)

  * [`ZeroOrderHold`](Examples.TestSampleWithADEffects.md)
