| 1 | package Data::Frame::Indexer; | ||||||||||||||||||||||||||||
| 2 | 12 | $Data::Frame::Indexer::VERSION = '0.006005'; | |||||||||||||||||||||||||||
| 3 | # ABSTRACT: Function interface for indexer | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use Data::Frame::Setup; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use Data::Frame::Indexer::Integer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 12 | ▶ | use Data::Frame::Indexer::Label; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 12 | ▶ | use Data::Frame::Types qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 12 | ▶ | use Data::Frame::Util qw(is_discrete); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 12 | ▶ | use parent qw(Exporter::Tiny); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 12 | our @EXPORT_OK = qw(indexer_s indexer_i); | |||||||||||||||||||||||||||
| 15 | 12 | our %EXPORT_TAGS = ( all => \@EXPORT_OK ); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | my $NumericIndices = | ||||||||||||||||||||||||||||
| 19 | 318 | ▶ | ColumnLike->where( sub { $_->type ne 'byte' and not is_discrete($_) } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 24 | ▶ | fun _as_indexer ($fallback_indexer_class) { | ||||||||||||||||||||||||||
|
Subroutine
_as_indexer: called CC=3 SCAR=11.0
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 22 | 418 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||
| 23 | 418 | ▶ | my $x = @_ > 1 ? \@_ : @_ == 1 ? $_[0] : []; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 418 | ▶ | return undef unless defined $x; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 411 | ▶ | return $x if ( Indexer->check($x) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 394 | ▶ | unless ( Ref::Util::is_plain_arrayref($x) or $x->$_DOES('PDL') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
Ref::Util::XS::is_plain_arrayref($x) or $x->$Data::Frame::Indexer::_DOES("PDL")
MC/DC100%2/2
Ref::Util::XS::is_plain_arrayref($x) or $x->$Data::Frame::Indexer::_DOES("PDL")
Ref::Util::XS::is_plain_arrayref($x)
$x->$Data::Frame::Indexer::_DOES("PDL")
Truth table100%3/3
A or B
A= Ref::Util::XS::is_plain_arrayref($x)B= $x->$Data::Frame::Indexer::_DOES("PDL")
| |||||||||||||||||||||||||||||
| 29 | 16 | $x = [$x]; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | 394 | ▶ | if ( $NumericIndices->check($x) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 28 | return Data::Frame::Indexer::Integer->new( indexer => $x->unpdl ); | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | 366 | $fallback_indexer_class->new( indexer => $x ); | |||||||||||||||||||||||||||
| 35 | 24 | }; | |||||||||||||||||||||||||||
| 36 | 12 | } | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 12 | *indexer_s = _as_indexer('Data::Frame::Indexer::Label'); | |||||||||||||||||||||||||||
| 39 | 12 | *indexer_i = _as_indexer('Data::Frame::Indexer::Integer'); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 12 | 1; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||