Skip to content

[Bug Report] Nested dictionary backend conversion loses iterator-based array type selections #9238

Backlog

Description

@sylvesterkaczmarek

Describe the bug

convert_dict_to_backend() accepts an iterable of array types. When the iterable is a one-shot iterator, the outer call consumes it while parsing the requested types. Recursive calls receive the exhausted iterator, so nested arrays remain in their original backend.

Steps to reproduce

import numpy as np
import torch
from isaaclab.utils.dict import convert_dict_to_backend

data = {'outer': {'values': np.array([1., 2.], dtype=np.float32)}}
result = convert_dict_to_backend(data, backend='torch', array_types=iter(('numpy',)))
assert isinstance(result['outer']['values'], torch.Tensor)

Expected: the nested NumPy array becomes a Torch tensor, just as when passing a tuple. Actual: the assertion fails.

System Info

main at ebf162a, macOS ARM64, Python 3.12, PyTorch 2.12.0. No Isaac Sim or CUDA required.

Additional context

Materialize the selection once as a tuple before parsing it and passing it to recursive calls. A parameterized regression covers tuples and iterators across the outer dictionary, nested dictionaries, and sibling branches. All 12 dictionary tests pass after the fix.

Checklist

  • Checked for similar issues and open PRs.
  • Reproduced without Isaac Sim.

Activity

  1. RandomOakForest commented on Dec 2, 2026

    @RandomOakForest
    Collaborator

    Thanks, I confirmed the iterator case on main and #9239 fixes it.

  2. added
    bug
    on Dec 2, 2026
  3. sylvesterkaczmarek commented on Dec 2, 2026

    @sylvesterkaczmarek
    ContributorAuthor

    Thanks, @RandomOakForest, for confirming the iterator issue. All 13 dictionary tests pass with the updated #9239 implementation. It also preserves the earlier ValueError when an iterator yields an invalid type before a subsequent exception. Scoped Ruff lint and formatting now pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions