Popular recipes tagged "set" but not "python"http://code.activestate.com/recipes/tags/set-python/2015-06-25T17:33:13-07:00ActiveState Code RecipesDelaunay triangulation (Python)
2015-02-08T15:24:11-08:00Alexander Pletzerhttp://code.activestate.com/recipes/users/4190754/http://code.activestate.com/recipes/579021-delaunay-triangulation/
<p style="color: grey">
Python
recipe 579021
by <a href="/recipes/users/4190754/">Alexander Pletzer</a>
(<a href="/recipes/tags/delaunay/">delaunay</a>, <a href="/recipes/tags/edge/">edge</a>, <a href="/recipes/tags/point/">point</a>, <a href="/recipes/tags/set/">set</a>, <a href="/recipes/tags/tessellation/">tessellation</a>, <a href="/recipes/tags/triangles/">triangles</a>, <a href="/recipes/tags/triangulation/">triangulation</a>, <a href="/recipes/tags/vertices/">vertices</a>).
</p>
<p>Given a set of points, this code will construct a Delaunay triangulation.</p>
OrderedSet (Python)
2015-06-25T17:33:13-07:00Sanderhttp://code.activestate.com/recipes/users/4192426/http://code.activestate.com/recipes/579071-orderedset/
<p style="color: grey">
Python
recipe 579071
by <a href="/recipes/users/4192426/">Sander</a>
(<a href="/recipes/tags/ordered/">ordered</a>, <a href="/recipes/tags/set/">set</a>).
</p>
<p>Set that remembers original insertion order.</p>
OrderedSet (Python)
2012-12-19T07:12:32-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/576694-orderedset/
<p style="color: grey">
Python
recipe 576694
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/ordered/">ordered</a>, <a href="/recipes/tags/set/">set</a>).
Revision 9.
</p>
<p>Set that remembers original insertion order.</p>
List comparison, difference and more using set & frozenset (Python)
2012-11-01T10:30:58-07:00Scott S-Allenhttp://code.activestate.com/recipes/users/4181178/http://code.activestate.com/recipes/578310-list-comparison-difference-and-more-using-set-froz/
<p style="color: grey">
Python
recipe 578310
by <a href="/recipes/users/4181178/">Scott S-Allen</a>
(<a href="/recipes/tags/compare/">compare</a>, <a href="/recipes/tags/contain/">contain</a>, <a href="/recipes/tags/difference/">difference</a>, <a href="/recipes/tags/lambda/">lambda</a>, <a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/remove/">remove</a>, <a href="/recipes/tags/set/">set</a>, <a href="/recipes/tags/union/">union</a>).
</p>
<p>Python has a powerful suite of tools for comparing lists by way of sets and frozensets. Here are a few examples and conveniences that many newcomers, even a few seasoned developers, are unaware.</p>
setdict (Python)
2010-11-27T03:00:28-08:00thom nealehttp://code.activestate.com/recipes/users/4176069/http://code.activestate.com/recipes/577471-setdict/
<p style="color: grey">
Python
recipe 577471
by <a href="/recipes/users/4176069/">thom neale</a>
(<a href="/recipes/tags/dict/">dict</a>, <a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/set/">set</a>).
</p>
<p>Set-like operations for dictionaries</p>
Union-Find (Python)
2010-05-10T20:32:15-07:00Ahmed El Deebhttp://code.activestate.com/recipes/users/4173897/http://code.activestate.com/recipes/577225-union-find/
<p style="color: grey">
Python
recipe 577225
by <a href="/recipes/users/4173897/">Ahmed El Deeb</a>
(<a href="/recipes/tags/disjoint/">disjoint</a>, <a href="/recipes/tags/forests/">forests</a>, <a href="/recipes/tags/set/">set</a>, <a href="/recipes/tags/unionfind/">unionfind</a>).
</p>
<p>A.k.a. Disjoint set forests. Minimalistic implementation. Directly ported from pseudo code on the Wikipedia page:
<a href="http://en.wikipedia.org/wiki/Disjoint-set_data_structure">http://en.wikipedia.org/wiki/Disjoint-set_data_structure</a></p>
<p>Employs path compression and union by rank as described in the link above.</p>
Sets with a custom equality/uniqueness function (Python)
2009-10-29T21:08:22-07:00Gabriel Genellinahttp://code.activestate.com/recipes/users/924636/http://code.activestate.com/recipes/576932-sets-with-a-custom-equalityuniqueness-function/
<p style="color: grey">
Python
recipe 576932
by <a href="/recipes/users/924636/">Gabriel Genellina</a>
(<a href="/recipes/tags/abstract_base_class/">abstract_base_class</a>, <a href="/recipes/tags/mutableset/">mutableset</a>, <a href="/recipes/tags/set/">set</a>, <a href="/recipes/tags/unique/">unique</a>).
Revision 4.
</p>
<p>The builtin <code>set</code> and <code>frozenset</code> types are based on object equality; they call __eq__ to determine whether an object is a member of the set or not. But there are cases when one needs a set of objects that are compared by other means, apart from the default __eq__ function. There are several ways to achieve that; this recipe presents two classes, FrozenKeyedSet and KeyedSet, that take an additional function <code>key</code> which is used to determine membership and uniqueness. Given two objects which return the same value for <code>key</code>, only one of them will be in the set.</p>
Set product (Python)
2010-04-12T19:06:22-07:00Paul Ghttp://code.activestate.com/recipes/users/4173653/http://code.activestate.com/recipes/577190-set-product/
<p style="color: grey">
Python
recipe 577190
by <a href="/recipes/users/4173653/">Paul G</a>
(<a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/multiply/">multiply</a>, <a href="/recipes/tags/product/">product</a>, <a href="/recipes/tags/set/">set</a>).
</p>
<p>This recipe provides a subclass of set which implements __mul__ and __pow__ to support the computation of set products. When multiplying two sets together, a new set is produced with elements which are the inter-set pairs.</p>