Greetings, all.
I am not very familiar with PDL::Bad, but it looks like the badflag isn't
flowing on elemental assignment. From the docs, "assgn does not process
bad values. It will set the bad-value flag of all output piddles if the
flag is set for any of the input piddles."
use PDL;
print 'Bad status = ', $PDL::Bad::Status, "\n"; # 'Bad status = 1'
print 'Using badval = ', double->badvalue, "\n"; # Using badval =
-1.79769313486232e+308
$a = sequence(double,10);
$b = zeroes(double,10,2);
my $mask = $a >= 6;
$b->slice(':,(1)') .= $a->setbadif($mask);
print $b, "\n", 'badflag = ', $b->badflag();
#OUTPUT
#*******************************************************************************************************************************************************
#[
# [ 0 0 0
0 0 0 0
0 0 0]
# [ 0 1 2
3 4 5 -1.7976931e+308 -1.7976931e+308
-1.7976931e+308 -1.7976931e+308]
#]
#
# badflag = 0
A quick inspection of PDL/Basic/Ops/ops.pd shows
# note: the extra code that adding 'HandleBad => 1' creates is
# unneeded here. Things could be made clever enough to work this out,
# but it's very low priority.
# It does add doc information though, and lets people know it's been
# looked at for bad value support
# DJB adds: not completely sure about this now that I have added code
# to avoid a valgrind-reported error (see the CacheBadFlagInit rule
# in PP.pm)
#
# Can't this be handled in Core.pm when '.=' is overloaded ?
#
pp_def(
'assgn',
# HandleBad => 1,
Pars => 'a(); [o]b();',
Code =>
'$b() = $a();',
# BadCode =>
# 'if ( $ISBAD(a()) ) { $SETBAD(b()); } else { $b() = $a(); }',
Doc =>
'Plain numerical assignment. This is used to implement the ".=" operator',
); # pp_def assgn
However, PDL/Basic/Core/Core.pm.PL has
".=" => sub {
my @args = reverse &PDL::Core::rswap;
PDL::Ops::assgn(@args);
return $args[1];
},
Should we add a CopyBadStatus entry to assgn?
Many thanks.
- Tim
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl