[SciPy-user] Splitting up and Joining Sets
lorenzo bolla
lbolla at gmail.com
Tue May 27 07:30:20 EDT 2008
maybe python sets are the right data structure to use: they ensure
uniqueness and order does not matter.
they can be built easily from numpy.array:
In [1]: import numpy
In [2]: x = set(numpy.arange(10))
In [3]: x
Out[3]: set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
hth,
L.
On Tue, May 27, 2008 at 11:58 AM, Lorenzo Isella <lorenzo.isella at gmail.com>
wrote:
> Dear All,
> I do not know for sure whether a SciPy array is the right tool for
> what I have in mind, but I would like to post this here anyhow.
> Say that you have a set of elements (plain integers):
> {1,2,3,4,5,6,7,8,9,10}, which can end up split into several subsets
> [no element is repeated from a subset to another, I always have 10
> elements as a whole]. Ordering does not matter, so {3,4,5} is the same
> as {5,3,4}. and {{1,2},{7,3}} is the same as {{7,3},{2,1}}.
> Now, this is what I would like to do:
> (1) Given e.g. the subsets {1,4,10},{3,7,6},{5,8,2} {9} I would like
> to be able to find out which sets were merged/split in a new
> configuration, e.g. {1,4,10,9} ,{3,7,6},{5,8,2} (joining of two sets)
> or {1,4,10},{3,7,6},{5,8} ,{9}, {2} (splitting of two sets).
> (2) There then may be a more subtle case, in which the total number of
> sets stays the same, but the structure of the sets changes e.g.:
> {1,4,10},{3,7,6},{5,8,2} {9} ---> {1,4,10},{3,7,6},{5,8} {9,2}, which
> I also would like to be able to detect, finding out which elements
> left which subset to end up in another one.
> (3) Even if a scipy array was not the most suitable structure to use
> for these manipulations, that is the way the data are originally
> manipulated in my code, so please let me know how I should convert
> them into another data type (if needed at all).
>
> Many thanks
>
> Lorenzo
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
--
Lorenzo Bolla
lbolla at gmail.com
http://lorenzobolla.emurse.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080527/087e0370/attachment.html>
More information about the SciPy-User
mailing list