panic if indices.len() != ndim
(&self, indices: &[isize], vm: &VirtualMachine)
| 263 | |
| 264 | /// panic if indices.len() != ndim |
| 265 | pub fn position(&self, indices: &[isize], vm: &VirtualMachine) -> PyResult<isize> { |
| 266 | let mut pos = 0; |
| 267 | for (i, (shape, stride, suboffset)) in indices |
| 268 | .iter() |
| 269 | .cloned() |
| 270 | .zip_eq(self.dim_desc.iter().cloned()) |
| 271 | { |
| 272 | let i = i.wrapped_at(shape).ok_or_else(|| { |
| 273 | vm.new_index_error(format!("index out of bounds on dimension {i}")) |
| 274 | })?; |
| 275 | pos += i as isize * stride + suboffset; |
| 276 | } |
| 277 | Ok(pos) |
| 278 | } |
| 279 | |
| 280 | pub fn for_each_segment<F>(&self, try_contiguous: bool, mut f: F) |
| 281 | where |
no test coverage detected