Skip to content

Commit

Permalink
Merge pull request #97 from sjsrey/api-nb
Browse files Browse the repository at this point in the history
2.4.0 Release
  • Loading branch information
sjsrey authored Dec 14, 2020
2 parents 783e342 + 6427ce8 commit b92a7e3
Show file tree
Hide file tree
Showing 127 changed files with 4,624 additions and 9,741 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ BoxPlot
```



### EqualInterval

```python
Expand Down Expand Up @@ -268,6 +269,29 @@ UserDefined
( 674.00, 4112.00] | 2
```

## Alternative API

As of version 2.4.0 the API has been extended. A `classify` function is now
available for a streamlined interface:

```python
>>> classify(y, 'boxplot')
BoxPlot

Interval Count
--------------------------
( -inf, -52.88] | 0
( -52.88, 2.57] | 15
( 2.57, 9.36] | 14
( 9.36, 39.53] | 14
( 39.53, 94.97] | 6
( 94.97, 4111.45] | 9

```




## Use Cases

### Creating and using a classification instance
Expand Down
Binary file removed docs/_images/equalinterval.png
Binary file not shown.
Binary file removed docs/_images/fisherjenks.png
Binary file not shown.
Binary file removed docs/_images/quantiles.png
Binary file not shown.
2,313 changes: 0 additions & 2,313 deletions docs/_modules/giddy/markov.html

This file was deleted.

13 changes: 8 additions & 5 deletions docs/_modules/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>

<html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Overview: module code &#8212; mapclassify v2.3.0 Manual</title>
<title>Overview: module code &#8212; mapclassify v2.4.0 Manual</title>
<link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/pysal-styles.css" />
Expand Down Expand Up @@ -40,7 +40,7 @@
</button>
<a class="navbar-brand" href="../index.html">
mapclassify</a>
<span class="navbar-text navbar-version pull-left"><b>2.3.0</b></span>
<span class="navbar-text navbar-version pull-left"><b>2.4.0</b></span>
</div>

<div class="collapse navbar-collapse nav-collapse">
Expand Down Expand Up @@ -73,6 +73,9 @@
<li class="toctree-l2"><a class="reference internal" href="../notebooks/03_choropleth.html">Choropleth</a></li>
<li class="toctree-l2"><a class="reference internal" href="../notebooks/04_pooled.html">Pooled Classification</a></li>
<li class="toctree-l2"><a class="reference internal" href="../notebooks/05_Greedy_coloring.html">Getting started with mapclassify.greedy</a></li>
<li class="toctree-l2"><a class="reference internal" href="../notebooks/06_api.html">Overview of the mapclassify API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../notebooks/06_api.html#Original-API-(&lt;-2.4.0)">Original API (&lt; 2.4.0)</a></li>
<li class="toctree-l2"><a class="reference internal" href="../notebooks/06_api.html#Extended-API-(&gt;=-2.40)">Extended API (&gt;= 2.40)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../api.html">API</a><ul>
Expand Down Expand Up @@ -122,7 +125,7 @@
<div class="body col-md-12 content" role="main">

<h1>All modules for which code is available</h1>
<ul><li><a href="giddy/markov.html">giddy.markov</a></li>
<ul><li><a href="mapclassify/_classify_API.html">mapclassify._classify_API</a></li>
<li><a href="mapclassify/classifiers.html">mapclassify.classifiers</a></li>
<li><a href="mapclassify/greedy.html">mapclassify.greedy</a></li>
</ul>
Expand All @@ -142,7 +145,7 @@ <h1>All modules for which code is available</h1>
</p>
<p>
&copy; Copyright 2018-, pysal developers.<br/>
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 3.0.3.<br/>
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.4.3.<br/>
</p>
</div>
</footer>
Expand Down
310 changes: 310 additions & 0 deletions docs/_modules/mapclassify/_classify_API.html

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions docs/_modules/mapclassify/classifiers.html

Large diffs are not rendered by default.

46 changes: 25 additions & 21 deletions docs/_modules/mapclassify/greedy.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>

<html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>mapclassify.greedy &#8212; mapclassify v2.3.0 Manual</title>
<title>mapclassify.greedy &#8212; mapclassify v2.4.0 Manual</title>
<link rel="stylesheet" href="../../_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../../_static/pysal-styles.css" />
Expand Down Expand Up @@ -40,7 +40,7 @@
</button>
<a class="navbar-brand" href="../../index.html">
mapclassify</a>
<span class="navbar-text navbar-version pull-left"><b>2.3.0</b></span>
<span class="navbar-text navbar-version pull-left"><b>2.4.0</b></span>
</div>

<div class="collapse navbar-collapse nav-collapse">
Expand Down Expand Up @@ -73,6 +73,9 @@
<li class="toctree-l2"><a class="reference internal" href="../../notebooks/03_choropleth.html">Choropleth</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../notebooks/04_pooled.html">Pooled Classification</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../notebooks/05_Greedy_coloring.html">Getting started with mapclassify.greedy</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../notebooks/06_api.html">Overview of the mapclassify API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../notebooks/06_api.html#Original-API-(&lt;-2.4.0)">Original API (&lt; 2.4.0)</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../notebooks/06_api.html#Extended-API-(&gt;=-2.40)">Extended API (&gt;= 2.40)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../api.html">API</a><ul>
Expand Down Expand Up @@ -408,10 +411,15 @@ <h1>Source code for mapclassify.greedy</h1><div class="highlight"><pre>
<span class="sd"> color : pd.Series</span>
<span class="sd"> pandas.Series representing assinged color codes</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">try</span><span class="p">:</span>
<span class="kn">import</span> <span class="nn">networkx</span> <span class="k">as</span> <span class="nn">nx</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ImportError</span><span class="p">(</span><span class="s2">&quot;The &#39;networkx&#39; package is required.&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">strategy</span> <span class="o">!=</span> <span class="s2">&quot;balanced&quot;</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span>
<span class="kn">import</span> <span class="nn">networkx</span> <span class="k">as</span> <span class="nn">nx</span>

<span class="n">STRATEGIES</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">algorithms</span><span class="o">.</span><span class="n">coloring</span><span class="o">.</span><span class="n">greedy_coloring</span><span class="o">.</span><span class="n">STRATEGIES</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>

<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ImportError</span><span class="p">(</span><span class="s2">&quot;The &#39;networkx&#39; package is required.&quot;</span><span class="p">)</span>

<span class="k">try</span><span class="p">:</span>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
Expand All @@ -421,34 +429,30 @@ <h1>Source code for mapclassify.greedy</h1><div class="highlight"><pre>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ImportError</span><span class="p">(</span><span class="s2">&quot;The &#39;libpysal&#39; package is required.&quot;</span><span class="p">)</span>

<span class="n">STRATEGIES</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">algorithms</span><span class="o">.</span><span class="n">coloring</span><span class="o">.</span><span class="n">greedy_coloring</span><span class="o">.</span><span class="n">STRATEGIES</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>

<span class="k">if</span> <span class="n">min_distance</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="c1"># TODO: use libpysal&#39;s fuzzy_contiguity instead of _geos_sw once pysal/libpysal#280 is released</span>
<span class="n">sw</span> <span class="o">=</span> <span class="n">_geos_sw</span><span class="p">(</span><span class="n">gdf</span><span class="p">,</span> <span class="n">tolerance</span><span class="o">=</span><span class="n">min_distance</span><span class="p">,</span> <span class="n">silence_warnings</span><span class="o">=</span><span class="n">silence_warnings</span><span class="p">)</span>

<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sw</span><span class="p">,</span> <span class="n">W</span><span class="p">):</span>
<span class="k">if</span> <span class="n">sw</span> <span class="o">==</span> <span class="s2">&quot;queen&quot;</span><span class="p">:</span>
<span class="n">sw</span> <span class="o">=</span> <span class="n">Queen</span><span class="o">.</span><span class="n">from_dataframe</span><span class="p">(</span>
<span class="n">gdf</span><span class="p">,</span> <span class="n">ids</span><span class="o">=</span><span class="n">gdf</span><span class="o">.</span><span class="n">index</span><span class="o">.</span><span class="n">to_list</span><span class="p">(),</span> <span class="n">silence_warnings</span><span class="o">=</span><span class="n">silence_warnings</span>
<span class="p">)</span>
<span class="n">sw</span> <span class="o">=</span> <span class="n">Queen</span><span class="o">.</span><span class="n">from_dataframe</span><span class="p">(</span><span class="n">gdf</span><span class="p">,</span> <span class="n">silence_warnings</span><span class="o">=</span><span class="n">silence_warnings</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">sw</span> <span class="o">==</span> <span class="s2">&quot;rook&quot;</span><span class="p">:</span>
<span class="n">sw</span> <span class="o">=</span> <span class="n">Rook</span><span class="o">.</span><span class="n">from_dataframe</span><span class="p">(</span>
<span class="n">gdf</span><span class="p">,</span> <span class="n">ids</span><span class="o">=</span><span class="n">gdf</span><span class="o">.</span><span class="n">index</span><span class="o">.</span><span class="n">to_list</span><span class="p">(),</span> <span class="n">silence_warnings</span><span class="o">=</span><span class="n">silence_warnings</span>
<span class="p">)</span>
<span class="n">sw</span> <span class="o">=</span> <span class="n">Rook</span><span class="o">.</span><span class="n">from_dataframe</span><span class="p">(</span><span class="n">gdf</span><span class="p">,</span> <span class="n">silence_warnings</span><span class="o">=</span><span class="n">silence_warnings</span><span class="p">)</span>

<span class="k">if</span> <span class="n">strategy</span> <span class="o">==</span> <span class="s2">&quot;balanced&quot;</span><span class="p">:</span>
<span class="k">return</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">(</span><span class="n">_balanced</span><span class="p">(</span><span class="n">gdf</span><span class="p">,</span> <span class="n">sw</span><span class="p">,</span> <span class="n">balance</span><span class="o">=</span><span class="n">balance</span><span class="p">,</span> <span class="n">min_colors</span><span class="o">=</span><span class="n">min_colors</span><span class="p">))</span>
<span class="n">color</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">(</span><span class="n">_balanced</span><span class="p">(</span><span class="n">gdf</span><span class="p">,</span> <span class="n">sw</span><span class="p">,</span> <span class="n">balance</span><span class="o">=</span><span class="n">balance</span><span class="p">,</span> <span class="n">min_colors</span><span class="o">=</span><span class="n">min_colors</span><span class="p">))</span>

<span class="k">elif</span> <span class="n">strategy</span> <span class="ow">in</span> <span class="n">STRATEGIES</span><span class="p">:</span>
<span class="n">color</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">greedy_color</span><span class="p">(</span>
<span class="n">sw</span><span class="o">.</span><span class="n">to_networkx</span><span class="p">(),</span> <span class="n">strategy</span><span class="o">=</span><span class="n">strategy</span><span class="p">,</span> <span class="n">interchange</span><span class="o">=</span><span class="n">interchange</span>
<span class="p">)</span>
<span class="n">color</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">(</span><span class="n">color</span><span class="p">)</span><span class="o">.</span><span class="n">sort_index</span><span class="p">()</span>
<span class="n">color</span><span class="o">.</span><span class="n">index</span> <span class="o">=</span> <span class="n">gdf</span><span class="o">.</span><span class="n">index</span>
<span class="k">return</span> <span class="n">color</span>

<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> is not a valid strategy.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">strategy</span><span class="p">))</span></div>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> is not a valid strategy.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">strategy</span><span class="p">))</span>

<span class="n">color</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">(</span><span class="n">color</span><span class="p">)</span><span class="o">.</span><span class="n">sort_index</span><span class="p">()</span>
<span class="n">color</span><span class="o">.</span><span class="n">index</span> <span class="o">=</span> <span class="n">gdf</span><span class="o">.</span><span class="n">index</span>
<span class="k">return</span> <span class="n">color</span></div>
</pre></div>

</div>
Expand All @@ -466,7 +470,7 @@ <h1>Source code for mapclassify.greedy</h1><div class="highlight"><pre>
</p>
<p>
&copy; Copyright 2018-, pysal developers.<br/>
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 3.0.3.<br/>
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.4.3.<br/>
</p>
</div>
</footer>
Expand Down
1 change: 1 addition & 0 deletions docs/_sources/api.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ Utilities

mapclassify.KClassifiers
mapclassify.gadf
mapclassify.classify
12 changes: 0 additions & 12 deletions docs/_sources/generated/giddy.markov.Markov.rst.txt

This file was deleted.

14 changes: 0 additions & 14 deletions docs/_sources/generated/giddy.markov.Spatial_Markov.rst.txt

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions docs/_sources/generated/mapclassify.Box_Plot.rst.txt

This file was deleted.

28 changes: 0 additions & 28 deletions docs/_sources/generated/mapclassify.Equal_Interval.rst.txt

This file was deleted.

28 changes: 0 additions & 28 deletions docs/_sources/generated/mapclassify.Fisher_Jenks.rst.txt

This file was deleted.

28 changes: 0 additions & 28 deletions docs/_sources/generated/mapclassify.Fisher_Jenks_Sampled.rst.txt

This file was deleted.

28 changes: 0 additions & 28 deletions docs/_sources/generated/mapclassify.HeadTail_Breaks.rst.txt

This file was deleted.

Loading

0 comments on commit b92a7e3

Please sign in to comment.