Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks #5

Merged
merged 6 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CCS/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,28 @@ our %EXPORT_TAGS = (config=>['%ccsConfig'], Func=>\@Export, default=>\@EXPORT, a
'INDX_TYPEDEF' => 'typedef PDL_Indx CCS_Indx; /**< typedef for CCS indices */
',
'INT_TYPE_CHRS' => [
'A',
'B',
'S',
'U',
'L',
'K',
'N',
'P',
'Q'
],
'INT_TYPE_KEYS' => [
'PDL_SB',
'PDL_B',
'PDL_S',
'PDL_US',
'PDL_L',
'PDL_UL',
'PDL_IND',
'PDL_ULL',
'PDL_LL'
],
'INT_TYPE_MAX_IONAME' => 'ccs_indx'
'INT_TYPE_MAX_IONAME' => 'longlong'
);

*PDL::ccs_indx = *ccs_indx = \&PDL::indx; ##-- typecasting for CCS indices
Expand Down
9 changes: 0 additions & 9 deletions CCS/IO/t/00_basic.t

This file was deleted.

7 changes: 5 additions & 2 deletions CCS/IO/t/01_io.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
##-*- Mode: CPerl -*-
use Test::More tests=>(6+(14*6));
use Test::More;
use strict;
use warnings;

##-- common subs
my $TEST_DIR;
Expand All @@ -16,7 +18,6 @@ use PDL;
use PDL::CCS;

