Conversation
The sub-terrain proportions were collected with np.array, which gives an int64 array when every proportion is an int, and the in-place normalization then raised UFuncTypeError. Build the array as float so integer proportions behave like the equivalent floats. Signed-off-by: Patrick-SCH03 <wwoo5241@gmail.com>
|
There was a problem hiding this comment.
Isaac Lab Review Bot
The patch explicitly creates floating-point proportion arrays in both terrain-generation modes, preventing NumPy’s in-place division from failing when every configured proportion is an integer. It includes focused regression coverage and the required changelog fragment.
- Design and architecture: The conversion remains localized to the private helpers that own proportion normalization and is applied consistently to both random and curriculum generation. This is the smallest change needed and does not alter terrain-selection architecture.
- API: No public signatures, defaults, or exports change. Integer proportions, already accepted by the configuration surface, now behave like equivalent float proportions. Existing float inputs retain the same normalized float64 representation, and the package changelog records the user-visible fix.
- Implementation: Both consumers of normalized proportions were traced: random selection through
np_rng.choiceand curriculum column assignment throughnp.cumsum. Constructing each array withdtype=floatdirectly resolves the deterministic NumPy casting failure. The parameterized seeded test exercises both paths and compares observable terrain origins and mesh vertices for equivalent integer and float configurations.
No blocking issues. No inline issue met the actionable-evidence threshold; the assessment above records the review feedback.
Automated review; human maintainers own approval decisions.
|
Backported to |
# Description
`TerrainGenerator` normalizes the sub-terrain proportions with
```python
proportions = np.array([sub_cfg.proportion for sub_cfg in self.cfg.sub_terrains.values()])
proportions /= np.sum(proportions)
```
in both `_generate_random_terrains` and `_generate_curriculum_terrains`.
When every `proportion` is an int (for example `proportion=1` and
`proportion=3`, which the `float` annotation accepts and `configclass`
does not convert), the array is `int64` and the in-place division
raises:
```
numpy._core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'divide' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
```
A single float proportion anywhere avoids it, which is why the in-repo
configs (all floats) never hit it.
This builds the array with `dtype=float` in both places. Integer and
float proportions now give identical terrains.
## Type of change
- Bug fix (non-breaking change which fixes an issue)
## Checklist
- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [ ] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added a changelog fragment under
`source/<pkg>/changelog.d/` for every touched package (do **not** edit
`CHANGELOG.rst` or bump `extension.toml` — CI handles that)
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
## Testing
- Added `test_generation_with_integer_proportions` (random and
curriculum modes): proportions `(1, 3)` must produce the same terrain
origins and mesh as `(1.0, 3.0)`. Both cases fail on `develop` with the
error above and pass with the fix.
- The whole `test_terrain_generator.py` passes locally (CPU, with Isaac
Sim imports stubbed out).
- Ruff v0.14.10 (the pre-commit pin) `check` and `format` are clean on
the changed files. I ran it directly because the full `./isaaclab.sh
--format` environment isn't available on my Windows machine.
## Release backport
- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`
---------
Signed-off-by: Patrick-SCH03 <wwoo5241@gmail.com>
Co-authored-by: Mustafa Haiderbhai <mhaiderbhai@nvidia.com>
(cherry picked from commit b39c274)
Description
TerrainGeneratornormalizes the sub-terrain proportions within both
_generate_random_terrainsand_generate_curriculum_terrains. When everyproportionis an int (for exampleproportion=1andproportion=3, which thefloatannotation accepts andconfigclassdoes not convert), the array isint64and the in-place division raises:A single float proportion anywhere avoids it, which is why the in-repo configs (all floats) never hit it.
This builds the array with
dtype=floatin both places. Integer and float proportions now give identical terrains.Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml— CI handles that)CONTRIBUTORS.mdor my name already exists thereTesting
test_generation_with_integer_proportions(random and curriculum modes): proportions(1, 3)must produce the same terrain origins and mesh as(1.0, 3.0). Both cases fail ondevelopwith the error above and pass with the fix.test_terrain_generator.pypasses locally (CPU, with Isaac Sim imports stubbed out).checkandformatare clean on the changed files. I ran it directly because the full./isaaclab.sh --formatenvironment isn't available on my Windows machine.Release backport
develop