Skip to content

Commit 75f0163

Browse files
committed
BackCode implies TwoWay and DefaultFlow
1 parent a6e7d4b commit 75f0163

File tree

6 files changed

+9
-19
lines changed

6 files changed

+9
-19
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- MatrixOps::svd now handles transpose transparently
1010
- all ops with two-way dataflow now work as lvalues
1111
- AffinePriv now implies TwoWay and P2Child
12+
- BackCode (including from EquivCPOffsCode) now implies TwoWay and DefaultFlow
1213

1314
2.103 2026-03-03
1415
- fix regression in *linvals so takes ndarrays as start and end again

lib/PDL/MatrixOps.pd

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,8 +1308,6 @@ EOT
13081308
);
13091309

13101310
pp_def('mstack',
1311-
DefaultFlow => 1,
1312-
TwoWay => 1,
13131311
Pars => 'x(n,m);y(n,p);[o]out(n,q=CALC($SIZE(m)+$SIZE(p)));',
13141312
GenericTypes => [ppdefs_all()],
13151313
Code => '
@@ -1332,8 +1330,6 @@ EOT
13321330
);
13331331

13341332
pp_def('augment',
1335-
DefaultFlow => 1,
1336-
TwoWay => 1,
13371333
Pars => 'x(n); y(p);[o]out(q=CALC($SIZE(n)+$SIZE(p)))',
13381334
GenericTypes => [ppdefs_all()],
13391335
Code => '

lib/PDL/Ops.pd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,6 @@ PDL_IF_BAD(if ( \$ISBAD(complexv()) ) \$SETBAD(b()); else,)
412412
$codestr
413413
}),
414414
!$backcode ? () : (
415-
DefaultFlow => 1,
416-
TwoWay => 1,
417415
BackCode => pp_line_numbers(__LINE__-1, qq{
418416
PDL_IF_BAD(if ( \$ISBAD(b()) ) \$SETBAD(complexv()); else {,)
419417
$backcode

lib/PDL/PP.pm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ my $pars_re = $PDL::PP::PdlParObj::pars_re;
10581058
$PDL::PP::deftbl =
10591059
[
10601060
PDL::PP::Rule->new(
1061-
[qw(RedoDims EquivCPOffsCode HandleBad P2Child TwoWay)],
1061+
[qw(RedoDims EquivCPOffsCode HandleBad P2Child)],
10621062
["Identity"],
10631063
"something to do with dataflow between CHILD & PARENT, I think.",
10641064
sub {
@@ -1077,7 +1077,7 @@ $PDL::PP::deftbl =
10771077
for(i=0; i<$PDL(CHILD)->nvals; i++) {
10781078
$EQUIVCPOFFS(i,i);
10791079
}'),
1080-
1, 1, 1);
1080+
1, 1);
10811081
}),
10821082

10831083
# used as a flag for many of the routines
@@ -1485,6 +1485,8 @@ EOF
14851485
}),
14861486
PDL::PP::Rule::Returns->new("OverloadDocValues", []),
14871487

1488+
PDL::PP::Rule::Returns::One->new('TwoWay', 'BackCode', 'BackCode => TwoWay'),
1489+
PDL::PP::Rule::Returns::One->new('DefaultFlow', 'BackCode', 'BackCode => DefaultFlow'),
14881490
PDL::PP::Rule::Returns::One->new('TwoWay', 'AffinePriv', 'AffinePriv => TwoWay'),
14891491
PDL::PP::Rule::Returns->new("TwoWayFlag", "TwoWay", "PDL_ITRANS_TWOWAY"),
14901492
PDL::PP::Rule::Returns::Zero->new("TwoWayFlag"),

lib/PDL/PP.pod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2611,6 +2611,7 @@ If I<set>, sets in the C<pdl_transvtable> (see L<PDL::Internals>) the
26112611
C<iflags> such that the trans will start with dataflow both forwards
26122612
and backwards. Note that setting this to any value (including 0) will
26132613
trigger the behaviour.
2614+
As of 2.104, implied by C<BackCode> (including from C<EquivCPOffsCode>).
26142615

26152616
=head3 HaveBroadcasting
26162617

@@ -2629,7 +2630,8 @@ first argument's C<copy> method will be used.
26292630
If true, sets in the C<pdl_transvtable> (see L<PDL::Internals>) the
26302631
C<iflags> such as to inform the trans's error checks connected to dataflow.
26312632
As of 2.104, also automatically sets C<Lvalue>.
2632-
As of 2.104, implied by C<AffinePriv>.
2633+
As of 2.104, implied by C<AffinePriv> and C<BackCode> (including
2634+
from C<EquivCPOffsCode>).
26332635

26342636
=head3 Identity
26352637

@@ -2640,6 +2642,7 @@ C<TwoWay> such that the function is a dataflowing identity transformation.
26402642

26412643
For dataflowing functions, this value (which gets parsed) overrides the
26422644
operation of that from children ndarrays to parents.
2645+
As of 2.104, implies C<TwoWay> and C<DefaultFlow>.
26432646

26442647
=head3 BadBackCode
26452648

lib/PDL/Slices.pd

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ my $index_init =
149149
pp_def('index',
150150
GenericTypes => [ppdefs_all],
151151
HandleBad => 1,
152-
DefaultFlow => 1,
153-
TwoWay => 1,
154152
Pars => 'a(n); indx ind(); [oca] c();',
155153
Code =>
156154
$index_init . ' $c() = $a(n => this_ind);',
@@ -164,8 +162,6 @@ pp_def('index',
164162
pp_def('index1d',
165163
GenericTypes => [ppdefs_all],
166164
HandleBad => 1,
167-
DefaultFlow => 1,
168-
TwoWay => 1,
169165
Pars => 'a(n); indx ind(m); [oca] c(m);',
170166
Code => pp_line_numbers(__LINE__, <<'EOF'),
171167
loop(m) %{
@@ -212,8 +208,6 @@ EOF
212208
pp_def('index2d',
213209
GenericTypes => [ppdefs_all],
214210
HandleBad => 1,
215-
DefaultFlow => 1,
216-
TwoWay => 1,
217211
Pars => 'a(na,nb); indx inda(); indx indb(); [oca] c();',
218212
Code =>
219213
$index2d_init . pp_line_numbers(__LINE__-1, ' $c() = $a(na => this_ind_a, nb => this_ind_b);'),
@@ -578,7 +572,6 @@ parameters. C<rangeb> is marginally faster as it makes a direct PP call,
578572
avoiding the perl argument-parsing step.
579573
EOD
580574
HandleBad => 1,
581-
TwoWay => 1,
582575
P2Child => 1,
583576

584577
# rdim: dimensionality of each range (0 dim of index PDL)
@@ -1405,7 +1398,6 @@ EOF
14051398
$EQUIVCPOFFS(i,i);
14061399
}
14071400
EOF
1408-
TwoWay => 1,
14091401
Doc => 'internal',
14101402
);
14111403

@@ -1816,8 +1808,6 @@ pp_def('rotate',
18161808
GenericTypes => [ppdefs_all],
18171809
Doc => 'Shift vector elements along with wrap.',
18181810
Pars=>'x(n); indx shift(); [oca]y(n)',
1819-
DefaultFlow => 1,
1820-
TwoWay => 1,
18211811
RedoDimsCode=>'if ($SIZE(n) == 0) $CROAK("can not shift zero size ndarray");',
18221812
Code=>$rotate_code.'
18231813
$y(n=>j++) = $x();

0 commit comments

Comments
 (0)