---
url: /dyad/stable/stdlib/BlockComponents/tests/Tables.Tests.InterpolationExtrapolation.md
description: >-
  Dyad Tables.Tests.InterpolationExtrapolation docs.  Tests interpolation with
  extrapolation by applying linear interpolation with constant extrapolation.
---

# `Tables.Tests.InterpolationExtrapolation` {#Tables.Tests.InterpolationExtrapolation}

Tests interpolation with extrapolation by applying linear interpolation with constant extrapolation.

This component creates an interpolation object configured with linear interpolation and constant extrapolation on a dataset containing time values from 0 to 1 and their corresponding squared values. The simulation runs beyond the data range to verify that extrapolation works correctly, extending the boundary values for inputs outside the dataset range.

## Usage {#Usage}

`BlockComponents.Tables.Tests.InterpolationExtrapolation()`

## Parameters: {#Parameters:}

|      Name |                                                                                                                      Description | Units |             Default value |
| ---------:| --------------------------------------------------------------------------------------------------------------------------------:| -----:| -------------------------:|
| `dataset` | Dataset containing time values from 0 to 1 and their squares, with 'ts' as independent variable and 'data' as dependent variable |     – | DyadTimeser...t_var="ts") |

## Variables {#Variables}

| Name |                                          Description | Units |
| ----:| ----------------------------------------------------:| -----:|
|  `y` | Output variable that receives the interpolated value |     – |

## Behavior {#Behavior}

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

## Source {#Source}

```dyad
"""
Tests interpolation with extrapolation by applying linear interpolation with constant extrapolation.

This component creates an interpolation object configured with linear interpolation and constant
extrapolation on a dataset containing time values from 0 to 1 and their corresponding squared values.
The simulation runs beyond the data range to verify that extrapolation works correctly, extending
the boundary values for inputs outside the dataset range.
"""
test component InterpolationExtrapolation
  "Interpolation object that performs linear interpolation with constant extrapolation"
  interp = BlockComponents.Tables.Interpolation(interpolation_type = InterpolationType.LinearInterpolation(), extrapolation_type = ExtrapolationType.Constant(), dataset = dataset) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 170, "y1": 70, "x2": 270, "y2": 170, "rot": 0}
      }
    }
  }
  "Dataset containing time values from 0 to 1 and their squares, with 'ts' as independent variable and 'data' as dependent variable"
  structural parameter dataset::DyadData.DyadTimeseries = DyadTimeseries(hcat(0:0.1:1, square(0:0.1:1)), dependent_vars = ["data"], independent_var = "ts")
  "Output variable that receives the interpolated value"
  variable y::Real
relations
  interp.u = time
  interp.y = y
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {"case1": {"stop": 1.5, "expect": {"signals": ["y"]}}},
    "doc": {"behavior": false}
  }
}
end
```

```dyad
"""
Tests interpolation with extrapolation by applying linear interpolation with constant extrapolation.

This component creates an interpolation object configured with linear interpolation and constant
extrapolation on a dataset containing time values from 0 to 1 and their corresponding squared values.
The simulation runs beyond the data range to verify that extrapolation works correctly, extending
the boundary values for inputs outside the dataset range.
"""
test component InterpolationExtrapolation
  "Interpolation object that performs linear interpolation with constant extrapolation"
  interp = BlockComponents.Tables.Interpolation(interpolation_type = InterpolationType.LinearInterpolation(), extrapolation_type = ExtrapolationType.Constant(), dataset = dataset) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 170, "y1": 70, "x2": 270, "y2": 170, "rot": 0}
      }
    }
  }
  "Dataset containing time values from 0 to 1 and their squares, with 'ts' as independent variable and 'data' as dependent variable"
  structural parameter dataset::DyadData.DyadTimeseries = DyadTimeseries(hcat(0:0.1:1, square(0:0.1:1)), dependent_vars = ["data"], independent_var = "ts")
  "Output variable that receives the interpolated value"
  variable y::Real
relations
  interp.u = time
  interp.y = y
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {"case1": {"stop": 1.5, "expect": {"signals": ["y"]}}},
    "doc": {"behavior": false}
  }
}
end
```

## Test Cases {#Test-Cases}

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

```julia
plt
```

![](xkxsday.svg)

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Interpolation`](Tables.Tests.InterpolationExtrapolation.md)
