Skip to content

Commit fef5b93

Browse files
authored
Merge pull request xtensor-stack#180 from PerretB/test_call_with_incorrect_type
Add test for function call with non array arguments
2 parents c58a745 + fe76309 commit fef5b93

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

test_python/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,7 @@ PYBIND11_MODULE(xtensor_python_test, m)
239239
[](C & self) -> C::array_type & { return self.array(); }
240240
)
241241
;
242+
243+
m.def("simple_array", [](xt::pyarray<int>) { return 1; } );
244+
m.def("simple_tensor", [](xt::pytensor<int, 1>) { return 2; } );
242245
}

test_python/test_pyarray.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ def test_col_row_major(self):
147147
xt.col_major_array(varF)
148148
xt.col_major_array(varF[:, :, 0]) # still col major!
149149

150+
def test_bad_argument_call(self):
151+
with self.assertRaises(TypeError):
152+
xt.simple_array("foo")
153+
154+
with self.assertRaises(TypeError):
155+
xt.simple_tensor("foo")
156+
150157
class AttributeTest(TestCase):
151158

152159
def setUp(self):

0 commit comments

Comments
 (0)