#67 Slice does not like whitespace

None
closed
None
1
2013-09-28
2012-01-24
No

Hi,
a minor bug but annoying to debug ... took me about an hour to find what's wrong ...

PDL (latest build) produced the following error :

print $cab2->dummy(-1,$$p{ky})->info;

$cabc2->info: PDL: Double D [128,6,1,2,8]

$$p{ky} is ' 128 ' - single quotes are only to show the padding white space.

Invalid slice str ',,,,,* 128 ': ' 128 ' at Basic/Core/Core.pm.PL (i.e. PDL::Core.pm) line 396
PDL::Core::barf('Invalid slice str \',,,,,* 128 \': \' 128 \'') called at Basic/Core/Core.pm.PL (i.e. PDL::Core.pm) line 1592
PDL::dummy('PDL=SCALAR(0x1df98c0)', -1, ' 128 ') called at /home/ingo/perl/reco_utils.pm line 84
reco_utils::epi('PDL=SCALAR(0x1df9998)', 'PDL=SCALAR(0x1df98a8)', 'PDL=SCALAR(0x1df9d28)', 'HASH(0x1dc9830)') called at /home/ingo/perl/reco_utils.pm line 364
reco_utils::fou('PDL=SCALAR(0x1df9bf0)', 'HASH(0x1dc9830)', 'PDL=SCALAR(0x1df9f38)') called at /home/ingo/perl/offline-reco.pl line 263
at Basic/Core/Core.pm.PL (i.e. PDL::Core.pm) line 396
PDL::Core::barf('Invalid slice str \',,,,,* 128 \': \' 128 \'') called at Basic/Core/Core.pm.PL (i.e. PDL::Core.pm) line 1592
PDL::dummy('PDL=SCALAR(0x1df98c0)', -1, ' 128 ') called at /home/ingo/perl/reco_utils.pm line 84
reco_utils::epi('PDL=SCALAR(0x1df9998)', 'PDL=SCALAR(0x1df98a8)', 'PDL=SCALAR(0x1df9d28)', 'HASH(0x1dc9830)') called at /home/ingo/perl/reco_utils.pm line 364
reco_utils::fou('PDL=SCALAR(0x1df9bf0)', 'HASH(0x1dc9830)', 'PDL=SCALAR(0x1df9f38)') called at /home/ingo/perl/offline-reco.pl line 263
Died at /home/ingo/perl/offline-reco.pl line 351.

The following works:

print $cab2->dummy(-1,($$p{ky})*1.)->info;

Discussion

  • David Mertens

    David Mertens - 2012-01-24

    This effects the slice method. The definition starts on line 1642 of Basic/Slices/slices.pd. Whitespace should be handled somewhere in the vicinity of line 1800, or by preprocessing and building our own local string that has no whitespace.

     
  • Chris Marshall

    Chris Marshall - 2012-01-24

    The current behavior is as documented. Please use niceslice
    to work around or use values that look like '*#'. The slice call
    might be able to be more permissive in this case but the mod
    will not be available for PDL-2.4.10.

    I've marked this as a feature request to improve PDL ease-of-use.

     
  • Chris Marshall

    Chris Marshall - 2012-01-24
    • milestone: --> 100443
    • priority: 5 --> 1
    • status: open --> open-remind
     
  • Chris Marshall

    Chris Marshall - 2012-05-18

    Moving to Feature Request tracker since the existing functionality works as documented.

     
  • Chris Marshall

    Chris Marshall - 2012-05-18
    • labels: 101696 -->
    • milestone: 100443 -->
     
  • Chris Marshall

    Chris Marshall - 2012-09-02
    • status: open-remind --> open
     
  • Chris Marshall

    Chris Marshall - 2012-09-02

    Since the problem here seems to be more the fact that slice() was called behind the scenes by dummy() with a generated string rather than the current slice syntax, I've modified dummy() to convert $size to a number before constructing the "*$size" argument for the underlying slice() call. This should avoid this hard-to-detect error.

     
  • Chris Marshall

    Chris Marshall - 2013-09-28
    • status: open --> closed
    • assigned_to: Chris Marshall
    • Group: -->
     
  • Chris Marshall

    Chris Marshall - 2013-09-28

    The unified slice support in the coming PDL-2.007 release is no longer sensitive to whitespace in the slice string.

     

Log in to post a comment.