#296 PDL::IO::Misc : rcols problem

closed-fixed
other (94)
5
2012-02-14
2012-02-14
bperret
No

When I run this small script

----------
#!/usr/bin/perl -w

use PDL;
use PDL::IO::Misc;

use strict;

my $f = 'ascii.txt';

my $x = sequence(5);
my $y = $x*$x;

wcols($x, $y, $f);

my $z = rcols($f, {}, []);

print $z, "\n";
----------

, the result is as expected

----------
[
[ 0 0]
[ 1 1]
[ 2 4]
[ 3 9]
[ 4 16]
]
----------

, but I also have this message

----------
Use of reference "ARRAY(0xa1b9aa0)" as array index at /usr/lib/perl5/site_perl/5.10.1/i386-linux-thread-multi/PDL/IO/Misc.pm line 595, <GEN1> line 1.
----------

I suggest to modify Misc.pm that way :

----------
CURRENT CODE
# strip out perl cols in explicit col list for return at end
@end_perl_cols = @perl_cols;
foreach my $col (@explicit_cols) {
if ( defined($is_perl_col[$col]) ) {
@end_perl_cols = grep { $_ != $col } @end_perl_cols;
}
};
----------

----------
NEW CODE
# strip out perl cols in explicit col list for return at end
@end_perl_cols = @perl_cols;
foreach my $col (@explicit_cols) {
if ( ref($col) ne "ARRAY" and defined($is_perl_col[$col]) ) {
@end_perl_cols = grep { $_ != $col } @end_perl_cols;
}
};
----------

Discussion

  • bperret
    bperret
    2012-02-14

    perldl -V

     
    Attachments
  • David Mertens
    David Mertens
    2012-02-14

    bperret, what version of PDL are you using? Can you please attach (as an attachment) the output of "pdl -V" and "perl -V' to this ticket?

    Thanks!

     
  • Chris Marshall
    Chris Marshall
    2012-02-14

    • assigned_to: nobody --> marshallch
    • labels: --> 101697
    • status: open --> closed-fixed
     
  • Chris Marshall
    Chris Marshall
    2012-02-14

    Bug fixed in Git.
    Thanks for reporting the problem!

     
  • David Mertens
    David Mertens
    2012-02-14

    bperret, never mind. Chris fixed it already. :-)

     
  • David Mertens
    David Mertens
    2012-02-14

    • labels: 101697 -->
    • assigned_to: marshallch --> nobody
    • status: closed-fixed --> open
     
  • Chris Marshall
    Chris Marshall
    2012-02-14

    Reclosing this ticket since things got confused by simultaneous updates
    by both Dave and me.

     
  • Chris Marshall
    Chris Marshall
    2012-02-14

    • assigned_to: nobody --> marshallch
    • labels: --> other
    • status: open --> closed-fixed