| 1 | package Chart::GGPlot::Range::Discrete; | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | # ABSTRACT: Discrete range | ||||||||||||||||||||||
| 4 | |||||||||||||||||||||||
| 5 | 8 | ▶ | use Chart::GGPlot::Class qw(:pdl); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | 8 | ▶ | use namespace::autoclean; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | 8 | our $VERSION = '0.002003'; # VERSION | |||||||||||||||||||||
| 9 | |||||||||||||||||||||||
| 10 | 8 | with qw(Chart::GGPlot::Range); | |||||||||||||||||||||
| 11 | |||||||||||||||||||||||
| 12 | 7 | ▶ | sub _build_range { PDL::SV->new([]); } | ||||||||||||||||||||
|
Subroutine
_build_range: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | 8 | ▶ | use List::AllUtils qw(uniq); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 15 | 8 | ▶ | use Types::PDL -types; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 16 | |||||||||||||||||||||||
| 17 | 8 | ▶ | use Chart::GGPlot::Util qw(:all); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 18 | |||||||||||||||||||||||
| 19 | # See R scales package train_descrete() method | ||||||||||||||||||||||
| 20 | 5 | ▶ | method train($p, $drop = false, $na_rm = false ) { | ||||||||||||||||||||
|
Subroutine
train: called CC=8 SCAR=21.0
Pod
undocumented
Branch: 4 branches
| |||||||||||||||||||||||
| 21 | 5 | ▶ | return $self->range if $p->isempty; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 22 | |||||||||||||||||||||||
| 23 | 5 | ▶ | unless (is_discrete($p)) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 24 | 1 | die "Continuous value supplied to discrete scale"; | |||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||
| 26 | |||||||||||||||||||||||
| 27 | 4 | my @range = @{ $self->range->unpdl }; | |||||||||||||||||||||
| 28 | 4 | ▶ | if ( $p->$_DOES('PDL::Factor') ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 29 | # TODO: This may be incorrect. | ||||||||||||||||||||||
| 30 | 2 | push @range, $p->levels->flatten; | |||||||||||||||||||||
| 31 | 2 | $self->range( ref($p)->new( [ uniq(@range) ] ) ); | |||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||
| 33 | else { | ||||||||||||||||||||||
| 34 | 2 | push @range, $p->flatten; | |||||||||||||||||||||
| 35 | 2 | $self->range( ref($p)->new( [ sort(uniq(@range)) ] ) ); | |||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||
| 37 | |||||||||||||||||||||||
| 38 | 4 | return $self->range; | |||||||||||||||||||||
| 39 | 8 | } | |||||||||||||||||||||
| 40 | |||||||||||||||||||||||
| 41 | 8 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||
| 42 | |||||||||||||||||||||||
| 43 | 8 | 1; | |||||||||||||||||||||
| 44 | |||||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||||