Skip to content

Commit

Permalink
deploy: c9f6ac5
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyguo11 committed Dec 13, 2024
1 parent 2dd6dbf commit 162d816
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main/_modules/omni/isaac/lab/utils/dict.html
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ <h1>Source code for omni.isaac.lab.utils.dict</h1><div class="highlight"><pre>
<span class="kn">import</span> <span class="nn">collections.abc</span>
<span class="kn">import</span> <span class="nn">hashlib</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">torch</span>
<span class="kn">from</span> <span class="nn">collections.abc</span> <span class="kn">import</span> <span class="n">Iterable</span><span class="p">,</span> <span class="n">Mapping</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Any</span>

Expand Down Expand Up @@ -549,6 +550,11 @@ <h1>Source code for omni.isaac.lab.utils.dict</h1><div class="highlight"><pre>
<span class="c1"># convert object to dictionary</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
<span class="n">obj_dict</span> <span class="o">=</span> <span class="n">obj</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">):</span>
<span class="c1"># We have to treat torch tensors specially because `torch.tensor.__dict__` returns an empty</span>
<span class="c1"># dict, which would mean that a torch.tensor would be stored as an empty dict. Instead we</span>
<span class="c1"># want to store it directly as the tensor.</span>
<span class="k">return</span> <span class="n">obj</span>
<span class="k">elif</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="s2">&quot;__dict__&quot;</span><span class="p">):</span>
<span class="n">obj_dict</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="vm">__dict__</span>
<span class="k">else</span><span class="p">:</span>
Expand All @@ -566,6 +572,7 @@ <h1>Source code for omni.isaac.lab.utils.dict</h1><div class="highlight"><pre>
<span class="c1"># check if attribute is a dictionary</span>
<span class="k">elif</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="s2">&quot;__dict__&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
<span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">class_to_dict</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="c1"># check if attribute is a list or tuple</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span>
<span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">value</span><span class="p">)([</span><span class="n">class_to_dict</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="p">])</span>
<span class="k">else</span><span class="p">:</span>
Expand Down

0 comments on commit 162d816

Please sign in to comment.