make[3]: Map ‘/home/benedict/prj/pyformex’ wordt binnengegaan running build_ext building ‘pyformex/lib/misc_’ extension x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/lib/python3/dist-packages/numpy/core/include -I/usr/include/python3.7m -c pyformex/lib/misc_.c -o build/temp.linux-x86_64-3.7/pyformex/lib/misc_.o make[3]: Map ‘/home/benedict/prj/pyformex’ wordt verlaten
The compiled library ‘misc_’ is not up to date! The compiled library ‘nurbs_’ is not up to date! Rebuilding pyFormex libraries, please wait Running command: cd /home/benedict/prj/pyformex/pyformex/..; make lib3 .. -- rst -- .. pyformex reference manual — collection .. CREATED WITH pyformex –docmodule: DO NOT EDIT
31. collection
— Tools for handling collections of elements belonging to multiple parts.¶
This module defines the Collection class.
-
class
collection.
Collection
(object_type=None)[source]¶ A collection is a set of (int,int) tuples.
The first part of the tuple has a limited number of values and are used as the keys in a dict. The second part can have a lot of different values and is implemented as an integer array with unique values. This is e.g. used to identify a set of individual parts of one or more OpenGL actors.
Examples:
>>> a = Collection() >>> a.add(range(7),3) >>> a.add(range(4)) >>> a.remove([2,4],3) >>> print(a) -1 [0 1 2 3]; 3 [0 1 3 5 6]; >>> a.add([[2,0],[2,3],[-1,7],[3,88]]) >>> print(a) -1 [0 1 2 3 7]; 2 [0 3]; 3 [ 0 1 3 5 6 88]; >>> a[2] = [1,2,3] >>> print(a) -1 [0 1 2 3 7]; 2 [1 2 3]; 3 [ 0 1 3 5 6 88]; >>> a[2] = [] >>> print(a) -1 [0 1 2 3 7]; 3 [ 0 1 3 5 6 88]; >>> a.set([[2,0],[2,3],[-1,7],[3,88]]) >>> print(a) -1 [7]; 2 [0 3]; 3 [88]; >>> print(a.keys()) [-1 2 3] >>> print([k for k in a]) [-1, 2, 3] >>> 2 in a True
-
add
(data, key=-1)[source]¶ Add new data to the collection.
data can be a 2d array with (key,val) tuples or a 1-d array of values. In the latter case, the key has to be specified separately, or a default value will be used.
data can also be another Collection, if it has the same object type.
-