-
Notifications
You must be signed in to change notification settings - Fork 47
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
NiceSlice code with dubious "=over" fails in 2.080 #406
Comments
Thank you for the report. As you can see, I adjusted the title because this does not report a "NiceSlice test" failing (it's not in the NiceSlice test suite). I also had to edit the text of your report to put in the appropriate ``` markers to make the code and output look like I believe you intended to. Please, before you add comments and/or report problems, use the "Preview" tab at the top of the text entry box, to make sure it looks as you intend. I always do. I am confused by what you wrote: you say "make test fails with NiceSlice errors". I have to assume you mean in your code, because PDL's "make test" passes just fine. Please be clear with that sort of thing :-) Most of all, I am very confused in that you say "2.079 still works", but then Also, please try adjusting your code to have a blank line after |
Another thing to try is to put a blank line before
If that in fact works, then Text::Balanced (and PDL::NiceSlice) are working correctly according to the POD spec, even if they need adjusting for real-world POD parsing by Perl itself. |
HI Ed, Adding blank lines around =over and =cut does not change anything. In 2.079, Text::Balanced reports this (I added a print statement at the end of the script to see how far it gets):
I am not sure if these are errors or warnings. |
Put these lines towards the end and run it under 2.079 and it gives the desired result of phase();
|
Please post some code (using ``` markers) that you are saying fails under 2.080, and confirm what version of Text::Balanced you have. |
|
Text::Balanced Version 2.06 |
If you don't like my example, here's another problem, PDL::Graphics::Prima. PDL 2.079 and Text::Balanced 2.06 prints these warnings.
PDL 2.080 gives a syntax error.
|
Your first message needs three backquotes at the start and finish of the block to be quoted, not one. That is why it renders wrongly. If you use the "Preview" function above the text box, you can see this before you post. After posting, it's possible to edit the text using the "..." menu top right of the message, selecting "Edit". More substantively, that code has |
Adding =back seems to mask the issue. This was just a minimal example demonstrating the problem, it is not unique, I think. Issues are with () {} ... in comments or pod of some sort, I think. |
PDL::Graphics::Prima triggers warnings in 2.079 with T:B 2.06 because it uses PDL::NiceSlice; I am pretty sure you'd have seen the same if you'd done The difference between P:G:P behaviour on the two PDLs is that 2.080 removed the vast amounts (about 500 lines) of overriding code. It looks like P:G:P demonstrates further bugs in T:B or Filter::Simple, which I will look into along with yours. In terms of the POD in your example code, Filter::Simple (https://metacpan.org/dist/Filter-Simple/source/lib/Filter/Simple.pm#L37-40) only considers By the way, referring to "mask"ing the issue doesn't seem accurate: either your code triggers a NiceSlice bug or it doesn't. |
OK, Ed, thank you. Here's one that triggers it without comments.
|
The following regression came about with code taken from PDL::Graphics::Prima: commit 0c6f5b92fcdff03a52a7a3ab08cfa5e16bd13099 (HEAD -> gha-ci, origin/gha-ci)
Date: Fri Dec 23 19:18:14 2022 -0500
drop! wip: "fix" regression in Filter::Simple relative to Filter::Util::Call
env PDL_NICESLICE_ENGINE='Filter::Simple' ...
env PDL_NICESLICE_ENGINE='Filter::Util::Call' ...
diff --git a/lib/PDL/Graphics/Prima/DataSet.pm b/lib/PDL/Graphics/Prima/DataSet.pm
index 39fb207..01f3119 100644
--- a/lib/PDL/Graphics/Prima/DataSet.pm
+++ b/lib/PDL/Graphics/Prima/DataSet.pm
@@ -1426,7 +1426,7 @@ sub guess_scaling_for {
my $lin_space = $lin_spaces->average;
my $lin_score = (($lin_spaces - $lin_space)**2)->sum / $lin_spaces->nelem;
- my $log_spaces = $data(1:-1) / $data(0:-2);
+ my $log_spaces = $data->slice('1:-1') / $data(0:-2);
my $log_space = $log_spaces->average;
my $log_score = (($log_spaces - $log_space)**2)->sum / $log_spaces->nelem; I have extracted the two lines which fail to filter together from this: #!/usr/bin/env perl
use PDL;
use PDL::NiceSlice;
my ($data, $lin_spaces);
my $lin_score = (($lin_spaces - $lin_space)**2)->sum / $lin_spaces->nelem;
my $log_spaces = $data(1:-1) / $data(0:-2);
no PDL::NiceSlice; $ for E in Filter::Util::Call Filter::Simple; do env PDL_NICESLICE_ENGINE=$E bash -c 'echo $PDL_NICESLICE_ENGINE && perl -c ns-reg.pl' ; done
Filter::Util::Call
ns-reg.pl syntax OK
Filter::Simple
syntax error at ns-reg.pl line 7, near "$data("
BEGIN not safe after errors--compilation aborted at ns-reg.pl line 8. $ for i in PDL Text::Balanced; do echo "$i $(mversion $i)"; done
PDL 2.081
Text::Balanced 2.06 Given that the |
A smaller example that breaks: #!/usr/bin/env perl
use PDL;
use PDL::NiceSlice;
my ($data, $lin_spaces);
my $lin_score = ($lin_spaces)->sum / $lin_spaces->nelem;
my $log_spaces = $data(1:-1) / $data(0:-2);
no PDL::NiceSlice; The |
By the way, to debug the filtered output of a given engine, you can use Add use Filter::tee ">$0-$ENV{PDL_NICESLICE_ENGINE}"; before the lines you want to see filtered then run for E in Filter::Util::Call Filter::Simple; do env PDL_NICESLICE_ENGINE=$E perl -c file-to-filter.pl; done |
From IRC:
|
Another way to debug source filters is to use diff <( PDL_NICESLICE_ENGINE=Filter::Util::Call perl -MFilter::ExtractSource -c file-to-filter.pl ) \
<( PDL_NICESLICE_ENGINE=Filter::Simple perl -MFilter::ExtractSource -c file-to-filter.pl ) |
Using this, I created the following test case that fails: #!/usr/bin/perl
use PDL::NiceSlice;
sub foo {
my ($x,$y) = @_;
$x / $y;
}
sub bar {
my ($r,$i) = @_;
$r/($i);
}
1; with a diff between the P:NS engines of: 12c12
< $r/($i);
---
> $r/->slice($i); This occurs even when the statements are in the same |
env PDL_NICESLICE_ENGINE='Filter::Simple' ... env PDL_NICESLICE_ENGINE='Filter::Util::Call' ... Fixing this properly will depend on <PDLPorters/pdl#406>. Adding this fix for now so that other fixes can move forward.
env PDL_NICESLICE_ENGINE='Filter::Simple' ... env PDL_NICESLICE_ENGINE='Filter::Util::Call' ... Fixing this properly will depend on <PDLPorters/pdl#406>. Adding this fix for now so that other fixes can move forward.
HI Ed,
make test fails with NiceSlice errors, so do a lot of programs. Both latest git as from CPAN.
2.079 still works.
Is this maybe related to Text-Balanced? Installed version is 2.06. Debian linux.
Here's a quite minimal example. I think it has to do with ( ) or {} in comments.
PDL 2.080: perl -Mblib -e "use test_ns; "
PDL 2.079: perl -Mblib -e "use test_ns; "
test_ns.pm:
The text was updated successfully, but these errors were encountered: