| 1 | package PDL::NDBin::Action::CodeRef; | ||||||||||
| 2 | # ABSTRACT: Action for PDL::NDBin that calls user sub | ||||||||||
| 3 | 2 | $PDL::NDBin::Action::CodeRef::VERSION = '0.016'; | |||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use PDL::Lite; # do not import any functions into this namespace | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use Params::Validate qw( validate CODEREF OBJECT SCALAR UNDEF ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | sub new | ||||||||||
| 12 | { | ||||||||||
| 13 | 0 | ▶ | my $class = shift; | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 14 | 0 | my $self = validate( @_, { | |||||||||
| 15 | N => { type => SCALAR, regex => qr/^\d+$/ }, | ||||||||||
| 16 | coderef => { type => CODEREF }, | ||||||||||
| 17 | type => { type => OBJECT | UNDEF, isa => 'PDL::Type', optional => 1 } | ||||||||||
| 18 | } ); | ||||||||||
| 19 | 0 | return bless $self, $class; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | sub process | ||||||||||
| 24 | { | ||||||||||
| 25 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
process: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 26 | 0 | my $iter = shift; | |||||||||
| 27 | 0 | ▶ | if( ! defined $self->{out} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | ▶ | my $type = defined $self->{type} ? $self->{type} : $iter->data->type; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 0 | $self->{out} = PDL->zeroes( $type, $self->{N} )->setbadif( 1 ); | |||||||||
| 30 | } | ||||||||||
| 31 | 0 | my $value = $self->{coderef}->( $iter ); | |||||||||
| 32 | 0 | ▶ | if( defined $value ) { $self->{out}->set( $iter->bin, $value ) } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | return $self; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | sub result | ||||||||||
| 38 | { | ||||||||||
| 39 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
result: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 40 | 0 | return $self->{out}; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 2 | 1; | |||||||||
| 44 | |||||||||||
| 45 | __END__ | ||||||||||