Skip to content

Commit

Permalink
minor code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMount committed Dec 20, 2021
1 parent 43f1171 commit f593d57
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 23 deletions.
6 changes: 3 additions & 3 deletions coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ pkg/vtreat/stats_utils.py 83 3 96%
pkg/vtreat/transform.py 17 4 76%
pkg/vtreat/util.py 152 21 86%
pkg/vtreat/vtreat_api.py 286 35 88%
pkg/vtreat/vtreat_db_adapter.py 104 2 98%
pkg/vtreat/vtreat_db_adapter.py 103 2 98%
pkg/vtreat/vtreat_impl.py 663 74 89%
-----------------------------------------------------
TOTAL 1364 150 89%
TOTAL 1363 150 89%


============================= 33 passed in 23.45s ==============================
============================= 33 passed in 22.22s ==============================
15 changes: 13 additions & 2 deletions docs/vtreat/vtreat_db_adapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ <h1 class="modulename">
<div class="codehilite"><pre><span></span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Convert the description of a vtreat variable treatment into a data algebra pipeline.</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">datetime</span>

<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Dict</span><span class="p">,</span> <span class="n">List</span><span class="p">,</span> <span class="n">Tuple</span>
<span class="kn">import</span> <span class="nn">numpy</span>
Expand Down Expand Up @@ -214,7 +213,7 @@ <h1 class="modulename">
<span class="n">match_q</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;(treatment_class == &#39;MappedCodeTransform&#39;) &amp; (orig_var == &#39;</span><span class="si">{</span><span class="n">ov</span><span class="si">}</span><span class="s2">&#39;) &amp; (variable == &#39;</span><span class="si">{</span><span class="n">vi</span><span class="si">}</span><span class="s2">&#39;)&quot;</span>
<span class="n">bi</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">jt</span><span class="o">.</span><span class="n">select_rows</span><span class="p">(</span><span class="n">match_q</span><span class="p">)</span>
<span class="o">.</span><span class="n">extend</span><span class="p">({</span><span class="n">ov</span><span class="p">:</span> <span class="s2">&quot;value&quot;</span><span class="p">,</span> <span class="n">vi</span><span class="p">:</span> <span class="s2">&quot;replacement&quot;</span><span class="p">,})</span>
<span class="o">.</span><span class="n">extend</span><span class="p">({</span><span class="n">ov</span><span class="p">:</span> <span class="s2">&quot;value&quot;</span><span class="p">,</span> <span class="n">vi</span><span class="p">:</span> <span class="s2">&quot;replacement&quot;</span><span class="p">})</span>
<span class="o">.</span><span class="n">select_columns</span><span class="p">([</span><span class="n">ov</span><span class="p">,</span> <span class="n">vi</span><span class="p">])</span>
<span class="p">)</span>
<span class="n">mi_table</span> <span class="o">=</span> <span class="n">vtreat_descr</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span>
Expand Down Expand Up @@ -348,6 +347,12 @@ <h1 class="modulename">
<span class="n">ops</span> <span class="o">=</span> <span class="n">ops</span><span class="o">.</span><span class="n">extend</span><span class="p">({</span><span class="n">v</span><span class="p">:</span> <span class="s2">&quot;0.0&quot;</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">map_vars</span><span class="p">})</span>

<span class="k">def</span> <span class="nf">update_code</span><span class="p">(</span><span class="n">i</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Build one update statement.</span>

<span class="sd"> :param i:</span>
<span class="sd"> :return:</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">step_i</span> <span class="o">=</span> <span class="n">mapping_steps</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
<span class="n">ov</span> <span class="o">=</span> <span class="n">step_i</span><span class="p">[</span><span class="s2">&quot;ov&quot;</span><span class="p">]</span>
<span class="n">vi</span> <span class="o">=</span> <span class="n">step_i</span><span class="p">[</span><span class="s2">&quot;vi&quot;</span><span class="p">]</span>
Expand Down Expand Up @@ -605,6 +610,12 @@ <h1 class="modulename">
<span class="n">ops</span> <span class="o">=</span> <span class="n">ops</span><span class="o">.</span><span class="n">extend</span><span class="p">({</span><span class="n">v</span><span class="p">:</span> <span class="s2">&quot;0.0&quot;</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">map_vars</span><span class="p">})</span>

<span class="k">def</span> <span class="nf">update_code</span><span class="p">(</span><span class="n">i</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Build one update statement.</span>

<span class="sd"> :param i:</span>
<span class="sd"> :return:</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">step_i</span> <span class="o">=</span> <span class="n">mapping_steps</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
<span class="n">ov</span> <span class="o">=</span> <span class="n">step_i</span><span class="p">[</span><span class="s2">&quot;ov&quot;</span><span class="p">]</span>
<span class="n">vi</span> <span class="o">=</span> <span class="n">step_i</span><span class="p">[</span><span class="s2">&quot;vi&quot;</span><span class="p">]</span>
Expand Down
Loading

0 comments on commit f593d57

Please sign in to comment.