PDLPorters/pdl

whereND drops all dimensions when mask is all zeroes

falsifian opened this issue · 1 comments

One of these is not like the others:

pdl> p zeroes( 2, 3, 1 )->whereND( pdl '1 1' )->shape
[2 3 1]
pdl> p zeroes( 2, 3, 1 )->whereND( pdl '1 0' )->shape
[1 3 1]
pdl> p zeroes( 2, 3, 1 )->whereND( pdl '0 1' )->shape
[1 3 1]
pdl> p zeroes( 2, 3, 1 )->whereND( pdl '0 0' )->shape
[0]

I would expect the last output to be [0 3 1].

This is PDL 2.081 on OpenBSD current on amd64.

Here's another behaviour that seems like a bug:

pdl> p zeroes( 2, 1 )->whereND( pdl '1 1' )

[
 [0 0]
]

pdl> p zeroes( 2, 0 )->whereND( pdl '1 1' )
Stringizing problem: Error in splitdim:nsp 2 cannot be greater than dim 0.     eval {...} called at /home/falsifian/perl5/lib/perl5/amd64-openbsd/PDL/Core.pm line 2849
        PDL::string(PDL=SCALAR(0x15b28c54b20), undef, "") called at /home/falsifian/perl5/bin/perldl line 409
        main::p(PDL=SCALAR(0x15b28c54b20)) called at (eval 343) line 4
        main::__ANON__() called at /home/falsifian/perl5/bin/perldl line 682
        eval {...} called at /home/falsifian/perl5/bin/perldl line 682
        main::eval_and_report("p zeroes( 2, 0 )->whereND( pdl '1 1' )\x{a}") called at /home/falsifian/perl5/bin/perldl line 618
        main::process_input() called at /home/falsifian/perl5/bin/perldl line 638
        eval {...} called at /home/falsifian/perl5/bin/perldl line 638
 at /home/falsifian/perl5/lib/perl5/amd64-openbsd/PDL/Core.pm line 2880, <STDIN> line 50.
        PDL::string(PDL=SCALAR(0x15b28c54b20), undef, "") called at /home/falsifian/perl5/bin/perldl line 409
        main::p(PDL=SCALAR(0x15b28c54b20)) called at (eval 343) line 4
        main::__ANON__() called at /home/falsifian/perl5/bin/perldl line 682
        eval {...} called at /home/falsifian/perl5/bin/perldl line 682
        main::eval_and_report("p zeroes( 2, 0 )->whereND( pdl '1 1' )\x{a}") called at /home/falsifian/perl5/bin/perldl line 618
        main::process_input() called at /home/falsifian/perl5/bin/perldl line 638
        eval {...} called at /home/falsifian/perl5/bin/perldl line 638

I would expect the second output to be an empty ndarray with shape [0 0] EDIT: [2 0].