Changeset 13193 for main/waeup.uniben/trunk/src
- Timestamp:
- 9 Aug 2015, 22:46:04 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/scripts.py
r13191 r13193 142 142 143 143 def partition(container, part_size=10000): 144 """Return a list of triples (<num>, <start>, <stop>). 144 """Partition `container` into chunks. 145 146 Get a list of triples (<num>, <index_start>, <index_end>) which 147 represent chunks of elements from `container`. 148 149 The `container` object must support `len()`. 150 151 Split length of `container` and tell what partitions we get, if each 152 partition is size `part_size` or less. 153 154 For instance a container of size 250 and `part_size` 100 would give: 155 156 [(0, 0, 99), 157 (1, 100, 199), 158 (2, 200, 249), 159 ] 145 160 146 161 """ 147 162 num = len(container) 148 print(" Number of studs: %s" % num)149 return [(idx, start, start + part_size - 1) for idx, start in enumerate(150 range(0, num, part_size))]163 print("Container elements: %s" % num) 164 return [(idx, start, min(start + part_size - 1, num - 1)) 165 for idx, start in enumerate(range(0, num, part_size))]
Note: See TracChangeset for help on using the changeset viewer.