MCPcopy Create free account
hub / github.com/activeloopai/deeplake / nonzero

Method nonzero

cpp/nd/array.hpp:857–883  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

855 }
856
857 inline void nonzero(icm::bit_vector_view output) const
858 {
859 if (has_data_) {
860 nd::switch_numeric_dtype(dtype(), [this, &output]<typename T>() {
861 auto y = data<T>();
862 output.set_from_span(y);
863 });
864 return;
865 }
866 try {
867 holder()->nonzero(output);
868 } catch (const invalid_operation&) {
869 int64_t i = 0L;
870 auto e = end();
871 for (auto it = begin(); it != e; ++it) {
872 try {
873 auto d = *it;
874 if (d && !d.empty() && d.value<bool>(0)) {
875 output.set(i);
876 }
877 } catch (const std::exception&) {
878 /// Intentionally empty.
879 }
880 ++i;
881 }
882 }
883 }
884
885 friend array eval(array);
886 friend void copy_data(const array& arr, std::span<uint8_t>);

Callers 1

nonzeroMethod · 0.45

Calls 8

switch_numeric_dtypeFunction · 0.85
dtypeEnum · 0.70
holderClass · 0.70
endFunction · 0.50
beginFunction · 0.50
set_from_spanMethod · 0.45
emptyMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected