Skip to content

Commit

Permalink
array module support: no longer use an alias for array type
Browse files Browse the repository at this point in the history
Finally fix #2226
  • Loading branch information
serge-sans-paille committed Aug 25, 2024
1 parent f4f339e commit 054414d
Show file tree
Hide file tree
Showing 10 changed files with 1,603 additions and 48 deletions.
2 changes: 1 addition & 1 deletion pythran/pythonic/array/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace array
types::array<typename details::typecodes<c>::type>
array(std::integral_constant<char, c>)
{
return types::empty_list{};
return {0};
}

template <char c, class E>
Expand Down
2 changes: 1 addition & 1 deletion pythran/pythonic/array/array/frombytes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace array
{
long size = seq.size();
seq.resize(size + s.size() / sizeof(T));
memcpy(&*seq.begin() + size, s.c_str(), s.size());
memcpy(seq.data() + size, s.c_str(), s.size());
return {};
}

Expand Down
2 changes: 1 addition & 1 deletion pythran/pythonic/array/array/fromfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace array
{
long p = seq.size();
seq.resize(p + n);
f.read_as(n, &*seq.begin() + p);
f.read_as(n, seq.data() + p);
return {};
}

Expand Down
20 changes: 18 additions & 2 deletions pythran/pythonic/include/__dispatch__/tolist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,36 @@ namespace __dispatch__
return numpy::ndarray::tolist(any);
}

template <class T, class S>
types::list<
typename std::conditional<std::is_integral<T>::value, long, double>::type>
tolist(types::sliced_array<T, S> &&a)
{
return {a.begin(), a.end()};
}

template <class T, class S>
types::list<
typename std::conditional<std::is_integral<T>::value, long, double>::type>
tolist(types::sliced_array<T, S> const &a)
{
return {a.begin(), a.end()};
}

template <class T>
types::list<
typename std::conditional<std::is_integral<T>::value, long, double>::type>
tolist(types::array<T> &&a)
{
return a;
return {a.begin(), a.end()};
}

template <class T>
types::list<
typename std::conditional<std::is_integral<T>::value, long, double>::type>
tolist(types::array<T> const &a)
{
return a;
return {a.begin(), a.end()};
}

DEFINE_FUNCTOR(pythonic::__dispatch__, tolist);
Expand Down
Loading

0 comments on commit 054414d

Please sign in to comment.