Append zeros to an Index Parameters ---------- num: int number of zeros to append
(self, num)
| 255 | return Index(F.scatter_row(tensor, index, value), self.dtype) |
| 256 | |
| 257 | def append_zeros(self, num): |
| 258 | """Append zeros to an Index |
| 259 | |
| 260 | Parameters |
| 261 | ---------- |
| 262 | num: int |
| 263 | number of zeros to append |
| 264 | """ |
| 265 | if num == 0: |
| 266 | return self |
| 267 | new_items = F.zeros((num,), dtype=F.int64, ctx=F.cpu()) |
| 268 | if len(self) == 0: |
| 269 | return Index(new_items, self.dtype) |
| 270 | else: |
| 271 | tensor = self.tousertensor() |
| 272 | tensor = F.cat((tensor, new_items), dim=0) |
| 273 | return Index(tensor, self.dtype) |
| 274 | |
| 275 | def nonzero(self): |
| 276 | """Return the nonzero positions""" |
nothing calls this directly
no test coverage detected