ndarray / Boost.NumPy

Boost.Python interface for NumPy; now deprecated in factor of the version in Boost.Python itself.
Boost Software License 1.0
151 stars 73 forks source link

vector has become more fragile #66

Closed nbecker closed 8 years ago

nbecker commented 8 years ago

After pulling all recent updates, I'm having new problems related to type deduction (code that previously compiled now fails). For example:

int BITS_PER_SYM = llr_mask.getShape()[1]; int n_syms = llr_mask.getShape()[0]; int syms_per_burst = intrlv_soft.getShape()[0]/BITS_PER_SYM; auto shape = nd::makeVector (syms_per_burst, BITS_PER_SYM);

auto w = nd::Array<flt_t,2,2> (nd::external (intrlv_soft.getData(), shape, nd::ROW_MAJOR, intrlv_soft.getManager()));

/home/nbecker/.local/include/ndarray/initialization.h:239:23: error: no matching function for call to 'computeStrides(const ndarray::Vector<int, 2>&, ndarray::DataOrderEnum&)' In file included from /home/nbecker/.local/include/ndarray.h:21:0, from /home/nbecker/.local/include/ndarray/bp/Array.h:15, from /home/nbecker/.local/include/ndarray/bp/auto/Array.h:16, from /home/nbecker/.local/include/ndarray/bp/auto.h:14, from llr.cc:6: /home/nbecker/.local/include/ndarray/initialization.h:152:18: note: candidate: template ndarray::Vector<long int, M> ndarray::computeStrides(const ndarray::Vector<long unsigned int, M>&, ndarray::DataOrderEnum) Vector<Offset,N> computeStrides(Vector<Size,N> const & shape, DataOrderEnum order=ROW_MAJOR) { ^~~~~~ /home/nbecker/.local/include/ndarray/initialization.h:152:18: note: template argument deduction/substitution failed: In file included from /home/nbecker/.local/include/ndarray.h:21:0, from /home/nbecker/.local/include/ndarray/bp/Array.h:15, from /home/nbecker/.local/include/ndarray/bp/auto/Array.h:16, from /home/nbecker/.local/include/ndarray/bp/auto.h:14, from llr.cc:6: /home/nbecker/.local/include/ndarray/initialization.h:239:23: note: mismatched types 'long unsigned int' and 'int' computeStrides(shape, order),

TallJimbo commented 8 years ago

Please try branch explicit_vector_casts (of ndarray, not Boost.NumPy).

nbecker commented 8 years ago

/home/nbecker/.local/include/ndarray/initialization.h: In function 'ndarray::detail::ExternalInitializer<T, N, Owner> ndarray::external(T*, const ndarray::Vector<U, N>&, ndarray::DataOrderEnum, const Owner&)': /home/nbecker/.local/include/ndarray/initialization.h:236:50: error: expected primary-expression before '(' token return detail::ExternalInitializer<T,N,Owner>( ^ /home/nbecker/.local/include/ndarray/initialization.h:239:54: error: expected ')' before 'order' computeStrides(shape.template cast() order), ^~~~~

On Mon, Jun 27, 2016 at 11:43 AM, Jim Bosch notifications@github.com wrote:

Please try branch explicit_vector_casts (of ndarray, not Boost.NumPy).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ndarray/Boost.NumPy/issues/66#issuecomment-228785558, or mute the thread https://github.com/notifications/unsubscribe/AAHK0FLhKx44F8i__pgD8S540lNb7Gmgks5qP--0gaJpZM4I_OEM .

Those who don't understand recursion are doomed to repeat it

TallJimbo commented 8 years ago

Sorry, there was a typo that I corrected fast enough that I hoped you wouldn't notice, but I was wrong. Please do git pull --rebase on the branch and try again.

nbecker commented 8 years ago

In file included from test1.cc:6:0: /home/nbecker/.local/include/ndarray/initialization.h: In function 'ndarray::detail::ExternalInitializer<T, N, Owner> ndarray::external(T, const ndarray::Vector<U, N>&, ndarray::DataOrderEnum, const Owner&)': /home/nbecker/.local/include/ndarray/initialization.h:236:50: error: expected primary-expression before '(' token return detail::ExternalInitializer<T,N,Owner>( ^ /home/nbecker/.local/include/ndarray/initialization.h:239:54: error: expected ')' before 'order' computeStrides(shape.template cast() order), ^~~~~ scons: ** [test1.cpython-35m-x86_64-linux-gnu.os] Error 1

On Mon, Jun 27, 2016 at 11:51 AM, Jim Bosch notifications@github.com wrote:

Sorry, there was a typo that I corrected fast enough that I hoped you wouldn't notice, but I was wrong. Please do git pull --rebase on the branch and try again.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ndarray/Boost.NumPy/issues/66#issuecomment-228788016, or mute the thread https://github.com/notifications/unsubscribe/AAHK0PGSS6mwqB746ofDUuJefUIfW_J4ks5qP_GdgaJpZM4I_OEM .

Those who don't understand recursion are doomed to repeat it

TallJimbo commented 8 years ago

Yeah, just saw that one too. I think I've got it fixed now git pull --rebase again, please.

nbecker commented 8 years ago

still not fixed:

template nd::Array<flt_t,2,2> bit_llr_to_sym_ll (nd::Array<flt_t,1,1> intrlv_soft, nd::Array<int,2,2> llr_mask) { int BITS_PER_SYM = llr_mask.getShape()[1]; int n_syms = llr_mask.getShape()[0]; int syms_per_burst = intrlv_soft.getShape()[0]/BITS_PER_SYM; auto shape = nd::makeVector (syms_per_burst, BITS_PER_SYM); // auto strides = nd::makeVector (BITS_PER_SYM, 1); // auto w = nd::Array<flt_t,2,2> (nd::external (intrlv_soft.getData(), shape, strides, intrlv_soft.getManager())); auto w = nd::Array<flt_t,2,2> (nd::external (intrlv_soft.getData(), shape, nd::ROW_MAJOR, intrlv_soft.getManager())) ...

In file included from llr.cc:5:0: /home/nbecker/.local/include/ndarray/Array.h:180:5: note: candidate: ndarray::Array<T, N, C>::Array(T, const CorePtr&) [with T = double; int N = 2; int C = 2; ndarray::Array<T, N, C>::CorePtr = boost::intrusive_ptr<const ndarray::detail::Core<2> >] Array(T \ data, CorePtr const & core) : Super(data, core) {} ^~~~~ /home/nbecker/.local/include/ndarray/Array.h:180:5: note: candidate expects 2 arguments, 1 provided In file included from /home/nbecker/.local/include/ndarray.h:21:0, from /home/nbecker/.local/include/ndarray/bp/Array.h:15, from /home/nbecker/.local/include/ndarray/bp/auto/Array.h:16, from /home/nbecker/.local/include/ndarray/bp/auto.h:14, from llr.cc:6: /home/nbecker/.local/include/ndarray/initialization.h:273:1: note: candidate: ndarray::Array<T, N, C>::Array(ndarray::Size, ndarray::Size, ndarray::Size, ndarray::Size, ndarray::Size, ndarray::Size, ndarray::Size, ndarray::Size) [with T = double; int N = 2; int C = 2; ndarray::Size = long unsigned int] Array<T,N,C>::Array(Size n1, Size n2, Size n3, Size n4, Size n5, Size n6, Size n7, Size n8) ^~~~ /home/nbecker/.local/include/ndarray/initialization.h:273:1: note: no known conversion for argument 1 from 'ndarray::ArrayBase<ndarray::Array<double, 2, 2> >::Index {aka ndarray::Vector<long unsigned int, 2>}' to 'ndarray::Size {aka long unsigned int}' [... lots more, but I think this is the 1 that matters]

This is gcc-6.1.1 (fedora 24)

On Mon, Jun 27, 2016 at 11:59 AM, Jim Bosch notifications@github.com wrote:

Yeah, just saw that one too. I think I've got it fixed now git pull --rebase again, please.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ndarray/Boost.NumPy/issues/66#issuecomment-228790464, or mute the thread https://github.com/notifications/unsubscribe/AAHK0Huo7DA6sWRetnzHG8MKZ7MAsb0nks5qP_N5gaJpZM4I_OEM .

Those who don't understand recursion are doomed to repeat it

nbecker commented 8 years ago

Maybe this is the problem: /home/nbecker/.local/include/ndarray/initialization.h: In instantiation of 'ndarray::detail::ExternalInitializer<T, N, Owner> ndarray::external(T_, const ndarray::Vector<U, N>&, ndarray::DataOrderEnum, const Owner&) [with T = double; int N = 2; U = int; Owner = boost::intrusive_ptrndarray::Manager]': llr.cc:31:47: required from 'ndarray::Array<flt_t, 2, 2> bit_llr_to_sym_ll(ndarray::Array<flt_t, 1, 1>, ndarray::Array<int, 2, 2>) [with flt_t = double]' llr.cc:77:11: required from 'void export_bit_llr_to_symll(const char) [with flt_t = double]' llr.cc:82:56: required from here /home/nbecker/.local/include/ndarray/initialization.h:239:23: error: no matching function for call to 'computeStrides(ndarray::Vector<long int, 2>, ndarray::DataOrderEnum&)' computeStrides(shape.template cast(), order),


In file included from /home/nbecker/.local/include/ndarray.h:21:0,
                 from /home/nbecker/.local/include/ndarray/bp/Array.h:15,
                 from
/home/nbecker/.local/include/ndarray/bp/auto/Array.h:16,
                 from /home/nbecker/.local/include/ndarray/bp/auto.h:14,
                 from llr.cc:6:
/home/nbecker/.local/include/ndarray/initialization.h:152:18: note:
candidate: template<int N> ndarray::Vector<long int, M>
ndarray::computeStrides(const ndarray::Vector<long unsigned int, M>&,
ndarray::DataOrderEnum)
 Vector<Offset,N> computeStrides(Vector<Size,N> const & shape,
DataOrderEnum order=ROW_MAJOR) {
                  ^~~~~~~~~~~~~~
/home/nbecker/.local/include/ndarray/initialization.h:152:18: note:
template argument deduction/substitution failed:
In file included from /home/nbecker/.local/include/ndarray.h:21:0,
                 from /home/nbecker/.local/include/ndarray/bp/Array.h:15,
                 from
/home/nbecker/.local/include/ndarray/bp/auto/Array.h:16,
                 from /home/nbecker/.local/include/ndarray/bp/auto.h:14,
                 from llr.cc:6:
/home/nbecker/.local/include/ndarray/initialization.h:239:23: note:
mismatched types 'long unsigned int' and 'long int'

On Mon, Jun 27, 2016 at 1:16 PM, Neal Becker ndbecker2@gmail.com wrote:

> still not fixed:
> 
> template<typename flt_t>
> nd::Array<flt_t,2,2> bit_llr_to_sym_ll (nd::Array<flt_t,1,1> intrlv_soft,
> nd::Array<int,2,2> llr_mask) {
>   int BITS_PER_SYM = llr_mask.getShape()[1];
>   int n_syms = llr_mask.getShape()[0];
>   int syms_per_burst = intrlv_soft.getShape()[0]/BITS_PER_SYM;
>   auto shape = nd::makeVector (syms_per_burst, BITS_PER_SYM);
>   //  auto strides = nd::makeVector (BITS_PER_SYM, 1);
>   //  auto w = nd::Array<flt_t,2,2> (nd::external (intrlv_soft.getData(),
> shape, strides, intrlv_soft.getManager()));
>   auto w = nd::Array<flt_t,2,2> (nd::external (intrlv_soft.getData(),
> shape, nd::ROW_MAJOR, intrlv_soft.getManager()))
> ...
> 
> In file included from llr.cc:5:0:
> /home/nbecker/.local/include/ndarray/Array.h:180:5: note: candidate:
> ndarray::Array<T, N, C>::Array(T*, const CorePtr&) [with T = double; int N
> = 2; int C = 2; ndarray::Array<T, N, C>::CorePtr =
> boost::intrusive_ptr<const ndarray::detail::Core<2> >]
>      Array(T \* data, CorePtr const & core) : Super(data, core) {}
>      ^~~~~
> /home/nbecker/.local/include/ndarray/Array.h:180:5: note:   candidate
> expects 2 arguments, 1 provided
> In file included from /home/nbecker/.local/include/ndarray.h:21:0,
>                  from /home/nbecker/.local/include/ndarray/bp/Array.h:15,
>                  from
> /home/nbecker/.local/include/ndarray/bp/auto/Array.h:16,
>                  from /home/nbecker/.local/include/ndarray/bp/auto.h:14,
>                  from llr.cc:6:
> /home/nbecker/.local/include/ndarray/initialization.h:273:1: note:
> candidate: ndarray::Array<T, N, C>::Array(ndarray::Size, ndarray::Size,
> ndarray::Size, ndarray::Size, ndarray::Size, ndarray::Size, ndarray::Size,
> ndarray::Size) [with T = double; int N = 2; int C = 2; ndarray::Size = long
> unsigned int]
>  Array<T,N,C>::Array(Size n1, Size n2, Size n3, Size n4, Size n5, Size n6,
> Size n7, Size n8)
>  ^~~~~~~~~~~~
> /home/nbecker/.local/include/ndarray/initialization.h:273:1: note:   no
> known conversion for argument 1 from
> 'ndarray::ArrayBase<ndarray::Array<double, 2, 2> >::Index {aka
> ndarray::Vector<long unsigned int, 2>}' to 'ndarray::Size {aka long
> unsigned int}'
> [... lots more, but I think this is the 1 that matters]
> 
> This is gcc-6.1.1 (fedora 24)
> 
> On Mon, Jun 27, 2016 at 11:59 AM, Jim Bosch notifications@github.com
> wrote:
> 
> > Yeah, just saw that one too. I think I've got it fixed now git pull
> > --rebase again, please.
> > 
> > —
> > You are receiving this because you authored the thread.
> > Reply to this email directly, view it on GitHub
> > https://github.com/ndarray/Boost.NumPy/issues/66#issuecomment-228790464,
> > or mute the thread
> > https://github.com/notifications/unsubscribe/AAHK0Huo7DA6sWRetnzHG8MKZ7MAsb0nks5qP_N5gaJpZM4I_OEM
> > .
> 
> ## 
> 
> _Those who don't understand recursion are doomed to repeat it_

## 

_Those who don't understand recursion are doomed to repeat it_
TallJimbo commented 8 years ago

We're getting close. Another commit is ready for you to try.

nbecker commented 8 years ago

kindof works, but there's another issue:

auto w = nd::Array<flt_t,2,2> (nd::external (intrlv_soft.getData(), shape, nd::ROW_MAJOR, intrlv_soft.getManager())); nd::Array<flt_t,2,2> ll0 (w.getShape()[0], w.getShape()[1]); nd::Array<flt_t,2,2> ll1 (w.getShape()[0], w.getShape()[1]);

I used to be able to write: nd::Array<flt_t,2,2> ll0 (w.getShape());

but now I had to be explicit (see above)

I think we really do want that to work to make things more generic.

Error was: llr.cc:33:41: error: no matching function for call to 'ndarray::Array<float, 2, 2>::Array(ndarray::ArrayBase<ndarray::Array<float, 2, 2> >::Index)' nd::Array<flt_t,2,2> ll1 (w.getShape());

On Mon, Jun 27, 2016 at 1:58 PM, Jim Bosch notifications@github.com wrote:

We're getting close. Another commit is ready for you to try.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ndarray/Boost.NumPy/issues/66#issuecomment-228824110, or mute the thread https://github.com/notifications/unsubscribe/AAHK0N9p4ysGYERWO4d7VLB7Q8iC7-ggks5qQA89gaJpZM4I_OEM .

Those who don't understand recursion are doomed to repeat it

TallJimbo commented 8 years ago

I don't seen any sign that this was removed recently, and moreover I don't see any sign it was ever present. Do you have a commit at which it worked?

Anyhow,I have no object to adding th is. I am actually a bit surprised that it doesn't already.

nbecker commented 8 years ago

There doesn't seem to be a constructor accepting getShape(), but allocate will work:

nd::Array<flt_t,2,2> ll0 = nd::allocate (w.getShape());

On Mon, Jun 27, 2016 at 2:11 PM, Jim Bosch notifications@github.com wrote:

I don't seen any sign that this was removed recently, and moreover I don't see any sign it was ever present. Do you have a commit at which it worked?

Anyhow,I have no object to adding th is. I am actually a bit surprised that it doesn't already.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ndarray/Boost.NumPy/issues/66#issuecomment-228827853, or mute the thread https://github.com/notifications/unsubscribe/AAHK0BINq8_NVg7rgGvJj4LGpBSJUnmwks5qQBI0gaJpZM4I_OEM .

Those who don't understand recursion are doomed to repeat it

nbecker commented 8 years ago

I think you can make this work by adding to initialization.hpp: template<typename T, int N, int C> template Array<T,N,C>::Array(Vector<U,N> const & shape) : Super (0, CorePtr()) { this->operator=(ndarray::allocate(shape)); }

And to Array.h: template explicit Array(Vector<U,N> const& shape);

On Mon, Jun 27, 2016 at 2:20 PM, Neal Becker ndbecker2@gmail.com wrote:

There doesn't seem to be a constructor accepting getShape(), but allocate will work:

nd::Array<flt_t,2,2> ll0 = nd::allocate (w.getShape());

On Mon, Jun 27, 2016 at 2:11 PM, Jim Bosch notifications@github.com wrote:

I don't seen any sign that this was removed recently, and moreover I don't see any sign it was ever present. Do you have a commit at which it worked?

Anyhow,I have no object to adding th is. I am actually a bit surprised that it doesn't already.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ndarray/Boost.NumPy/issues/66#issuecomment-228827853, or mute the thread https://github.com/notifications/unsubscribe/AAHK0BINq8_NVg7rgGvJj4LGpBSJUnmwks5qQBI0gaJpZM4I_OEM .

Those who don't understand recursion are doomed to repeat it

Those who don't understand recursion are doomed to repeat it

TallJimbo commented 8 years ago

I am working exactly that. I haven't been able to get it working, but I suspect it's because of another stupid typo somewhere.

TallJimbo commented 8 years ago

Ok, got it; feature is on the same branch as the previous fixes.

nbecker commented 8 years ago

Perfect! All my library of software compiles fine.

I made 1 mistake - nd::Array (Vector const&) probably never worked - I had previously used nd::allocate for this. But I think it's a good addition.

On Mon, Jun 27, 2016 at 2:44 PM, Jim Bosch notifications@github.com wrote:

Ok, got it; feature is on the same branch as the previous fixes.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ndarray/Boost.NumPy/issues/66#issuecomment-228837506, or mute the thread https://github.com/notifications/unsubscribe/AAHK0E7_YoopApc_YiuSWesHUX5FKkcHks5qQBn9gaJpZM4I_OEM .

Those who don't understand recursion are doomed to repeat it

TallJimbo commented 8 years ago

Merged to master.