Unverified Commit 6443c5a5 authored by AutonomousHansen's avatar AutonomousHansen Committed by GitHub

Fixes typos in the interpolation test of Scipy library (#430)

# Description

Currently `test_scipy.py` fails with the following error:
```
======================================================================
ERROR: test_interpolation (test_scipy.TestScipyOperations)
Test scipy interpolation 2D method.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/workspace/orbit/source/extensions/omni.isaac.orbit/test/deps/test_scipy.py", line 58, in test_interpolation
    func_RectBiVariate = interpolate.RectBivariateSpline(y, x, height_field_downsampled)
  File "/isaac-sim/exts/omni.pip.compute/pip_prebundle/scipy/interpolate/_fitpack2.py", line 1494, in __init__
    raise ValueError('x dimension of z must have same number of '
ValueError: x dimension of z must have same number of elements as x

----------------------------------------------------------------------
Ran 1 test in 0.003s

FAILED (errors=1)
There was an error running python
```
#426 changed the argument in `test_scipy.py` but did not change the
ordering to be the correct `(x,y)`. This fixes that.

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] I have run all the tests with `./orbit.sh --test` and they pass
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->
parent 3c0626fb
......@@ -51,19 +51,19 @@ class TestScipyOperations(unittest.TestCase):
# interpolate the sampled heights to obtain the height field
x_upsampled = np.linspace(0, size[0] * horizontal_scale, width_pixels)
y_upsampled = np.linspace(0, size[1] * horizontal_scale, length_pixels)
# -- method 1: interp2d (this will be deprecated in the future 1.13 release)
# -- method 1: interp2d (this will be deprecated in the future 1.12 release)
func_interp2d = interpolate.interp2d(y, x, height_field_downsampled, kind="cubic")
z_upsampled_interp2d = func_interp2d(y_upsampled, x_upsampled)
# -- method 2: RectBivariateSpline (alternate to interp2d)
func_RectBiVariate = interpolate.RectBivariateSpline(y, x, height_field_downsampled)
z_upsampled_RectBivariant = func_RectBiVariate(y_upsampled, x_upsampled)
func_RectBiVariate = interpolate.RectBivariateSpline(x, y, height_field_downsampled)
z_upsampled_RectBivariant = func_RectBiVariate(x_upsampled, y_upsampled)
# -- method 3: RegularGridInterpolator (recommended from scipy but slow!)
# Ref: https://github.com/scipy/scipy/issues/18010
func_RegularGridInterpolator = interpolate.RegularGridInterpolator(
(y, x), height_field_downsampled, method="cubic"
(x, y), height_field_downsampled, method="cubic"
)
yy_upsampled, xx_upsampled = np.meshgrid(y_upsampled, x_upsampled, indexing="ij", sparse=True)
z_upsampled_RegularGridInterpolator = func_RegularGridInterpolator((yy_upsampled, xx_upsampled))
xx_upsampled, yy_upsampled = np.meshgrid(x_upsampled, y_upsampled, indexing="ij", sparse=True)
z_upsampled_RegularGridInterpolator = func_RegularGridInterpolator((xx_upsampled, yy_upsampled))
# check if the interpolated height field is the same as the sampled height field
np.testing.assert_allclose(z_upsampled_interp2d, z_upsampled_RectBivariant, atol=1e-14)
......
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