Branch Coverage

blib/lib/PDL/IO/FITS.pm
Criterion Covered Total %
branch 288 578 49.8


line true false branch
81 49 0 if ($PDL::Astro_FITS_Header)
84 0 49 if $x < 1.12
87 0 49 unless ($PDL::Astro_FITS_Header)
88 0 0 unless ($ENV{'PDL_FITS_LEGACY'} or $PDL::Config{'FITS_LEGACY'})
335 0 46 if @_ < 1 or @_ > 2
348 3 43 $file =~ /\[\d+\]$/ ? :
349 3 43 $file =~ s/\[(\d+)\]$// ? :
353 0 46 if $file =~ /\.gz$/
354 0 46 if $file =~ /\.Z$/
356 0 46 unless my $fh = 'IO::File'->new($file)
377 0 48 if (wantarray and not $opt->{'data'} and @extensions) { }
383 0 0 if $fh->eof
387 0 48 if $nbytes == 0 and not $line =~ /^SIMPLE = +T/
389 0 48 if $fh->eof or not $ct
394 2 46 if ($line =~ /^XTENSION= \'(\w+)\s*\'/) { }
0 46 elsif (@extensions) { }
398 0 0 if $PDL::verbose
403 48 0 if $PDL::Astro_FITS_Header
414 3 45 if (not wantarray and $currentext != $extnum)
419 0 3 if $fh->eof
422 0 3 if $fh->eof
426 3 0 if $line =~ /^XTENSION\= \'(\w+)\s*\'/
427 3 0 if ($currentext == $extnum)
439 48 0 if ($PDL::Astro_FITS_Header and $opt->{'afh'}) { }
465 0 0 if (substr($line, 0, 8) ne ' ')
471 0 0 if ($name =~ /^HISTORY/) { }
476 0 0 if $rest =~ m[^= +([^\/\' ][^\/ ]*) *( +/(.*))?$]
477 0 0 if $rest =~ m[^= \'(.*)\' *( +/(.*))?$]
478 0 0 if defined $3
481 0 0 if defined $name and $name eq 'END'
486 0 0 if $#history >= 0
490 0 0 if $skip
502 3 1 if (not defined $foo->{'XTENSION'} and $foo->{'NAXIS'} == 0 and not wantarray and not $explicit_extension)
507 0 3 if $PDL::verbose
516 1 44 if (not $opt->{'data'} or $foo->{'NAXIS'} == 0) { }
528 44 0 if (ref $PDL::IO::FITS::_Extension->{$ext_type}) { }
537 0 0 if $PDL::verbose or $PDL::debug
549 3 42 if wantarray
556 1 42 if (wantarray)
558 1 0 if (ref $extensions[0] eq 'HASH' and $extensions[0]{'SIMPLE'} and exists $extensions[0]{'NAXIS'} and $extensions[0]{'NAXIS'} == 0)
617 0 41 if $PDL::verbose
625 41 0 if (defined $$type_table{0 + $foo->{'BITPIX'}}) { }
644 0 41 if $PDL::verbose
649 0 41 if $PDL::verbose
658 41 0 unless (isbigendian())
660 5 36 if $pdl->get_datatype == $PDL::IO::FITS::PDL_S
661 18 23 if $pdl->get_datatype == $PDL::IO::FITS::PDL_L or $pdl->get_datatype == $PDL::IO::FITS::PDL_F
662 14 27 if $pdl->get_datatype == $PDL::IO::FITS::PDL_D or $pdl->get_datatype == $PDL::IO::FITS::PDL_LL
665 41 0 if (exists $opt->{'bscale'})
682 0 41 if $PDL::debug
684 41 0 if ($PDL::Bad::Status)
688 1 40 if ($foo->{'BITPIX'} > 0 and exists $foo->{'BLANK'}) { }
23 17 elsif ($foo->{'BITPIX'} < 0) { }
692 1 0 if ($blank == $pdl->badvalue) { }
704 0 2 if $pdl->badflag and $PDL::verbose
710 0 41 if $PDL::verbose
711 41 0 if not defined $bscale or $bscale eq ''
712 41 0 if not defined $bzero or $bzero eq ''
721 39 2 if ($pdl->badflag == 0) { }
2 0 elsif ($pdl->ngood > 0) { }
730 0 0 if $PDL::verbose
737 0 41 if $bscale != 1
738 0 41 if $bzero != 0
740 0 41 if $tmp->get_datatype != $pdl->get_datatype
742 0 41 if $bscale != 1
743 0 41 if $bzero != 0
893 0 0 if length $$hdr{"TSCAL$n"} or length $$hdr{"TZERO$n"}
906 0 0 if ($rowlen != 1)
940 0 0 if $PDL::debug
956 0 0 unless (isbigendian())
957 0 0 if ($post == 2) { }
0 0 elsif ($post == 4) { }
0 0 elsif ($post == 8) { }
0 0 elsif ($post != 1) { }
965 0 0 defined $$hdr{"TZERO$n"} ? :
966 0 0 defined $$hdr{"TSCAL$n"} ? :
969 0 0 if (length $$hdr{"TZERO$n"} or length $$hdr{"TSCAL$n"})
988 0 3 unless $hdr->{'BITPIX'} == 8
1001 0 3 unless $hdr->{'TFIELDS'}
1018 0 9 unless $$hdr{"TTYPE$i"} eq $name
1021 9 0 if ($$hdr{"TFORM$i"} =~ /(\d*)(P?.)(.*)/) { }
1030 0 0 if $$hdr{"TFORM$i"}
1035 0 9 if $tmpcol->{'type'} eq 'X'
1041 0 9 unless $tmpcol->{'handler'} = $$PDL::IO::FITS_bintable_handlers{$tmpcol->{'type'}}
1048 1 8 if (ref $foo eq 'CODE') { }
1069 0 9 if $PDL::debug
1077 0 3 if $rowlen != $hdr->{'NAXIS1'}
1084 0 3 if ($hdr->{'THEAP'})
1085 0 0 if ($hdr->{'THEAP'} < $n1) { }
1093 0 3 $hdr->{'THEAP'} ? :
1096 0 3 if $PDL::verbose
1100 3 0 if ($n2) { }
1112 4 32 if (ref $reader eq 'CODE') { }
32 0 elsif (ref $tmpcol->{'data'} eq 'PDL') { }
1135 0 12 if (length $rawtable ne $prelen - $hdr->{'NAXIS1'})
1151 0 9 if (ref $post eq 'CODE') { }
8 1 elsif (ref $tmpcol->{'data'} eq 'PDL') { }
0 1 elsif (defined $post) { }
1165 8 0 unless (isbigendian())
1166 1 7 if ($post == 2) { }
4 3 elsif ($post == 4) { }
2 1 elsif ($post == 8) { }
0 1 elsif ($post != 1) { }
1179 8 0 if ($opt->{'bscale'}) { }
1180 0 8 defined $$hdr{"TZERO$i"} ? :
1181 0 8 defined $$hdr{"TSCAL$i"} ? :
1187 0 8 if ($valid_tzero or $valid_tscal)
1188 0 0 if ($tmpcol->{'type'} =~ /[ALX]/i) { }
1201 0 0 if ($pdl->badflag == 0) { }
0 0 elsif ($pdl->ngood > 0) { }
1218 0 0 if $tmp->get_datatype != $pdl->get_datatype
1238 0 0 if defined $hdr->{$x}
1246 0 8 if (exists $$hdr{"TDIM$i"}) { }
1247 0 0 if ($$hdr{"TDIM$i"} =~ /\((\s*\d+(\s*\,\s*\d+)*\s*)\)/) { }
1252 0 0 if ($tds > $tmpcol->{'data'}->dim(0)) { }
0 0 elsif ($tds < $tmpcol->{'data'}->dim(0)) { }
1266 8 0 if ($hdr->{'NAXIS2'} > 0 and $tmpcol->{'rpt'} > 0)
1270 8 0 $tmpcol->{'data'}->dim(0) == 1 ? :
1285 0 0 if ($hdr->{'ZIMAGE'} and $hdr->{'ZCMPTYPE'} and $opt->{'expand'})
1287 0 0 if ($@)
1404 0 0 unless (defined $tc)
1412 0 0 if ($$type_table{$hdr->{'ZBITPIX'}}) { }
1429 0 0 if ($$hdr{"ZTILE$i"}) { }
1432 0 0 $i == 1 ? :
1445 0 0 if ($tilecount != $tbl->{'COMPRESSED_DATA'}->dim(0))
1451 0 0 if ($hdr->{'ZQUANTIZ'})
1484 0 0 if ($patchup->nelem)
1485 0 0 unless (defined $tbl->{'UNCOMPRESSED_DATA'})
1488 0 0 if ($tbl->{'UNCOMPRESSED_DATA'}->dim(1) != $tilesize)
1508 0 0 if defined $hdr->{'ZSCALE'}
1509 0 0 if defined $hdr->{'ZZERO'}
1518 0 0 if ($hdr->{$k})
1526 0 0 if (exists $$hdr{'Z' . $_} and defined $$hdr{'Z' . $_})
1533 0 0 if $k =~ /^Z/ or $k eq 'TFIELDS' or $k =~ /^TTYPE/ or $k =~ /^TFORM/
1541 0 0 if (exists $hdr->{'BSCALE'} or exists $hdr->{'BLANK'})
1795 31 145 if ($k =~ /(HISTORY|COMMENT)/) { }
1797 31 0 unless ref $hdr{$k} eq 'ARRAY'
1809 0 145 if (ref $hdrk eq 'ARRAY')
1813 0 145 if ref $hdrk
1815 0 145 if ($hdrk eq '') { }
1821 0 145 ref $hdr{'COMMENT'} eq 'HASH' ? :
1823 114 31 if ($hdrk =~ /^ *([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))? *$/) { }
0 31 elsif ($hdrk eq 'F' or $hdrk eq 'T') { }
1824 0 114 $com ? :
1826 0 114 if $com
1833 0 0 if $com
1845 0 31 $com ? :
1848 0 31 if (defined $com) { }
1857 0 145 if ref $hdr{'COMMENT'} eq 'HASH'
1864 0 38 if $#_ < 1 or $#_ > 3
1870 0 38 if (ref $x eq 'HASH') { }
38 0 elsif (ref $y eq 'HASH' or not defined $y) { }
1884 0 38 if ($file =~ /\.gz$/) { }
0 38 elsif ($file =~ /\.Z$/) { }
1901 31 7 if (UNIVERSAL::isa($pdl, 'PDL')) { }
3 4 elsif (ref $pdl eq 'HASH') { }
1 3 elsif (ref $pdl eq 'ARRAY') { }
3 0 elsif (length ref $pdl == 0) { }
1917 0 35 unless my $fh = 'IO::File'->new($file)
1921 4 31 if ($issue_nullhdu)
1927 3 33 if (ref $pdl eq 'HASH') { }
33 0 elsif (UNIVERSAL::isa($pdl, 'PDL')) { }
1929 0 0 $pdl->{'tbl'} =~ /^a/i ? :
0 3 exists $pdl->{'tbl'} ? :
1937 21 12 unless defined $BITPIX
1938 21 12 if ($BITPIX eq '')
1939 2 19 if $pdl->get_datatype == $PDL::IO::FITS::PDL_B
1940 2 19 if $pdl->get_datatype == $PDL::IO::FITS::PDL_S or $pdl->get_datatype == $PDL::IO::FITS::PDL_US
1941 3 18 if $pdl->get_datatype == $PDL::IO::FITS::PDL_L
1942 1 20 if $pdl->get_datatype == $PDL::IO::FITS::PDL_LL
1943 2 19 if $pdl->get_datatype == $PDL::IO::FITS::PDL_F
1944 11 10 if $pdl->get_datatype == $PDL::IO::FITS::PDL_D
1945 0 21 if $pdl->get_datatype == $PDL::IO::FITS::PDL_IND
1947 0 33 if ($BITPIX eq '')
1953 4 29 if $BITPIX == 8
1954 5 28 if $BITPIX == 16
1955 5 28 if $BITPIX == 32
1956 1 32 if $BITPIX == 64
1957 4 29 if $BITPIX == -32
1958 14 19 if $BITPIX == -64
1963 15 18 if ($BITPIX > 0)
1966 4 11 if $BITPIX == 8
1967 5 10 if $BITPIX == 16
1968 5 10 if $BITPIX == 32
1969 1 14 if $BITPIX == 64
1971 0 15 if ($min < $dmin or $max > $dmax)
1974 0 0 if $max > $dmax
1976 0 15 if $PDL::verbose
1982 0 33 if ($opt->{'compress'})
1995 2 0 if ($PDL::Astro_FITS_Header and defined $h and ref $h eq 'HASH' and not defined tied %$h)
2003 0 5 if (length $k > 8 or not $k =~ /^[A-Z_][A-Z\d\_]*$/i)
2011 2 0 if ($all_valid_fits)
2025 2 31 if (defined $h and (defined tied %$h and UNIVERSAL::isa(tied %$h, 'Astro::FITS::Header'))) { }
2041 0 2 if ($issue_nullhdu) { }
2064 0 2 if $correction
2067 2 0 unless exists $h->{'BUNIT'}
2068 0 2 if $bscale != 1
2069 0 2 if $bzero != 0
2071 0 2 if ($pdl->badflag)
2072 0 0 if ($BITPIX > 0) { }
2090 6 12 if $kw =~ s/\d$//
2093 12 6 if (defined $index[0])
2094 12 0 if ($kn <= $pdl->getndims) { }
2095 10 2 unless $index[0] == $kk
2146 2 29 if ($issue_nullhdu) { }
2157 0 31 if (defined $h)
2164 31 0 unless exists $hdr{'BUNIT'}
2173 0 31 if ($bscale != 1 or $bzero != 0)
2185 2 29 if ($pdl->badflag)
2186 1 1 if ($BITPIX > 0) { }
2191 1 0 unless $k =~ /HISTORY/
2202 33 0 if $nbytes != 0
2209 33 0 unless (isbigendian())
2210 5 28 if $BITPIX == 16
2211 9 24 if $BITPIX == 32 or $BITPIX == -32
2212 15 18 if $BITPIX == -64 or $BITPIX == 64
2230 1 1 if ($pdl->badflag and $BITPIX < 0 and $PDL::Bad::UseNaN == 0)
2232 0 1 if $PDL::verbose
2246 0 0 if ($pdl->badflag and $BITPIX < 0 and $PDL::Bad::UseNaN == 0)
2256 1 1 if ($pdl->badflag and $BITPIX < 0 and $PDL::Bad::UseNaN == 0)
2298 64 62 if ($a =~ /^(.*[^\d])(\d+)$/)
2300 42 22 if ($b =~ /^(.*[^\d])(\d+)$/)
2303 23 19 if ($an eq $bn)
2324 8 1 if UNIVERSAL::isa($var, 'PDL')
2325 1 0 if ref $var eq 'ARRAY'
2326 0 0 unless ref $var
2328 0 0 if $PDL::verbose
2372 1 2 if (defined $hdr)
2378 0 3 unless defined $tbl
2380 0 3 unless ref $hash eq 'HASH'
2390 0 3 if $PDL::verbose
2400 3 6 unless defined $rows and $rows != 1
2401 0 9 if ($r != $rows and $r != 1)
2406 0 3 if $PDL::verbose
2415 0 3 if $PDL::debug
2424 9 0 unless ($nosquish)
2429 0 9 if (defined $ohash->{$name})
2441 0 0 if $PDL::debug or $name ne $key and $PDL::verbose
2455 0 2 unless /^TTYPE(\d*)$/
2459 0 2 if ($num > $cols or $num < 1)
2460 0 0 if $PDL::verbose
2469 0 2 unless ($name = $namesbykey{$key})
2471 0 0 unless ($key = $keysbyname{$key})
2472 0 0 if $PDL::verbose
2487 2 7 if ($colnums{$name}) { }
2494 0 3 if $PDL::debug and $i != $cols
2498 0 3 if $PDL::debug
2509 3 0 if ($tbl eq 'binary') { }
0 0 elsif ($tbl eq 'ascii') { }
2541 8 1 if (UNIVERSAL::isa($var, 'PDL')) { }
1 0 elsif (ref $var eq 'ARRAY') { }
0 0 elsif (ref $var) { }
2566 0 8 if UNIVERSAL::isa($var, 'PDL::Complex')
2572 0 8 unless (defined $t)
2573 0 0 if $PDL::verbose
2589 2 2 if $l > $rpt
2606 0 9 if (exists $hash->{$lname})
2612 0 0 if (not UNIVERSAL::isa($var, 'PDL') or $var->ndims != 2 or not UNIVERSAL::isa($lengths, 'PDL') or $lengths->ndims != 1 or $lengths->dim(0) != $var->dim(0))
2646 0 0 if (ref $len eq 'ARRAY') { }
0 0 elsif (UNIVERSAL::isa($len, 'PDL')) { }
0 0 elsif (ref $len) { }
2659 0 0 $l ? :
2662 0 0 if ($l)
2665 0 0 $csub ? :
2668 0 0 unless (isbigendian())
2669 0 0 if $tmp->get_datatype == $PDL::IO::FITS::PDL_S
2670 0 0 if $tmp->get_datatype == $PDL::IO::FITS::PDL_L or $tmp->get_datatype == $PDL::IO::FITS::PDL_F
2672 0 0 if $tmp->get_datatype == $PDL::IO::FITS::PDL_D
2691 0 9 if (UNIVERSAL::isa($var, 'PDL') and $var->ndims > 1)
2710 32 4 if ($internaltype[$c] eq 'P') { }
2712 4 28 $converters[$c] ? :
2718 32 0 unless (isbigendian())
2719 4 28 if $tmp->get_datatype == $PDL::IO::FITS::PDL_S
2720 16 16 if $tmp->get_datatype == $PDL::IO::FITS::PDL_L or $tmp->get_datatype == $PDL::IO::FITS::PDL_F
2722 8 24 if $tmp->get_datatype == $PDL::IO::FITS::PDL_D
2728 0 4 $#$x == 0 ? :
4 0 ref $x eq 'ARRAY' ? :
2743 0 3 if (length $table != $table_size)
2775 30 18 if defined $type
2779 12 36 if defined $comment
2800 0 3 unless $PDL::Astro_FITS_Header
2804 0 3 unless defined $heap
2810 0 3 $tbl eq 'ascii' ? :
2815 0 3 $tbl eq 'ascii' ? :
2816 0 3 if length $heap
2822 24 18 if defined $newhdr{$field} or $field =~ /^end|simple|xtension$/i
2825 0 18 $hdr->{$field} =~ /^[tf]$/i ? :
0 18 UNIVERSAL::isa($hdr->{'field'}, 'PDL') ? :
2843 0 4 if ($Astro::FITS::Header) { }