diff --git a/include/xtensor/xaccessible.hpp b/include/xtensor/xaccessible.hpp index 934d724d5..090922785 100644 --- a/include/xtensor/xaccessible.hpp +++ b/include/xtensor/xaccessible.hpp @@ -174,7 +174,7 @@ namespace xt template inline auto xconst_accessible::at(Args... args) const -> const_reference { - check_access(derived_cast().shape(), static_cast(args)...); + check_access(derived_cast().shape(), args...); return derived_cast().operator()(args...); } @@ -273,7 +273,7 @@ namespace xt template inline auto xaccessible::at(Args... args) -> reference { - check_access(derived_cast().shape(), static_cast(args)...); + check_access(derived_cast().shape(), args...); return derived_cast().operator()(args...); } @@ -316,7 +316,7 @@ namespace xt inline auto xaccessible::periodic(Args... args) -> reference { normalize_periodic(derived_cast().shape(), args...); - return derived_cast()(static_cast(args)...); + return derived_cast()(args...); } /** diff --git a/include/xtensor/xstrides.hpp b/include/xtensor/xstrides.hpp index 17cf95eb4..65eb956e0 100644 --- a/include/xtensor/xstrides.hpp +++ b/include/xtensor/xstrides.hpp @@ -642,6 +642,12 @@ namespace xt return true; } + template + inline bool check_in_bounds_impl(const S&, missing_type) + { + return true; + } + template inline bool check_in_bounds_impl(const S& shape, T& arg, Args&... args) { @@ -669,6 +675,11 @@ namespace xt { } + template + inline void normalize_periodic_impl(const S&, missing_type) + { + } + template inline void normalize_periodic_impl(const S& shape, T& arg, Args&... args) { diff --git a/test/test_xtensor.cpp b/test/test_xtensor.cpp index 859b061f7..85fac3ec3 100644 --- a/test/test_xtensor.cpp +++ b/test/test_xtensor.cpp @@ -167,7 +167,7 @@ namespace xt } } - TEST(xtensor, missign) + TEST(xtensor, missing) { xt::xtensor a {{0, 1, 2}, @@ -202,6 +202,19 @@ namespace xt EXPECT_EQ(a(9, 9, 9, 2, 0), 6); EXPECT_EQ(a(9, 9, 9, 2, 1), 7); EXPECT_EQ(a(9, 9, 9, 2, 2), 8); + + EXPECT_EQ(a.periodic(-1, xt::missing), a(2, xt::missing)); + EXPECT_EQ(a.periodic(-2, xt::missing), a(1, xt::missing)); + EXPECT_EQ(a.periodic(-3, xt::missing), a(0, xt::missing)); + + EXPECT_EQ(a.at(0, xt::missing), a.at(0, 0)); + EXPECT_EQ(a.at(1, xt::missing), a.at(1, 0)); + EXPECT_EQ(a.at(2, xt::missing), a.at(2, 0)); + + EXPECT_TRUE(a.in_bounds(0, xt::missing)); + EXPECT_TRUE(a.in_bounds(1, xt::missing)); + EXPECT_TRUE(a.in_bounds(2, xt::missing)); + EXPECT_FALSE(a.in_bounds(3, xt::missing)); } TEST(xtensor, resize)