Menu

#424 Calling PDL on a list of piddles fails to propogate bad values

normal
closed
None
5
2016-10-08
2016-06-10
No

Below is a documented test script which I hope explains the situation. If I have multiple piddles that I concatenate with pdl($thing1, $thing2), and those things have bad values, the result will copy the value representing bad values, but will not copy the bad flag. This is not a problem with cat($thing1, $thing2).

I originally encountered this problem on a Linux machine running PDL v2.007 (from Ubuntu repositories), but could reproduce the problem on a Mac running v2.016. I will attach perldl -V for both systems.

use strict;
use warnings;
use PDL;
use Test::More;

# First create a piddle with bad data:
my $foo = pdl(1, 2, 3, 1);
$foo = $foo->setvaltobad(1);
ok($foo->badflag, 'Able to create piddle with bad flag')
    or diag "foo is $foo, expected [BAD 2 3 BAD]";
is($foo->nbad, 2, 'We have a bad values')
    or diag "foo is $foo, expected [BAD 2 3 BAD]";

# Use pdl($foo) to copy it:
my $bar = pdl($foo);
ok($bar->badflag, 'pdl($bad_thing) copies bad flag')
    or diag "bar is $bar, expected [BAD 2 3 BAD]";
is($bar->nbad, 2, 'pdl($bad_thing) copies bad values')
    or diag "bar is $bar, expected [BAD 2 3 BAD]";

# Create a combined piddle with cat()
my $quux = cat($foo, $bar);
ok($quux->badflag, 'cat($bad_thing, $bad_thing) copies bad flag')
    or diag "quux is ${quux}expected\n[\n [BAD 2 3 BAD]\n [BAD 2 3 BAD]\n]";
is($quux->nbad, 4, 'cat($bad_thing, $bad_thing) copies bad values')
    or diag "quux is ${quux}expected\n[\n [BAD 2 3 BAD]\n [BAD 2 3 BAD]\n]";

# Create a combined piddle with pdl()
my $baz = pdl($foo, $bar);
ok($baz->badflag, 'pdl($bad_thing, $bad_thing) copies bad flag')
    or diag "baz is ${baz}expected\n[\n [BAD 2 3 BAD]\n [BAD 2 3 BAD]\n]";
is($baz->nbad, 4, 'pdl($bad_thing, $bad_thing) copies bad values')
    or diag "baz is ${baz}expected\n[\n [BAD 2 3 BAD]\n [BAD 2 3 BAD]\n]";

done_testing;
1 Attachments

Related

Bugs: #424

Discussion

  • David Mertens

    David Mertens - 2016-06-10

    Here's the perldl -V for the Mac

     
  • David Mertens

    David Mertens - 2016-06-10

    In case it isn't clear, the problem is that the first six tests pass, but the last two do not. :-)

     
  • Derek Lamb

    Derek Lamb - 2016-06-10

    Possibly related to #308 (https://sourceforge.net/p/pdl/bugs/308/), especially if pdl( $pdla, $pdlb) works by creating the destination piddle and .= the source piddles into it.

     
    • Chris Marshall

      Chris Marshall - 2016-06-10

      See the previous bug/feature request:

      #308 propagate badflag with .=
      https://sourceforge.net/p/pdl/bugs/308/

      On Fri, Jun 10, 2016 at 12:38 PM, Derek Lamb lambd@users.sf.net wrote:

      Possibly related to #308 (https://sourceforge.net/p/pdl/bugs/308/),
      especially if pdl( $pdla, $pdlb) works by creating the destination piddle
      and .= the source piddles into it.


      Status: open
      Group: normal
      Created: Fri Jun 10, 2016 01:58 PM UTC by David Mertens
      Last Updated: Fri Jun 10, 2016 02:00 PM UTC
      Owner: David Mertens
      Attachments:

      Below is a documented test script which I hope explains the situation. If
      I have multiple piddles that I concatenate with pdl($thing1, $thing2), and
      those things have bad values, the result will copy the value representing
      bad values, but will not copy the bad flag. This is not a problem with
      cat($thing1, $thing2).

      I originally encountered this problem on a Linux machine running PDL
      v2.007 (from Ubuntu repositories), but could reproduce the problem on a Mac
      running v2.016. I will attach perldl -V for both systems.

      use strict;use warnings;use PDL;use Test::More;

      First create a piddle with bad data:my $foo = pdl(1, 2, 3, 1);$foo = $foo->setvaltobad(1);ok($foo->badflag, 'Able to create piddle with bad flag')

      or diag "foo is $foo, expected [BAD 2 3 BAD]";is($foo->nbad, 2, 'We have a bad values')
      or diag "foo is $foo, expected [BAD 2 3 BAD]";
      

      Use pdl($foo) to copy it:my $bar = pdl($foo);ok($bar->badflag, 'pdl($bad_thing) copies bad flag')

      or diag "bar is $bar, expected [BAD 2 3 BAD]";is($bar->nbad, 2, 'pdl($bad_thing) copies bad values')
      or diag "bar is $bar, expected [BAD 2 3 BAD]";
      

      Create a combined piddle with cat()my $quux = cat($foo, $bar);ok($quux->badflag, 'cat($bad_thing, $bad_thing) copies bad flag')

      or diag "quux is ${quux}expected\n[\n [BAD 2 3 BAD]\n [BAD 2 3 BAD]\n]";is($quux->nbad, 4, 'cat($bad_thing, $bad_thing) copies bad values')
      or diag "quux is ${quux}expected\n[\n [BAD 2 3 BAD]\n [BAD 2 3 BAD]\n]";
      

      Create a combined piddle with pdl()my $baz = pdl($foo, $bar);ok($baz->badflag, 'pdl($bad_thing, $bad_thing) copies bad flag')

      or diag "baz is ${baz}expected\n[\n [BAD 2 3 BAD]\n [BAD 2 3 BAD]\n]";is($baz->nbad, 4, 'pdl($bad_thing, $bad_thing) copies bad values')
      or diag "baz is ${baz}expected\n[\n [BAD 2 3 BAD]\n [BAD 2 3 BAD]\n]";
      

      done_testing;


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/pdl/bugs/424/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #424

  • Derek Lamb

    Derek Lamb - 2016-08-04
    • status: open --> pending-fixed
     
  • Derek Lamb

    Derek Lamb - 2016-08-04

    works for me on current master -- thanks Craig & Zaki!

     
  • Chris Marshall

    Chris Marshall - 2016-10-08
    • status: pending-fixed --> closed
     

Log in to post a comment.