Skip to content

Commit

Permalink
capture current wrong type-convert behaviour when flowing - #511
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Dec 23, 2024
1 parent 12859c3 commit 65cd714
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/cygwin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: perl
name: Cygwin
on:
push:
branches:
Expand Down
48 changes: 48 additions & 0 deletions t/core.t
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,54 @@ $cf++;
is_pdl $x, pdl(2..4);
}

{
my $o_float = PDL::plus(float(1), float(2));
is_pdl $o_float, float(3);
# 3-arg is (a,b,swap); 4-arg is (a,b,output,swap)
PDL::plus(float(1), float(2), $o_float = null, 0);
is_pdl $o_float, float(3);
PDL::plus(float(1), float(2), my $o_double = double(0), 0);
is_pdl $o_double, pdl(3);
is 0+$o_double->trans_children, 0, 'no trans_children from non-flowing';

PDL::plus(my $i_float = float(1)->flowing, float(2), $o_double = double(0), 0);
is +($i_float->trans_children)[0]->vtable->name, 'converttypei_new', 'input trans_children[0] is convert output type > inputs';
is_pdl $o_double, pdl(3);
is $o_double->trans_parent->vtable->name, 'PDL::Ops::plus', 'right trans_parent from flowing output type > inputs';
is 0+$o_double->trans_children, 0, '0 trans_children on output from flowing';

PDL::plus(my $i_double = double(1)->flowing, double(2), $o_float = float(0), 0);
is +($i_double->trans_children)[0]->vtable->name, 'PDL::Ops::plus', 'current trans_children[0] is NOT convert on input from flowing output type < inputs';
is_pdl $o_float, float(0), 'current output wrongly 0 from flowing output type < inputs';
is $o_float->trans_parent, undef, 'current no trans_parent from flowing output type < inputs';
is 0+$o_float->trans_children, 1, 'current 1 trans_children from flowing output type < inputs';
is +($o_float->trans_children)[0]->vtable->name, 'converttypei_new', 'current trans_children[0] is convert output type < inputs';

eval {PDL::plus(double(1)->flowing, double(2), float(0)->slice(''), 0)};
is $@, '', "current no error when flowing output to flowing xform, out type < input";

for ([\&float,\&cfloat,\&cdouble], [\&double,\&cdouble,\&cfloat], [\&ldouble,\&cldouble]) {
my ($rt, $ct, $other_ct) = @$_;
my $o_cmplx = czip($rt->(3), $rt->(2));
is_pdl $o_cmplx, $ct->('3+2i'), 'right answer from no supplied output '.$rt->();
czip($rt->(3), $rt->(2), $o_cmplx = $ct->(0));
is_pdl $o_cmplx, $ct->('3+2i'), 'right answer from supplied output '.$rt->();
$o_cmplx = czip($rt->(3)->flowing, $rt->(2));
is_pdl $o_cmplx, $ct->('3+2i'), 'right answer from flowing, no supplied output '.$rt->();
czip($rt->(3)->flowing, $rt->(2), $o_cmplx = $ct->(0));
if ($ct->() eq 'cldouble') {
is_pdl $o_cmplx, $ct->('3+2i'), 'right answer from flowing, supplied output '.$rt->();
} else {
is_pdl $o_cmplx, $ct->(0), 'current wrong answer from flowing, supplied output '.$rt->();
}
eval {czip($rt->(3)->flowing, $rt->(2), $ct->(0)->slice(''))};

Check failure on line 861 in t/core.t

View workflow job for this annotation

GitHub Actions / ci (5.30, ubuntu-latest, true, true)

(in cleanup) INVALID MAGICNO in PDL=0x555acdd4b7d0 got 0x555f9878042b instead of 0x24645399
is $@, '', 'current wrongly no error when supply output with parent to flowing';
next if !$other_ct;
czip($rt->(3)->flowing, $rt->(2), $o_cmplx = $other_ct->(0));
is_pdl $o_cmplx, $other_ct->(0), 'current wrong answer from flowing, input '.$rt->().', supplied output '.$other_ct->();
}
}

my $notouch = sequence(4);
$notouch->set_donttouchdata;
eval { $notouch->setdims([2,2]); $notouch->make_physical; };
Expand Down

0 comments on commit 65cd714

Please sign in to comment.