MCPcopy Index your code
hub / github.com/RustPython/RustPython / position

Method position

crates/vm/src/protocol/buffer.rs:265–278  ·  view source on GitHub ↗

panic if indices.len() != ndim

(&self, indices: &[isize], vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

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

Callers 15

cipher_descriptionFunction · 0.45
findMethod · 0.45
readlineMethod · 0.45
trim_spacesMethod · 0.45
decode_utf8_compatibleFunction · 0.45
encode_utf8_compatibleFunction · 0.45
encodeFunction · 0.45
_findfirstfileFunction · 0.45
listvolumesFunction · 0.45
find_encoding_in_lineFunction · 0.45
EnumValueFunction · 0.45
QueryValueFunction · 0.45

Calls 4

zip_eqMethod · 0.80
ok_or_elseMethod · 0.80
wrapped_atMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected