NumSeq/OEIS.pm

filter: Statementstmt 92.1% 35 / 38 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 90.0% 9 / 10 Podpod 100% 3 / 3 totaltotal 83.3% 50 / 60 CC 4 SCAR 7.4
CC
4
Cov
84%
new
4.3
oeis_anum
2.0
BEGIN
1.0
CRAP 2.1
« NumSeq/DivisorCount.pm ↑ Summary NumSeq/PrimeIndexOrder.pm »
1 # Copyright 2011, 2012, 2013, 2014, 2016, 2018, 2019 Kevin Ryde
2  
3 # This file is part of Math-NumSeq.
4 #
5 # Math-NumSeq is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # Math-NumSeq is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
17  
18 package Math::NumSeq::OEIS;
19 2 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 2 ▶use vars '$VERSION','@ISA';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 $VERSION = 74;
25  
26 2 ▶use Math::NumSeq;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 2 @ISA = ('Math::NumSeq');
28  
29 # uncomment this to run the ### lines
30 #use Smart::Comments;
31  
32  
33 # use constant name => Math::NumSeq::__('OEIS');
34 2 ▶use constant description => Math::NumSeq::__('OEIS sequence, by its A-number. There\'s code for some sequences, others look in ~/OEIS directory for downloaded files A123456.internal, A123456.html and/or b123456.txt.');
Subroutine BEGIN: called CC=1 SCAR=0.0
35 2 ▶use constant characteristic_integer => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 # recalculated each time for updated file min/max
38 sub parameter_info_array {
39 65 ▶ require Math::NumSeq::OEIS::Catalogue;
Subroutine parameter_info_array: called CC=1 SCAR=0.0
Pod documented
40 return [
41 65 { name => 'anum',
42 type => 'string',
43 display => Math::NumSeq::__('OEIS A-number'),
44 type_hint => 'oeis_anum',
45 width => 8,
46 minimum => Math::NumSeq::OEIS::Catalogue->anum_first,
47 maximum => Math::NumSeq::OEIS::Catalogue->anum_last,
48 default => 'A000290', # Squares, an arbitrary choice
49 },
50 ];
51 }
52 ### parameter_info_array parameter_info_array()
53  
54 sub oeis_anum {
55 0 ▶ my ($self) = @_;
Subroutine oeis_anum: not called CC=1 SCAR=6.9
Pod documented
56 0 return $self->{'oeis_anum'};
57 }
58  
59 sub new {
60 2 ▶ my ($class, %options) = @_;
Subroutine new: called CC=4 SCAR=14.7
Pod documented
61 ### Values-OEIS: @_
62  
63 2 my $anum = $options{'anum'};
64 2 ▶ if (! defined $anum) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $anum) 0 2 2
65 0 $anum = parameter_info_array()->[0]->{'default'};
66 }
67 ### $anum
68  
69 2 require Math::NumSeq::OEIS::Catalogue;
70 2 ▶ my $info = Math::NumSeq::OEIS::Catalogue->anum_to_info($anum)
Condition33%1/3
'Math::NumSeq::OEIS::Catalogue'->anum_to_info($anum) || croak('No data for OEIS sequence ', $anum)
l!l&&r!l&&!r
200
MC/DC0%0/2
'Math::NumSeq::OEIS::Catalogue'->anum_to_info($anum) || croak('No data for OEIS sequence ', $anum)
'Math::NumSeq::OEIS::Catalogue'->anum_to_info($anum) croak('No data for OEIS sequence ', $anum)
Truth table33%1/3
A || B
A= 'Math::NumSeq::OEIS::Catalogue'->anum_to_info($anum)B= croak('No data for OEIS sequence ', $anum)
ABresult
1X1
011
000
71 || croak 'No data for OEIS sequence ',$anum;
72 ### $info
73  
74 2 my $numseq_class = $info->{'class'};
75 2 my $parameters = $info->{'parameters'};
76 2 require Module::Load;
77 2 Module::Load::load($numseq_class);
78 2 ▶ return $numseq_class->new (%options, ($parameters ? @$parameters : ()));
Branch: 1 branch
BranchTrueFalseTotal
$parameters ? : 0 2 2
79 }
80  
81 2 1;
82 __END__
« NumSeq/DivisorCount.pm ↑ Summary NumSeq/PrimeIndexOrder.pm »