Skip to content

Commit

Permalink
fix RValue conversion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
carsten-forty2 committed Sep 27, 2018
1 parent 8a2fa34 commit 172c31f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/custom_rvalue.cpp
Expand Up @@ -61,6 +61,13 @@ template < class ValueType > void * checkConvertibleSequenz(PyObject * obj){
__DC(obj << "\t Object is nd.array with dtype == bool* .. non convertable to GIMLI::IVector")
return NULL;
}
} else if (typeid(ValueType) == typeid(bool)){
PyArrayObject *arr = (PyArrayObject *)obj;

if (PyArray_TYPE(arr) != NPY_BOOL){
__DC(obj << "\t Object is nd.array with dtype != bool .. non convertable to GIMLI::BVector")
return NULL;
}
}

return obj;
Expand Down
8 changes: 8 additions & 0 deletions python/pygimli/testing/test_XVector.py
Expand Up @@ -96,6 +96,14 @@ def test_RVectorOP(self):
self.assertEqual(sum(2.0 * v), 10)
self.assertEqual(sum(1.0 / v), 5)


v2 = np.ones(len(v))* 0.01
# check pg * np
self.assertEqual(sum(v * v2), 5*0.01)
# check np * pg
self.assertEqual(sum(v2 * v), 5*0.01)


#v = pg.CVector(5, 1.0)

#self.assertEqual(sum(v + 1), 10)
Expand Down

0 comments on commit 172c31f

Please sign in to comment.