Skip to content

Commit

Permalink
capture t/01-pptest.t test into t/slice.t as only needs op with 2 [o,…
Browse files Browse the repository at this point in the history
…phys]
  • Loading branch information
mohawk2 committed Feb 8, 2024
1 parent a92cbf5 commit 962b922
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Basic/Core/pdlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ pdl_error pdl__ensure_trans(pdl_trans *trans,int what,int *wd, int recurse_count
if (!PDL_VAFFOK(child) || (child->state & PDL_ALLOCATED))
child->state &= ~PDL_ANYCHANGED;
if (!wd) continue;
PDLDEBUG_f(printf(" pdl__ensure_trans wd="); pdl_dump_flags_fixspace(wd[j], 0, PDL_FLAGS_PDL));
char isvaffine = (PDL_VAFFOK(child) &&
VAFFINE_FLAG_OK(vtable->per_pdl_flags,j));
PDLDEBUG_f(printf(" pdl__ensure_trans isvaffine=%d wd=", (int)isvaffine); pdl_dump_flags_fixspace(wd[j], 0, PDL_FLAGS_PDL));
if (!isvaffine || (wd[j] & PDL_PARENTDIMSCHANGED))
CHANGED(child,wd[j],0);
if (isvaffine)
Expand Down
32 changes: 0 additions & 32 deletions t/01-pptest.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ void ppcp(PDL_Byte *dst, PDL_Byte *src, int len)
for (i=0;i<len;i++)
*dst++=*src++;
}
void tinplace_c2(int n, PDL_Float* data1, PDL_Float* data2)
{
int i;
for (i=0;i<n;i++) {
data1[i] = 599.0;
data2[i] = 699.0;
}
}
EOF

'tests.pd' => <<'EOF',
Expand Down Expand Up @@ -118,16 +109,6 @@ pp_def( '_flatten_into',
',
);
pp_addhdr << 'EOH';
void tinplace_c2(int n, PDL_Float* data1, PDL_Float* data2);
EOH
pp_def('fooflow2',
Pars => '[io]a(n);[io]b(n)',
GenericTypes => ['F'],
Code => 'tinplace_c2($SIZE(n),$P(a),$P(b));',
);
pp_def( 'broadcastloop_continue',
Pars => 'in(); [o] out()',
Code => q[
Expand Down Expand Up @@ -489,19 +470,6 @@ is_deeply \@msg, [], 'no warnings' or diag explain \@msg;
eval { _flatten_into(null, 2) };
ok 1; #was also segfaulting
# test the bug alluded to in the comments in pdl_changed (pdlapi.c)
# used to segfault
my $xx=ones(float,3,4);
my $sl1 = $xx->slice('(0)');
my $sl11 = $sl1->slice('');
my $sl2 = $xx->slice('(1)');
my $sl22 = $sl2->slice('');
fooflow2($sl11, $sl22);
ok(all $xx->slice('(0)') == 599);
ok(all $xx->slice('(1)') == 699);
# test that continues in a broadcastloop work
{
my $in = sequence(10);
Expand Down
12 changes: 12 additions & 0 deletions t/slice.t
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,18 @@ for ([0,1], [1,0], [1,1]) {
$got = $y->unpdl;
is_deeply $got, $exp, "mv=$mv mult=$mult clump" or diag explain $got;
}
# test the bug alluded to in the comments in pdl_changed (pdlapi.c)
# used to segfault
my $xx=ones(double,3,4);
my $sl1 = $xx->slice('(0)');
my $sl11 = $sl1->slice('');
my $sl2 = $xx->slice('(1)');
my $sl22 = $sl2->slice('');
my $roots = pdl '[1 -2396-2796i -778800+5024412i 2652376792-1643494392i -684394069604-217389559200i]'; # gives 4 roots of 599+699i
PDL::polyroots($roots->re, $roots->im, $sl11, $sl22);
my $got;
ok all(approx $got=$xx->slice('(0)'), 599), "col=0" or diag "got=$got";
ok all(approx $got=$xx->slice('(1)'), 699), "col=1" or diag "got=$got";
}

# captured from https://www.perlmonks.org/?node_id=11153348
Expand Down

0 comments on commit 962b922

Please sign in to comment.