MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / equivalent

Function equivalent

edrav2/eprj/boost/libs/python/src/numpy/dtype.cpp:103–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101int dtype::get_itemsize() const { return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;}
102
103bool equivalent(dtype const & a, dtype const & b) {
104 // On Windows x64, the behaviour described on
105 // http://docs.scipy.org/doc/numpy/reference/c-api.array.html for
106 // PyArray_EquivTypes unfortunately does not extend as expected:
107 // "For example, on 32-bit platforms, NPY_LONG and NPY_INT are equivalent".
108 // This should also hold for 64-bit platforms (and does on Linux), but not
109 // on Windows. Implement an alternative:
110#ifdef _MSC_VER
111 if (sizeof(long) == sizeof(int) &&
112 // Manually take care of the type equivalence.
113 ((a == dtype::get_builtin<long>() || a == dtype::get_builtin<int>()) &&
114 (b == dtype::get_builtin<long>() || b == dtype::get_builtin<int>()) ||
115 (a == dtype::get_builtin<unsigned int>() || a == dtype::get_builtin<unsigned long>()) &&
116 (b == dtype::get_builtin<unsigned int>() || b == dtype::get_builtin<unsigned long>()))) {
117 return true;
118 } else {
119 return PyArray_EquivTypes(
120 reinterpret_cast<PyArray_Descr*>(a.ptr()),
121 reinterpret_cast<PyArray_Descr*>(b.ptr())
122 );
123 }
124#else
125 return PyArray_EquivTypes(
126 reinterpret_cast<PyArray_Descr*>(a.ptr()),
127 reinterpret_cast<PyArray_Descr*>(b.ptr())
128 );
129#endif
130}
131
132namespace
133{

Callers 15

convertibleMethod · 0.70
copy_construct_tests1Function · 0.50
copy_construct_tests2Function · 0.50
move_construct_tests1Function · 0.50
move_construct_tests2Function · 0.50
move_assign_tests2Function · 0.50
constructor_tests1Function · 0.50
constructor_tests2Function · 0.50
simple_testFunction · 0.50
assign_tests1Function · 0.50
assign_tests2Function · 0.50
operator()Method · 0.50

Calls 1

ptrMethod · 0.45

Tested by 13

copy_construct_tests1Function · 0.40
copy_construct_tests2Function · 0.40
move_construct_tests1Function · 0.40
move_construct_tests2Function · 0.40
move_assign_tests2Function · 0.40
constructor_tests1Function · 0.40
constructor_tests2Function · 0.40
simple_testFunction · 0.40
assign_tests1Function · 0.40
assign_tests2Function · 0.40
operator()Method · 0.40
mainFunction · 0.40