Hmmm.   Looks like you’ve discovered a wart.  Indexing pdl(1,2) with an Empty 
does the right thing and returns Empty.  But indexing a scalar or a 1-D PDL 
with one element fails.  I think it’s because Empties are implemented under the 
hood as 1x0 PDLs (to distinguish them from Nulls, which have 0 in the first 
position).  



> On Jan 11, 2018, at 8:52 PM, Trevor Carey-Smith 
> <[email protected]> wrote:
> 
> Hi,
> 
> Sorry I've been out of the PDL loop for a long time, but have an old script 
> written in PDL that I use a lot. After a recent IT upgrade here we have 
> shifted to PDL v2.018 and I'm getting some behaviour that is new from our 
> previous install (2.4 in the old numbering system???).
> 
> The script uses some which() statements to create indexing vectors to slice 
> the original pdl. Normally when the which statement comes back empty, the 
> slice command returns an empty pdl itself. But if the slicing dimension 
> (regardless of the total number of dimensions) of the original pdl is of 
> length 1 bad things happen. Perhaps an example is clearer:
> 
> pdl> p $empty=pdl([])
> Empty[0]
> pdl> p $d2=pdl([1,2])
> [1 2]
> pdl> p $d2($empty)
> Empty[0]
> pdl> p $d1=pdl([1])
> [1]
> pdl> p $d1($empty)
> Stringizing problem: slice: slice starts out of bounds in pos 0 (start is 1; 
> source dim 0 runs 0 to 0).       eval {...} called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/lib/perl5/site_perl/5.24.1/x86_64-linux-thread-multi/PDL/Core.pm
>  line 2857
>       PDL::string(PDL=SCALAR(0x1053d10), undef, "") called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 402
>       main::p(PDL=SCALAR(0x1053d10)) called at (eval 151) line 4
>       main::__ANON__() called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 719
>       eval {...} called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 719
>       main::eval_and_report("p \$d1->slice(\$empty)\x{a}") called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 655
>       main::process_input() called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 675
>       eval {...} called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 675
> at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/lib/perl5/site_perl/5.24.1/x86_64-linux-thread-multi/PDL/Core.pm
>  line 2888, <STDIN> line 92.
>       PDL::string(PDL=SCALAR(0x1053d10), undef, "") called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 402
>       main::p(PDL=SCALAR(0x1053d10)) called at (eval 151) line 4
>       main::__ANON__() called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 719
>       eval {...} called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 719
>       main::eval_and_report("p \$d1->slice(\$empty)\x{a}") called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 655
>       main::process_input() called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 675
>       eval {...} called at 
> /scale_akl_persistent/filesets/opt_niwa/centos7-x86_64-skl_prelim/GCC-4.8.5/Perl/5.24.1-GCC-4.8.5/bin/perldl
>  line 675
> 
> Can anyone shed any light on what's going on here??
> 
> Thanks,
> Trevor.
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> pdl-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pdl-general
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to