Skip to content

Commit

Permalink
test/custom: extend testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarpent committed Jan 9, 2025
1 parent d6f09e6 commit bf656d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 11 additions & 2 deletions unittest/python/test_user_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,17 @@ def test_cast(from_dtype, to_dtype):
test_cast(user_type.CustomDouble, np.int32)
test_cast(np.int32, user_type.CustomDouble)

test(user_type.CustomFloat)

v = user_type.CustomDouble(1)
a = np.array(v)
assert type(v) is a.dtype.type

test(user_type.CustomFloat)

test_cast(user_type.CustomFloat, np.float32)
test_cast(np.double, user_type.CustomFloat)

test_cast(user_type.CustomFloat, np.int64)
test_cast(np.int64, user_type.CustomFloat)

test_cast(user_type.CustomFloat, np.int32)
test_cast(np.int32, user_type.CustomFloat)
5 changes: 5 additions & 0 deletions unittest/user_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,19 @@ BOOST_PYTHON_MODULE(user_type) {

eigenpy::registerCast<DoubleType, double>(true);
eigenpy::registerCast<double, DoubleType>(true);
eigenpy::registerCast<DoubleType, float>(false);
eigenpy::registerCast<float, DoubleType>(true);
eigenpy::registerCast<DoubleType, int>(false);
eigenpy::registerCast<int, DoubleType>(true);
eigenpy::registerCast<DoubleType, long long>(false);
eigenpy::registerCast<long long, DoubleType>(true);
eigenpy::registerCast<DoubleType, long>(false);
eigenpy::registerCast<long, DoubleType>(true);

eigenpy::registerCast<FloatType, double>(true);
eigenpy::registerCast<double, FloatType>(false);
eigenpy::registerCast<FloatType, float>(true);
eigenpy::registerCast<float, FloatType>(true);
eigenpy::registerCast<FloatType, long long>(false);
eigenpy::registerCast<long long, FloatType>(true);
eigenpy::registerCast<FloatType, int>(false);
Expand Down

0 comments on commit bf656d4

Please sign in to comment.