Skip to content

Commit

Permalink
Deploying to gh-pages from @ 7579265 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed May 13, 2024
1 parent 30063b5 commit 8ecc474
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions _downloads/621e2c7711e8623173875c33222eddb6/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,9 @@
fixed:
- Bug in macro cache logic.
date: 2024-05-08 15:07:51
- bump: patch
changes:
changed:
- Replaced unsafe numpy-Python comparison with use of numpy dtype to convert byte-string
arrays to Unicode ones within enums
date: 2024-05-13 16:26:53
7 changes: 5 additions & 2 deletions _modules/policyengine_core/enums/enum.html
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,11 @@ <h1>Source code for policyengine_core.enums.enum</h1><div class="highlight"><pre
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array</span><span class="p">,</span> <span class="n">EnumArray</span><span class="p">):</span>
<span class="k">return</span> <span class="n">array</span>

<span class="c1"># if array.dtype.kind == &quot;b&quot;:</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array</span> <span class="o">==</span> <span class="mi">0</span><span class="p">,</span> <span class="nb">bool</span><span class="p">):</span>
<span class="c1"># First, convert byte-string arrays to Unicode-string arrays</span>
<span class="c1"># Confusingly, Numpy uses &quot;S&quot; to refer to byte-string arrays</span>
<span class="c1"># and &quot;U&quot; to refer to Unicode-string arrays, which are also</span>
<span class="c1"># referred to as the &quot;str&quot; type</span>
<span class="k">if</span> <span class="n">array</span><span class="o">.</span><span class="n">dtype</span><span class="o">.</span><span class="n">kind</span> <span class="o">==</span> <span class="s2">&quot;S&quot;</span><span class="p">:</span>
<span class="c1"># Convert boolean array to string array</span>
<span class="n">array</span> <span class="o">=</span> <span class="n">array</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">str</span><span class="p">)</span>

Expand Down

0 comments on commit 8ecc474

Please sign in to comment.