Set values at given positions of an Index. Set is not done in place, instead, a new Index object will be returned. Parameters ---------- index: utils.Index Positions to set values value: int or utils.Index Values to set. If value is an
(self, index, value)
| 230 | ) |
| 231 | |
| 232 | def set_items(self, index, value): |
| 233 | """Set values at given positions of an Index. Set is not done in place, |
| 234 | instead, a new Index object will be returned. |
| 235 | |
| 236 | Parameters |
| 237 | ---------- |
| 238 | index: utils.Index |
| 239 | Positions to set values |
| 240 | value: int or utils.Index |
| 241 | Values to set. If value is an integer, then all positions are set |
| 242 | to the same value |
| 243 | |
| 244 | Returns |
| 245 | ------- |
| 246 | utils.Index |
| 247 | The new values. |
| 248 | """ |
| 249 | tensor = self.tousertensor() |
| 250 | index = index.tousertensor() |
| 251 | if isinstance(value, int): |
| 252 | value = F.full_1d(len(index), value, dtype=F.int64, ctx=F.cpu()) |
| 253 | else: |
| 254 | value = value.tousertensor() |
| 255 | return Index(F.scatter_row(tensor, index, value), self.dtype) |
| 256 | |
| 257 | def append_zeros(self, num): |
| 258 | """Append zeros to an Index |
nothing calls this directly
no test coverage detected