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 in sort #262

Open
tdegeus opened this issue May 28, 2021 · 0 comments
Open

Bug in sort #262

tdegeus opened this issue May 28, 2021 · 0 comments

Comments

@tdegeus
Copy link
Member

tdegeus commented May 28, 2021

The following code

#include <xtensor.hpp>
#include <pybind11/pybind11.h>

namespace py = pybind11;

#define FORCE_IMPORT_ARRAY
#include <xtensor-python/pyarray.hpp>
#include <xtensor-python/pytensor.hpp>

template <class T>
inline auto foo(const T& arg)
{
    return xt::sort(arg);
}

PYBIND11_MODULE(mymodule, m)
{
    xt::import_numpy();
    m.doc() = "Module description";
    m.def("foo", &foo<xt::pytensor<size_t, 1>>, "Function description", py::arg("arg"));
}

Gives:

...\include\xtensor\xsort.hpp(155,31): error C2397: conversion from 'unsigned __int64' to '_Ty' requires a narrowing conversion with
          [
              _Ty=ptrdiff_t
          ]
...\include\xtensor\xsort.hpp(204): message : see reference to function template instantiation 'auto xt::detail::flat_sort_impl<xt::pytensor<size_t,1,xt::layout_type::dynamic>,eval_type>(const xt::xexpression<D> &)' being compiled with
          [
              D=xt::pytensor<size_t,1,xt::layout_type::dynamic>
          ]
...\main.cpp(13): message : see reference to function template instantiation 'auto xt::sort<D>(const xt::xexpression<D> &,ptrdiff_t)' being compiled with
          [
              D=xt::pytensor<size_t,1,xt::layout_type::dynamic>
          ]
...\main.cpp(20): message : see reference to function template instantiation 'auto foo<xt::pytensor<size_t,1,xt::layout_type::dynamic>>(const T &)' being compiled with
          [
              T=xt::pytensor<size_t,1,xt::layout_type::dynamic>
          ]

on Windows. It works fine on macOS, and gives a very vague error message on Linux.

For full CI, see tdegeus/xtensor-python_examples#1

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