Container
- class PlasmaCalcs.tools.iterables.Container(stuff)
Bases:
objecta container for multiple objects, & rules for enumerating & indexing.
Here, implements self.__getitem__ so that self[i]=self.data[i],and self.enumerate which yields (i, self[i]) pairs.subclass should implement __init__, _enumerate_all, and new_empty.Methods
__init__(stuff)should set self.data = something related to stuff.
enumerate([idx])iterate through i in idx, yielding (i, self[i]) pairs.
new_empty([fill])return a new container of the same shape as self, filled with the value fill.
size([idx])return the number of objects in the container, or in idx if provided.
iterate through all objs in self, yielding (i, self[i]) pairs.
return the number of objects in the container.
- __init__(stuff)
should set self.data = something related to stuff.
- _enumerate_all()
iterate through all objs in self, yielding (i, self[i]) pairs.
Equivalent to self.enumerate(idx=None).The implementation will depend on the container type; subclass should implement.
- _size_all()
return the number of objects in the container.
The implementation will depend on the container type; subclass should implement.
- enumerate(idx=None)
iterate through i in idx, yielding (i, self[i]) pairs.
If idx is None, iterate through all objs in self (see self._enumerate_all).
- new_empty(fill=UNSET)
return a new container of the same shape as self, filled with the value fill.
The implementation will depend on the container type; subclass should implement.
- size(idx=None)
return the number of objects in the container, or in idx if provided.