| 1 | package PDL::StringfiableExtension; | ||||||||||
| 2 | 12 | $PDL::StringfiableExtension::VERSION = '0.006005'; | |||||||||
| 3 | 12 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 12 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 12 | ▶ | use PDL::Lite (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 12 | ▶ | use List::AllUtils (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | |||||||||||
| 9 | { | ||||||||||
| 10 | # This is a hack. | ||||||||||
| 11 | # This gets PDL to stringify the single element and then gets the | ||||||||||
| 12 | # element out of that string. | ||||||||||
| 13 | 12 | my $_pdl_stringify_temp = PDL::Core::pdl([[0]]); | |||||||||
| 14 | 12 | my $_pdl_stringify_temp_single = PDL::Core::pdl(0); | |||||||||
| 15 | 10253 | ▶ | sub PDL::element_stringify { | ||||||||
|
Subroutine
element_stringify: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 16 | 10253 | my ($self, $element) = @_; | |||||||||
| 17 | 10253 | ▶ | if( $self->ndims == 0 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 6 | return $_pdl_stringify_temp_single->set(0, $element)->string; | |||||||||
| 19 | } | ||||||||||
| 20 | # otherwise | ||||||||||
| 21 | 10247 | ( $_pdl_stringify_temp->set(0,0, $element)->string =~ /\[(.*)\]/ )[0]; | |||||||||
| 22 | } | ||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 12 | ▶ | sub PDL::element_stringify_max_width { | ||||||||
|
Subroutine
element_stringify_max_width: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 26 | 24 | my ($self) = @_; | |||||||||
| 27 | 24 | my @vals = @{ $self->uniq->unpdl }; | |||||||||
| 28 | 24 | my @lens = map { length $self->element_stringify($_) } @vals; | |||||||||
| 29 | 24 | List::AllUtils::max( @lens ); | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 12 | 1; | |||||||||
| 33 | |||||||||||
| 34 | __END__ | ||||||||||