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

Function is_equiv_shape

crates/vm/src/builtins/memory.rs:1149–1166  ·  view source on GitHub ↗
(a: &BufferDescriptor, b: &BufferDescriptor)

Source from the content-addressed store, hash-verified

1147}
1148
1149fn is_equiv_shape(a: &BufferDescriptor, b: &BufferDescriptor) -> bool {
1150 if a.ndim() != b.ndim() {
1151 return false;
1152 }
1153
1154 let a_iter = a.dim_desc.iter().map(|x| x.0);
1155 let b_iter = b.dim_desc.iter().map(|x| x.0);
1156 for (a_shape, b_shape) in a_iter.zip(b_iter) {
1157 if a_shape != b_shape {
1158 return false;
1159 }
1160 // if both shape is 0, ignore the rest
1161 if a_shape == 0 {
1162 break;
1163 }
1164 }
1165 true
1166}
1167
1168fn is_equiv_format(a: &BufferDescriptor, b: &BufferDescriptor) -> bool {
1169 // TODO: skip @

Callers 2

eqMethod · 0.85
is_equiv_structureFunction · 0.85

Calls 3

ndimMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected