MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/Imath / getitem_mask

Method getitem_mask

src/python/PyImath/PyImathFixedVArray.cpp:617–660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

615
616template <class T>
617FixedArray<int>
618FixedVArray<T>::SizeHelper::getitem_mask (const FixedArray<int>& mask) const
619{
620 int len = mask.len();
621 if (len != _a.len())
622 {
623 throw std::invalid_argument("Dimensions of mask do not match array");
624 }
625
626 int count = 0;
627 for (Py_ssize_t i = 0; i < mask.len(); ++i)
628 {
629 if (mask[i]) count += 1;
630 }
631
632 FixedArray<int> f(count);
633
634 if (_a._indices)
635 {
636 size_t index = 0;
637 for (Py_ssize_t i = 0; i < mask.len(); ++i)
638 {
639 if (mask[i])
640 {
641 f.direct_index(index) = _a._ptr[_a.raw_ptr_index(i)*_a._stride].size();
642 index += 1;
643 }
644 }
645 }
646 else
647 {
648 size_t index = 0;
649 for (Py_ssize_t i = 0; i < mask.len(); ++i)
650 {
651 if (mask[i])
652 {
653 f.direct_index(index) = _a._ptr[i*_a._stride].size();
654 index += 1;
655 }
656 }
657 }
658
659 return f;
660}
661
662
663template <class T>

Callers

nothing calls this directly

Calls 3

lenMethod · 0.45
sizeMethod · 0.45
raw_ptr_indexMethod · 0.45

Tested by

no test coverage detected