Skip to content

Commit

Permalink
Merge pull request #127 from dylan-profiler/develop
Browse files Browse the repository at this point in the history
v0.6.0
  • Loading branch information
sbrugman authored Sep 22, 2020
2 parents 98c1dea + 6239770 commit a43e35c
Show file tree
Hide file tree
Showing 63 changed files with 432 additions and 101 deletions.
13 changes: 11 additions & 2 deletions docs/_modules/visions/types/boolean.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ <h1>Source code for visions.types.boolean</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">visions.types.type</span> <span class="kn">import</span> <span class="n">VisionsBaseType</span>
<span class="kn">from</span> <span class="nn">visions.utils</span> <span class="kn">import</span> <span class="n">func_nullable_series_contains</span>
<span class="kn">from</span> <span class="nn">visions.utils.coercion.test_utils</span> <span class="kn">import</span> <span class="n">coercion_map</span><span class="p">,</span> <span class="n">coercion_map_test</span>
<span class="kn">from</span> <span class="nn">visions.utils.series_utils</span> <span class="kn">import</span> <span class="n">series_not_empty</span><span class="p">,</span> <span class="n">series_not_sparse</span>

<span class="n">hasnan_bool_name</span> <span class="o">=</span> <span class="s2">&quot;boolean&quot;</span> <span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">pd</span><span class="o">.</span><span class="n">__version__</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;.&quot;</span><span class="p">)[</span><span class="mi">0</span><span class="p">])</span> <span class="o">&gt;=</span> <span class="mi">1</span> <span class="k">else</span> <span class="s2">&quot;Bool&quot;</span>

Expand All @@ -213,11 +214,17 @@ <h1>Source code for visions.types.boolean</h1><div class="highlight"><pre>


<span class="k">def</span> <span class="nf">string_is_bool</span><span class="p">(</span><span class="n">series</span><span class="p">,</span> <span class="n">state</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">string_coercions</span><span class="p">):</span>
<span class="k">return</span> <span class="n">coercion_map_test</span><span class="p">(</span><span class="n">string_coercions</span><span class="p">)(</span><span class="n">series</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">return</span> <span class="n">coercion_map_test</span><span class="p">(</span><span class="n">string_coercions</span><span class="p">)(</span><span class="n">series</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span>
<span class="k">except</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span>


<span class="k">def</span> <span class="nf">string_to_bool</span><span class="p">(</span><span class="n">series</span><span class="p">,</span> <span class="n">state</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">string_coercions</span><span class="p">):</span>
<span class="k">return</span> <span class="n">to_bool</span><span class="p">(</span><span class="n">coercion_map</span><span class="p">(</span><span class="n">string_coercions</span><span class="p">)(</span><span class="n">series</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">()),</span> <span class="n">state</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">return</span> <span class="n">to_bool</span><span class="p">(</span><span class="n">coercion_map</span><span class="p">(</span><span class="n">string_coercions</span><span class="p">)(</span><span class="n">series</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">()),</span> <span class="n">state</span><span class="p">)</span>
<span class="k">except</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span>


<span class="k">def</span> <span class="nf">_get_relations</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">TypeRelation</span><span class="p">]:</span>
Expand Down Expand Up @@ -258,6 +265,8 @@ <h1>Source code for visions.types.boolean</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">_get_relations</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span>

<span class="nd">@classmethod</span>
<span class="nd">@series_not_sparse</span>
<span class="nd">@series_not_empty</span>
<span class="k">def</span> <span class="nf">contains_op</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">series</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">,</span> <span class="n">state</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">pdt</span><span class="o">.</span><span class="n">is_categorical_dtype</span><span class="p">(</span><span class="n">series</span><span class="p">)</span> <span class="ow">and</span> <span class="n">pdt</span><span class="o">.</span><span class="n">is_bool_dtype</span><span class="p">(</span><span class="n">series</span><span class="p">):</span>
<span class="k">return</span> <span class="kc">True</span>
Expand Down
3 changes: 3 additions & 0 deletions docs/_modules/visions/types/categorical.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ <h1>Source code for visions.types.categorical</h1><div class="highlight"><pre>

<span class="kn">from</span> <span class="nn">visions.relations</span> <span class="kn">import</span> <span class="n">IdentityRelation</span><span class="p">,</span> <span class="n">TypeRelation</span>
<span class="kn">from</span> <span class="nn">visions.types.type</span> <span class="kn">import</span> <span class="n">VisionsBaseType</span>
<span class="kn">from</span> <span class="nn">visions.utils.series_utils</span> <span class="kn">import</span> <span class="n">series_not_empty</span><span class="p">,</span> <span class="n">series_not_sparse</span>


<span class="k">def</span> <span class="nf">_get_relations</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">TypeRelation</span><span class="p">]:</span>
Expand All @@ -211,6 +212,8 @@ <h1>Source code for visions.types.categorical</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">_get_relations</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span>

<span class="nd">@classmethod</span>
<span class="nd">@series_not_sparse</span>
<span class="nd">@series_not_empty</span>
<span class="k">def</span> <span class="nf">contains_op</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">series</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">,</span> <span class="n">state</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="k">return</span> <span class="n">pdt</span><span class="o">.</span><span class="n">is_categorical_dtype</span><span class="p">(</span><span class="n">series</span><span class="p">)</span></div>
</pre></div>
Expand Down
3 changes: 3 additions & 0 deletions docs/_modules/visions/types/complex.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ <h1>Source code for visions.types.complex</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">visions.types.float</span> <span class="kn">import</span> <span class="n">string_is_float</span>
<span class="kn">from</span> <span class="nn">visions.types.type</span> <span class="kn">import</span> <span class="n">VisionsBaseType</span>
<span class="kn">from</span> <span class="nn">visions.utils.coercion</span> <span class="kn">import</span> <span class="n">test_utils</span>
<span class="kn">from</span> <span class="nn">visions.utils.series_utils</span> <span class="kn">import</span> <span class="n">series_not_empty</span><span class="p">,</span> <span class="n">series_not_sparse</span>


<span class="k">def</span> <span class="nf">test_imaginary_in_string</span><span class="p">(</span>
Expand Down Expand Up @@ -241,6 +242,8 @@ <h1>Source code for visions.types.complex</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">_get_relations</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span>

<span class="nd">@classmethod</span>
<span class="nd">@series_not_sparse</span>
<span class="nd">@series_not_empty</span>
<span class="k">def</span> <span class="nf">contains_op</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">series</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">,</span> <span class="n">state</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="k">return</span> <span class="n">pdt</span><span class="o">.</span><span class="n">is_complex_dtype</span><span class="p">(</span><span class="n">series</span><span class="p">)</span></div>
</pre></div>
Expand Down
3 changes: 3 additions & 0 deletions docs/_modules/visions/types/count.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ <h1>Source code for visions.types.count</h1><div class="highlight"><pre>

<span class="kn">from</span> <span class="nn">visions.relations</span> <span class="kn">import</span> <span class="n">IdentityRelation</span><span class="p">,</span> <span class="n">TypeRelation</span>
<span class="kn">from</span> <span class="nn">visions.types.type</span> <span class="kn">import</span> <span class="n">VisionsBaseType</span>
<span class="kn">from</span> <span class="nn">visions.utils.series_utils</span> <span class="kn">import</span> <span class="n">series_not_empty</span><span class="p">,</span> <span class="n">series_not_sparse</span>


<span class="k">def</span> <span class="nf">_get_relations</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">TypeRelation</span><span class="p">]:</span>
Expand All @@ -211,6 +212,8 @@ <h1>Source code for visions.types.count</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">_get_relations</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span>

<span class="nd">@classmethod</span>
<span class="nd">@series_not_sparse</span>
<span class="nd">@series_not_empty</span>
<span class="k">def</span> <span class="nf">contains_op</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">series</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">,</span> <span class="n">state</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="k">return</span> <span class="n">pdt</span><span class="o">.</span><span class="n">is_unsigned_integer_dtype</span><span class="p">(</span><span class="n">series</span><span class="p">)</span></div>
</pre></div>
Expand Down
4 changes: 3 additions & 1 deletion docs/_modules/visions/types/date.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ <h1>Source code for visions.types.date</h1><div class="highlight"><pre>

<span class="kn">from</span> <span class="nn">visions.relations</span> <span class="kn">import</span> <span class="n">IdentityRelation</span><span class="p">,</span> <span class="n">InferenceRelation</span><span class="p">,</span> <span class="n">TypeRelation</span>
<span class="kn">from</span> <span class="nn">visions.types.type</span> <span class="kn">import</span> <span class="n">VisionsBaseType</span>
<span class="kn">from</span> <span class="nn">visions.utils</span> <span class="kn">import</span> <span class="n">func_nullable_series_contains</span>
<span class="kn">from</span> <span class="nn">visions.utils.series_utils</span> <span class="kn">import</span> <span class="p">(</span>
<span class="n">class_name_attrs</span><span class="p">,</span>
<span class="n">func_nullable_series_contains</span><span class="p">,</span>
<span class="n">nullable_series_contains</span><span class="p">,</span>
<span class="n">series_not_empty</span><span class="p">,</span>
<span class="p">)</span>


Expand Down Expand Up @@ -236,6 +237,7 @@ <h1>Source code for visions.types.date</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">_get_relations</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span>

<span class="nd">@classmethod</span>
<span class="nd">@series_not_empty</span>
<span class="nd">@nullable_series_contains</span>
<span class="k">def</span> <span class="nf">contains_op</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">series</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">,</span> <span class="n">state</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="k">return</span> <span class="n">class_name_attrs</span><span class="p">(</span><span class="n">series</span><span class="p">,</span> <span class="n">date</span><span class="p">,</span> <span class="p">[</span><span class="s2">&quot;year&quot;</span><span class="p">,</span> <span class="s2">&quot;month&quot;</span><span class="p">,</span> <span class="s2">&quot;day&quot;</span><span class="p">])</span></div>
Expand Down
3 changes: 3 additions & 0 deletions docs/_modules/visions/types/date_time.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ <h1>Source code for visions.types.date_time</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">visions.relations</span> <span class="kn">import</span> <span class="n">IdentityRelation</span><span class="p">,</span> <span class="n">InferenceRelation</span><span class="p">,</span> <span class="n">TypeRelation</span>
<span class="kn">from</span> <span class="nn">visions.types.type</span> <span class="kn">import</span> <span class="n">VisionsBaseType</span>
<span class="kn">from</span> <span class="nn">visions.utils.coercion</span> <span class="kn">import</span> <span class="n">test_utils</span>
<span class="kn">from</span> <span class="nn">visions.utils.series_utils</span> <span class="kn">import</span> <span class="n">series_not_empty</span><span class="p">,</span> <span class="n">series_not_sparse</span>


<span class="k">def</span> <span class="nf">string_is_datetime</span><span class="p">(</span><span class="n">series</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">,</span> <span class="n">state</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
Expand Down Expand Up @@ -232,6 +233,8 @@ <h1>Source code for visions.types.date_time</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">_get_relations</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span>

<span class="nd">@classmethod</span>
<span class="nd">@series_not_sparse</span>
<span class="nd">@series_not_empty</span>
<span class="k">def</span> <span class="nf">contains_op</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">series</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">,</span> <span class="n">state</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="k">return</span> <span class="n">pdt</span><span class="o">.</span><span class="n">is_datetime64_any_dtype</span><span class="p">(</span><span class="n">series</span><span class="p">)</span></div>
</pre></div>
Expand Down
3 changes: 2 additions & 1 deletion docs/_modules/visions/types/file.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ <h1>Source code for visions.types.file</h1><div class="highlight"><pre>

<span class="kn">from</span> <span class="nn">visions.relations</span> <span class="kn">import</span> <span class="n">IdentityRelation</span><span class="p">,</span> <span class="n">TypeRelation</span>
<span class="kn">from</span> <span class="nn">visions.types.type</span> <span class="kn">import</span> <span class="n">VisionsBaseType</span>
<span class="kn">from</span> <span class="nn">visions.utils.series_utils</span> <span class="kn">import</span> <span class="n">nullable_series_contains</span>
<span class="kn">from</span> <span class="nn">visions.utils.series_utils</span> <span class="kn">import</span> <span class="n">nullable_series_contains</span><span class="p">,</span> <span class="n">series_not_empty</span>


<span class="k">def</span> <span class="nf">_get_relations</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">TypeRelation</span><span class="p">]:</span>
Expand All @@ -213,6 +213,7 @@ <h1>Source code for visions.types.file</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">_get_relations</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span>

<span class="nd">@classmethod</span>
<span class="nd">@series_not_empty</span>
<span class="nd">@nullable_series_contains</span>
<span class="k">def</span> <span class="nf">contains_op</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">series</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">,</span> <span class="n">state</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="k">return</span> <span class="nb">all</span><span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">)</span> <span class="ow">and</span> <span class="n">p</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">series</span><span class="p">)</span></div>
Expand Down
Loading

0 comments on commit a43e35c

Please sign in to comment.