Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Error when using vstack with mixed shape type #2756

Open
spectre-ns opened this issue Dec 8, 2023 · 1 comment
Open

[Bug] Error when using vstack with mixed shape type #2756

spectre-ns opened this issue Dec 8, 2023 · 1 comment

Comments

@spectre-ns
Copy link
Contributor

See the following godbolt link: https://godbolt.org/z/e11s1999W

The issue appears to be due to the following code:

    /**
     * @brief Stack xexpressions in sequence vertically (row wise).
     * This is equivalent to concatenation along the first axis after
     * 1-D arrays of shape (N) have been reshape to (1, N).
     *
     * @param t \ref xtuple of xexpressions to stack
     * @return xgenerator evaluating to stacked elements
     */
    template <class... CT>
    inline auto vstack(std::tuple<CT...>&& t)
    {
        using shape_type = promote_shape_t<typename std::decay_t<CT>::shape_type...>;
        using source_shape_type = decltype(std::get<0>(t).shape());
        auto new_shape = detail::vstack_shape(
            t,
            xtl::forward_sequence<shape_type, source_shape_type>(std::get<0>(t).shape())
        );
        return detail::make_xgenerator(detail::vstack_impl<CT...>(std::move(t), size_t(0)), new_shape);
    }

There should be a check to make sure that the most generic shape type is used rather than just the first type.

@spectre-ns
Copy link
Contributor Author

spectre-ns commented Dec 12, 2023

@JohanMabille @SylvainCorlay Is the intent with Xtensor that all interfaces calls work with all expressions? I'm finding that in this case and others that I need to insert xt::eval() calls strategically to 'flatten' the expressions which reduces the power of the lazy computing paradigm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant