diff --git a/pythran/pythonic/include/numpy/array.hpp b/pythran/pythonic/include/numpy/array.hpp index fbc6081c7..d64ec19f4 100644 --- a/pythran/pythonic/include/numpy/array.hpp +++ b/pythran/pythonic/include/numpy/array.hpp @@ -53,6 +53,13 @@ namespace numpy typename types::array_base::shape_t> array(types::array_base &&, dtype d = dtype()); + template + auto array(std::tuple t) + -> decltype(array(types::to_array::type>(t))) + { + return array(types::to_array::type>(t)); + } + DEFINE_FUNCTOR(pythonic::numpy, array); } // namespace numpy PYTHONIC_NS_END diff --git a/pythran/tests/test_numpy_func2.py b/pythran/tests/test_numpy_func2.py index d03db9c0d..71d68afcc 100644 --- a/pythran/tests/test_numpy_func2.py +++ b/pythran/tests/test_numpy_func2.py @@ -737,6 +737,9 @@ def test_array2D_(self): def test_array_iter(self): self.run_test("def np_array_iter():\n from numpy import array\n return array(list(reversed(range(0, 300)))) + 3", np_array_iter=[]) + def test_array_tuple(self): + self.run_test("def np_array_tuple(x):\n from numpy import array\n return array((1, 2, x))", 3.5, np_array_tuple=[float]) + def test_array_typed(self): self.run_test("def np_array_typed(a):\n from numpy import array, int64\n return array(a, int64)", [1.,2.,3.], np_array_typed=[List[float]])