@@ -48,33 +48,9 @@ namespace xt
4848 using complex_t = std::complex <double >;
4949 shape_type shape = { 3 , 2 };
5050 pyarray<complex_t > a (shape, complex_t (1.2 , 2.5 ));
51- auto f = [](const pyarray<complex_t >& t) {
52- return std::make_tuple (pyvectorize ([](complex_t x) { return std::abs (x); })(t),
53- pyvectorize ([](complex_t x) { return std::arg (x); })(t));
54- };
55-
56- auto res = f (a);
57- double expected_abs = std::abs (a (1 , 1 ));
58- double expected_arg = std::arg (a (1 , 1 ));
59- EXPECT_EQ (expected_abs, std::get<0 >(res)(1 , 1 ));
60- EXPECT_EQ (expected_arg, std::get<1 >(res)(1 , 1 ));
61- }
62-
63- TEST (pyvectorize, complex_pybind)
64- {
65- using complex_t = std::complex <double >;
66- shape_type shape = { 3 , 2 };
67- pyarray<complex_t > a (shape, complex_t (1.2 , 2.5 ));
68- auto f = [](const pyarray<complex_t >& t) {
69- return pybind11::make_tuple (pyvectorize ([](complex_t x) { return std::abs (x); })(t),
70- pyvectorize ([](complex_t x) { return std::arg (x); })(t));
71- };
72-
51+ auto f = pyvectorize ([](complex_t x) { return std::abs (x); });
7352 auto res = f (a);
74- double expected_abs = std::abs (a (1 , 1 ));
75- double expected_arg = std::arg (a (1 , 1 ));
76-
77- EXPECT_EQ (expected_abs, res[0 ].cast <pyarray<double >>()(1 , 1 ));
78- EXPECT_EQ (expected_arg, res[1 ].cast <pyarray<double >>()(1 , 1 ));
53+ double exp = std::abs (a (1 , 1 ));
54+ EXPECT_EQ (exp, res (1 , 1 ));
7955 }
8056}
0 commit comments