API Docs
API Docs
Python bindings to the interpn Rust library
for N-dimensional interpolation and extrapolation.
MulticubicRectilinear
Bases: BaseModel
Multicubic interpolation on a rectilinear grid in up to 8 dimensions.
This method uses a symmetrized Hermite spline interpolant, which provides a continuous value and first derivative. Unlike a B-spline, the second derivative is not continuous; however, also unlike a B-spline, the first derivatives are maintained to more exactly match the data as estimated by a central difference.
If linearize_extrapolation is set, dimensions on which extrapolation is occurring
(but not other dimensions) are extrapolated linearly from the last
two grid points on that dimension.
All array inputs must be of the same type, either np.float32 or np.float64 and must be 1D and contiguous and have size at least 4.
Source code in src/interpn/multicubic_rectilinear.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
check_bounds(obs, atol)
Check if the observation points violated the bounds on each dimension.
This performs a (small) allocation for the output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
atol
|
float
|
Absolute tolerance on bounds. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If an unexpected data type is encountered |
Returns:
| Type | Description |
|---|---|
NDArray[bool_]
|
An array of flags for each dimension, each True if that dimension's |
NDArray[bool_]
|
bounds were violated. |
Source code in src/interpn/multicubic_rectilinear.py
eval(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array.
This function does not reallocate inputs, and will error if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
AssertionError
|
If input data is not contiguous or dimensions do not match |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/multicubic_rectilinear.py
eval_unchecked(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array, and skipping checks on the dimensionality and contiguousness of the inputs.
This function does not reallocate inputs, and will error in a lower-level function if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/multicubic_rectilinear.py
new(grids, vals, linearize_extrapolation=True)
classmethod
Initialize interpolator and check types and dimensions, casting other arrays
to the same type as vals if they do not match, and flattening and/or
reallocating into contiguous storage if necessary.
This method exists primarily to remove boilerplate introduced by mixing pydantic and numpy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grids
|
list[NDArray]
|
1D arrays of grid coordinate values. All grids must be monotonically increasing. |
required |
vals
|
NDArray
|
Values at grid points in C-style ordering, as obtained from np.meshgrid(..., indexing="ij") |
required |
linearize_extrapolation
|
bool
|
Whether to fall back to a linear interpolant outside the grid |
True
|
Returns:
| Type | Description |
|---|---|
MulticubicRectilinear
|
A new MultilinearRectilinear interpolator instance. |
Source code in src/interpn/multicubic_rectilinear.py
MulticubicRegular
Bases: BaseModel
Multicubic interpolation on a regular grid in up to 8 dimensions.
This method uses a symmetrized Hermite spline interpolant, which provides a continuous value and first derivative. Unlike a B-spline, the second derivative is not continuous; however, also unlike a B-spline, the first derivatives are maintained to more exactly match the data as estimated by a central difference.
If linearize_extrapolation is set, dimensions on which extrapolation is occurring
(but not other dimensions) are extrapolated linearly from the last
two grid points on that dimension.
All array inputs must be of the same type, either np.float32 or np.float64 and must be 1D and contiguous and have size at least 4.
Source code in src/interpn/multicubic_regular.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
check_bounds(obs, atol)
Check if the observation points violated the bounds on each dimension.
This performs a (small) allocation for the output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
atol
|
float
|
Absolute tolerance on bounds. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If an unexpected data type is encountered |
Returns:
| Type | Description |
|---|---|
NDArray[bool_]
|
An array of flags for each dimension, each True if that dimension's |
NDArray[bool_]
|
bounds were violated. |
Source code in src/interpn/multicubic_regular.py
eval(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array.
This function does not reallocate inputs, and will error if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
AssertionError
|
If input data is not contiguous or dimensions do not match |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/multicubic_regular.py
eval_unchecked(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array, and skipping checks on the dimensionality and contiguousness of the inputs.
This function does not reallocate inputs, and will error in a lower-level function if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/multicubic_regular.py
new(dims, starts, steps, vals, linearize_extrapolation=True)
classmethod
Initialize interpolator and check types and dimensions, casting other arrays
to the same type as vals if they do not match, and flattening and/or
reallocating into contiguous storage if necessary.
This method exists primarily to remove boilerplate introduced by mixing pydantic and numpy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dims
|
list[int]
|
Number of elements on each dimension of the grid |
required |
starts
|
NDArray
|
Starting point of each dimension of the grid |
required |
steps
|
NDArray
|
Step size on each dimension of the grid |
required |
vals
|
NDArray
|
Values at grid points in C-style ordering, as obtained from np.meshgrid(..., indexing="ij") |
required |
linearize_extrapolation
|
bool
|
Whether to fall back to a linear interpolant outside the grid |
True
|
Returns:
| Type | Description |
|---|---|
MulticubicRegular
|
A new MulticubicRegular interpolator instance. |
Source code in src/interpn/multicubic_regular.py
MultilinearRectilinear
Bases: BaseModel
Multilinear interpolation on a rectilinear grid in up to 8 dimensions.
All array inputs must be of the same type, either np.float32 or np.float64 and must be 1D and contiguous.
Source code in src/interpn/multilinear_rectilinear.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
check_bounds(obs, atol)
Check if the observation points violated the bounds on each dimension.
This performs a (small) allocation for the output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
atol
|
float
|
Absolute tolerance on bounds. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If an unexpected data type is encountered |
Returns:
| Type | Description |
|---|---|
NDArray[bool_]
|
An array of flags for each dimension, each True if that dimension's |
NDArray[bool_]
|
bounds were violated. |
Source code in src/interpn/multilinear_rectilinear.py
eval(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array.
This function does not reallocate inputs, and will error if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
AssertionError
|
If input data is not contiguous or dimensions do not match |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/multilinear_rectilinear.py
eval_unchecked(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array, and skipping checks on the dimensionality and contiguousness of the inputs.
This function does not reallocate inputs, and will error in a lower-level function if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/multilinear_rectilinear.py
new(grids, vals)
classmethod
Initialize interpolator and check types and dimensions, casting other arrays
to the same type as vals if they do not match, and flattening and/or
reallocating into contiguous storage if necessary.
This method exists primarily to remove boilerplate introduced by mixing pydantic and numpy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grids
|
list[NDArray]
|
1D arrays of grid coordinate values. All grids must be monotonically increasing. |
required |
vals
|
NDArray
|
Values at grid points in C-style ordering, as obtained from np.meshgrid(..., indexing="ij") |
required |
Returns:
| Type | Description |
|---|---|
MultilinearRectilinear
|
A new MultilinearRectilinear interpolator instance. |
Source code in src/interpn/multilinear_rectilinear.py
MultilinearRegular
Bases: BaseModel
Multilinear interpolation on a regular grid in up to 8 dimensions.
All array inputs must be of the same type, either np.float32 or np.float64 and must be 1D and contiguous.
Source code in src/interpn/multilinear_regular.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
check_bounds(obs, atol)
Check if the observation points violated the bounds on each dimension.
This performs a (small) allocation for the output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
atol
|
float
|
Absolute tolerance on bounds. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If an unexpected data type is encountered |
Returns:
| Type | Description |
|---|---|
NDArray[bool_]
|
An array of flags for each dimension, each True if that dimension's |
NDArray[bool_]
|
bounds were violated. |
Source code in src/interpn/multilinear_regular.py
eval(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array.
This function does not reallocate inputs, and will error if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
AssertionError
|
If input data is not contiguous or dimensions do not match |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/multilinear_regular.py
eval_unchecked(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array, and skipping checks on the dimensionality and contiguousness of the inputs.
This function does not reallocate inputs, and will error in a lower-level function if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/multilinear_regular.py
new(dims, starts, steps, vals)
classmethod
Initialize interpolator and check types and dimensions, casting other arrays
to the same type as vals if they do not match, and flattening and/or
reallocating into contiguous storage if necessary.
This method exists primarily to remove boilerplate introduced by mixing pydantic and numpy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dims
|
list[int]
|
Number of elements on each dimension of the grid |
required |
starts
|
NDArray
|
Starting point of each dimension of the grid |
required |
steps
|
NDArray
|
Step size on each dimension of the grid |
required |
vals
|
NDArray
|
Values at grid points in C-style ordering, as obtained from np.meshgrid(..., indexing="ij") |
required |
Returns:
| Type | Description |
|---|---|
MultilinearRegular
|
A new MultilinearRegular interpolator instance. |
Source code in src/interpn/multilinear_regular.py
NearestRectilinear
Bases: BaseModel
Nearest-neighbor interpolation on a rectilinear grid in up to 6 dimensions.
All array inputs must be of the same type, either np.float32 or np.float64 and must be 1D and contiguous.
Source code in src/interpn/nearest_rectilinear.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
check_bounds(obs, atol)
Check if the observation points violated the bounds on each dimension.
This performs a (small) allocation for the output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
atol
|
float
|
Absolute tolerance on bounds. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If an unexpected data type is encountered |
Returns:
| Type | Description |
|---|---|
NDArray[bool_]
|
An array of flags for each dimension, each True if that dimension's |
NDArray[bool_]
|
bounds were violated. |
Source code in src/interpn/nearest_rectilinear.py
eval(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array.
This function does not reallocate inputs, and will error if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
AssertionError
|
If input data is not contiguous or dimensions do not match |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/nearest_rectilinear.py
eval_unchecked(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array, and skipping checks on the dimensionality and contiguousness of the inputs.
This function does not reallocate inputs, and will error in a lower-level function if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/nearest_rectilinear.py
new(grids, vals)
classmethod
Initialize interpolator and check types and dimensions, casting other arrays
to the same type as vals if they do not match, and flattening and/or
reallocating into contiguous storage if necessary.
This method exists primarily to remove boilerplate introduced by mixing pydantic and numpy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grids
|
list[NDArray]
|
1D arrays of grid coordinate values. All grids must be monotonically increasing. |
required |
vals
|
NDArray
|
Values at grid points in C-style ordering, as obtained from np.meshgrid(..., indexing="ij") |
required |
Returns:
| Type | Description |
|---|---|
NearestRectilinear
|
A new NearestRectilinear interpolator instance. |
Source code in src/interpn/nearest_rectilinear.py
NearestRegular
Bases: BaseModel
Nearest-neighbor interpolation on a regular grid in up to 6 dimensions.
All array inputs must be of the same type, either np.float32 or np.float64 and must be 1D and contiguous.
Source code in src/interpn/nearest_regular.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
check_bounds(obs, atol)
Check if the observation points violated the bounds on each dimension.
This performs a (small) allocation for the output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
atol
|
float
|
Absolute tolerance on bounds. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If an unexpected data type is encountered |
Returns:
| Type | Description |
|---|---|
NDArray[bool_]
|
An array of flags for each dimension, each True if that dimension's |
NDArray[bool_]
|
bounds were violated. |
Source code in src/interpn/nearest_regular.py
eval(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array.
This function does not reallocate inputs, and will error if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
AssertionError
|
If input data is not contiguous or dimensions do not match |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/nearest_regular.py
eval_unchecked(obs, out=None)
Evaluate the interpolator at a set of observation points, optionally writing the output into a preallocated array, and skipping checks on the dimensionality and contiguousness of the inputs.
This function does not reallocate inputs, and will error in a lower-level function if the inputs are not contiguous or are of the wrong data type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
list[NDArray]
|
[x, y, ...] coordinates of observation points. |
required |
out
|
NDArray | None
|
Optional preallocated array for output. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data type is not np.float32 or np.float64 |
Returns:
| Type | Description |
|---|---|
NDArray
|
Array of evaluated values in the same shape and data type as obs[0] |
Source code in src/interpn/nearest_regular.py
new(dims, starts, steps, vals)
classmethod
Initialize interpolator and check types and dimensions, casting other arrays
to the same type as vals if they do not match, and flattening and/or
reallocating into contiguous storage if necessary.
This method exists primarily to remove boilerplate introduced by mixing pydantic and numpy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dims
|
list[int]
|
Number of elements on each dimension of the grid |
required |
starts
|
NDArray
|
Starting point of each dimension of the grid |
required |
steps
|
NDArray
|
Step size on each dimension of the grid |
required |
vals
|
NDArray
|
Values at grid points in C-style ordering, as obtained from np.meshgrid(..., indexing="ij") |
required |
Returns:
| Type | Description |
|---|---|
NearestRegular
|
A new NearestRegular interpolator instance. |