"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "GENERATED/PDL/Bad.pm" between
PDL-2.082.tar.gz and PDL-2.083.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

Bad.pm  (PDL-2.082):Bad.pm  (PDL-2.083)
skipping to change at line 26 skipping to change at line 26
#line 19 "bad.pd" #line 19 "bad.pd"
=head1 NAME =head1 NAME
PDL::Bad - PDL always processes bad values PDL::Bad - PDL always processes bad values
=head1 DESCRIPTION =head1 DESCRIPTION
This module is loaded when you do C<use PDL>, This module is loaded when you do C<use PDL>,
C<Use PDL::Lite> or C<PDL::LiteF>. C<use PDL::Lite> or C<use PDL::LiteF>.
Implementation details are given in Implementation details are given in
L<PDL::BadValues>. L<PDL::BadValues>.
=head1 SYNOPSIS =head1 SYNOPSIS
use PDL::Bad; use PDL::Bad;
print "\nBad value per PDL support in PDL is turned " . print "\nBad value per PDL support in PDL is turned " .
$PDL::Bad::PerPdl ? "on" : "off" . ".\n"; $PDL::Bad::PerPdl ? "on" : "off" . ".\n";
skipping to change at line 77 skipping to change at line 77
$PDL::Bad::UseNaN = 0; $PDL::Bad::UseNaN = 0;
$PDL::Bad::PerPdl = 1; $PDL::Bad::PerPdl = 1;
use strict; use strict;
use PDL::Types; use PDL::Types;
use PDL::Primitive; use PDL::Primitive;
############################################################ ############################################################
############################################################ ############################################################
#line 95 "Bad.pm"
#line 98 "bad.pd"
#line 79 "bad.pd"
############################################################ ############################################################
############################################################ ############################################################
*badflag = \&PDL::badflag; *badflag = \&PDL::badflag;
*badvalue = \&PDL::badvalue; *badvalue = \&PDL::badvalue;
*orig_badvalue = \&PDL::orig_badvalue; *orig_badvalue = \&PDL::orig_badvalue;
############################################################ ############################################################
############################################################ ############################################################
skipping to change at line 214 skipping to change at line 212
=cut =cut
*check_badflag = \&PDL::check_badflag; *check_badflag = \&PDL::check_badflag;
sub PDL::check_badflag { sub PDL::check_badflag {
my $pdl = shift; my $pdl = shift;
$pdl->badflag(0) if $pdl->badflag and $pdl->nbad == 0; $pdl->badflag(0) if $pdl->badflag and $pdl->nbad == 0;
return $pdl->badflag; return $pdl->badflag;
} # sub: check_badflag() } # sub: check_badflag()
#line 234 "Bad.pm"
#line 309 "bad.pd"
#line 288 "bad.pd"
# note: # note:
# if sent an ndarray, we have to change its bad values # if sent an ndarray, we have to change its bad values
# (but only if it contains bad values) # (but only if it contains bad values)
# - there's a slight overhead in that the badflag is # - there's a slight overhead in that the badflag is
# cleared and then set (hence propagating to all # cleared and then set (hence propagating to all
# children) but we'll ignore that) # children) but we'll ignore that)
# - we can ignore this for float/double types # - we can ignore this for float/double types
# since we can't change the bad value # since we can't change the bad value
# #
sub PDL::badvalue { sub PDL::badvalue {
no strict 'refs'; no strict 'refs';
my ( $self, $val ) = @_; my ( $self, $val ) = @_;
my $num; my $num;
if ( UNIVERSAL::isa($self,"PDL") ) { if ( UNIVERSAL::isa($self,"PDL") ) {
$num = $self->get_datatype; $num = $self->get_datatype;
if ( $num < $PDL_F && defined($val) && $self->badflag ) { if ( $num < $PDL_F && defined($val) && $self->badflag ) {
$self->inplace->setbadtoval( $val ); $self->inplace->setbadtoval( $val );
$self->badflag(1); $self->badflag(1);
} }
return PDL::_badvalue_per_pdl_int($self, $val, $num); return PDL::Bad::_badvalue_per_pdl_int($self, $val, $num);
} elsif ( UNIVERSAL::isa($self,"PDL::Type") ) { } elsif ( UNIVERSAL::isa($self,"PDL::Type") ) {
$num = $self->enum; $num = $self->enum;
} else { } else {
# assume it's a number # assume it's a number
$num = $self; $num = $self;
} }
PDL::_badvalue_int( $val, $num ); PDL::Bad::_badvalue_int( $val, $num );
} }
sub PDL::orig_badvalue { sub PDL::orig_badvalue {
no strict 'refs'; no strict 'refs';
my $self = shift; my $self = shift;
my $num; my $num;
if ( UNIVERSAL::isa($self,"PDL") ) { if ( UNIVERSAL::isa($self,"PDL") ) {
$num = $self->get_datatype; $num = $self->get_datatype;
} elsif ( UNIVERSAL::isa($self,"PDL::Type") ) { } elsif ( UNIVERSAL::isa($self,"PDL::Type") ) {
$num = $self->enum; $num = $self->enum;
} else { } else {
# assume it's a number # assume it's a number
$num = $self; $num = $self;
} }
PDL::_default_badvalue_int($num); PDL::Bad::_default_badvalue_int($num);
} }
############################################################ ############################################################
############################################################ ############################################################
#line 287 "Bad.pm" #line 273 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 isbad =head2 isbad
=for sig =for sig
Signature: (a(); int [o]b()) Signature: (a(); int [o]b())
=for ref =for ref
Returns a binary mask indicating which values of Returns a binary mask indicating which values of
skipping to change at line 298 skipping to change at line 292
print $y, "\n"; print $y, "\n";
[0 1 0] [0 1 0]
=for bad =for bad
This method works with input ndarrays that are bad. The output ndarray This method works with input ndarrays that are bad. The output ndarray
will never contain bad values, but its bad value flag will be the will never contain bad values, but its bad value flag will be the
same as the input ndarray's flag. same as the input ndarray's flag.
=cut =cut
#line 327 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*isbad = \&PDL::isbad; *isbad = \&PDL::isbad;
#line 334 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 isgood =head2 isgood
=for sig =for sig
Signature: (a(); int [o]b()) Signature: (a(); int [o]b())
=for ref =for ref
Is a value good? Is a value good?
skipping to change at line 336 skipping to change at line 324
print $y, "\n"; print $y, "\n";
[1 0 1] [1 0 1]
=for bad =for bad
This method works with input ndarrays that are bad. The output ndarray This method works with input ndarrays that are bad. The output ndarray
will never contain bad values, but its bad value flag will be the will never contain bad values, but its bad value flag will be the
same as the input ndarray's flag. same as the input ndarray's flag.
=cut =cut
#line 373 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*isgood = \&PDL::isgood; *isgood = \&PDL::isgood;
#line 380 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 nbadover =head2 nbadover
=for sig =for sig
Signature: (a(n); indx [o] b()) Signature: (a(n); indx [o] b())
=for ref =for ref
Find the number of bad elements along the 1st dimension. Find the number of bad elements along the 1st dimension.
skipping to change at line 376 skipping to change at line 358
$spectrum = nbadover $image->transpose $spectrum = nbadover $image->transpose
=for bad =for bad
nbadover processes input values that are bad. The output ndarray will not have nbadover processes input values that are bad. The output ndarray will not have
any bad values, but the bad flag will be set if the input ndarray had its bad any bad values, but the bad flag will be set if the input ndarray had its bad
flag set. flag set.
=cut =cut
#line 421 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*nbadover = \&PDL::nbadover; *nbadover = \&PDL::nbadover;
#line 428 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 ngoodover =head2 ngoodover
=for sig =for sig
Signature: (a(n); indx [o] b()) Signature: (a(n); indx [o] b())
=for ref =for ref
Find the number of good elements along the 1st dimension. Find the number of good elements along the 1st dimension.
skipping to change at line 417 skipping to change at line 393
$spectrum = ngoodover $image->transpose $spectrum = ngoodover $image->transpose
=for bad =for bad
ngoodover processes input values that are bad. The output ndarray will not have ngoodover processes input values that are bad. The output ndarray will not have
any bad values, but the bad flag will be set if the input ndarray had its bad any bad values, but the bad flag will be set if the input ndarray had its bad
flag set. flag set.
=cut =cut
#line 470 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*ngoodover = \&PDL::ngoodover; *ngoodover = \&PDL::ngoodover;
#line 477 "Bad.pm"
#line 533 "bad.pd" #line 512 "bad.pd"
*nbad = \&PDL::nbad; *nbad = \&PDL::nbad;
sub PDL::nbad { sub PDL::nbad {
my($x) = @_; my $tmp; my($x) = @_; my $tmp;
$x->clump(-1)->nbadover($tmp=PDL->nullcreate($x) ); $x->clump(-1)->nbadover($tmp=PDL->nullcreate($x) );
return $tmp; return $tmp;
} }
#line 490 "Bad.pm"
#line 533 "bad.pd"
#line 512 "bad.pd"
*ngood = \&PDL::ngood; *ngood = \&PDL::ngood;
sub PDL::ngood { sub PDL::ngood {
my($x) = @_; my $tmp; my($x) = @_; my $tmp;
$x->clump(-1)->ngoodover($tmp=PDL->nullcreate($x) ); $x->clump(-1)->ngoodover($tmp=PDL->nullcreate($x) );
return $tmp; return $tmp;
} }
#line 503 "Bad.pm"
#line 545 "bad.pd"
#line 524 "bad.pd"
=head2 nbad =head2 nbad
=for ref =for ref
Returns the number of bad values in an ndarray Returns the number of bad values in an ndarray
=for usage =for usage
$x = nbad($data); $x = nbad($data);
skipping to change at line 520 skipping to change at line 488
=cut =cut
*setbadat = \&PDL::setbadat; *setbadat = \&PDL::setbadat;
sub PDL::setbadat { sub PDL::setbadat {
barf 'Usage: setbadat($pdl, $x, $y, ...)' if $#_<1; barf 'Usage: setbadat($pdl, $x, $y, ...)' if $#_<1;
my $self = shift; my $self = shift;
PDL::Core::set_c ($self, [@_], $self->badvalue); PDL::Core::set_c ($self, [@_], $self->badvalue);
$self->badflag(1); $self->badflag(1);
return $self; return $self;
} }
#line 584 "Bad.pm" #line 532 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 setbadif =head2 setbadif
=for sig =for sig
Signature: (a(); int mask(); [o]b()) Signature: (a(); int mask(); [o]b())
=for ref =for ref
Set elements bad based on the supplied mask, otherwise Set elements bad based on the supplied mask, otherwise
skipping to change at line 566 skipping to change at line 532
The output always has its bad flag set, even if it does not contain The output always has its bad flag set, even if it does not contain
any bad values (use L</check_badflag> to check any bad values (use L</check_badflag> to check
whether there are any bad values in the output). whether there are any bad values in the output).
The input ndarray can have bad values: any bad values in the input ndarrays The input ndarray can have bad values: any bad values in the input ndarrays
are copied across to the output ndarray. are copied across to the output ndarray.
Also see L</setvaltobad> and L</setnantobad>. Also see L</setvaltobad> and L</setnantobad>.
=cut =cut
#line 636 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*setbadif = \&PDL::setbadif; *setbadif = \&PDL::setbadif;
#line 643 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 setvaltobad =head2 setvaltobad
=for sig =for sig
Signature: (a(); [o]b(); double value) Signature: (a(); [o]b(); double value)
=for ref =for ref
Set bad all those elements which equal the supplied value. Set bad all those elements which equal the supplied value.
skipping to change at line 604 skipping to change at line 564
if you want to convert NaN to the bad value. if you want to convert NaN to the bad value.
=for bad =for bad
The output always has its bad flag set, even if it does not contain The output always has its bad flag set, even if it does not contain
any bad values (use L</check_badflag> to check any bad values (use L</check_badflag> to check
whether there are any bad values in the output). whether there are any bad values in the output).
Any bad values in the input ndarrays are copied across to the output ndarray. Any bad values in the input ndarrays are copied across to the output ndarray.
=cut =cut
#line 682 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*setvaltobad = \&PDL::setvaltobad; *setvaltobad = \&PDL::setvaltobad;
#line 689 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 setnantobad =head2 setnantobad
=for sig =for sig
Signature: (a(); [o]b()) Signature: (a(); [o]b())
=for ref =for ref
Sets NaN values (for complex, where either is NaN) in the input ndarray bad Sets NaN values (for complex, where either is NaN) in the input ndarray bad
skipping to change at line 640 skipping to change at line 594
=for bad =for bad
This method can process ndarrays with bad values: those bad values This method can process ndarrays with bad values: those bad values
are propagated into the output ndarray. Any value that is not a number are propagated into the output ndarray. Any value that is not a number
(before version 2.040 the test was for "not finite") (before version 2.040 the test was for "not finite")
is also set to bad in the output ndarray. If all values from the input is also set to bad in the output ndarray. If all values from the input
ndarray are good, the output ndarray will B<not> have its ndarray are good, the output ndarray will B<not> have its
bad flag set. bad flag set.
=cut =cut
#line 726 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*setnantobad = \&PDL::setnantobad; *setnantobad = \&PDL::setnantobad;
#line 733 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 setinftobad =head2 setinftobad
=for sig =for sig
Signature: (a(); [o]b()) Signature: (a(); [o]b())
=for ref =for ref
Sets non-finite values (for complex, where either is non-finite) in Sets non-finite values (for complex, where either is non-finite) in
skipping to change at line 675 skipping to change at line 623
=for bad =for bad
This method can process ndarrays with bad values: those bad values This method can process ndarrays with bad values: those bad values
are propagated into the output ndarray. Any value that is not finite are propagated into the output ndarray. Any value that is not finite
is also set to bad in the output ndarray. If all values from the input is also set to bad in the output ndarray. If all values from the input
ndarray are finite, the output ndarray will B<not> have its ndarray are finite, the output ndarray will B<not> have its
bad flag set. bad flag set.
=cut =cut
#line 769 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*setinftobad = \&PDL::setinftobad; *setinftobad = \&PDL::setinftobad;
#line 776 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 setnonfinitetobad =head2 setnonfinitetobad
=for sig =for sig
Signature: (a(); [o]b()) Signature: (a(); [o]b())
=for ref =for ref
Sets non-finite values (for complex, where either is non-finite) in Sets non-finite values (for complex, where either is non-finite) in
skipping to change at line 710 skipping to change at line 652
=for bad =for bad
This method can process ndarrays with bad values: those bad values This method can process ndarrays with bad values: those bad values
are propagated into the output ndarray. Any value that is not finite are propagated into the output ndarray. Any value that is not finite
is also set to bad in the output ndarray. If all values from the input is also set to bad in the output ndarray. If all values from the input
ndarray are finite, the output ndarray will B<not> have its ndarray are finite, the output ndarray will B<not> have its
bad flag set. bad flag set.
=cut =cut
#line 812 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*setnonfinitetobad = \&PDL::setnonfinitetobad; *setnonfinitetobad = \&PDL::setnonfinitetobad;
#line 819 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 setbadtonan =head2 setbadtonan
=for sig =for sig
Signature: (a(); [o] b();) Signature: (a(); [o] b();)
=for ref =for ref
Sets Bad values to NaN Sets Bad values to NaN
skipping to change at line 745 skipping to change at line 681
$x->inplace->setbadtonan; $x->inplace->setbadtonan;
=for bad =for bad
This method processes input ndarrays with bad values. The output ndarrays will This method processes input ndarrays with bad values. The output ndarrays will
not contain bad values (insofar as NaN is not Bad as far as PDL is concerned) not contain bad values (insofar as NaN is not Bad as far as PDL is concerned)
and the output ndarray does not have its bad flag set. As an inplace and the output ndarray does not have its bad flag set. As an inplace
operation, it clears the bad flag. operation, it clears the bad flag.
=cut =cut
#line 855 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*setbadtonan = \&PDL::setbadtonan; *setbadtonan = \&PDL::setbadtonan;
#line 862 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 setbadtoval =head2 setbadtoval
=for sig =for sig
Signature: (a(); [o]b(); double newval) Signature: (a(); [o]b(); double newval)
=for ref =for ref
Replace any bad values by a (non-bad) value. Replace any bad values by a (non-bad) value.
skipping to change at line 780 skipping to change at line 710
print "a badflag: ", $x->badflag, "\n"; print "a badflag: ", $x->badflag, "\n";
a badflag: 0 a badflag: 0
=for bad =for bad
The output always has its bad flag cleared. The output always has its bad flag cleared.
If the input ndarray does not have its bad flag set, then If the input ndarray does not have its bad flag set, then
values are copied with no replacement. values are copied with no replacement.
=cut =cut
#line 897 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*setbadtoval = \&PDL::setbadtoval; *setbadtoval = \&PDL::setbadtoval;
#line 904 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 badmask =head2 badmask
=for sig =for sig
Signature: (a(); b(); [o]c()) Signature: (a(); b(); [o]c())
=for ref =for ref
Clears all C<infs> and C<nans> in C<$a> to the corresponding value in C<$b>. Clears all C<infs> and C<nans> in C<$a> to the corresponding value in C<$b>.
skipping to change at line 809 skipping to change at line 733
badmask can be run with C<$x> inplace: badmask can be run with C<$x> inplace:
badmask($x->inplace,0); badmask($x->inplace,0);
$x->inplace->badmask(0); $x->inplace->badmask(0);
=for bad =for bad
If bad values are present, these are also cleared. If bad values are present, these are also cleared.
=cut =cut
#line 933 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*badmask = \&PDL::badmask; *badmask = \&PDL::badmask;
#line 940 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 copybad =head2 copybad
=for sig =for sig
Signature: (a(); mask(); [o]b()) Signature: (a(); mask(); [o]b())
=for ref =for ref
Copies values from one ndarray to another, setting them Copies values from one ndarray to another, setting them
skipping to change at line 853 skipping to change at line 771
$c = $x + $mask * 0 $c = $x + $mask * 0
=for bad =for bad
This handles input ndarrays that are bad. If either C<$x> This handles input ndarrays that are bad. If either C<$x>
or C<$mask> have bad values, those values will be marked or C<$mask> have bad values, those values will be marked
as bad in the output ndarray and the output ndarray will have as bad in the output ndarray and the output ndarray will have
its bad value flag set to true. its bad value flag set to true.
=cut =cut
#line 985 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*copybad = \&PDL::copybad; *copybad = \&PDL::copybad;
#line 992 "Bad.pm"
#line 958 "../../blib/lib/PDL/PP.pm"
=head2 locf =head2 locf
=for sig =for sig
Signature: (a(n); [o]b(n)) Signature: (a(n); [o]b(n))
=for ref =for ref
Last Observation Carried Forward - replace Last Observation Carried Forward - replace
every BAD value with the most recent non-BAD value prior to it. every BAD value with the most recent non-BAD value prior to it.
Any leading BADs will be set to 0. Any leading BADs will be set to 0.
=for bad =for bad
locf processes bad values. locf processes bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1020 "Bad.pm"
#line 960 "../../blib/lib/PDL/PP.pm"
*locf = \&PDL::locf; *locf = \&PDL::locf;
#line 1027 "Bad.pm"
#line 1091 "bad.pd" #line 1070 "bad.pd"
=head1 AUTHOR =head1 AUTHOR
Doug Burke (djburke@cpan.org), 2000, 2001, 2003, 2006. Doug Burke (djburke@cpan.org), 2000, 2001, 2003, 2006.
The per-ndarray bad value support is by Heiko Klein (2006). The per-ndarray bad value support is by Heiko Klein (2006).
CPAN documentation fixes by David Mertens (2010, 2013). CPAN documentation fixes by David Mertens (2010, 2013).
All rights reserved. There is no warranty. You are allowed to All rights reserved. There is no warranty. You are allowed to
redistribute this software / documentation under certain conditions. For redistribute this software / documentation under certain conditions. For
details, see the file COPYING in the PDL distribution. If this file is details, see the file COPYING in the PDL distribution. If this file is
separated from the PDL distribution, the copyright notice should be separated from the PDL distribution, the copyright notice should be
included in the file. included in the file.
=cut =cut
#line 1051 "Bad.pm" #line 936 "Bad.pm"
# Exit with OK status # Exit with OK status
1; 1;
 End of changes. 45 change blocks. 
105 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)