Thanks! I was not aware of the padding vs. replicating behavior, but I guess it is due to the possibility of pdl accepting non-ndarray arguments.
Regards, Luis On Thu, Aug 21, 2025 at 11:36:29AM +0000, Jörg Sommrey wrote: > The "pdl" constructor does not replicate values to match dimensions but pads > them instead. In contrary, "cat" works as expected: > > pdl> do_print 1 > 1 > > pdl> $v = sequence 2 > [0 1] > > pdl> cat $v(,*1), $v(*1,) > > [ > [ > [0 1] > [0 1] > ] > [ > [0 0] > [1 1] > ] > ] > > Best regards, > -jo > > On Tue 19 Aug 2025 07:09:32 PM CEST, Luis Mochan <moc...@icf.unam.mx> wrote: > > > I'm confused by variations of the following program: > > use v5.36; > > use PDL; > > use PDL::NiceSlice; > > my $v=sequence(2); > > my $m=pdl($v->slice(":,*2"), $v->slice("*2,:")); > > say $m; > > > > The output is > > > > [ > > [ > > [0 1] > > [0 1] > > ] > > [ > > [0 0] > > [1 1] > > ] > > ] > > > > which is what I expected. But after a small change: > > > > use v5.36; > > use PDL; > > use PDL::NiceSlice; > > my $v=sequence(2); > > my $m=pdl($v->slice(":,*"), $v->slice("*,:")); > > say $m; > > > > the output becomes > > > > > > [ > > [ > > [0 1] > > [0 0] > > ] > > [ > > [0 0] > > [1 0] > > ] > > ] > > > > The same if I replace * by *1. Was I wrong to expect the same output? > > I expected the dummy dimension of size 1 (or unspecified size) would > > lead to the initial array [0 1] being replicated as many times as > > required by the actual dimensions of the other arrays. > > > > Best regards, > > Luis > > > -- o W. Luis Mochán, | tel:(52)(777)329-1734 /<(*) Instituto de Ciencias Físicas, UNAM | fax:(52)(777)317-5388 `>/ /\ Av. Universidad s/n CP 62210 | (*)/\/ \ Cuernavaca, Morelos, México | moc...@fis.unam.mx /\_/\__/ GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16 C2DF 5F0A C52B 791E B9EB _______________________________________________ pdl-general mailing list pdl-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-general