BEGIN {
##-- use: 6
use_ok('PDL::CCS::IO::Common');
use_ok('PDL::CCS::IO::FastRaw');
use_ok('PDL::CCS::IO::FITS');
Expand Down Expand Up @@ -99,3 +100,5 @@ do {
iotest($ccs, 'ccs.petsc', qw(rpetsc wpetsc)); ##-- petsc: bin
iotest($ccs, 'ccs.petscb', qw(rpetsc wpetsc), {ioblock=>2}); ##-- petsc: bin, with block i/o
};

done_testing;
3 changes: 0 additions & 3 deletions CCS/MatrixOps/t/00_basic.t

This file was deleted.

3 changes: 0 additions & 3 deletions CCS/Ops/t/00_basic.t

This file was deleted.

3 changes: 1 addition & 2 deletions CCS/Ufunc/ccsufunc.pd
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,13 @@ sub ccs_accum_hash {
CCS_Indx ival1,ival2;
int cmpval, carp_unsorted=0;
$GENERIC(nzvalsOut) missingOut;
$GENERIC(missing) missingVal;
$GENERIC(missing) missingVal = $missing();
).($args{decls} ? $args{decls} : '').q(
).($args{tmp_type} ? $args{tmp_type} : '$GENERIC(nzvalsOut)').q( tmp;
//
//-- init
).($args{init_code}||'').q(
).($args{init_missingOut} || 'missingOut = $missing();').q(
missingVal = $missing();
nMissingInit = $N()-1;
nMissing = nMissingInit;
).(defined($args{tmp_reset}) ? $args{tmp_reset} : 'tmp = $nzvalsIn(NnzIn=>0);').q( /* initialize tmp */
Expand Down
3 changes: 0 additions & 3 deletions CCS/Ufunc/t/00_basic.t

This file was deleted.

10 changes: 6 additions & 4 deletions CCS/Ufunc/t/01_ufunc.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- Mode: CPerl -*-
# t/01_ufunc.t
use Test::More tests => 52;
use Test::More;
use strict;
use warnings;

##-- common subs
my $TEST_DIR;
Expand Down Expand Up @@ -74,8 +76,8 @@ sub test_ufunc {

my $BAD = pdl(0)->setvaltobad(0);

foreach $missing (0,1,31,$BAD) { ## *4
foreach $pdl_ufunc_name (
for my $missing (0,1,31,$BAD) { ## *4
for my $pdl_ufunc_name (
qw(sumover prodover dsumover dprodover), ## *13
qw(andover orover bandover borover),
qw(maximum minimum),
Expand All @@ -90,5 +92,5 @@ foreach $missing (0,1,31,$BAD) { ## *4
}

print "\n";
# end of t/*.t

done_testing;
3 changes: 0 additions & 3 deletions CCS/Utils/t/00_basic.t

This file was deleted.

10 changes: 5 additions & 5 deletions CCS/Utils/t/01_nnz.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- Mode: CPerl -*-
# t/01_nnz.t: test n nonzeros
use Test::More tests => 5;
use Test::More;
use strict;
use warnings;

##-- common subs
my $TEST_DIR;
Expand All @@ -17,13 +19,11 @@ use PDL;
use PDL::CCS::Utils;

## 1--4: test nnz
$p = pdl(double, [ [0,1,2], [0,0,1e-7], [0,1,0], [1,1,1] ]);
my $p = pdl(double, [ [0,1,2], [0,0,1e-7], [0,1,0], [1,1,1] ]);
isok("nnz(0)", $p->slice(",(0)")->nnz, 2);
isok("nnz(flat)", $p->flat->nnz, 7);
isok("nnza(flat,1e-8)", $p->flat->nnza(1e-8), 7);
isok("nnza(flat,1e-5)", $p->flat->nnza(1e-5), 6);
isok("nnza(flat:long,1)", $p->flat->long->nnza(1), 1);

print "\n";
# end of t/01_nnz.t

done_testing;
9 changes: 4 additions & 5 deletions CCS/Utils/t/02_encode.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- Mode: CPerl -*-
# t/02_encode.t: test ccs encoding
use Test::More tests => 6;
use Test::More;
use strict;
use warnings;

##-- common subs
my $TEST_DIR;
Expand Down Expand Up @@ -49,7 +51,4 @@ pdlok("ccs_encode_pointers:ptr1", $aptr1, pdl(long,[0,2,4,7,11,14,16]));
my $awi1x = $awhich->slice("(1),")->index($awi1);
pdlok("ccs_encode_pointers:awi1", $awi1x, $awi1x->qsort);


print "\n";
# end of t/02_encode.t

done_testing;
9 changes: 4 additions & 5 deletions CCS/Utils/t/03_decode.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- Mode: CPerl -*-
# t/03_encode.t: test ccs pointer-decoding
use Test::More tests => 8;
use Test::More;
use strict;
use warnings;

##-- common subs
my $TEST_DIR;
Expand Down Expand Up @@ -72,7 +74,4 @@ $vals_proj = $avals->index($apnzi);
pdlok("ccs_decode_pointer:partial:dim=1:which", $which_proj->vv_qsortvec, $aslice1->whichND->vv_qsortvec);
pdlok("ccs_decode_pointer:partial:dim=1:vals", $vals_proj, $aslice1->indexND($which_proj));


print "\n";
# end of t/03_decode.t

done_testing;
3 changes: 0 additions & 3 deletions CCS/t/00_basic.t

This file was deleted.

17 changes: 7 additions & 10 deletions CCS/t/01_encode.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- Mode: CPerl -*-
# t/01_encode.t
use Test::More tests => 83;
use Test::More;
use strict;
use warnings;

##-- common subs
my $TEST_DIR;
Expand All @@ -11,6 +13,7 @@ BEGIN {
eval qq{use lib ("$TEST_DIR/$_/blib/lib","$TEST_DIR/$_/blib/arch");} foreach (qw(../.. ..));
do "$TEST_DIR/common.plt" or die("$0: failed to load $TEST_DIR/common.plt: $@");
}
our ($a, $abad, $agood, $awhich, $avals, $BAD);

##-- common modules
use PDL;
Expand All @@ -28,11 +31,7 @@ sub test_basic {
##-- check missing
$missing = 0 if (!defined($missing));
$missing = PDL->topdl($missing);
if ($missing->isbad) {
$awhichND = whichND(!isbad($a));
} else {
$awhichND = whichND($a!=$missing);
}
my $awhichND = whichND($missing->isbad ? !isbad($a) : $a!=$missing);

isok("${label}:_nnz", $ccs->_nnz==$awhichND->dim(1));
pdlok("${label}:whichND", $ccs->whichND->vv_qsortvec, $awhichND->vv_qsortvec);
Expand All @@ -49,7 +48,7 @@ sub test_basic {
## missing==0

##-- 1*nbasic: newFromDense(): basic properties
$ccs = PDL::CCS::Nd->newFromDense($a);
my $ccs = PDL::CCS::Nd->newFromDense($a);
test_basic("newFromDense:missing=0", $a, $ccs, 0);

##-- 2*nbasic: toccs(): basic properties
Expand Down Expand Up @@ -85,6 +84,4 @@ test_basic("newFromWhich:missing=BAD:implicit", $a, PDL::CCS::Nd->newFromWhich($
isok("PDL::todense():no-copy", overload::StrVal($a) eq overload::StrVal($a->todense));
isok("CCS::toccs():no-copy", overload::StrVal($ccs) eq overload::StrVal($ccs->toccs));

print "\n";
# end of t/*.t

done_testing;
8 changes: 4 additions & 4 deletions CCS/t/02_indexing.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- Mode: CPerl -*-
# t/02_indexing.t
use Test::More tests => 26;
use Test::More;
use strict;
use warnings;

##-- common subs
my $TEST_DIR;
Expand Down Expand Up @@ -90,6 +92,4 @@ my $sub2 = $ccs->pxsubset1d(1,$yi);
isok("pxsubset1d:defined", defined($sub2));
pdlok("pxsubset1d:vals", $sub2->decode->dice_axis(1,$yi), $a->dice_axis(1,$yi));

print "\n";
# end of t/*.t

done_testing;
18 changes: 7 additions & 11 deletions CCS/t/03_ufuncs.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- Mode: CPerl -*-
# t/03_ufuncs.t
use Test::More tests => 2*4*17;
use Test::More;
use strict;
use warnings;

##-- common subs
my $TEST_DIR;
Expand All @@ -11,14 +13,12 @@ BEGIN {
eval qq{use lib ("$TEST_DIR/$_/blib/lib","$TEST_DIR/$_/blib/arch");} foreach (qw(../.. ..));
do "$TEST_DIR/common.plt" or die("$0: failed to load $TEST_DIR/common.plt: $@");
}
our ($a, $abad, $agood, $awhich, $avals, $BAD);

##-- common modules
use PDL;
use PDL::CCS::Nd;

use version;
my $HAVE_PDL_2_014 = version->parse($PDL::VERSION) >= version->parse("2.014");

##--------------------------------------------------------------
## ufunc test

Expand Down Expand Up @@ -62,7 +62,6 @@ sub test_ufunc {

##-- check output type
SKIP: {
skip("${label}:type - only for PDL >= v2.014",1) if (!$HAVE_PDL_2_014);
isok("${label}:type", $ccs_rc->type, $dense_rc->type)
or diag "ccs_rc(", $ccs_rc->info, ")=$ccs_rc\n",
"dense_rc(", $dense_rc->info, ")=$dense_rc\n";
Expand All @@ -82,9 +81,8 @@ sub test_ufunc {

##--------------------------------------------------------------
## all tests
our ($BAD);
foreach $missing (0,1,255,$BAD) { ##-- *4
foreach $ufunc (
for my $missing (0,1,255,$BAD) { ##-- *4
for my $ufunc (
qw(sumover prodover dsumover dprodover), ## *17
qw(andover orover bandover borover),
qw(maximum minimum),
Expand All @@ -98,6 +96,4 @@ foreach $missing (0,1,255,$BAD) { ##-- *4
}
}

print "\n";
# end of t/*.t

done_testing;
14 changes: 7 additions & 7 deletions CCS/t/04_unops.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- Mode: CPerl -*-
# t/04_unops.t
use Test::More tests => 144;
use Test::More;
use strict;
use warnings;

##-- common subs
my $TEST_DIR;
Expand All @@ -11,6 +13,7 @@ BEGIN {
eval qq{use lib ("$TEST_DIR/$_/blib/lib","$TEST_DIR/$_/blib/arch");} foreach (qw(../.. ..));
do "$TEST_DIR/common.plt" or die("$0: failed to load $TEST_DIR/common.plt: $@");
}
our ($a, $abad, $agood, $awhich, $avals, $BAD);

##-- common modules
use PDL;
Expand Down Expand Up @@ -52,9 +55,8 @@ sub test_unop {
}
}

our ($BAD);
foreach $missing (0,1,255,$BAD) { ##-- *4
foreach $op (
for my $missing (0,1,255,$BAD) { ##-- *4
for my $op (
[qw(bitnot ~)],
[qw(not !)],
qw(sqrt abs sin cos log log10), 'exp' ##-- *9
Expand All @@ -65,6 +67,4 @@ foreach $missing (0,1,255,$BAD) { ##-- *4
}
}

print "\n";
# end of t/*.t

done_testing;
Loading